You may have noticed earlier that instead of the DMA setting the address lines to 0x00123456 as we said earlier, the DMA only set 0x3456. The reason for this takes a bit of explaining.
When the original IBM PC was designed, IBM elected to use both DMA and interrupt controller chips that were designed for use with the 8085, an 8-bit processor with an address space of 16 bits (64K). Since the IBM PC supported more than 64K of memory, something had to be done to allow the DMA to read or write memory locations above the 64K mark. What IBM did to solve this problem was to add a latch for each DMA channel, that holds the upper bits of the address to be read to or written from. Whenever a DMA channel is active, the contents of that latch is written to the address bus and kept there until the DMA operation for the channel ends. These latches are called ``Page Registers''.
So for our example above, the DMA would put the 0x3456 part of the address on the bus, and the Page Register for DMA channel 2 would put 0x0012xxxx on the bus. Together, these two values form the complete address in memory that is to be accessed.
Because the Page Register latch is independent of the DMA chip, the area of memory to be read or written must not span a 64K physical boundary. If the DMA accesses memory location 0xffff, the DMA will then increment the address register and it will access the next byte at 0x0000, not 0x10000. The results of letting this happen are probably not intended.
Note: ``Physical'' 64K boundaries should not be confused with 8086-mode 64K ``Segments'', which are created by adding a segment register with an offset register. Page Registers have no address overlap.
To further complicate matters, the external DMA address latches on the PC/AT hold only eight bits, so that gives us 8+16=24 bits, which means that the DMA can only point at memory locations between 0 and 16Meg. For newer computers that allow more than 16Meg of memory, the PC-compatible DMA cannot access locations above 16Meg.
To get around this restriction, operating systems will reserve a buffer in an area below 16Meg that also doesn't span a physical 64K boundary. Then the DMA will be programmed to read data to that buffer. Once the DMA has moved the data into this buffer, the operating system will then copy the data from the buffer to the address where the data is really supposed to be stored.
When writing data from an address above 16Meg to a DMA-based peripheral, the data must be first copied from where it resides into a buffer located below 16Meg, and then the DMA can copy the data from the buffer to the hardware. In FreeBSD, these reserved buffers are called ``Bounce Buffers''. In the MS-DOS world, they are sometimes called ``Smart Buffers''.