02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

I<br />

Writing a SCSI-2 Device Driver<br />

/***************************************************************************<br />

*<br />

* xxxEventTypeGet - parse SCSI and DMA status registers at interrupt time<br />

*<br />

* RETURNS: an interrupt (event) type code<br />

*/<br />

LOCAL int xxxEventTypeGet<br />

(<br />

SIOP * pSiop<br />

)<br />

{<br />

/* Read interrupt status registers */<br />

key = intLock ();<br />

/* Check for fatal errors first */<br />

/* No fatal errors; try the rest (order of tests is important) */<br />

return (INTERRUPT_TYPE);<br />

}<br />

/***************************************************************************<br />

*<br />

* xxxThreadActivate - activate a SCSI connection for an initiator thread<br />

*<br />

* Set whatever thread/controller state variables need to be set. Ensure that<br />

* all buffers used by the thread are coherent with the contents of the<br />

* system caches (if any).<br />

*<br />

* Set transfer parameters for the thread based on what its target device<br />

* last negotiated.<br />

*<br />

* Update the thread context (including shared memory area) and note that<br />

* there is a new client script to be activated (see "xxxActivate()").<br />

*<br />

* Set the thread's state to ESTABLISHED.<br />

* Do not wait for the script to be activated. Completion of the script is<br />

* signalled by an event which is handled by "xxxEvent()".<br />

*<br />

* RETURNS: OK or ERROR<br />

*/<br />

LOCAL STATUS xxxThreadActivate<br />

(<br />

SIOP * pSiop, /* ptr to controller info */<br />

XXX_THREAD * pThread /* ptr to thread info */<br />

)<br />

{<br />

scsiCacheSynchronize (pScsiThread, SCSI_CACHE_PRE_COMMAND);<br />

I<br />

scsiWideXferNegotiate (pScsiCtrl, pScsiTarget, WIDE_XFER_NEW_THREAD);<br />

scsiSyncXferNegotiate (pScsiCtrl, pScsiTarget, SYNC_XFER_NEW_THREAD);<br />

if (xxxThreadParamsSet (pThread, pScsiTarget->xferOffset,<br />

pScsiTarget->xferPeriod) != OK)<br />

return (ERROR);<br />

343

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

Saved successfully!

Ooh no, something went wrong!