|
|
struct hbadata *prefixgetblk(int flag);
The
getblk( )
routine returns a
hbadata(D4sdi)
structure.
Typically, the HBA drivers use some other structure
and cast it to a struct hbadata *
before returning.
The command block consists, minimally, of a pointer to an
xsb(D4sdi)
structure
and may consist of addition HBA specific
data.
Passing commands from target drivers to HBA drivers
depends on the command block data structure
to pass down the needed command information.
Each HBA driver defines and allocates
its own supply of command blocks,
allowing each HBA driver to be flexible
in servicing its needs.
This routine is called by the sdi_send(D3sdi), sdi_xsend(D3sdi), sdi_icmd(D3sdi), sdi_xicmd(D3sdi), sdi_translate(D3sdi), and sdi_xtranslate(D3sdi) functions, which can be called from interrupt context during fault handling. The target driver calls these functions with the flag argument, which is passed along to the HBA getblk( ) routine.
The command blocks are requested and then freed randomly. For this reason, using a free-list system makes manipulating command blocks for the getblk( ) and freeblk(D2sdi) faster and simpler than alternative schemes. When an HBA driver needs a command block, it requests one from its free list. If, the HBA driver has allocated all the blocks in its free list, the next getblk( ) request should block, awaiting the next block to be freed, if the sleep flag indicates that it can sleep. Otherwise, the call should fail with a NULL return.