1 /* The kernel call implemented in this file:
2 * m_type: SYS_EXEC
3 *
4 * The parameters for this kernel call are:
5 * m1_i1: PR_PROC_NR (process that did exec call)
6 * m1_p1: PR_STACK_PTR (new stack pointer)
7 * m1_p2: PR_NAME_PTR (pointer to program name)
8 * m1_p3: PR_IP_PTR (new instruction pointer)
9 */
10 #include "../system.h"
11 #include <string.h>
12 #include <signal.h>
13
14 #if USE_EXEC
15
16 /*===========================================================================*
17 * do_exec *
18 *===========================================================================*/
19 PUBLIC int do_exec(m_ptr)
20 register message *m_ptr; /* pointer to request message */
21 {
22 /* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */
23 register struct proc *rp;
24 reg_t sp; /* new sp */
25 phys_bytes phys_name;
26 char *np;
27
28 rp = proc_addr(m_ptr->PR_PROC_NR);
29 sp = (reg_t) m_ptr->PR_STACK_PTR;
30 rp->p_reg.sp = sp; /* set the stack pointer */
31 #if (CHIP == M68000)
32 rp->p_splow = sp; /* set the stack pointer low water */
33 #ifdef FPP
34 /* Initialize fpp for this process */
35 fpp_new_state(rp);
36 #endif
37 #endif
38 #if (CHIP == INTEL) /* wipe extra LDT entries */
39 phys_memset(vir2phys(&rp->p_ldt[EXTRA_LDT_INDEX]), 0,
40 (LDT_SIZE - EXTRA_LDT_INDEX) * sizeof(rp->p_ldt[0]));
41 #endif
42 rp->p_reg.pc = (reg_t) m_ptr->PR_IP_PTR; /* set pc */
43 rp->p_rts_flags &= ~RECEIVING; /* PM does not reply to EXEC call */
44 if (rp->p_rts_flags == 0) lock_enqueue(rp);
45
46 /* Save command name for debugging, ps(1) output, etc. */
47 phys_name = numap_local(m_ptr->m_source, (vir_bytes) m_ptr->PR_NAME_PTR,
48 (vir_bytes) P_NAME_LEN - 1);
49 if (phys_name != 0) {
50 phys_copy(phys_name, vir2phys(rp->p_name), (phys_bytes) P_NAME_LEN - 1);
51 for (np = rp->p_name; (*np & BYTE) >= ' '; np++) {}
52 *np = 0; /* mark end */
53 } else {
54 strncpy(rp->p_name, "<unset>", P_NAME_LEN);
55 }
56 return(OK);
57 }
58 #endif /* USE_EXEC */
59
Cache object: a2ec88b9b3fe9baf4202d46540e36a70
|