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. --- doc/mach.texi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'doc') diff --git a/doc/mach.texi b/doc/mach.texi index dcf0f93c..91ec96ee 100644 --- a/doc/mach.texi +++ b/doc/mach.texi @@ -3056,6 +3056,30 @@ specified and @code{KERN_NO_SPACE} if there was not enough space left to satisfy the request. @end deftypefun +@deftypefun kern_return_t vm_allocate_contiguous (@w{host_priv_t @var{host_priv}}, @w{vm_task_t @var{target_task}}, @w{vm_address_t *@var{vaddr}}, @w{phys_addr_t *@var{paddr}}, @w{vm_size_t @var{size}}, @w{phys_addr_t @var{pmin}}, @w{phys_addr_t @var{pmax}}, @w{phys_addr_t @var{palign}}) +The function @code{vm_allocate} allocates a region of physical memory, +placing virtual mapping of the physical pages in the specified @var{task}'s +address space. + +The virtual space will be allocated wherever it is available. The virtual +address at which the physical memory was mapped will be returned in +@var{vaddr}. The physical address of the start of the allocated physical +memory will be returned in @var{paddr}. + +@var{size} is the number of bytes to allocate (rounded by the system in +a machine dependent way to an integral number of virtual pages). + +Constraints can be set on the physical address, to cope with hardware physical +memory access constraints, e.g. DMAs. @var{pmin} is the minimum physical address +at which the allocated memory should start. @var{pmax} is the maximum physical +address at which the allocated memory should end. @var{palign} is the alignment +restriction, which has to be a power of two. + +The function returns @code{KERN_SUCCESS} if the memory was successfully +allocated, @code{KERN_RESOURCE_SHORTAGE} if there was not enough physical memory +left to satisfy the request, and @code{KERN_NO_SPACE} if there was not enough +virtual space left to satisfy the request. +@end deftypefun @node Memory Deallocation @section Memory Deallocation -- cgit v1.2.3