From: Tomas Hruby Date: Tue, 15 Sep 2009 09:57:22 +0000 (+0000) Subject: proc_addr() returns address based on location in proc array X-Git-Tag: v3.1.5~147 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=4fd433694f53bd9060e9f8f514d4e337da9dd7e6;p=minix.git proc_addr() returns address based on location in proc array - pproc_addr is not neccessary to get the address of a process if we know its number - local proc variables in system calls implementation (sys_task) conflicts with the global proc array of all process, therefore the variable were renamed to proc_nr as they hold the process number --- diff --git a/kernel/proc.h b/kernel/proc.h index f08f434a5..65e94875e 100755 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -198,7 +198,7 @@ struct proc { #define NIL_PROC ((struct proc *) 0) #define NIL_SYS_PROC ((struct proc *) 1) #define cproc_addr(n) (&(proc + NR_TASKS)[(n)]) -#define proc_addr(n) (pproc_addr + NR_TASKS)[(n)] +#define proc_addr(n) (&(proc[NR_TASKS + (n)])) #define proc_nr(p) ((p)->p_nr) #define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS) diff --git a/kernel/system/do_endksig.c b/kernel/system/do_endksig.c index 1e62dc05b..7d4ad7f36 100644 --- a/kernel/system/do_endksig.c +++ b/kernel/system/do_endksig.c @@ -22,15 +22,15 @@ message *m_ptr; /* pointer to request message */ * signal it got with SYS_GETKSIG. */ register struct proc *rp; - int proc; + int proc_nr; /* Get process pointer and verify that it had signals pending. If the * process is already dead its flags will be reset. */ - if(!isokendpt(m_ptr->SIG_ENDPT, &proc)) + if(!isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return EINVAL; - rp = proc_addr(proc); + rp = proc_addr(proc_nr); if (!RTS_ISSET(rp, SIG_PENDING)) return(EINVAL); /* PM has finished one kernel signal. Perhaps process is ready now? */ diff --git a/kernel/system/do_exec.c b/kernel/system/do_exec.c index 1fbdd0b0f..c37eeb7c7 100644 --- a/kernel/system/do_exec.c +++ b/kernel/system/do_exec.c @@ -24,12 +24,12 @@ register message *m_ptr; /* pointer to request message */ register struct proc *rp; phys_bytes phys_name; char *np; - int proc; + int proc_nr; - if(!isokendpt(m_ptr->PR_ENDPT, &proc)) + if(!isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return EINVAL; - rp = proc_addr(proc); + rp = proc_addr(proc_nr); /* Save command name for debugging, ps(1) output, etc. */ if(data_copy(who_e, (vir_bytes) m_ptr->PR_NAME_PTR, diff --git a/kernel/system/do_irqctl.c b/kernel/system/do_irqctl.c index 53893c391..041b77b4c 100644 --- a/kernel/system/do_irqctl.c +++ b/kernel/system/do_irqctl.c @@ -137,7 +137,7 @@ irq_hook_t *hook; * interrupts are transformed into messages to a driver. The IRQ line will be * reenabled if the policy says so. */ - int proc; + int proc_nr; /* As a side-effect, the interrupt handler gathers random information by * timestamping the interrupt events. This is used for /dev/random. @@ -148,14 +148,14 @@ irq_hook_t *hook; * If it's dead, this should never happen, as processes that die * automatically get their interrupt hooks unhooked. */ - if(!isokendpt(hook->proc_nr_e, &proc)) + if(!isokendpt(hook->proc_nr_e, &proc_nr)) minix_panic("invalid interrupt handler", hook->proc_nr_e); /* Add a bit for this interrupt to the process' pending interrupts. When * sending the notification message, this bit map will be magically set * as an argument. */ - priv(proc_addr(proc))->s_int_pending |= (1 << hook->notify_id); + priv(proc_addr(proc_nr))->s_int_pending |= (1 << hook->notify_id); /* Build notification message and return. */ lock_notify(HARDWARE, hook->proc_nr_e); diff --git a/kernel/system/do_newmap.c b/kernel/system/do_newmap.c index 028cd290b..580b69469 100644 --- a/kernel/system/do_newmap.c +++ b/kernel/system/do_newmap.c @@ -20,12 +20,12 @@ message *m_ptr; /* pointer to request message */ register struct proc *rp; /* process whose map is to be loaded */ struct mem_map *map_ptr; /* virtual address of map inside caller */ phys_bytes src_phys; /* physical address of map at the */ - int proc; + int proc_nr; map_ptr = (struct mem_map *) m_ptr->PR_MEM_PTR; - if (! isokendpt(m_ptr->PR_ENDPT, &proc)) return(EINVAL); - if (iskerneln(proc)) return(EPERM); - rp = proc_addr(proc); + if (! isokendpt(m_ptr->PR_ENDPT, &proc_nr)) return(EINVAL); + if (iskerneln(proc_nr)) return(EPERM); + rp = proc_addr(proc_nr); return newmap(rp, map_ptr); } diff --git a/kernel/system/do_sigreturn.c b/kernel/system/do_sigreturn.c index 7079f9392..6e286675f 100644 --- a/kernel/system/do_sigreturn.c +++ b/kernel/system/do_sigreturn.c @@ -26,11 +26,11 @@ message *m_ptr; /* pointer to request message */ */ struct sigcontext sc; register struct proc *rp; - int proc, r; + int proc_nr, r; - if (! isokendpt(m_ptr->SIG_ENDPT, &proc)) return(EINVAL); - if (iskerneln(proc)) return(EPERM); - rp = proc_addr(proc); + if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL); + if (iskerneln(proc_nr)) return(EPERM); + rp = proc_addr(proc_nr); /* Copy in the sigcontext structure. */ if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR, diff --git a/kernel/system/do_sigsend.c b/kernel/system/do_sigsend.c index c12c2c406..ba340dec4 100644 --- a/kernel/system/do_sigsend.c +++ b/kernel/system/do_sigsend.c @@ -28,12 +28,12 @@ message *m_ptr; /* pointer to request message */ register struct proc *rp; struct sigcontext sc, *scp; struct sigframe fr, *frp; - int proc, r; + int proc_nr, r; phys_bytes ph; - if (!isokendpt(m_ptr->SIG_ENDPT, &proc)) return(EINVAL); - if (iskerneln(proc)) return(EPERM); - rp = proc_addr(proc); + if (!isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL); + if (iskerneln(proc_nr)) return(EPERM); + rp = proc_addr(proc_nr); ph = umap_local(proc_addr(who_p), D, (vir_bytes) m_ptr->SIG_CTXT_PTR, sizeof(struct sigmsg)); if(!ph) return EFAULT;