2008-11-19 13:26:10 +01:00
|
|
|
#include "syslib.h"
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl(endpoint_t who, int param, u32_t value)
|
2008-11-19 13:26:10 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = who;
|
|
|
|
m.SVMCTL_PARAM = param;
|
|
|
|
m.SVMCTL_VALUE = value;
|
2010-02-09 16:20:09 +01:00
|
|
|
r = _kernel_call(SYS_VMCTL, &m);
|
2008-11-19 13:26:10 +01:00
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_get_cr3_i386(endpoint_t who, u32_t *cr3)
|
2008-11-19 13:26:10 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = who;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_I386_GETCR3;
|
2010-02-09 16:20:09 +01:00
|
|
|
r = _kernel_call(SYS_VMCTL, &m);
|
2008-11-19 13:26:10 +01:00
|
|
|
if(r == OK) {
|
|
|
|
*cr3 = m.SVMCTL_VALUE;
|
|
|
|
}
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_set_addrspace(endpoint_t who,
|
2010-05-12 10:31:05 +02:00
|
|
|
phys_bytes ptroot, void *ptroot_v)
|
|
|
|
{
|
|
|
|
message m;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = who;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_SETADDRSPACE;
|
|
|
|
m.SVMCTL_PTROOT = ptroot;
|
|
|
|
m.SVMCTL_PTROOT_V = ptroot_v;
|
|
|
|
r = _kernel_call(SYS_VMCTL, &m);
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_get_memreq(endpoint_t *who, vir_bytes *mem,
|
2010-01-14 16:24:16 +01:00
|
|
|
vir_bytes *len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s,
|
|
|
|
endpoint_t *requestor)
|
2008-11-19 13:26:10 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = SELF;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_MEMREQ_GET;
|
2010-02-09 16:20:09 +01:00
|
|
|
r = _kernel_call(SYS_VMCTL, &m);
|
2010-01-14 16:24:16 +01:00
|
|
|
if(r >= 0) {
|
|
|
|
*who = m.SVMCTL_MRG_TARGET;
|
|
|
|
*mem = m.SVMCTL_MRG_ADDR;
|
|
|
|
*len = m.SVMCTL_MRG_LENGTH;
|
|
|
|
*wrflag = m.SVMCTL_MRG_FLAG;
|
|
|
|
*who_s = m.SVMCTL_MRG_EP2;
|
|
|
|
*mem_s = m.SVMCTL_MRG_ADDR2;
|
2009-09-21 16:42:58 +02:00
|
|
|
*requestor = (endpoint_t) m.SVMCTL_MRG_REQUESTOR;
|
2008-11-19 13:26:10 +01:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
2008-12-16 15:42:32 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_enable_paging(void * data)
|
2009-09-21 16:42:58 +02:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
m.SVMCTL_WHO = SELF;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_ENABLE_PAGING;
|
2010-03-22 08:42:52 +01:00
|
|
|
m.SVMCTL_VALUE = (u32_t) data;
|
2010-02-09 16:20:09 +01:00
|
|
|
return _kernel_call(SYS_VMCTL, &m);
|
2009-09-21 16:42:58 +02:00
|
|
|
}
|
2009-11-11 13:07:06 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_get_mapping(int index,
|
2009-11-11 13:07:06 +01:00
|
|
|
phys_bytes *addr, phys_bytes *len, int *flags)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
message m;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = SELF;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_KERN_PHYSMAP;
|
|
|
|
m.SVMCTL_VALUE = (int) index;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
r = _kernel_call(SYS_VMCTL, &m);
|
2009-11-11 13:07:06 +01:00
|
|
|
|
|
|
|
if(r != OK)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
*addr = m.SVMCTL_MAP_PHYS_ADDR;
|
|
|
|
*len = m.SVMCTL_MAP_PHYS_LEN;
|
|
|
|
*flags = m.SVMCTL_MAP_FLAGS;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_vmctl_reply_mapping(int index, vir_bytes addr)
|
2009-11-11 13:07:06 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
|
|
|
m.SVMCTL_WHO = SELF;
|
|
|
|
m.SVMCTL_PARAM = VMCTL_KERN_MAP_REPLY;
|
|
|
|
m.SVMCTL_VALUE = index;
|
|
|
|
m.SVMCTL_MAP_VIR_ADDR = (char *) addr;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return _kernel_call(SYS_VMCTL, &m);
|
2009-11-11 13:07:06 +01:00
|
|
|
}
|