Remove building with NOCRYPTO option
[minix.git] / minix / kernel / system / do_clear.c
blob372b28f89c126ebb008de33c508291b43957e746
1 /* The kernel call implemented in this file:
2 * m_type: SYS_CLEAR
4 * The parameters for this kernel call are:
5 * m_lsys_krn_sys_clear.endpt (endpoint of process to clean up)
6 */
8 #include "kernel/system.h"
10 #include <minix/endpoint.h>
12 #if USE_CLEAR
14 /*===========================================================================*
15 * do_clear *
16 *===========================================================================*/
17 int do_clear(struct proc * caller, message * m_ptr)
19 /* Handle sys_clear. Only the PM can request other process slots to be cleared
20 * when a process has exited.
21 * The routine to clean up a process table slot cancels outstanding timers,
22 * possibly removes the process from the message queues, and resets certain
23 * process table fields to the default values.
25 struct proc *rc;
26 int exit_p;
27 int i;
29 if(!isokendpt(m_ptr->m_lsys_krn_sys_clear.endpt, &exit_p)) {
30 /* get exiting process */
31 return EINVAL;
33 rc = proc_addr(exit_p); /* clean up */
35 release_address_space(rc);
37 /* Don't clear if already cleared. */
38 if(isemptyp(rc)) return OK;
40 /* Check the table with IRQ hooks to see if hooks should be released. */
41 for (i=0; i < NR_IRQ_HOOKS; i++) {
42 if (rc->p_endpoint == irq_hooks[i].proc_nr_e) {
43 rm_irq_handler(&irq_hooks[i]); /* remove interrupt handler */
44 irq_hooks[i].proc_nr_e = NONE; /* mark hook as free */
48 /* Remove the process' ability to send and receive messages */
49 clear_endpoint(rc);
51 /* Turn off any alarm timers at the clock. */
52 reset_kernel_timer(&priv(rc)->s_alarm_timer);
54 /* Make sure that the exiting process is no longer scheduled,
55 * and mark slot as FREE. Also mark saved fpu contents as not significant.
57 RTS_SETFLAGS(rc, RTS_SLOT_FREE);
59 /* release FPU */
60 release_fpu(rc);
61 rc->p_misc_flags &= ~MF_FPU_INITIALIZED;
63 /* Release the process table slot. If this is a system process, also
64 * release its privilege structure. Further cleanup is not needed at
65 * this point. All important fields are reinitialized when the
66 * slots are assigned to another, new process.
68 if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE;
70 #if 0
71 /* Clean up virtual memory */
72 if (rc->p_misc_flags & MF_VM) {
73 vm_map_default(rc);
75 #endif
77 return OK;
80 #endif /* USE_CLEAR */