KCall methods do not depend on m_source and m_type fields

- substituted the use of the m_source message field by
  caller->p_endpoint in kernel calls. It is the same information, just
  passed more intuitively.
  
- the last dependency on m_type field is removed.
  
- do_unused() is substituted by a check for NULL.

- this pretty much removes the depency of kernel calls on the general
  message format. In the future this may be used to pass the kcall
  arguments in a different structure or registers (x86-64, ARM?) The
  kcall number may be passed in a register already.
This commit is contained in:
Tomas Hruby
2010-06-01 08:54:31 +00:00
parent ebbd319ac0
commit 40f440b8cd
12 changed files with 56 additions and 74 deletions

View File

@@ -3,7 +3,6 @@
.PATH: ${.CURDIR}/system
SRCS+= \
do_unused.c \
do_fork.c \
do_exec.c \
do_newmap.c \

View File

@@ -30,9 +30,9 @@ PUBLIC int do_copy(struct proc * caller, message * m_ptr)
int i;
#if 0
if (m_ptr->m_source != PM_PROC_NR && m_ptr->m_source != VFS_PROC_NR &&
m_ptr->m_source != RS_PROC_NR && m_ptr->m_source != MEM_PROC_NR &&
m_ptr->m_source != VM_PROC_NR)
if (caller->p_endpoint != PM_PROC_NR && caller->p_endpoint != VFS_PROC_NR &&
caller->p_endpoint != RS_PROC_NR && caller->p_endpoint != MEM_PROC_NR &&
caller->p_endpoint != VM_PROC_NR)
{
static int first=1;
if (first)
@@ -40,7 +40,7 @@ PUBLIC int do_copy(struct proc * caller, message * m_ptr)
first= 0;
printf(
"do_copy: got request from %d (source %d, seg %d, destination %d, seg %d)\n",
m_ptr->m_source,
caller->p_endpoint,
m_ptr->CP_SRC_ENDPT,
m_ptr->CP_SRC_SPACE,
m_ptr->CP_DST_ENDPT,
@@ -65,7 +65,7 @@ PUBLIC int do_copy(struct proc * caller, message * m_ptr)
int p;
/* Check if process number was given implictly with SELF and is valid. */
if (vir_addr[i].proc_nr_e == SELF)
vir_addr[i].proc_nr_e = m_ptr->m_source;
vir_addr[i].proc_nr_e = caller->p_endpoint;
if (vir_addr[i].segment != PHYS_SEG) {
if(! isokendpt(vir_addr[i].proc_nr_e, &p)) {
printf("do_copy: %d: seg 0x%x, %d not ok endpoint\n",
@@ -73,10 +73,6 @@ PUBLIC int do_copy(struct proc * caller, message * m_ptr)
return(EINVAL);
}
}
/* Check if physical addressing is used without SYS_PHYSCOPY. */
if ((vir_addr[i].segment & PHYS_SEG) &&
m_ptr->m_type != SYS_PHYSCOPY) return(EPERM);
}
/* Check for overflow. This would happen for 64K segments and 16-bit

View File

@@ -43,7 +43,7 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
case IRQ_DISABLE:
if (irq_hook_id >= NR_IRQ_HOOKS || irq_hook_id < 0 ||
irq_hooks[irq_hook_id].proc_nr_e == NONE) return(EINVAL);
if (irq_hooks[irq_hook_id].proc_nr_e != m_ptr->m_source) return(EPERM);
if (irq_hooks[irq_hook_id].proc_nr_e != caller->p_endpoint) return(EPERM);
if (m_ptr->IRQ_REQUEST == IRQ_ENABLE) {
enable_irq(&irq_hooks[irq_hook_id]);
}
@@ -76,7 +76,7 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
{
printf(
"do_irqctl: IRQ check failed for proc %d, IRQ %d\n",
m_ptr->m_source, irq_vec);
caller->p_endpoint, irq_vec);
return EPERM;
}
}
@@ -90,7 +90,7 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
/* Try to find an existing mapping to override. */
hook_ptr = NULL;
for (i=0; !hook_ptr && i<NR_IRQ_HOOKS; i++) {
if (irq_hooks[i].proc_nr_e == m_ptr->m_source
if (irq_hooks[i].proc_nr_e == caller->p_endpoint
&& irq_hooks[i].notify_id == notify_id) {
irq_hook_id = i;
hook_ptr = &irq_hooks[irq_hook_id]; /* existing hook */
@@ -108,7 +108,7 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
if (hook_ptr == NULL) return(ENOSPC);
/* Install the handler. */
hook_ptr->proc_nr_e = m_ptr->m_source; /* process to notify */
hook_ptr->proc_nr_e = caller->p_endpoint; /* process to notify */
hook_ptr->notify_id = notify_id; /* identifier to pass */
hook_ptr->policy = m_ptr->IRQ_POLICY; /* policy for interrupts */
put_irq_handler(hook_ptr, irq_vec, generic_handler);
@@ -121,7 +121,7 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
if (irq_hook_id < 0 || irq_hook_id >= NR_IRQ_HOOKS ||
irq_hooks[irq_hook_id].proc_nr_e == NONE) {
return(EINVAL);
} else if (m_ptr->m_source != irq_hooks[irq_hook_id].proc_nr_e) {
} else if (caller->p_endpoint != irq_hooks[irq_hook_id].proc_nr_e) {
return(EPERM);
}
/* Remove the handler and return. */

View File

@@ -26,7 +26,7 @@ PUBLIC int do_profbuf(struct proc * caller, message * m_ptr)
struct proc *rp;
/* Store process name, control struct, table locations. */
if(!isokendpt(m_ptr->m_source, &proc_nr))
if(!isokendpt(caller->p_endpoint, &proc_nr))
return EDEADSRCDST;
if(cprof_procs_no >= NR_SYS_PROCS)

View File

@@ -34,7 +34,7 @@ PUBLIC int do_setalarm(struct proc * caller, message * m_ptr)
/* Get the timer structure and set the parameters for this alarm. */
tp = &(priv(caller)->s_alarm_timer);
tmr_arg(tp)->ta_int = m_ptr->m_source;
tmr_arg(tp)->ta_int = caller->p_endpoint;
tp->tmr_func = cause_alarm;
/* Return the ticks left on the previous alarm. */

View File

@@ -28,7 +28,7 @@ PUBLIC int do_times(struct proc * caller, message * m_ptr)
* The clock's interrupt handler may run to update the user or system time
* while in this code, but that cannot do any harm.
*/
e_proc_nr = (m_ptr->T_ENDPT == SELF) ? m_ptr->m_source : m_ptr->T_ENDPT;
e_proc_nr = (m_ptr->T_ENDPT == SELF) ? caller->p_endpoint : m_ptr->T_ENDPT;
if(e_proc_nr != NONE && isokendpt(e_proc_nr, &proc_nr)) {
rp = proc_addr(proc_nr);
m_ptr->T_USER_TIME = rp->p_user_time;

View File

@@ -1,16 +0,0 @@
/* This file provides a catch-all handler for unused kernel calls. A kernel
* call may be unused when it is not defined or when it is disabled in the
* kernel's configuration.
*/
#include "kernel/system.h"
/*===========================================================================*
* do_unused *
*===========================================================================*/
PUBLIC int do_unused(struct proc * caller, message * m_ptr)
{
printf("SYSTEM: got unused request %d from %d\n",
m_ptr->m_type, m_ptr->m_source);
return(EBADREQUEST); /* illegal message type */
}

View File

@@ -94,7 +94,7 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
{
printf(
"do_vdevio: I/O port check failed for proc %d, port 0x%x\n",
m_ptr->m_source, port);
caller->p_endpoint, port);
return EPERM;
}
}

View File

@@ -22,7 +22,7 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
endpoint_t ep = m_ptr->SVMCTL_WHO;
struct proc *p, *rp, *target;
if(ep == SELF) { ep = m_ptr->m_source; }
if(ep == SELF) { ep = caller->p_endpoint; }
if(!isokendpt(ep, &proc_nr)) {
printf("do_vmctl: unexpected endpoint %d from VM\n", ep);

View File

@@ -34,7 +34,7 @@ PUBLIC int do_vtimer(struct proc * caller, message * m_ptr)
return(EINVAL);
/* The target process must be valid. */
proc_nr_e = (m_ptr->VT_ENDPT == SELF) ? m_ptr->m_source : m_ptr->VT_ENDPT;
proc_nr_e = (m_ptr->VT_ENDPT == SELF) ? caller->p_endpoint : m_ptr->VT_ENDPT;
if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL);
rp = proc_addr(proc_nr);