07.06.2013 Views

Scsi - Index of

Scsi - Index of

Scsi - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

可以看到这个函数的参数有一个是struct scsi_host_template 结构体的指针,而她将返回一个<br />

struct <strong>Scsi</strong>_Host 结构体的指针,回想一下,前面咱们调用这个函数的那句,<br />

790 us->host = scsi_host_alloc(&usb_stor_host_template, size<strong>of</strong>(us));<br />

103<br />

凭一种男人的直觉,可以猜出,这个函数申请了一个<strong>Scsi</strong>_Host 结构体,并返回指向她的指针赋给<br />

us->host.从高一点的角度来说,这么一句话实际上就是在scsi 核心层注册了一个scsi 卡,当然这里的<br />

scsi<br />

卡是虚拟的.顺便来看看us->host.她实际上就是一个struct <strong>Scsi</strong>_Host 结构体的指针,而struct<br />

<strong>Scsi</strong>_Host 又是一个变态的数据结构,她的定义在include/scsi/scsi_host.h 中:<br />

376 struct <strong>Scsi</strong>_Host {<br />

377 /*<br />

378 * __devices is protected by the host_lock, but you should<br />

379 * usually use scsi_device_lookup / shost_for_each_device<br />

380 * to access it and don't care about locking yourself.<br />

381 * In the rare case <strong>of</strong> beeing in irq context you can use<br />

382 * their __ prefixed variants with the lock held. NEVER<br />

383 * access this list directly from a driver.<br />

384 */<br />

385 struct list_head __devices;<br />

386<br />

387 struct scsi_host_cmd_pool *cmd_pool;<br />

388 spinlock_t free_list_lock;<br />

389 struct list_head free_list; /* backup store <strong>of</strong> cmd structs */<br />

390 struct list_head starved_list;<br />

391<br />

392 spinlock_t default_lock;<br />

393 spinlock_t *host_lock;<br />

394<br />

395 struct semaphore scan_mutex;/* serialize scanning activity */<br />

396<br />

397 struct list_head eh_cmd_q;<br />

398 struct task_struct * ehandler; /* Error recovery thread. */<br />

399 struct semaphore * eh_wait; /* The error recovery thread waits<br />

400 on this. */<br />

401 struct completion * eh_notify; /* wait for eh to begin or end */<br />

402 struct semaphore * eh_action; /* Wait for specific actions on the<br />

403 host. */<br />

404 unsigned int eh_active:1; /* Indicates the eh thread is awake<br />

and active if<br />

405 this is true. */<br />

406 unsigned int eh_kill:1; /* set when killing the eh thread */<br />

407 wait_queue_head_t host_wait;<br />

408 struct scsi_host_template *hostt;<br />

409 struct scsi_transport_template *transportt;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!