question about DMA addressing

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
albeva
Member
Member
Posts: 42
Joined: Thu Aug 21, 2008 8:31 pm

question about DMA addressing

Post by albeva »

Sorry if this has been answered somewhere but

I know that DMA is supposed to be within first 16MB right? I am now in the process of writing a mm and want to have an option to allocate memory suitable for DMA operations. But it's a bit gray area for me at the moment.

does DMA memory has to be allocated withing physical 16MB? or it doesn't matter as long as it mapped < 0x1000000 on the virtual address space?
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: question about DMA addressing

Post by bewing »

ISA DMA must be within the first 16M of physical memory. But there are other kinds of DMA. Most Busmastering DMA must be within the first 4G of physical memory. No DMA can use virtual memory -- only the CPU uses virtual memory.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: question about DMA addressing

Post by Combuster »

From the DMA's point of view, there is no memory translation like paging or segmentation, so it sees 16MB of memory exactly the way it is: 640k of normal memory followed by video memory and bios, another 14M of memory, and the ISA hole should it be there. Whatever cheats you tell the processor to play on the applications do *not* apply for DMA.

Hence you need to allocate a stretch of *physical* memory as a DMA buffer. Then you can map portions of it anywhere into the address space if that is deemed necessary, but you don't need to do so.

Edit: beaten to the point
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: question about DMA addressing

Post by Brendan »

Hi,
albeva wrote:does DMA memory has to be allocated withing physical 16MB?
Yes, but there's a few more restrictions for ISA DMA.

For the 8-bit channels, you can't cross a 64 KiB boundary (e.g. you can't do a DMA transfer of 512 bytes from 0x0000FF00 to 0x000100FF), and you can't transfer more than 64 KiB in one go.

For the 16-bit channels I'm not sure (it's been a while). In theory I think the DMA controller itself will handle 128 KiB transfers (or 65536 words), but the "DMA page" part of it (which was implemented as a separate chip originally) might mess it up and cause it to wrap around, so that the second 64 KiB overwrites the first 64 KiB.

[EDIT] Ok, I was wrong about 16-bit DMA transfers - they can transfer 128 KiB of data and can't cross 128 KiB boundaries. I also found a good source of information, um, here... :oops: [/EDIT]


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
albeva
Member
Member
Posts: 42
Joined: Thu Aug 21, 2008 8:31 pm

Re: question about DMA addressing

Post by albeva »

thanks guys. I found wiki page about it too. DMA seems such a mess...
Post Reply