Adapter Objects

< BACK  NEXT >
[oR]

Just as multiple devices on the same controller need to coordinate their hardware access, so it is that devices that perform DMA need an orderly way to share system DMA resources. The I/O Manager uses adapter objects to prevent arguments over DMA hardware. There is one adapter object for each DMA data transfer channel on the system.

Like a controller object, an adapter object can be owned by only one device at a time. Before starting a DMA transfer, the Start I/O routine asks for ownership of the adapter object. If the hardware is free, ownership is granted. If not, the device's request is put on hold until the current owner releases the hardware. Obviously, if the device supports only programmed I/O, it has no need for an adapter object. The life cycle of the adapter object is described below.

  1. The HAL creates Adapter objects for any DMA data channels detected at boot time.

  2. The DriverEntry or AddDevice routine locates the adapter object for its device and stores that pointer in the device or controller extension. Adapter objects for nonsystem (i.e., bus master) DMA hardware may be created on the fly.

  3. The Start I/O routine requests ownership of the adapter object on behalf of a specific device.

  4. When ownership is granted, the I/O Manager calls the driver's adapter Control routine. This routine then uses the adapter object to set up a DMA transfer.

  5. The driver's DpcForIsr routine may use the adapter object to perform additional operations in the case of a split transfer. When a transfer is finished, DpcForIsr releases the adapter object.

Another important function of the adapter object is to manage mapping registers. The HAL uses these registers to map the standard physical pages of a user's buffer onto the contiguous range of addresses required by most DMA hardware. The complete mechanics of DMA transfers are covered in detail in chapter 12.

Layout of an Adapter Object

Figure 4.5 illustrates the relationship of adapter objects to other structures. As the diagram shows, the adapter object is completely opaque and has no externally visible fields. When working with DMA devices, the pointer to the adapter object, as well as the number of mapping registers it supports, should be stored in the device extension or controller extension structure.

Figure 4.5. The adapter object
graphics/04fig05.gif

Table 4.9. Access Functions for an Adapter Object
Adapter Object Access Functions
Function Description Called by...
IoGetDmaAdapter Gets a pointer to an adapter object DriverEntry or AddDevice
AllocateAdapterChannel Requests exclusive ownership of DMA hardware Start I/O
MapTransfer Sets up DMA hardware for a data transfer Adapter Control/DpcForIsr
FlushAdapterBuffers Flushes data after partial transfers DpcForIsr
FreeMapRegisters Releases map registers DpcForIsr
FreeAdapterChannel Releases adapter object DpcForIsr

Manipulating Adapter Objects

Both the HAL and the I/O Manager export functions that can be used to manipulate adapter objects. Table 4.9 lists the more common adapter functions.

< BACK  NEXT >


The Windows 2000 Device Driver Book(c) A Guide for Programmers
The Windows 2000 Device Driver Book: A Guide for Programmers (2nd Edition)
ISBN: 0130204315
EAN: 2147483647
Year: 2000
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net