4 #include <minix/callnr.h>
6 #include <minix/config.h>
7 #include <minix/const.h>
9 #include <minix/endpoint.h>
10 #include <minix/keymap.h>
11 #include <minix/minlib.h>
12 #include <minix/type.h>
13 #include <minix/ipc.h>
14 #include <minix/sysutil.h>
15 #include <minix/syslib.h>
16 #include <minix/bitmap.h>
25 #include "sanitycheck.h"
27 PUBLIC
void free_proc(struct vmproc
*vmp
)
30 if(vmp
->vm_flags
& VMF_HASPT
) {
31 vmp
->vm_flags
&= ~VMF_HASPT
;
34 vmp
->vm_regions
= NULL
;
36 vmp
->vm_bytecopies
= 0;
40 PUBLIC
void clear_proc(struct vmproc
*vmp
)
42 vmp
->vm_regions
= NULL
;
43 vmp
->vm_callback
= NULL
; /* No pending vfs callback. */
44 vmp
->vm_flags
= 0; /* Clear INUSE, so slot is free. */
48 vmp
->vm_bytecopies
= 0;
52 /*===========================================================================*
54 *===========================================================================*/
55 PUBLIC
int do_exit(message
*msg
)
60 SANITYCHECK(SCL_FUNCTIONS
);
62 if(vm_isokendpt(msg
->VME_ENDPOINT
, &proc
) != OK
) {
63 printf("VM: bogus endpoint VM_EXIT %d\n", msg
->VME_ENDPOINT
);
67 if(!(vmp
->vm_flags
& VMF_EXITING
)) {
68 printf("VM: unannounced VM_EXIT %d\n", msg
->VME_ENDPOINT
);
72 if(vmp
->vm_flags
& VMF_HAS_DMA
) {
74 } else if(vmp
->vm_flags
& VMF_HASPT
) {
75 /* Free pagetable and pages allocated by pt code. */
76 SANITYCHECK(SCL_DETAIL
);
78 SANITYCHECK(SCL_DETAIL
);
80 /* Free the data and stack segments. */
81 free_mem(vmp
->vm_arch
.vm_seg
[D
].mem_phys
,
82 vmp
->vm_arch
.vm_seg
[S
].mem_vir
+
83 vmp
->vm_arch
.vm_seg
[S
].mem_len
-
84 vmp
->vm_arch
.vm_seg
[D
].mem_vir
);
86 if (find_share(vmp
, vmp
->vm_ino
, vmp
->vm_dev
, vmp
->vm_ctime
) == NULL
) {
87 /* No other process shares the text segment,
90 free_mem(vmp
->vm_arch
.vm_seg
[T
].mem_phys
,
91 vmp
->vm_arch
.vm_seg
[T
].mem_len
);
94 SANITYCHECK(SCL_DETAIL
);
96 /* Reset process slot fields. */
99 SANITYCHECK(SCL_FUNCTIONS
);
103 /*===========================================================================*
105 *===========================================================================*/
106 PUBLIC
int do_willexit(message
*msg
)
111 if(vm_isokendpt(msg
->VMWE_ENDPOINT
, &proc
) != OK
) {
112 printf("VM: bogus endpoint VM_EXITING %d\n",
118 vmp
->vm_flags
|= VMF_EXITING
;