How to access RAM memory with a DMA controller?

I want to copy data from flash memory to RAM. So, how can I set the RAM destination memory address in the DMA controller so that it can use its channel to copy data from the source address (in flash memory) to RAM.

I am doing this on an x86-arch, and this is 8237 DMA.

+4
source share
1 answer

The DMA 8237 controller is capable of transferring from RAM to RAM, from I / O to RAM and from RAM to an I / O device.

Please note that you can copy up to 64 KB of data. If you want to copy more than 64 KB, you will need more than one transfer operation.

Assuming you are using the same environment as the IBM PC, and you can set the address of the destination memory segment in a separate latch, you need to:

  • Normalize the destination segment: offset so that the offset is below 16. Normalization is performed in this way (DIV - integer division, MOD - module):

    normalized_segment = segment + offset DIV 16

    normalized_offset = offset MOD 16

  • Load the segment value into the high-order bit latch belonging to the channel you want to use (page address register)

  • Load the offset address into the start address register of the DMA channel you want to use.
  • Continue to configure DMA (transmission length, mode, interrupt on EOC, etc.)
+1
source

Source: https://habr.com/ru/post/1394979/


All Articles