Message type for SYS_FORK
Change-Id: Ibcf4fdfec51129b2be3d667ec07aea0f42e3fd89
This commit is contained in:
parent
2027f8bc78
commit
cc0c1fbd75
4 changed files with 39 additions and 19 deletions
|
@ -359,8 +359,6 @@
|
|||
#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 */
|
||||
#define PR_FORK_FLAGS m1_i3 /* optional flags for fork operation */
|
||||
#define PR_FORK_MSGADDR m1_p1 /* reply message address of forked child */
|
||||
|
||||
/* Constants for exec. FIXME: these do not belong here. */
|
||||
#define PMEF_AUXVECTORS 20
|
||||
|
|
|
@ -719,6 +719,23 @@ typedef struct {
|
|||
} mess_lsys_krn_sys_copy;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_copy);
|
||||
|
||||
typedef struct {
|
||||
endpoint_t endpt;
|
||||
endpoint_t slot;
|
||||
uint32_t flags;
|
||||
|
||||
uint8_t padding[44];
|
||||
} mess_lsys_krn_sys_fork;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_fork);
|
||||
|
||||
typedef struct {
|
||||
endpoint_t endpt;
|
||||
vir_bytes msgaddr;
|
||||
|
||||
uint8_t padding[48];
|
||||
} mess_krn_lsys_sys_fork;
|
||||
_ASSERT_MSG_SIZE(mess_krn_lsys_sys_fork);
|
||||
|
||||
typedef struct {
|
||||
int request;
|
||||
endpoint_t endpt;
|
||||
|
@ -1582,6 +1599,7 @@ typedef struct {
|
|||
mess_sigcalls m_sigcalls;
|
||||
|
||||
mess_krn_lsys_schedule m_krn_lsys_schedule;
|
||||
mess_krn_lsys_sys_fork m_krn_lsys_sys_fork;
|
||||
mess_krn_lsys_sys_getwhoami m_krn_lsys_sys_getwhoami;
|
||||
mess_krn_lsys_sys_irqctl m_krn_lsys_sys_irqctl;
|
||||
mess_krn_lsys_sys_times m_krn_lsys_sys_times;
|
||||
|
@ -1666,6 +1684,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_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;
|
||||
mess_lsys_krn_sys_iopenable m_lsys_krn_sys_iopenable;
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
* m_type: SYS_FORK
|
||||
*
|
||||
* The parameters for this kernel call are:
|
||||
* m1_i1: PR_ENDPT (parent, process that forked)
|
||||
* m1_i2: PR_SLOT (child's process table slot)
|
||||
* m1_p1: PR_MEM_PTR (new memory map for the child)
|
||||
* m1_i3: PR_FORK_FLAGS (fork flags)
|
||||
* m_lsys_krn_sys_fork.endpt (parent, process that forked)
|
||||
* m_lsys_krn_sys_fork.slot (child's process table slot)
|
||||
* m_lsys_krn_sys_fork.flags (fork flags)
|
||||
* m_krn_lsys_sys_fork.endpt (endpoint of the child)
|
||||
* m_krn_lsys_sys_fork.msgaddr (new memory map for the child)
|
||||
*/
|
||||
|
||||
#include "kernel/system.h"
|
||||
|
@ -24,7 +25,10 @@
|
|||
*===========================================================================*/
|
||||
int do_fork(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
/* Handle sys_fork(). PR_ENDPT has forked. The child is PR_SLOT. */
|
||||
/* Handle sys_fork().
|
||||
* m_lsys_krn_sys_fork.endpt has forked.
|
||||
* The child is m_lsys_krn_sys_fork.slot.
|
||||
*/
|
||||
#if defined(__i386__)
|
||||
char *old_fpu_save_area_p;
|
||||
#endif
|
||||
|
@ -34,11 +38,11 @@ int do_fork(struct proc * caller, message * m_ptr)
|
|||
int p_proc;
|
||||
int namelen;
|
||||
|
||||
if(!isokendpt(m_ptr->PR_ENDPT, &p_proc))
|
||||
if(!isokendpt(m_ptr->m_lsys_krn_sys_fork.endpt, &p_proc))
|
||||
return EINVAL;
|
||||
|
||||
rpp = proc_addr(p_proc);
|
||||
rpc = proc_addr(m_ptr->PR_SLOT);
|
||||
rpc = proc_addr(m_ptr->m_lsys_krn_sys_fork.slot);
|
||||
if (isemptyp(rpp) || ! isemptyp(rpc)) return(EINVAL);
|
||||
|
||||
assert(!(rpp->p_misc_flags & MF_DELIVERMSG));
|
||||
|
@ -64,7 +68,7 @@ int do_fork(struct proc * caller, message * m_ptr)
|
|||
#endif
|
||||
if(++gen >= _ENDPOINT_MAX_GENERATION) /* increase generation */
|
||||
gen = 1; /* generation number wraparound */
|
||||
rpc->p_nr = m_ptr->PR_SLOT; /* this was obliterated by copy */
|
||||
rpc->p_nr = m_ptr->m_lsys_krn_sys_fork.slot; /* this was obliterated by copy */
|
||||
rpc->p_endpoint = _ENDPOINT(gen, rpc->p_nr); /* new endpoint of slot */
|
||||
|
||||
rpc->p_reg.retreg = 0; /* child sees pid = 0 to know it is child */
|
||||
|
@ -102,11 +106,11 @@ int do_fork(struct proc * caller, message * m_ptr)
|
|||
}
|
||||
|
||||
/* Calculate endpoint identifier, so caller knows what it is. */
|
||||
m_ptr->PR_ENDPT = rpc->p_endpoint;
|
||||
m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir;
|
||||
m_ptr->m_krn_lsys_sys_fork.endpt = rpc->p_endpoint;
|
||||
m_ptr->m_krn_lsys_sys_fork.msgaddr = rpp->p_delivermsg_vir;
|
||||
|
||||
/* Don't schedule process in VM mode until it has a new pagetable. */
|
||||
if(m_ptr->PR_FORK_FLAGS & PFF_VMINHIBIT) {
|
||||
if(m_ptr->m_lsys_krn_sys_fork.flags & PFF_VMINHIBIT) {
|
||||
RTS_SET(rpc, RTS_VMINHIBIT);
|
||||
}
|
||||
|
||||
|
@ -128,4 +132,3 @@ int do_fork(struct proc * caller, message * m_ptr)
|
|||
}
|
||||
|
||||
#endif /* USE_FORK */
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ vir_bytes *msgaddr;
|
|||
message m;
|
||||
int r;
|
||||
|
||||
m.PR_ENDPT = parent;
|
||||
m.PR_SLOT = child;
|
||||
m.PR_FORK_FLAGS = flags;
|
||||
m.m_lsys_krn_sys_fork.endpt = parent;
|
||||
m.m_lsys_krn_sys_fork.slot = child;
|
||||
m.m_lsys_krn_sys_fork.flags = flags;
|
||||
r = _kernel_call(SYS_FORK, &m);
|
||||
*child_endpoint = m.PR_ENDPT;
|
||||
*msgaddr = (vir_bytes) m.PR_FORK_MSGADDR;
|
||||
*child_endpoint = m.m_krn_lsys_sys_fork.endpt;
|
||||
*msgaddr = m.m_krn_lsys_sys_fork.msgaddr;
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue