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
);
80 /* Free pagetable and pages allocated by pt code. */
81 SANITYCHECK(SCL_DETAIL
);
83 SANITYCHECK(SCL_DETAIL
);
85 SANITYCHECK(SCL_DETAIL
);
87 /* Reset process slot fields. */
90 SANITYCHECK(SCL_FUNCTIONS
);
94 /*===========================================================================*
96 *===========================================================================*/
97 int do_willexit(message
*msg
)
102 if(vm_isokendpt(msg
->VMWE_ENDPOINT
, &proc
) != OK
) {
103 printf("VM: bogus endpoint VM_EXITING %d\n",
109 vmp
->vm_flags
|= VMF_EXITING
;
114 int do_procctl(message
*msg
, int transid
)
119 if(vm_isokendpt(msg
->VMPCTL_WHO
, &proc
) != OK
) {
120 printf("VM: bogus endpoint VM_PROCCTL %ld\n",
126 switch(msg
->VMPCTL_PARAM
) {
128 if(msg
->m_source
!= RS_PROC_NR
129 && msg
->m_source
!= VFS_PROC_NR
)
132 if(pt_new(&vmp
->vm_pt
) != OK
)
133 panic("VMPPARAM_CLEAR: pt_new failed");
134 pt_bind(&vmp
->vm_pt
, vmp
);
136 case VMPPARAM_HANDLEMEM
:
138 if(msg
->m_source
!= VFS_PROC_NR
)
141 handle_memory_start(vmp
, msg
->VMPCTL_M1
,
142 msg
->VMPCTL_LEN
, msg
->VMPCTL_FLAGS
,
143 VFS_PROC_NR
, VFS_PROC_NR
, transid
, 1);