Message type for SYS_EXEC

Change-Id: I349e28b8bb3705386f04e4860cffc6ed74a5532f
This commit is contained in:
Lionel Sambuc 2014-05-26 12:03:25 +02:00
parent cc0c1fbd75
commit 886c867c38
7 changed files with 34 additions and 25 deletions

View file

@ -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

View file

@ -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;

View file

@ -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 *);

View file

@ -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 <string.h>
@ -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, "<unset>", 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 */

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);