How can a program use DMA transfers while running under a DOS extender+DPMI environment ?
I mean how can we allocate and get physical address of the dma buffer allocated, so as to supply that physical address to the DMA controller, or PCI bus master device.
There are two possiblities:
The DOS Extender or DPMI server/host support virtual memory. eg Causeway.
The DOS Extender or DPMI server/host doesn’t support virtual memory, but paging is enabled. eg DOS32a.
I’m using Open Watcom C compiler.
The runtime environment is :
FreeDOS + XMS(no EMS/EMM386) + DOS extender(DOS32a)
For DJGPP, the solution is here
But will that last mentioned solution ie via XMS, work with DOS32a too?
DOS32a docs say that before switching to protected mode, it allocates all of the available extended memory, and then our program can allocate that memory via DPMI function 501h.
NOTE: The dma buffer can be 1MB or so, so I can’t use conventional memory for it.
For a clean DPMI solution you may want to explore the following DPMI functions (excerpts from Ralf Brown’s Interrupt List):
If neither of the above lets you map virtual addresses to physical addresses nor obtain physical addresses of allocated blocks (e.g. unsupported), you’ll need to look into implementation details of your DPMI host (e.g. if it doesn’t enable page translation or it can be turned off, then all addresses are physical).
EDIT: It looks like you should be able to allocate memory (more than and beyond 1MB) and get its physical and virtual addresses. First, allocate it using XMS/Himem.sys and lock it. That’ll give you the physical address. Next, use the DPMI function 0x800 to get the corresponding virtual address.
Here’s how (disregard the 16-bit version (compiled with Borland/Turbo C/C++), it’s only used only to validate the XMS routines):
Sample output (under DosBox):
Note that DOS/32 does not enable page translation (unless there’s VCPI). CR0’s PG bit is 0, CR3 is 0 and the obtained physical and virtual addresses are the same, everything speaks for that. And so the virtual and physical addresses are the same thing.