Looking for steps to allocate and reserve and DMA buffer throught the Config.bib file setting RRS feed

  • Question

  • Hi,

    Needs a help!!

    Recently i do a DMA core driver development. I intended to reserved a region of phyiscal memory in RAM for DMA buffer. I tried to do this by modifying the Config.bib file memory layout as follow (those bold statements are added and adjusted by me) :


    DMA       80100000  00030000  RESERVED   ; DMA, see platform.reg for 8237 driver
    BLDR      80130000  00050000  RESERVED   ; bootloader loads here - see bldr.bib
    BLDRRAM1  80180000  0007C000  RESERVED   ; bootloader uses this as RAM - see bldr.bib
    AUDIOBUF  801FC000  00002000  RESERVED   ; Audio DMA buffer for BSP_WAVEDEV_SB16, shared with bootloader RAM
    BLDRRAM2  801FE000  00001000  RESERVED   ; bootloader uses this as RAM - see bldr.bib
    ETHDMA    80200000  00020000  RESERVED   ; KITL Ethernet, see ETHDMA_BUFFER_BASE
    MTDMA   80220000  06400000  RESERVED  ; DMA buffer reserved by Christopher

    ; System Reserved   64 KB
    ; ACPI Data         56 KB
    ; ACPI NVS          72 KB
    ; System Reserved   1.3 MB
    ; VideoFrame        1-8 MB  Bios depends
    ; We must reserved at least 0x00980000 top memory region

        NK       86620000    02600000  RAMIMAGE ;

        #if  defined IMGRAM128
            ; 128 MB of RAM (note: AUTOSIZE will adjust NK/RAM boundary)
            RAM      82200000  05000000  RAM
            nk.exe:dwOEMTotalRAM 0    07200000  FIXUPVAR
        #elif defined IMGRAM256
            ; 256 MB of RAM (note: AUTOSIZE will adjust NK/RAM boundary)
            RAM      82200000  0D000000  RAM
            nk.exe:dwOEMTotalRAM 0    0F200000  FIXUPVAR
        #elif defined IMGRAM512
            ; 512 MB of RAM (note: AUTOSIZE will adjust NK/RAM boundary)
            ;RAM      82200000  1D000000  RAM ;
            RAM      88E20000  163E0000  RAM  ; RAM region define in accordance 256MB DMA buffer preserved

            nk.exe:dwOEMTotalRAM 0    1F200000  FIXUPVAR

    ;  Disable autodetection by ACPI
    ;        nk.exe:dwOEMTotalRAM 0    20000000  FIXUPVAR
             nk.exe:dwOEMTotalRAM 0    1F200000  FIXUPVAR
    ;  Default size = 256 MB
            RAM      82200000  0D000000  RAM
            nk.exe:dwOEMTotalRAM 0    0F200000  FIXUPVAR



    1. According to my understanding from this line "MTDMA   80220000  06400000  RESERVED  ;", the 0x80220000 is the starting virtual address (in Kernel virtual memory space) and it mapped to physical RAM memory at address 0x00220000. Can anyone or expertise tell me that whether my understanding to this is correct or not??

    2. After i made the DMA buffer reservation throught he Config.bib, do i still to call the functions VirtualAlloc and follow by VirtualCopy to copy the data from physical to virtual memory or vice versa? Or I just need to call VirtualCopy only because i already have the virtual address and phyiscal address which they have been stated in the Config.bib, 0x80220000 and 0x00220000?

    3. Can someone share with me the process and steps to allocate and reserved and DMA buffer, then the way to copy the data to/from application allocated buffer (user mode space virtual memory) from/to the physical memory through the Config.bib?

    Thanks & regards


    Tuesday, September 18, 2012 2:21 AM

All replies

  • Looking at the config.bib content you posted I imagine you're working on an x86 BSP. If your code is running in kernel mode you can access directly the reserved memory at 0x80220000 (probably you will likely used the corresponding uncached virtual address 0xA0220000) while the address used to program the hardware needs to be the physical one which is, as you  mentioned 0x220000. If your code is running in user mode you still need to use

    PVOID MmMapIoSpace( 
      PHYSICAL_ADDRESS PhysicalAddress, 
      ULONG NumberOfBytes, 
      BOOLEAN CacheEnable 
    In order to map the physical address to a virtual address accessible from not-kernel mode

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom Check my blog:

    Tuesday, September 18, 2012 5:35 AM
  • First, thanks for the reply.

    In fact my intention here is allocating a statical physical memory, which is a DMA buffer for my DMA controller use. Therefore, i statically resereve it by using the MEMORY section of run-time image's BID file, Config.bib.

    MTDMA   80220000  06400000  RESERVED;

    My understand is, from the bold line of code in Config.bib, it means the 0x80220000 is referring to the kernel virtual memory space (cache). My driver is configured as kernel mode driver and from the microsoft article it recommened use uncached virtual address for device driver instead of cached virtual address.

    I wonder, do i need to call VirtualAlloc and VirtualCopy do to a mapping in between physical memory and kernel virtual (cache or uncache) memory space?

    or the VirtualAlloc and VirtualCopy are only used for when dynamically allocating a physical memory with AllocPhysMem?

    May I know what are the proper steps that if i want to allocate a static or fix physical memory space as DMA buffer through the Config.bib, and how my kernel mode device driver is going to access the memory space?


    Monday, October 8, 2012 8:17 AM