There is a fairly simplistic memory allocator in the form of a DMA allocator in 
libsel4utils that operates basically as you describe. See: 
https://github.com/seL4/seL4_libs/blob/master/libsel4utils/include/sel4utils/page_dma.h

It requires you to be using various other abstractions for allocations (vka_t) 
and address space management (vspace_t) that are found in our libraries, but 
then gives you a ps_dma_man_t 
(https://github.com/seL4/util_libs/blob/master/libplatsupport/include/platsupport/io.h#L195)
 interface that, whilst aims to be for DMA management, can give you contiguous 
mappings.

Adrian

On Wed 30-Nov-2016 9:30 AM, Jeff Waugh wrote:
On Wed, Nov 30, 2016 at 8:49 AM, PX 
<[email protected]<mailto:[email protected]>> wrote:
I want to allocate a contiguous physical memory block  (larger than a physical 
page) and map it to contiguous virtual addresses in the vspace, what's the best 
way to do it? Are there existing libraries allowing me to do that?

Not super familiar with the library sitch, but at a fundamental level:

- First you need an untyped of the correct size (and possibly at the correct 
position in physical memory), which may be available to you immediately, or 
you'll need to retype a larger one.

- Then you can retype it into page objects. A single seL4_UntypedRetype call 
can give you many pages, so you just need to choose the appropriate page size. 
If you wanted a 4MB contiguous block on x86_64, you could retype a 4MB untyped 
into two 2MB pages. If you wanted a 1MB contiguous block, you could retype a 
1MB untyped into 256 4KB pages (as it happens, 256 is the default maximum 
number of objects you can make in an UntypedRetype call).

- Then you can seL4_$ARCH_{PageDirectory/Table/PDPT/etc}_Map and ultimately 
seL4_$ARCH_Page_Map them into contiguous virtual addresses.

(libsimple / vka / allocman are the things to look at in the seL4 userland 
stack, and there's a bit of this sort of stuff in the tutorial on the wiki.)

Thanks,
Jeff



_______________________________________________
Devel mailing list
[email protected]<mailto:[email protected]>
https://sel4.systems/lists/listinfo/devel


_______________________________________________
Devel mailing list
[email protected]
https://sel4.systems/lists/listinfo/devel

Reply via email to