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>
23 #include "sanitycheck.h"
25 static void reset_vm_rusage(struct vmproc
*vmp
)
28 vmp
->vm_total_max
= 0;
29 vmp
->vm_minor_page_fault
= 0;
30 vmp
->vm_major_page_fault
= 0;
33 void free_proc(struct vmproc
*vmp
)
37 region_init(&vmp
->vm_regions_avl
);
39 vmp
->vm_bytecopies
= 0;
41 vmp
->vm_region_top
= 0;
45 void clear_proc(struct vmproc
*vmp
)
47 region_init(&vmp
->vm_regions_avl
);
49 vmp
->vm_flags
= 0; /* Clear INUSE, so slot is free. */
51 vmp
->vm_bytecopies
= 0;
53 vmp
->vm_region_top
= 0;
57 /*===========================================================================*
59 *===========================================================================*/
60 int do_exit(message
*msg
)
65 SANITYCHECK(SCL_FUNCTIONS
);
67 if(vm_isokendpt(msg
->VME_ENDPOINT
, &proc
) != OK
) {
68 printf("VM: bogus endpoint VM_EXIT %d\n", msg
->VME_ENDPOINT
);
73 if(!(vmp
->vm_flags
& VMF_EXITING
)) {
74 printf("VM: unannounced VM_EXIT %d\n", msg
->VME_ENDPOINT
);
77 if(vmp
->vm_flags
& VMF_VM_INSTANCE
) {
78 vmp
->vm_flags
&= ~VMF_VM_INSTANCE
;
83 /* Free pagetable and pages allocated by pt code. */
84 SANITYCHECK(SCL_DETAIL
);
86 SANITYCHECK(SCL_DETAIL
);
88 SANITYCHECK(SCL_DETAIL
);
90 /* Reset process slot fields. */
93 SANITYCHECK(SCL_FUNCTIONS
);
97 /*===========================================================================*
99 *===========================================================================*/
100 int do_willexit(message
*msg
)
105 if(vm_isokendpt(msg
->VMWE_ENDPOINT
, &proc
) != OK
) {
106 printf("VM: bogus endpoint VM_EXITING %d\n",
112 vmp
->vm_flags
|= VMF_EXITING
;
117 int do_procctl(message
*msg
, int transid
)
122 if(vm_isokendpt(msg
->VMPCTL_WHO
, &proc
) != OK
) {
123 printf("VM: bogus endpoint VM_PROCCTL %ld\n",
129 switch(msg
->VMPCTL_PARAM
) {
131 if(msg
->m_source
!= RS_PROC_NR
132 && msg
->m_source
!= VFS_PROC_NR
)
135 if(pt_new(&vmp
->vm_pt
) != OK
)
136 panic("VMPPARAM_CLEAR: pt_new failed");
137 pt_bind(&vmp
->vm_pt
, vmp
);
139 case VMPPARAM_HANDLEMEM
:
141 if(msg
->m_source
!= VFS_PROC_NR
)
144 handle_memory_start(vmp
, msg
->VMPCTL_M1
,
145 msg
->VMPCTL_LEN
, msg
->VMPCTL_FLAGS
,
146 VFS_PROC_NR
, VFS_PROC_NR
, transid
, 1);