Re: L4Re: Allocating pinned memory and obtaining its physical address
Jakub Jermář <[email protected]> Sun, 23 Apr 2023 10:09:52 +0200
| Newsgroups | gmane.comp.micro-kernel.l4.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Paul, On 4/23/23 00:29, Paul Boddie wrote: > Hello, > > Sorry to be lazy and not dig too deeply into the documentation and code, but > once upon a time it was possible to use the l4re_ma functions to allocate > pinned memory. Then, one would use the dataspace protocol to obtain the > physical address of the memory via the capability involved in memory > allocation. > > This exercise would be sufficient to get into a position to initialise > peripherals in a system-on-a-chip, setting registers with the physical memory > addresses they would need for things like DMA. The initialisation of things > like framebuffers would rely on this procedure. > > I see that the "phys" operation in the dataspace protocol was discarded some > time ago, and now there is a "DMA space" abstraction instead: > > https://l4re.org/doc/group__api__l4re__c__dma.html > > Are there any examples of how I might obtain a physical address associated > with a block of memory using this new API? The idea is that you have a dataspace and a DMA space. In order to obtain a DMA address that you can then use to program your I/O device, you need to map a portion of the dataspace into the DMA space. After use you unmap it from the DMA space. See for example the implementation of the Inout buffer in our nvme-driver: https://github.com/kernkonzept/nvme-driver/blob/master/server/src/inout_buffer.h#L46 This API hides the differences between physical addresses and addresses translated by IOMMU - you simply get a DMA address with which you work. Whether you get a physical or IOMMU-virtual address depends on how the DMA space was created (and also on the capabilities of the underlying hardware). Cheers, Jakub > > Thanks in advance for any guidance that might be offered! > > Paul > > > > _______________________________________________ > l4-hackers mailing list > [email protected] > https://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers