xref: /minix3/minix/lib/libsys/sys_vmctl.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #include "syslib.h"
2*433d6423SLionel Sambuc 
sys_vmctl(endpoint_t who,int param,u32_t value)3*433d6423SLionel Sambuc int sys_vmctl(endpoint_t who, int param, u32_t value)
4*433d6423SLionel Sambuc {
5*433d6423SLionel Sambuc   message m;
6*433d6423SLionel Sambuc   int r;
7*433d6423SLionel Sambuc 
8*433d6423SLionel Sambuc   m.SVMCTL_WHO = who;
9*433d6423SLionel Sambuc   m.SVMCTL_PARAM = param;
10*433d6423SLionel Sambuc   m.SVMCTL_VALUE = value;
11*433d6423SLionel Sambuc   r = _kernel_call(SYS_VMCTL, &m);
12*433d6423SLionel Sambuc   return(r);
13*433d6423SLionel Sambuc }
14*433d6423SLionel Sambuc 
15*433d6423SLionel Sambuc /* Get page directory base register */
sys_vmctl_get_pdbr(endpoint_t who,u32_t * pdbr)16*433d6423SLionel Sambuc int sys_vmctl_get_pdbr(endpoint_t who, u32_t *pdbr)
17*433d6423SLionel Sambuc {
18*433d6423SLionel Sambuc   message m;
19*433d6423SLionel Sambuc   int r;
20*433d6423SLionel Sambuc 
21*433d6423SLionel Sambuc   m.SVMCTL_WHO = who;
22*433d6423SLionel Sambuc   m.SVMCTL_PARAM = VMCTL_GET_PDBR;
23*433d6423SLionel Sambuc   r = _kernel_call(SYS_VMCTL, &m);
24*433d6423SLionel Sambuc   if(r == OK) {
25*433d6423SLionel Sambuc 	*pdbr = m.SVMCTL_VALUE;
26*433d6423SLionel Sambuc   }
27*433d6423SLionel Sambuc   return(r);
28*433d6423SLionel Sambuc }
29*433d6423SLionel Sambuc 
sys_vmctl_set_addrspace(endpoint_t who,phys_bytes ptroot,void * ptroot_v)30*433d6423SLionel Sambuc int sys_vmctl_set_addrspace(endpoint_t who,
31*433d6423SLionel Sambuc         phys_bytes ptroot, void *ptroot_v)
32*433d6423SLionel Sambuc {
33*433d6423SLionel Sambuc   message m;
34*433d6423SLionel Sambuc   int r;
35*433d6423SLionel Sambuc 
36*433d6423SLionel Sambuc   m.SVMCTL_WHO = who;
37*433d6423SLionel Sambuc   m.SVMCTL_PARAM = VMCTL_SETADDRSPACE;
38*433d6423SLionel Sambuc   m.SVMCTL_PTROOT = ptroot;
39*433d6423SLionel Sambuc   m.SVMCTL_PTROOT_V = ptroot_v;
40*433d6423SLionel Sambuc   r = _kernel_call(SYS_VMCTL, &m);
41*433d6423SLionel Sambuc 
42*433d6423SLionel Sambuc   return(r);
43*433d6423SLionel Sambuc }
44*433d6423SLionel Sambuc 
sys_vmctl_get_memreq(endpoint_t * who,vir_bytes * mem,vir_bytes * len,int * wrflag,endpoint_t * who_s,vir_bytes * mem_s,endpoint_t * requestor)45*433d6423SLionel Sambuc int sys_vmctl_get_memreq(endpoint_t *who, vir_bytes *mem,
46*433d6423SLionel Sambuc         vir_bytes *len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s,
47*433d6423SLionel Sambuc         endpoint_t *requestor)
48*433d6423SLionel Sambuc {
49*433d6423SLionel Sambuc   message m;
50*433d6423SLionel Sambuc   int r;
51*433d6423SLionel Sambuc 
52*433d6423SLionel Sambuc   m.SVMCTL_WHO = SELF;
53*433d6423SLionel Sambuc   m.SVMCTL_PARAM = VMCTL_MEMREQ_GET;
54*433d6423SLionel Sambuc   r = _kernel_call(SYS_VMCTL, &m);
55*433d6423SLionel Sambuc   if(r >= 0) {
56*433d6423SLionel Sambuc 	*who = m.SVMCTL_MRG_TARGET;
57*433d6423SLionel Sambuc 	*mem = m.SVMCTL_MRG_ADDR;
58*433d6423SLionel Sambuc 	*len = m.SVMCTL_MRG_LENGTH;
59*433d6423SLionel Sambuc 	*wrflag = m.SVMCTL_MRG_FLAG;
60*433d6423SLionel Sambuc 	*who_s = m.SVMCTL_MRG_EP2;
61*433d6423SLionel Sambuc 	*mem_s = m.SVMCTL_MRG_ADDR2;
62*433d6423SLionel Sambuc 	*requestor = (endpoint_t) m.SVMCTL_MRG_REQUESTOR;
63*433d6423SLionel Sambuc   }
64*433d6423SLionel Sambuc   return r;
65*433d6423SLionel Sambuc }
66*433d6423SLionel Sambuc 
sys_vmctl_get_mapping(int index,phys_bytes * addr,phys_bytes * len,int * flags)67*433d6423SLionel Sambuc int sys_vmctl_get_mapping(int index,
68*433d6423SLionel Sambuc 	phys_bytes *addr, phys_bytes *len, int *flags)
69*433d6423SLionel Sambuc {
70*433d6423SLionel Sambuc 	int r;
71*433d6423SLionel Sambuc 	message m;
72*433d6423SLionel Sambuc 
73*433d6423SLionel Sambuc 	m.SVMCTL_WHO = SELF;
74*433d6423SLionel Sambuc 	m.SVMCTL_PARAM = VMCTL_KERN_PHYSMAP;
75*433d6423SLionel Sambuc 	m.SVMCTL_VALUE = (int) index;
76*433d6423SLionel Sambuc 
77*433d6423SLionel Sambuc 	r = _kernel_call(SYS_VMCTL, &m);
78*433d6423SLionel Sambuc 
79*433d6423SLionel Sambuc 	if(r != OK)
80*433d6423SLionel Sambuc 		return r;
81*433d6423SLionel Sambuc 
82*433d6423SLionel Sambuc 	*addr = m.SVMCTL_MAP_PHYS_ADDR;
83*433d6423SLionel Sambuc 	*len = m.SVMCTL_MAP_PHYS_LEN;
84*433d6423SLionel Sambuc 	*flags = m.SVMCTL_MAP_FLAGS;
85*433d6423SLionel Sambuc 
86*433d6423SLionel Sambuc 	return OK;
87*433d6423SLionel Sambuc }
88*433d6423SLionel Sambuc 
sys_vmctl_reply_mapping(int index,vir_bytes addr)89*433d6423SLionel Sambuc int sys_vmctl_reply_mapping(int index, vir_bytes addr)
90*433d6423SLionel Sambuc {
91*433d6423SLionel Sambuc 	message m;
92*433d6423SLionel Sambuc 
93*433d6423SLionel Sambuc 	m.SVMCTL_WHO = SELF;
94*433d6423SLionel Sambuc 	m.SVMCTL_PARAM = VMCTL_KERN_MAP_REPLY;
95*433d6423SLionel Sambuc 	m.SVMCTL_VALUE = index;
96*433d6423SLionel Sambuc 	m.SVMCTL_MAP_VIR_ADDR = (char *) addr;
97*433d6423SLionel Sambuc 
98*433d6423SLionel Sambuc 	return _kernel_call(SYS_VMCTL, &m);
99*433d6423SLionel Sambuc }
100