![]() |
![]() | ||
|
[Book Overview]
[Top]
[Prev] | |||
In this and the previous chapters I have covered the basic elements of hardware access, namely direct memory access, I/O port access, and interrupts, but there is another aspect that is worth introducing: DMA.
Reference sources
DMA is perhaps somewhat too esoteric for a book of this general nature; however,a few notes are in order and I can point you in the right direction.
The best reference would be Microsoft's Virtual DMA Services Specification, part number 098-10869.
Another introductory reference is "DMA Revealed" by Karen Hazzah, Windows/DOS Developer's Journal, April 1992, pages 5-20.
What is DMA?
Basically, DMA takes the job of data transfer away from the CPU for the sake of speedy transfer of blocks of data, usually between a hardware device and memory. It requires a DMA controller chip. Initialization involves telling the controller the address of the memory buffer and how many bytes to transfer.
Bolting a segment down
With Windows, there are complications, because the CPU can be in Real or Protected mode. In Protected mode the buffer should be constrained to be below 1Mb and should also be contiguous.
Paging normally will split a segment up all over the place, but there are mechanisms in Windows for keeping a segment together. The DMA controller is given the selector:offset and simply increments the offset without regard to paging remember that the CPU is turned off at this time, and the DMA chip has complete control of the bus.
Another implication of this is that it is wise to keep memory buffers to no more than 64Kb.
I did note earlier that by declaring the DLL data segment FIXED, it will load below 1Mb and be contiguous. However there appears to be some doubt about the latter, as the recommendation is that to ensure that pages are contiguous, another service must be called: the INT-4Bh/Lock-DMA function.
INT-4Bh
INT-4Bh provides the extensions to DOS for DMA handling, and you will find these documented in the above Microsoft reference not anywhere else,that I'm aware of.
The services, available from both Windows Standard and Enhanced modes, are:
Some of the discussion in this and earlier chapters has referred to Real mode. Although Windows normally runs in Protected mode, Real mode is still encountered, as is virtual-86 mode, and more specific treatment is provided on this topic in the next chapter.