From 2dbf108457d0a0057cc63d5b3b89fd4da48d2a72 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 9 Jul 2020 22:28:58 +0200 Subject: Add vm_allocate_contiguous RPC This allows privileged userland drivers to allocate buffers for e.g. DMA, and thus need them to be physically contiguous and get their physical address. Initial work by Zheng Da, reworked by Richard Braun, Damien Zammit, and myself. * doc/mach.texi (vm_allocate_contiguous): New RPC. * i386/include/mach/i386/machine_types.defs (rpc_phys_addr_t): New type. * i386/include/mach/i386/vm_types.h [!MACH_KERNEL] (phys_addr_t): Set type to 64bits. (rpc_phys_addr_t): New type, always 64bits. * include/mach/gnumach.defs (vm_allocate_contiguous):New RPC. * vm/vm_user.c (vm_allocate_contiguous): New function. --- include/mach/gnumach.defs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs index 97ab573c..d423a10a 100644 --- a/include/mach/gnumach.defs +++ b/include/mach/gnumach.defs @@ -165,3 +165,27 @@ routine vm_msync( address : vm_address_t; size : vm_size_t; sync_flags : vm_sync_t); + +/* + * This routine is created for allocating DMA buffers. + * We are going to get a contiguous physical memory + * and its physical address in addition to the virtual address. + * We can specify physical memory range limits and alignment. + * NB: + * pmax is defined as the byte after the maximum address, + * eg 0x100000000 for 4GiB limit. + */ +/* XXX + * Future work: the RPC should return a special + * memory object (similar to device_map() ), which can then be mapped into + * the process address space with vm_map() like any other memory object. + */ +routine vm_allocate_contiguous( + host_priv : host_priv_t; + target_task : vm_task_t; + out vaddr : vm_address_t; + out paddr : rpc_phys_addr_t; + size : vm_size_t; + pmin : rpc_phys_addr_t; + pmax : rpc_phys_addr_t; + palign : rpc_phys_addr_t); -- cgit v1.2.3