From: Lionel Sambuc Date: Mon, 26 May 2014 10:03:25 +0000 (+0200) Subject: Message type for SYS_EXEC X-Git-Tag: v3.3.0~211 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch05.html?a=commitdiff_plain;h=886c867c38d2a7b94f04fcd494b8f2129982d230;p=minix.git Message type for SYS_EXEC Change-Id: I349e28b8bb3705386f04e4860cffc6ed74a5532f --- diff --git a/include/minix/com.h b/include/minix/com.h index 13c27237a..3c30633c4 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -353,12 +353,6 @@ /* Field names for SYS_FORK, _EXEC, _EXIT, GETMCONTEXT, SETMCONTEXT.*/ #define PR_ENDPT m1_i1 /* indicates a process */ -#define PR_PRIORITY m1_i2 /* process priority */ -#define PR_SLOT m1_i2 /* indicates a process slot */ -#define PR_STACK_PTR m1_p1 /* used for stack ptr in sys_exec, sys_getsp */ -#define PR_NAME_PTR m1_p2 /* tells where program name is for dmp */ -#define PR_IP_PTR m1_p3 /* initial value for ip after exec */ -#define PR_PS_STR_PTR m1_p4 /* pointer to ps_strings, expected by __start */ /* Constants for exec. FIXME: these do not belong here. */ #define PMEF_AUXVECTORS 20 diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 62fa2174b..fc0f2f3f8 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -719,6 +719,17 @@ typedef struct { } mess_lsys_krn_sys_copy; _ASSERT_MSG_SIZE(mess_lsys_krn_sys_copy); +typedef struct { + endpoint_t endpt; + vir_bytes ip; + vir_bytes stack; + vir_bytes name; + vir_bytes ps_str; + + uint8_t padding[36]; +} mess_lsys_krn_sys_exec; +_ASSERT_MSG_SIZE(mess_lsys_krn_sys_exec); + typedef struct { endpoint_t endpt; endpoint_t slot; @@ -1684,6 +1695,7 @@ typedef struct { mess_lsys_krn_schedule m_lsys_krn_schedule; mess_lsys_krn_sys_abort m_lsys_krn_sys_abort; mess_lsys_krn_sys_copy m_lsys_krn_sys_copy; + mess_lsys_krn_sys_exec m_lsys_krn_sys_exec; mess_lsys_krn_sys_fork m_lsys_krn_sys_fork; mess_lsys_krn_sys_getinfo m_lsys_krn_sys_getinfo; mess_lsys_krn_sys_getmcontext m_lsys_krn_sys_getmcontext; diff --git a/include/minix/syslib.h b/include/minix/syslib.h index ad7d8d8de..a9ac48788 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -29,7 +29,7 @@ int _kernel_call(int syscallnr, message *msgptr); int sys_abort(int how); int sys_enable_iop(endpoint_t proc_ep); -int sys_exec(endpoint_t proc_ep, char *stack_ptr, char *progname, +int sys_exec(endpoint_t proc_ep, vir_bytes stack_ptr, vir_bytes progname, vir_bytes pc, vir_bytes ps_str); int sys_fork(endpoint_t parent, endpoint_t child, endpoint_t *, u32_t vm, vir_bytes *); diff --git a/kernel/system/do_exec.c b/kernel/system/do_exec.c index 9c038a131..f97901c36 100644 --- a/kernel/system/do_exec.c +++ b/kernel/system/do_exec.c @@ -2,10 +2,11 @@ * m_type: SYS_EXEC * * The parameters for this kernel call are: - * m1_i1: PR_ENDPT (process that did exec call) - * m1_p1: PR_STACK_PTR (new stack pointer) - * m1_p2: PR_NAME_PTR (pointer to program name) - * m1_p3: PR_IP_PTR (new instruction pointer) + * m_lsys_krn_sys_exec.endpt (process that did exec call) + * m_lsys_krn_sys_exec.stack (new stack pointer) + * m_lsys_krn_sys_exec.name (pointer to program name) + * m_lsys_krn_sys_exec.ip (new instruction pointer) + * m_lsys_krn_sys_exec.ps_str (struct ps_strings *) */ #include "kernel/system.h" #include @@ -23,7 +24,7 @@ int do_exec(struct proc * caller, message * m_ptr) int proc_nr; char name[PROC_NAME_LEN]; - if(!isokendpt(m_ptr->PR_ENDPT, &proc_nr)) + if(!isokendpt(m_ptr->m_lsys_krn_sys_exec.endpt, &proc_nr)) return EINVAL; rp = proc_addr(proc_nr); @@ -33,7 +34,7 @@ int do_exec(struct proc * caller, message * m_ptr) } /* Save command name for debugging, ps(1) output, etc. */ - if(data_copy(caller->p_endpoint, (vir_bytes) m_ptr->PR_NAME_PTR, + if(data_copy(caller->p_endpoint, m_ptr->m_lsys_krn_sys_exec.name, KERNEL, (vir_bytes) name, (phys_bytes) sizeof(name) - 1) != OK) strncpy(name, "", PROC_NAME_LEN); @@ -41,8 +42,10 @@ int do_exec(struct proc * caller, message * m_ptr) name[sizeof(name)-1] = '\0'; /* Set process state. */ - arch_proc_init(rp, (u32_t) m_ptr->PR_IP_PTR, (u32_t) m_ptr->PR_STACK_PTR, - (u32_t) m_ptr->PR_PS_STR_PTR, name); + arch_proc_init(rp, + (u32_t) m_ptr->m_lsys_krn_sys_exec.ip, + (u32_t) m_ptr->m_lsys_krn_sys_exec.stack, + (u32_t) m_ptr->m_lsys_krn_sys_exec.ps_str, name); /* No reply to EXEC call */ RTS_UNSET(rp, RTS_RECEIVING); @@ -55,4 +58,3 @@ int do_exec(struct proc * caller, message * m_ptr) return(OK); } #endif /* USE_EXEC */ - diff --git a/lib/libsys/sys_exec.c b/lib/libsys/sys_exec.c index 342dd4a44..ed585f41c 100644 --- a/lib/libsys/sys_exec.c +++ b/lib/libsys/sys_exec.c @@ -1,17 +1,17 @@ #include "syslib.h" -int sys_exec(endpoint_t proc_ep, char *stack_ptr, char *progname, +int sys_exec(endpoint_t proc_ep, vir_bytes stack_ptr, vir_bytes progname, vir_bytes pc, vir_bytes ps_str) { /* A process has exec'd. Tell the kernel. */ message m; - m.PR_ENDPT = proc_ep; - m.PR_STACK_PTR = stack_ptr; - m.PR_NAME_PTR = progname; - m.PR_IP_PTR = (char *)pc; - m.PR_PS_STR_PTR = (char *)ps_str; + m.m_lsys_krn_sys_exec.endpt = proc_ep; + m.m_lsys_krn_sys_exec.stack = stack_ptr; + m.m_lsys_krn_sys_exec.name = progname; + m.m_lsys_krn_sys_exec.ip = pc; + m.m_lsys_krn_sys_exec.ps_str = ps_str; return _kernel_call(SYS_EXEC, &m); } diff --git a/servers/pm/exec.c b/servers/pm/exec.c index 5e6b3ad35..123534e0d 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -189,7 +189,7 @@ void exec_restart(struct mproc *rmp, int result, vir_bytes pc, vir_bytes sp, } /* Call kernel to exec with SP and PC set by VFS. */ - r = sys_exec(rmp->mp_endpoint, (char *) sp, rmp->mp_name, pc, ps_str); + r = sys_exec(rmp->mp_endpoint, sp, (vir_bytes)rmp->mp_name, pc, ps_str); if (r != OK) panic("sys_exec failed: %d", r); } diff --git a/servers/vm/main.c b/servers/vm/main.c index 8fbb769d2..cc738ab94 100644 --- a/servers/vm/main.c +++ b/servers/vm/main.c @@ -342,8 +342,9 @@ static void exec_bootproc(struct vmproc *vmp, struct boot_image *ip) panic("vm: could not copy stack for boot process %s (ep=%d)\n", execi->progname, vmp->vm_endpoint); - if(sys_exec(vmp->vm_endpoint, (char *)vsp, execi->progname, execi->pc, - vsp + ((int)psp - (int)frame)) != OK) + if(sys_exec(vmp->vm_endpoint, (vir_bytes)vsp, + (vir_bytes)execi->progname, execi->pc, + vsp + ((int)psp - (int)frame)) != OK) panic("vm: boot process exec of process %s (ep=%d) failed\n", execi->progname,vmp->vm_endpoint);