DMA

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

DMA

Post by icealys »

when the cpu gives an address to the DMA controller to write to, is it a physical address or virtual?
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: DMA

Post by Combuster »

Where is virtual memory implemented?
Is the DMA controller part of that?
"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 ]
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

Re: DMA

Post by icealys »

virtual memory is implemented on the operating system...the OS maps virtual addresses to physical addresses and updates a page table which is sent to the memory management unit. With DMA, the cpu initiates the transfer by sending the number of bytes and the write address to the dma controller. It allows the cpu to do other operations while I/O from a device is in progress. My question is...is the dma controller aware of virtual addresses? Or just physical addresses?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: DMA

Post by thepowersgang »

Would it make sense to apply a mapping that could change when a process switch hapens (which could be at any time) to an asynchronous hardware device? Answer that and you have the answer to your original question.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
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: DMA

Post by Combuster »

icealys wrote:the OS maps virtual addresses to physical addresses and updates a page table which is sent to the memory management unit.
Now again, what is actually performing virtual to physical translations? How is it wired to the DMA controller?
"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 ]
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

Re: DMA

Post by icealys »

Now again, what is actually performing virtual to physical translations? How is it wired to the DMA controller?
the MMU is doing the translations and I think anytime you access RAM the transfer needs to go through the MMU.

thepowersgang: what do you mean by applying mapping to an asynchronous hardware device? Do you mean to tell me that the mmu gets updated and knows what the current running process is?
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: DMA

Post by Combuster »

I think
Wrong. Don't think, know. If you only think it means you're too lazy to make sure.

Now back to the original question: Where is the MMU implemented? Where is the DMA controller?
"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 ]
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

Re: DMA

Post by icealys »

Now back to the original question: Where is the MMU implemented? Where is the DMA controller?
umm I'm not too sure why you are asking these questions in my thread but they are both on the die of the cpu.
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: DMA

Post by Combuster »

icealys wrote:umm I'm not too sure why you are asking these questions in my thread
Because I want to teach you something more important than just the answer, and the alternative is reporting you for breaking forum rules (smart questions, required knowledge).
but they are both on the die of the cpu.
Post your source, please. :wink:
"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
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Re: DMA

Post by mathematician »

icealys wrote:
Now back to the original question: Where is the MMU implemented? Where is the DMA controller?
umm I'm not too sure why you are asking these questions in my thread but they are both on the die of the cpu.
The DMA controller is in the South Bridge. Hisorically it was a self contained chip.

virtual memory is implemented on the operating system...
Virtual memory is implemented in the processor, and the operating system makes use of the hardware's capabilities. Just as it does with the DMA controller.
The continuous image of a connected set is connected.
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

Re: DMA

Post by icealys »

thats true...

the IOMMU is what makes it possible for DMA to use virtual addresses which hides fragmentation of physical RAM.
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Re: DMA

Post by mathematician »

icealys wrote:thats true...

the IOMMU is what makes it possible for DMA to use virtual addresses which hides fragmentation of physical RAM.
DMA doesn't use virtual addresses. The chipset knows nothing about the memory mapping effected by the CPU. It uses physical addresses. That is why the OS's memory manager has to make special arrangements for devices which need contiguous chunks of physical memory.
The continuous image of a connected set is connected.
icealys
Member
Member
Posts: 60
Joined: Mon Feb 17, 2014 3:54 pm

Re: DMA

Post by icealys »

thx for clearing that up...but what is the IOMMU used for then?
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: DMA

Post by Combuster »

mathematician wrote:The DMA controller is in the South Bridge. Hisorically it was a self contained chip.
Thanks for providing the incomplete answer. Actually, there are many DMA controllers in a computer - none of which are in the CPU because DMA is meant to bypass the CPU.
But yes, ISA DMA is typically on the southbridge.
mathematician wrote:DMA doesn't use virtual addresses.
Not exactly true. It does if there's a GART or IOMMU in the way.

IOMMU
Which is not the MMU, is located elsewhere (not on the CPU), but still performs the same task of address translation and protection. Although more often than that, it's not even present at all.

When it does exist, it acts completely independent from the CPU, and needs to be configured explicitly to do something other than pretending it doesn't exist.
"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 ]
Post Reply