source: trunk/minix/kernel/system/do_exec.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.9 KB
Line 
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_ENDPT (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#include <minix/endpoint.h>
14
15#if USE_EXEC
16
17/*===========================================================================*
18 * do_exec *
19 *===========================================================================*/
20PUBLIC int do_exec(m_ptr)
21register message *m_ptr; /* pointer to request message */
22{
23/* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */
24 register struct proc *rp;
25 reg_t sp; /* new sp */
26 phys_bytes phys_name;
27 char *np;
28 int proc;
29
30 if(!isokendpt(m_ptr->PR_ENDPT, &proc))
31 return EINVAL;
32
33 rp = proc_addr(proc);
34 sp = (reg_t) m_ptr->PR_STACK_PTR;
35 rp->p_reg.sp = sp; /* set the stack pointer */
36#if (CHIP == M68000)
37 rp->p_splow = sp; /* set the stack pointer low water */
38#ifdef FPP
39 /* Initialize fpp for this process */
40 fpp_new_state(rp);
41#endif
42#endif
43#if (CHIP == INTEL) /* wipe extra LDT entries */
44 phys_memset(vir2phys(&rp->p_ldt[EXTRA_LDT_INDEX]), 0,
45 (LDT_SIZE - EXTRA_LDT_INDEX) * sizeof(rp->p_ldt[0]));
46#endif
47 rp->p_reg.pc = (reg_t) m_ptr->PR_IP_PTR; /* set pc */
48 rp->p_rts_flags &= ~RECEIVING; /* PM does not reply to EXEC call */
49 if (rp->p_rts_flags == 0) lock_enqueue(rp);
50 /* Save command name for debugging, ps(1) output, etc. */
51 phys_name = numap_local(who_p, (vir_bytes) m_ptr->PR_NAME_PTR,
52 (vir_bytes) P_NAME_LEN - 1);
53 if (phys_name != 0) {
54 phys_copy(phys_name, vir2phys(rp->p_name), (phys_bytes) P_NAME_LEN - 1);
55 for (np = rp->p_name; (*np & BYTE) >= ' '; np++) {}
56 *np = 0; /* mark end */
57 } else {
58 strncpy(rp->p_name, "<unset>", P_NAME_LEN);
59 }
60 return(OK);
61}
62#endif /* USE_EXEC */
63
Note: See TracBrowser for help on using the repository browser.