相关文章推荐
温柔的铁板烧  ·  Exchange ...·  7 月前    · 
> I want to learn the implementation of simulation DMA, including the flow of > DMA read/write. > The first step I tried is to learn it by debugging qemu-system-arm. The > machine I used is raspi2. Bcm2835 DMA controller is initialed during > booting, but I find that there are no other devices use DMA read or write > during the booting. (I set breakpoint at dma_memory_rw() )Therefore, I have > no idea how to observe the behavior of DMA read/write. There is no single set of functions that all DMA operations go through, I'm afraid. You need to look at the device that you're interested in and see what it does. In the case of bcm2835_dma, its main loop for doing DMA memory transfers is bcm2835_dma_update(), which does loads and stores via ld_le_phys() and stl_le_phys(). The dma_memory_rw() function is primarily needed for devices which might be in a system using KVM -- that is where the barrier operations that it enforces become important. Devices that are written to only need to operate in a pure-emulation environment, like bcm2835_dma, don't necessarily use it. > I have read the files under /hw/dma, but these files only describe DMA > structure, they are not related to the behavior of DMA read/write. What I > want to learn is how QEMU dispatch the DMA read/write(using other threads > except cpu thread to do read/write?), and how to invoke guest CPU that the > DMA read/write finish( send signal to main loop thread or CPU thread?). A device that does DMA is just doing memory accesses. Those accesses are generally done synchronously, because for QEMU memory access is fast in comparison to other things. We only implement "DMA controllers" to satisfy guest code that requires them to be functional, not because doing memory transfers in parallel with CPU execution is faster. > As far as I know is that using DMA read/write will call function > dma_memory_rw(). I don't know how to invoke DMA read/write in the guest > application. Is there any way to invoke DMA in application? or any method > that I can learn how DMA is simulated in QEMU? A guest application interacts with emulated hardware in QEMU by writing to that hardware's registers, the same as if it were talking to real hardware. Generally it will do things that trigger DMA accesses by programming the emulated hardware appropriately. QEMU will then do what it has been told to do; if this also means it needs to signal an interrupt to the guest CPU it will do that (via the emulated interrupt controller). thanks -- PMM [Next in Thread]
  • [Qemu-arm] Ask about how DMA is implemented in qemu-arm-system , Eva Chen , 2018/04/27
  • Re: [Qemu-arm] Ask about how DMA is implemented in qemu-arm-system , Peter Maydell <=
  •