From: Tomas Hruby Date: Tue, 1 Jun 2010 08:51:37 +0000 (+0000) Subject: do_safecopy split X-Git-Tag: v3.1.7~23 X-Git-Url: http://zhaoyanbai.com/repos/man.host.html?a=commitdiff_plain;h=ebbd319ac0caacb4a10b6b56903871732fe7abd5;p=minix.git do_safecopy split - removes dependency of do_safecopy() on the m_type field of the kcall messages. - instead of do_safecopy() figuring out what action is requested, the correct safecopy method is called right away. --- diff --git a/kernel/proc.c b/kernel/proc.c index 40e454bf9..4980356e3 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -588,10 +588,10 @@ const int flags; caller_ptr->p_sendto_e = dst_e; /* Process is now blocked. Put in on the destination's queue. */ - assert(caller_ptr->p_q_link == NULL); xpp = &dst_ptr->p_caller_q; /* find end of list */ while (*xpp) xpp = &(*xpp)->p_q_link; *xpp = caller_ptr; /* add caller to end */ + caller_ptr->p_q_link = NULL; /* mark new end of list */ } return(OK); } @@ -697,40 +697,37 @@ const int flags; /* Check caller queue. Use pointer pointers to keep code simple. */ xpp = &caller_ptr->p_caller_q; while (*xpp) { - struct proc * sender = *xpp; - - if (src_e == ANY || src_p == proc_nr(sender)) { + if (src_e == ANY || src_p == proc_nr(*xpp)) { int call; - assert(!RTS_ISSET(sender, RTS_SLOT_FREE)); - assert(!RTS_ISSET(sender, RTS_NO_ENDPOINT)); + assert(!RTS_ISSET(*xpp, RTS_SLOT_FREE)); + assert(!RTS_ISSET(*xpp, RTS_NO_ENDPOINT)); /* Found acceptable message. Copy it and update status. */ assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG)); - caller_ptr->p_delivermsg = sender->p_sendmsg; - caller_ptr->p_delivermsg.m_source = sender->p_endpoint; + caller_ptr->p_delivermsg = (*xpp)->p_sendmsg; + caller_ptr->p_delivermsg.m_source = (*xpp)->p_endpoint; caller_ptr->p_misc_flags |= MF_DELIVERMSG; - RTS_UNSET(sender, RTS_SENDING); + RTS_UNSET(*xpp, RTS_SENDING); - call = (sender->p_misc_flags & MF_REPLY_PEND ? SENDREC : SEND); + call = ((*xpp)->p_misc_flags & MF_REPLY_PEND ? SENDREC : SEND); IPC_STATUS_ADD_CALL(caller_ptr, call); /* * if the message is originaly from the kernel on behalf of this * process, we must send the status flags accordingly */ - if (sender->p_misc_flags & MF_SENDING_FROM_KERNEL) { + if ((*xpp)->p_misc_flags & MF_SENDING_FROM_KERNEL) { IPC_STATUS_ADD_FLAGS(caller_ptr, IPC_FLG_MSG_FROM_KERNEL); /* we can clean the flag now, not need anymore */ - sender->p_misc_flags &= ~MF_SENDING_FROM_KERNEL; + (*xpp)->p_misc_flags &= ~MF_SENDING_FROM_KERNEL; } - if (sender->p_misc_flags & MF_SIG_DELAY) - sig_delay_done(sender); + if ((*xpp)->p_misc_flags & MF_SIG_DELAY) + sig_delay_done(*xpp); - *xpp = sender->p_q_link; /* remove from queue */ - sender->p_q_link = NULL; + *xpp = (*xpp)->p_q_link; /* remove from queue */ return(OK); /* report success */ } - xpp = &sender->p_q_link; /* proceed to next */ + xpp = &(*xpp)->p_q_link; /* proceed to next */ } } diff --git a/kernel/system.c b/kernel/system.c index c2f7233ee..ef405463f 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -208,8 +208,8 @@ PUBLIC void system_init(void) map(SYS_UMAP, do_umap); /* map virtual to physical address */ map(SYS_VIRCOPY, do_vircopy); /* use pure virtual addressing */ map(SYS_PHYSCOPY, do_copy); /* use physical addressing */ - map(SYS_SAFECOPYFROM, do_safecopy); /* copy with pre-granted permission */ - map(SYS_SAFECOPYTO, do_safecopy); /* copy with pre-granted permission */ + map(SYS_SAFECOPYFROM, do_safecopy_from);/* copy with pre-granted permission */ + map(SYS_SAFECOPYTO, do_safecopy_to); /* copy with pre-granted permission */ map(SYS_VSAFECOPY, do_vsafecopy); /* vectored safecopy */ /* Mapping. */ diff --git a/kernel/system.h b/kernel/system.h index 832d3303d..39da172c5 100644 --- a/kernel/system.h +++ b/kernel/system.h @@ -179,7 +179,8 @@ _PROTOTYPE( int do_vtimer, (struct proc * caller, message *m_ptr) ); #define do_vtimer do_unused #endif -_PROTOTYPE( int do_safecopy, (struct proc * caller, message *m_ptr) ); +_PROTOTYPE( int do_safecopy_to, (struct proc * caller, message *m_ptr) ); +_PROTOTYPE( int do_safecopy_from, (struct proc * caller, message *m_ptr) ); _PROTOTYPE( int do_vsafecopy, (struct proc * caller, message *m_ptr) ); _PROTOTYPE( int do_iopenable, (struct proc * caller, message *m_ptr) ); _PROTOTYPE( int do_vmctl, (struct proc * caller, message *m_ptr) ); diff --git a/kernel/system/do_safecopy.c b/kernel/system/do_safecopy.c index ff4fd93e3..4650ae307 100644 --- a/kernel/system/do_safecopy.c +++ b/kernel/system/do_safecopy.c @@ -335,27 +335,25 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE } /*===========================================================================* - * do_safecopy * + * do_safecopy_to * *===========================================================================*/ -PUBLIC int do_safecopy(struct proc * caller, message * m_ptr) +PUBLIC int do_safecopy_to(struct proc * caller, message * m_ptr) { - static int access, src_seg, dst_seg; - - /* Set src and dst parameters. */ - if(m_ptr->m_type == SYS_SAFECOPYFROM) { - src_seg = D; - dst_seg = m_ptr->SCP_SEG; - access = CPF_READ; - } else if(m_ptr->m_type == SYS_SAFECOPYTO) { - src_seg = m_ptr->SCP_SEG; - dst_seg = D; - access = CPF_WRITE; - } else panic("Impossible system call nr.: %d", m_ptr->m_type); + return safecopy(caller, m_ptr->SCP_FROM_TO, caller->p_endpoint, + (cp_grant_id_t) m_ptr->SCP_GID, m_ptr->SCP_SEG, D, + m_ptr->SCP_BYTES, m_ptr->SCP_OFFSET, + (vir_bytes) m_ptr->SCP_ADDRESS, CPF_WRITE); +} +/*===========================================================================* + * do_safecopy_from * + *===========================================================================*/ +PUBLIC int do_safecopy_from(struct proc * caller, message * m_ptr) +{ return safecopy(caller, m_ptr->SCP_FROM_TO, caller->p_endpoint, - (cp_grant_id_t) m_ptr->SCP_GID, src_seg, dst_seg, + (cp_grant_id_t) m_ptr->SCP_GID, D, m_ptr->SCP_SEG, m_ptr->SCP_BYTES, m_ptr->SCP_OFFSET, - (vir_bytes) m_ptr->SCP_ADDRESS, access); + (vir_bytes) m_ptr->SCP_ADDRESS, CPF_READ); } /*===========================================================================*