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>
24 #include "sanitycheck.h"
26 PUBLIC
void free_proc(struct vmproc
*vmp
)
28 if(vmp
->vm_flags
& VMF_HASPT
) {
29 vmp
->vm_flags
&= ~VMF_HASPT
;
33 vmp
->vm_regions
= NULL
;
35 vmp
->vm_bytecopies
= 0;
39 PUBLIC
void clear_proc(struct vmproc
*vmp
)
41 vmp
->vm_regions
= NULL
;
42 vmp
->vm_callback
= NULL
; /* No pending vfs callback. */
43 vmp
->vm_flags
= 0; /* Clear INUSE, so slot is free. */
47 vmp
->vm_bytecopies
= 0;
51 /*===========================================================================*
53 *===========================================================================*/
54 PUBLIC
int do_exit(message
*msg
)
59 SANITYCHECK(SCL_FUNCTIONS
);
61 if(vm_isokendpt(msg
->VME_ENDPOINT
, &proc
) != OK
) {
62 printf("VM: bogus endpoint VM_EXIT %d\n", msg
->VME_ENDPOINT
);
66 if(!(vmp
->vm_flags
& VMF_EXITING
)) {
67 printf("VM: unannounced VM_EXIT %d\n", msg
->VME_ENDPOINT
);
71 if(vmp
->vm_flags
& VMF_HAS_DMA
) {
73 } else if(vmp
->vm_flags
& VMF_HASPT
) {
74 /* Free pagetable and pages allocated by pt code. */
75 SANITYCHECK(SCL_DETAIL
);
77 SANITYCHECK(SCL_DETAIL
);
79 /* Free the data and stack segments. */
80 FREE_MEM(vmp
->vm_arch
.vm_seg
[D
].mem_phys
,
81 vmp
->vm_arch
.vm_seg
[S
].mem_vir
+
82 vmp
->vm_arch
.vm_seg
[S
].mem_len
-
83 vmp
->vm_arch
.vm_seg
[D
].mem_vir
);
85 if (find_share(vmp
, vmp
->vm_ino
, vmp
->vm_dev
, vmp
->vm_ctime
) == NULL
) {
86 /* No other process shares the text segment,
89 FREE_MEM(vmp
->vm_arch
.vm_seg
[T
].mem_phys
,
90 vmp
->vm_arch
.vm_seg
[T
].mem_len
);
93 SANITYCHECK(SCL_DETAIL
);
95 /* Reset process slot fields. */
98 SANITYCHECK(SCL_FUNCTIONS
);
102 /*===========================================================================*
104 *===========================================================================*/
105 PUBLIC
int do_willexit(message
*msg
)
110 if(vm_isokendpt(msg
->VMWE_ENDPOINT
, &proc
) != OK
) {
111 printf("VM: bogus endpoint VM_EXITING %d\n",
117 vmp
->vm_flags
|= VMF_EXITING
;
122 PUBLIC
void _exit(int code
)
127 PUBLIC
void __exit(int code
)