1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * SVMCTL_WHO which process
6 * SVMCTL_PARAM set this setting (VMCTL_*)
7 * SVMCTL_VALUE to this value
10 #include "../system.h"
13 #include <minix/type.h>
14 #include <minix/config.h>
16 /*===========================================================================*
18 *===========================================================================*/
19 PUBLIC
int do_vmctl(m_ptr
)
20 register message
*m_ptr
; /* pointer to request message */
23 endpoint_t ep
= m_ptr
->SVMCTL_WHO
;
26 if(ep
== SELF
) { ep
= m_ptr
->m_source
; }
30 if(!isokendpt(ep
, &proc_nr
)) {
31 kprintf("do_vmctl: unexpected endpoint %d from VM\n", ep
);
35 p
= proc_addr(proc_nr
);
37 switch(m_ptr
->SVMCTL_PARAM
) {
38 case VMCTL_CLEAR_PAGEFAULT
:
39 RTS_LOCK_UNSET(p
, PAGEFAULT
);
41 case VMCTL_MEMREQ_GET
:
42 /* Send VM the information about the memory request. */
45 if(!RTS_ISSET(rp
, VMREQUEST
))
46 minix_panic("do_vmctl: no VMREQUEST set", NO_NUM
);
48 /* Reply with request fields. */
49 m_ptr
->SVMCTL_MRG_ADDR
= (char *) rp
->p_vmrequest
.start
;
50 m_ptr
->SVMCTL_MRG_LEN
= rp
->p_vmrequest
.length
;
51 m_ptr
->SVMCTL_MRG_WRITE
= rp
->p_vmrequest
.writeflag
;
52 m_ptr
->SVMCTL_MRG_EP
= rp
->p_vmrequest
.who
;
53 rp
->p_vmrequest
.vmresult
= VMSUSPEND
;
55 /* Remove from request chain. */
56 vmrequest
= vmrequest
->p_vmrequest
.nextrequestor
;
59 case VMCTL_MEMREQ_REPLY
:
60 if(!(rp
= p
->p_vmrequest
.requestor
))
61 minix_panic("do_vmctl: no requestor set", ep
);
62 p
->p_vmrequest
.requestor
= NULL
;
63 if(!RTS_ISSET(rp
, VMREQUEST
))
64 minix_panic("do_vmctl: no VMREQUEST set", ep
);
65 if(rp
->p_vmrequest
.vmresult
!= VMSUSPEND
)
66 minix_panic("do_vmctl: result not VMSUSPEND set",
67 rp
->p_vmrequest
.vmresult
);
68 rp
->p_vmrequest
.vmresult
= m_ptr
->SVMCTL_VALUE
;
69 if(rp
->p_vmrequest
.vmresult
== VMSUSPEND
)
70 minix_panic("VM returned VMSUSPEND?", NO_NUM
);
71 if(rp
->p_vmrequest
.vmresult
!= OK
)
72 kprintf("SYSTEM: VM replied %d to mem request\n",
73 rp
->p_vmrequest
.vmresult
);
75 /* Put on restart chain. */
76 rp
->p_vmrequest
.nextrestart
= vmrestart
;
81 if(rp
->p_vmrequest
.vmresult
== OK
) {
83 rp
->p_vmrequest
.start
,
84 rp
->p_vmrequest
.length
,
85 rp
->p_vmrequest
.writeflag
) != OK
) {
86 kprintf("SYSTEM: request %d:0x%lx-0x%lx, wrflag %d, failed\n",
88 rp
->p_vmrequest
.start
, rp
->p_vmrequest
.start
+ rp
->p_vmrequest
.length
,
89 rp
->p_vmrequest
.writeflag
);
91 minix_panic("SYSTEM: fail but VM said OK", NO_NUM
);
96 #if VM_KERN_NOPAGEZERO
97 case VMCTL_NOPAGEZERO
:
102 /* Try architecture-specific vmctls. */
103 return arch_do_vmctl(m_ptr
, p
);