vm: add third-party mmap() mode and PROCCTL

these two functions will be used to support all exec() functionality
going into a single library shared by RS and VFS and exec() knowledge
leaving VM.

	. third-party mmap: allow certain processes (VFS, RS) to
	  do mmap() on behalf of another process
	. PROCCTL: used to free and clear a process' address space
This commit is contained in:
Ben Gras
2012-06-06 00:50:13 +02:00
parent 1daf36038c
commit ee4016155e
12 changed files with 98 additions and 7 deletions

View File

@@ -21,8 +21,8 @@ __weak_alias(minix_munmap_text, _minix_munmap_text)
#include <string.h>
#include <errno.h>
void *minix_mmap(void *addr, size_t len, int prot, int flags,
int fd, off_t offset)
void *minix_mmap_for(endpoint_t forwhom,
void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
message m;
int r;
@@ -33,6 +33,11 @@ void *minix_mmap(void *addr, size_t len, int prot, int flags,
m.VMM_FLAGS = flags;
m.VMM_FD = fd;
m.VMM_OFFSET = offset;
m.VMM_FORWHOM = forwhom;
if(forwhom != SELF) {
m.VMM_FLAGS |= MAP_THIRDPARTY;
}
r = _syscall(VM_PROC_NR, VM_MMAP, &m);
@@ -43,6 +48,12 @@ void *minix_mmap(void *addr, size_t len, int prot, int flags,
return (void *) m.VMM_RETADDR;
}
void *minix_mmap(void *addr, size_t len, int prot, int flags,
int fd, off_t offset)
{
return minix_mmap_for(SELF, addr, len, prot, flags, fd, offset);
}
int minix_munmap(void *addr, size_t len)
{
message m;

View File

@@ -127,6 +127,7 @@ SRCS= \
vm_push_sig.c \
vm_umap.c \
vm_yield_get_block.c \
vm_procctl.c \
vprintf.c \
.if ${MKCOVERAGE} != "no"

22
lib/libsys/vm_procctl.c Normal file
View File

@@ -0,0 +1,22 @@
#include "syslib.h"
#include <minix/vm.h>
#include <string.h>
/*===========================================================================*
* vm_exit *
*===========================================================================*/
int vm_procctl(endpoint_t ep, int param)
{
message m;
int result;
memset(&m, 0, sizeof(m));
m.VMPCTL_WHO = ep;
m.VMPCTL_PARAM = param;
result = _taskcall(VM_PROC_NR, VM_PROCCTL, &m);
return(result);
}