4 #include <minix/callnr.h>
6 #include <minix/config.h>
7 #include <minix/const.h>
9 #include <minix/endpoint.h>
10 #include <minix/minlib.h>
11 #include <minix/type.h>
12 #include <minix/ipc.h>
13 #include <minix/sysutil.h>
14 #include <minix/syslib.h>
15 #include <minix/bitmap.h>
24 #include "sanitycheck.h"
26 static void reset_vm_rusage(struct vmproc
*vmp
)
29 vmp
->vm_total_max
= 0;
30 vmp
->vm_minor_page_fault
= 0;
31 vmp
->vm_major_page_fault
= 0;
34 void free_proc(struct vmproc
*vmp
)
38 region_init(&vmp
->vm_regions_avl
);
40 vmp
->vm_bytecopies
= 0;
42 vmp
->vm_region_top
= 0;
46 void clear_proc(struct vmproc
*vmp
)
48 region_init(&vmp
->vm_regions_avl
);
50 vmp
->vm_flags
= 0; /* Clear INUSE, so slot is free. */
52 vmp
->vm_bytecopies
= 0;
54 vmp
->vm_region_top
= 0;
58 /*===========================================================================*
60 *===========================================================================*/
61 int do_exit(message
*msg
)
66 SANITYCHECK(SCL_FUNCTIONS
);
68 if(vm_isokendpt(msg
->VME_ENDPOINT
, &proc
) != OK
) {
69 printf("VM: bogus endpoint VM_EXIT %d\n", msg
->VME_ENDPOINT
);
74 if(!(vmp
->vm_flags
& VMF_EXITING
)) {
75 printf("VM: unannounced VM_EXIT %d\n", msg
->VME_ENDPOINT
);
78 if(vmp
->vm_flags
& VMF_VM_INSTANCE
) {
79 vmp
->vm_flags
&= ~VMF_VM_INSTANCE
;
84 /* Free pagetable and pages allocated by pt code. */
85 SANITYCHECK(SCL_DETAIL
);
87 SANITYCHECK(SCL_DETAIL
);
89 SANITYCHECK(SCL_DETAIL
);
91 /* Reset process slot fields. */
94 SANITYCHECK(SCL_FUNCTIONS
);
98 /*===========================================================================*
100 *===========================================================================*/
101 int do_willexit(message
*msg
)
106 if(vm_isokendpt(msg
->VMWE_ENDPOINT
, &proc
) != OK
) {
107 printf("VM: bogus endpoint VM_EXITING %d\n",
113 vmp
->vm_flags
|= VMF_EXITING
;
118 int do_procctl(message
*msg
, int transid
)
123 if(vm_isokendpt(msg
->VMPCTL_WHO
, &proc
) != OK
) {
124 printf("VM: bogus endpoint VM_PROCCTL %ld\n",
130 switch(msg
->VMPCTL_PARAM
) {
132 if(msg
->m_source
!= RS_PROC_NR
133 && msg
->m_source
!= VFS_PROC_NR
)
136 if(pt_new(&vmp
->vm_pt
) != OK
)
137 panic("VMPPARAM_CLEAR: pt_new failed");
138 pt_bind(&vmp
->vm_pt
, vmp
);
140 case VMPPARAM_HANDLEMEM
:
142 if(msg
->m_source
!= VFS_PROC_NR
)
145 handle_memory_start(vmp
, msg
->VMPCTL_M1
,
146 msg
->VMPCTL_LEN
, msg
->VMPCTL_FLAGS
,
147 VFS_PROC_NR
, VFS_PROC_NR
, transid
, 1);