Removal of the system task

* Userspace change to use the new kernel calls

	- _taskcall(SYSTASK...) changed to _kernel_call(...)

	- int 32 reused for the kernel calls

	- _do_kernel_call() to make the trap to kernel

	- kernel_call() to make the actuall kernel call from C using
	  _do_kernel_call()

	- unlike ipc call the kernel call always succeeds as kernel is
	  always available, however, kernel may return an error

* Kernel side implementation of kernel calls

	- the SYSTEm task does not run, only the proc table entry is
	  preserved

	- every data_copy(SYSTEM is no data_copy(KERNEL

	- "locking" is an empty operation now as everything runs in
	  kernel

	- sys_task() is replaced by kernel_call() which copies the
	  message into kernel, dispatches the call to its handler and
	  finishes by either copying the results back to userspace (if
	  need be) or by suspending the process because of VM

	- suspended processes are later made runnable once the memory
	  issue is resolved, picked up by the scheduler and only at
	  this time the call is resumed (in fact restarted) which does
	  not need to copy the message from userspace as the message
	  is already saved in the process structure.

	- no ned for the vmrestart queue, the scheduler will restart
	  the system calls

	- no special case in do_vmctl(), all requests remove the
	  RTS_VMREQUEST flag
This commit is contained in:
Tomas Hruby
2010-02-09 15:20:09 +00:00
parent 5e57818431
commit 728f0f0c49
84 changed files with 274 additions and 249 deletions

View File

@@ -407,7 +407,8 @@ PRIVATE struct gate_table_s gate_table_ioapic[] = {
};
PRIVATE struct gate_table_s gate_table_common[] = {
{ ipc_entry, SYS386_VECTOR, USER_PRIVILEGE },
{ ipc_entry, IPC_VECTOR, USER_PRIVILEGE },
{ kernel_call_entry, KERN_CALL_VECTOR, USER_PRIVILEGE },
{ level0_call, LEVEL0_VECTOR, TASK_PRIVILEGE },
{ NULL, 0, 0}
};

View File

@@ -21,12 +21,12 @@ struct reg86u reg86;
PUBLIC int do_int86(struct proc * caller, message * m_ptr)
{
data_copy(caller->p_endpoint, (vir_bytes) m_ptr->INT86_REG86,
SYSTEM, (vir_bytes) &reg86, sizeof(reg86));
KERNEL, (vir_bytes) &reg86, sizeof(reg86));
level0(int86);
/* Copy results back to the caller */
data_copy(SYSTEM, (vir_bytes) &reg86,
data_copy(KERNEL, (vir_bytes) &reg86,
caller->p_endpoint, (vir_bytes) m_ptr->INT86_REG86, sizeof(reg86));
/* The BIOS call eats interrupts. Call get_randomness to generate some

View File

@@ -243,7 +243,7 @@ PUBLIC void proc_stacktrace(struct proc *whichproc)
#define PRCOPY(pr, pv, v, n) \
(iskernel ? (memcpy((char *) v, (char *) pv, n), OK) : \
data_copy(pr->p_endpoint, pv, SYSTEM, (vir_bytes) (v), n))
data_copy(pr->p_endpoint, pv, KERNEL, (vir_bytes) (v), n))
if(PRCOPY(whichproc, v_bp, &v_hbp, sizeof(v_hbp)) != OK) {
kprintf("(v_bp 0x%lx ?)", v_bp);

View File

@@ -377,7 +377,7 @@ hwint15:
hwint_slave(15)
/*
* syscall is only from a process to kernel
* IPC is only from a process to kernel
*/
.balign 16
.globl ipc_entry
@@ -411,6 +411,36 @@ ipc_entry:
jmp restart
/*
* kernel call is only from a process to kernel
*/
.balign 16
.globl kernel_call_entry
kernel_call_entry:
SAVE_PROCESS_CTX(0)
/* save the pointer to the current process */
push %ebp
/* for stack trace */
movl $0, %ebp
/*
* pass the syscall arguments from userspace to the handler.
* SAVE_PROCESS_CTX() does not clobber these registers, they are still
* set as the userspace have set them
*/
push %eax
call kernel_call
/* restore the current process pointer and save the return value */
add $8, %esp
jmp restart
.balign 16
/*
* called by the exception interrupt vectors. If the exception does not push

View File

@@ -212,7 +212,8 @@ PUBLIC void idt_init(void)
{ alignment_check, ALIGNMENT_CHECK_VECTOR, INTR_PRIVILEGE },
{ machine_check, MACHINE_CHECK_VECTOR, INTR_PRIVILEGE },
{ simd_exception, SIMD_EXCEPTION_VECTOR, INTR_PRIVILEGE },
{ ipc_entry, SYS386_VECTOR, USER_PRIVILEGE },/* 386 system call */
{ ipc_entry, IPC_VECTOR, USER_PRIVILEGE },
{ kernel_call_entry, KERN_CALL_VECTOR, USER_PRIVILEGE },
{ level0_call, LEVEL0_VECTOR, TASK_PRIVILEGE },
{ NULL, 0, 0}
};

View File

@@ -25,9 +25,9 @@
#define unset_sys_bit(map,bit) \
( MAP_CHUNK(map.chunk,bit) &= ~(1 << CHUNK_OFFSET(bit) )
#define reallock do { int d; d = intr_disabled(); intr_disable(); locklevel++; if(d && locklevel == 1) { minix_panic("reallock while interrupts disabled first time", __LINE__); } } while(0)
#define reallock
#define realunlock do { if(!intr_disabled()) { minix_panic("realunlock while interrupts enabled", __LINE__); } if(locklevel < 1) { minix_panic("realunlock while locklevel below 1", __LINE__); } locklevel--; if(locklevel == 0) { intr_enable(); } } while(0)
#define realunlock
/* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
* are used when debugging is enabled. See debug.h for more information.

View File

@@ -145,6 +145,7 @@ miscflagstr(int flags)
FLAG(MF_ASYNMSG);
FLAG(MF_FULLVM);
FLAG(MF_DELIVERMSG);
FLAG(MF_KCALL_RESUME);
return str;
}

View File

@@ -26,7 +26,6 @@ EXTERN struct loadinfo kloadinfo; /* status of load average */
/* Process scheduling information and the kernel reentry count. */
EXTERN struct proc *proc_ptr; /* pointer to currently running process */
EXTERN struct proc *bill_ptr; /* process to bill for clock ticks */
EXTERN struct proc *vmrestart; /* first process on vmrestart queue */
EXTERN struct proc *vmrequest; /* first process on vmrequest queue */
EXTERN struct proc *pagefaults; /* first process on pagefault queue */
EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */

View File

@@ -203,6 +203,8 @@ PUBLIC void main()
if (rp->p_nr == HARDWARE) RTS_SET(rp, RTS_PROC_STOP);
/* IDLE task is never put on a run queue as it is never ready to run */
if (rp->p_nr == IDLE) RTS_SET(rp, RTS_PROC_STOP);
/* SYSTEM does not run anymore */
if (rp->p_nr == SYSTEM) RTS_SET(rp, RTS_PROC_STOP);
RTS_UNSET(rp, RTS_SLOT_FREE); /* remove RTS_SLOT_FREE and schedule */
alloc_segments(rp);
}

View File

@@ -205,10 +205,14 @@ check_misc_flags:
vmassert(proc_ptr);
vmassert(proc_is_runnable(proc_ptr));
while (proc_ptr->p_misc_flags &
(MF_DELIVERMSG | MF_SC_DEFER | MF_SC_TRACE | MF_SC_ACTIVE)) {
(MF_KCALL_RESUME | MF_DELIVERMSG |
MF_SC_DEFER | MF_SC_TRACE | MF_SC_ACTIVE)) {
vmassert(proc_is_runnable(proc_ptr));
if (proc_ptr->p_misc_flags & MF_DELIVERMSG) {
if (proc_ptr->p_misc_flags & MF_KCALL_RESUME) {
kernel_call_resume(proc_ptr);
}
else if (proc_ptr->p_misc_flags & MF_DELIVERMSG) {
TRACE(VF_SCHEDULING, printf("delivering to %s / %d\n",
proc_ptr->p_name, proc_ptr->p_endpoint););
if(delivermsg(proc_ptr) == VMSUSPEND) {
@@ -832,14 +836,14 @@ field, caller->p_name, entry, priv(caller)->s_asynsize, priv(caller)->s_asyntab)
#define A_RETRIEVE(entry, field) \
if(data_copy(caller_ptr->p_endpoint, \
table_v + (entry)*sizeof(asynmsg_t) + offsetof(struct asynmsg,field),\
SYSTEM, (vir_bytes) &tabent.field, \
KERNEL, (vir_bytes) &tabent.field, \
sizeof(tabent.field)) != OK) {\
ASCOMPLAIN(caller_ptr, entry, #field); \
return EFAULT; \
}
#define A_INSERT(entry, field) \
if(data_copy(SYSTEM, (vir_bytes) &tabent.field, \
if(data_copy(KERNEL, (vir_bytes) &tabent.field, \
caller_ptr->p_endpoint, \
table_v + (entry)*sizeof(asynmsg_t) + offsetof(struct asynmsg,field),\
sizeof(tabent.field)) != OK) {\

View File

@@ -220,6 +220,12 @@ struct proc {
#define MF_REPLY_PEND 0x001 /* reply to IPC_REQUEST is pending */
#define MF_VIRT_TIMER 0x002 /* process-virtual timer is running */
#define MF_PROF_TIMER 0x004 /* process-virtual profile timer is running */
#define MF_KCALL_RESUME 0x008 /* processing a kernel call was interrupted,
most likely because we need VM to resolve a
problem or a long running copy was preempted.
We need to resume the kernel call execution
now
*/
#define MF_ASYNMSG 0x010 /* Asynchrous message pending */
#define MF_FULLVM 0x020
#define MF_DELIVERMSG 0x040 /* Copy message for him before running */

View File

@@ -94,11 +94,11 @@ irq_hook_t *hook;
/* Note: k_reenter is always 0 here. */
/* Store sample (process name and program counter). */
data_copy(SYSTEM, (vir_bytes) proc_ptr->p_name,
data_copy(KERNEL, (vir_bytes) proc_ptr->p_name,
sprof_ep, sprof_data_addr_vir + sprof_info.mem_used,
strlen(proc_ptr->p_name));
data_copy(SYSTEM, (vir_bytes) &proc_ptr->p_reg.pc, sprof_ep,
data_copy(KERNEL, (vir_bytes) &proc_ptr->p_reg.pc, sprof_ep,
(vir_bytes) (sprof_data_addr_vir + sprof_info.mem_used +
sizeof(proc_ptr->p_name)),
(vir_bytes) sizeof(proc_ptr->p_reg.pc));

View File

@@ -58,13 +58,14 @@ _PROTOTYPE( void unset_sendto_bit, (struct proc *rc, int id) );
_PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) );
_PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) );
_PROTOTYPE( void sig_delay_done, (struct proc *rp) );
_PROTOTYPE( void sys_task, (void) );
_PROTOTYPE( void kernel_call, (message *m_user, struct proc * caller) );
_PROTOTYPE( void system_init, (void) );
#define numap_local(proc_nr, vir_addr, bytes) \
umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes))
_PROTOTYPE( phys_bytes umap_grant, (struct proc *, cp_grant_id_t, vir_bytes));
_PROTOTYPE( void clear_endpoint, (struct proc *rc) );
_PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
_PROTOTYPE( void kernel_call_resume, (struct proc *p));
/* system/do_newmap.c */
_PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,

View File

@@ -58,85 +58,92 @@ char *callnames[NR_SYS_CALLS];
callnames[(call_nr-KERNEL_CALL)] = #call_nr; \
call_vec[(call_nr-KERNEL_CALL)] = (handler)
FORWARD _PROTOTYPE( void initialize, (void));
FORWARD _PROTOTYPE( struct proc *vmrestart_check, (message *));
PRIVATE void kernel_call_finish(struct proc * caller, message *msg, int result)
{
if(result == VMSUSPEND) {
/* Special case: message has to be saved for handling
* until VM tells us it's allowed. VM has been notified
* and we must wait for its reply to restart the call.
*/
vmassert(RTS_ISSET(caller, RTS_VMREQUEST));
vmassert(caller->p_vmrequest.type == VMSTYPE_KERNELCALL);
caller->p_vmrequest.saved.reqmsg = *msg;
caller->p_misc_flags |= MF_KCALL_RESUME;
} else {
/*
* call is finished, we could have been suspended because of VM,
* remove the request message
*/
caller->p_vmrequest.saved.reqmsg.m_source = NONE;
if (result != EDONTREPLY) {
/* copy the result as a message to the original user buffer */
msg->m_source = SYSTEM;
msg->m_type = result; /* report status of call */
if (copy_msg_to_user(caller, msg,
(message *)caller->p_delivermsg_vir)) {
kprintf("WARNING wrong user pointer 0x%08x from "
"process %s / %d\n",
caller->p_delivermsg_vir,
caller->p_name,
caller->p_endpoint);
result = EBADREQUEST;
}
}
}
}
PRIVATE int kernel_call_dispatch(struct proc * caller, message *msg)
{
int result = OK;
int call_nr;
call_nr = msg->m_type - KERNEL_CALL;
/* See if the caller made a valid request and try to handle it. */
if (call_nr < 0 || call_nr >= NR_SYS_CALLS) { /* check call number */
kprintf("SYSTEM: illegal request %d from %d.\n",
call_nr,msg->m_source);
result = EBADREQUEST; /* illegal message type */
}
else if (!GET_BIT(priv(caller)->s_k_call_mask, call_nr)) {
result = ECALLDENIED; /* illegal message type */
} else {
/* handle the system call */
result = (*call_vec[call_nr])(caller, msg);
}
return result;
}
/*===========================================================================*
* sys_task *
* kernel_call *
*===========================================================================*/
PUBLIC void sys_task()
/*
* this function checks the basic syscall parameters and if accepted it
* dispatches its handling to the right handler
*/
PUBLIC void kernel_call(message *m_user, struct proc * caller)
{
/* Main entry point of sys_task. Get the message and dispatch on type. */
static message m;
register int result;
register struct proc *caller_ptr;
int s;
int call_nr;
int who_p;
endpoint_t who_e;
int result = OK;
message msg;
while (TRUE) {
struct proc *restarting;
restarting = vmrestart_check(&m);
if(!restarting) {
int r;
/* Get work. Block and wait until a request message arrives. */
if((r=receive(ANY, &m)) != OK)
minix_panic("receive() failed", r);
}
call_nr = m.m_type - KERNEL_CALL;
who_e = m.m_source;
okendpt(who_e, &who_p);
caller_ptr = proc_addr(who_p);
/* See if the caller made a valid request and try to handle it. */
if (call_nr < 0 || call_nr >= NR_SYS_CALLS) { /* check call number */
kprintf("SYSTEM: illegal request %d from %d.\n",
call_nr,m.m_source);
result = EBADREQUEST; /* illegal message type */
}
else if (!GET_BIT(priv(caller_ptr)->s_k_call_mask, call_nr)) {
result = ECALLDENIED; /* illegal message type */
}
else {
/* handle the system call */
result = (*call_vec[call_nr])(caller_ptr, &m);
}
if(result == VMSUSPEND) {
/* Special case: message has to be saved for handling
* until VM tells us it's allowed. VM has been notified
* and we must wait for its reply to restart the call.
*/
vmassert(RTS_ISSET(caller_ptr, RTS_VMREQUEST));
vmassert(caller_ptr->p_vmrequest.type == VMSTYPE_KERNELCALL);
caller_ptr->p_vmrequest.saved.reqmsg = m;
} else if (result != EDONTREPLY) {
/* Send a reply, unless inhibited by a handler function.
* Use the kernel function lock_send() to prevent a system
* call trap.
*/
if(restarting) {
vmassert(!RTS_ISSET(restarting, RTS_VMREQUEST));
#if 0
vmassert(!RTS_ISSET(restarting, RTS_VMREQTARGET));
#endif
}
m.m_type = result; /* report status of call */
if(WILLRECEIVE(caller_ptr, SYSTEM)) {
if (OK != (s=lock_send(m.m_source, &m))) {
kprintf("SYSTEM, reply to %d failed: %d\n",
m.m_source, s);
}
} else {
kprintf("SYSTEM: not replying to %d; not ready\n",
caller_ptr->p_endpoint);
}
}
caller->p_delivermsg_vir = (vir_bytes) m_user;
/*
* the ldt and cr3 of the caller process is loaded because it just've trapped
* into the kernel or was already set in schedcheck() before we resume
* execution of an interrupted kernel call
*/
if (copy_msg_from_user(caller, m_user, &msg) == 0) {
msg.m_source = caller->p_endpoint;
result = kernel_call_dispatch(caller, &msg);
}
else {
kprintf("WARNING wrong user pointer 0x%08x from process %s / %d\n",
m_user, caller->p_name, caller->p_endpoint);
result = EBADREQUEST;
}
kernel_call_finish(caller, &msg, result);
}
/*===========================================================================*
@@ -541,52 +548,28 @@ register struct proc *rc; /* slot of process to clean up */
}
/*===========================================================================*
* vmrestart_check *
* kernel_call_resume *
*===========================================================================*/
PRIVATE struct proc *vmrestart_check(message *m)
PUBLIC void kernel_call_resume(struct proc *caller)
{
int type;
struct proc *restarting;
int who_p;
int result;
/* Anyone waiting to be vm-restarted? */
vmassert(!RTS_ISSET(p, RTS_SLOT_FREE));
vmassert(!RTS_ISSET(p, RTS_VMREQUEST));
if(!(restarting = vmrestart))
return NULL;
vmassert(p->p_vmrequest.saved.reqmsg.m_source == p->p_endpoint);
vmassert(!RTS_ISSET(restarting, RTS_SLOT_FREE));
vmassert(RTS_ISSET(restarting, RTS_VMREQUEST));
/*
printf("KERNEL_CALL restart from %s / %d rts 0x%08x misc 0x%08x\n",
caller->p_name, caller->p_endpoint,
caller->p_rts_flags, caller->p_misc_flags);
*/
type = restarting->p_vmrequest.type;
restarting->p_vmrequest.type = VMSTYPE_SYS_NONE;
vmrestart = restarting->p_vmrequest.nextrestart;
switch(type) {
case VMSTYPE_KERNELCALL:
*m = restarting->p_vmrequest.saved.reqmsg;
restarting->p_vmrequest.saved.reqmsg.m_source = NONE;
vmassert(m->m_source == restarting->p_endpoint);
/* Original caller could've disappeared in the meantime. */
if(!isokendpt(m->m_source, &who_p)) {
kprintf("SYSTEM: ignoring call %d from dead %d\n",
m->m_type, m->m_source);
return NULL;
}
{ int i;
i = m->m_type - KERNEL_CALL;
if(i >= 0 && i < NR_SYS_CALLS) {
#if 0
kprintf("SYSTEM: restart %s from %d\n",
callnames[i], m->m_source);
#endif
} else {
minix_panic("call number out of range", i);
}
}
return restarting;
default:
minix_panic("strange restart type", type);
}
minix_panic("fell out of switch", NO_NUM);
return NULL;
/*
* we are resuming the kernel call so we have to remove this flag so it
* can be set again
*/
caller->p_misc_flags &= ~MF_KCALL_RESUME;
result = kernel_call_dispatch(caller, &caller->p_vmrequest.saved.reqmsg);
kernel_call_finish(caller, &caller->p_vmrequest.saved.reqmsg, result);
}

View File

@@ -30,9 +30,8 @@ PUBLIC int do_abort(struct proc * caller, message * m_ptr)
int len;
len = MIN(m_ptr->ABRT_MON_LEN, sizeof(paramsbuffer)-1);
if((p=data_copy(m_ptr->ABRT_MON_ENDPT,
(vir_bytes) m_ptr->ABRT_MON_ADDR,
SYSTEM, (vir_bytes) paramsbuffer, len)) != OK) {
if((p=data_copy(m_ptr->ABRT_MON_ENDPT, (vir_bytes) m_ptr->ABRT_MON_ADDR,
KERNEL, (vir_bytes) paramsbuffer, len)) != OK) {
return p;
}
paramsbuffer[len] = '\0';

View File

@@ -47,7 +47,7 @@ PUBLIC int do_cprofile(struct proc * caller, message * m_ptr)
}
/* Set reset flag. */
data_copy(SYSTEM, (vir_bytes) &cprof_ctl_inst.reset,
data_copy(KERNEL, (vir_bytes) &cprof_ctl_inst.reset,
cprof_proc_info[i].endpt, cprof_proc_info[i].ctl_v,
sizeof(cprof_ctl_inst.reset));
}
@@ -90,7 +90,7 @@ PUBLIC int do_cprofile(struct proc * caller, message * m_ptr)
/* Copy control struct from proc to local variable. */
data_copy(cprof_proc_info[i].endpt, cprof_proc_info[i].ctl_v,
SYSTEM, (vir_bytes) &cprof_ctl_inst,
KERNEL, (vir_bytes) &cprof_ctl_inst,
sizeof(cprof_ctl_inst));
/* Calculate memory used. */
@@ -108,7 +108,7 @@ PUBLIC int do_cprofile(struct proc * caller, message * m_ptr)
if (cprof_mem_size < cprof_info.mem_used) cprof_info.mem_used = -1;
/* Copy the info struct to the user process. */
data_copy(SYSTEM, (vir_bytes) &cprof_info,
data_copy(KERNEL, (vir_bytes) &cprof_info,
m_ptr->PROF_ENDPT, (vir_bytes) m_ptr->PROF_CTL_PTR,
sizeof(cprof_info));
@@ -120,7 +120,7 @@ PUBLIC int do_cprofile(struct proc * caller, message * m_ptr)
vir_dst = (vir_bytes) m_ptr->PROF_MEM_PTR;
for (i=0; i<cprof_procs_no; i++) {
len = (phys_bytes) strlen(cprof_proc_info[i].name);
data_copy(SYSTEM, (vir_bytes) cprof_proc_info[i].name,
data_copy(KERNEL, (vir_bytes) cprof_proc_info[i].name,
m_ptr->PROF_ENDPT, vir_dst, len);
vir_dst += CPROF_PROCNAME_LEN;

View File

@@ -34,7 +34,7 @@ PUBLIC 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,
SYSTEM, (vir_bytes) rp->p_name, (phys_bytes) P_NAME_LEN - 1) != OK)
KERNEL, (vir_bytes) rp->p_name, (phys_bytes) P_NAME_LEN - 1) != OK)
strncpy(rp->p_name, "<unset>", P_NAME_LEN);
/* Do architecture-specific exec() stuff. */

View File

@@ -184,7 +184,7 @@ PUBLIC int do_getinfo(struct proc * caller, message * m_ptr)
/* Try to make the actual copy for the requested data. */
if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG);
r = data_copy_vmcheck(caller, SYSTEM, src_vir, caller->p_endpoint,
r = data_copy_vmcheck(caller, KERNEL, src_vir, caller->p_endpoint,
(vir_bytes) m_ptr->I_VAL_PTR, length);
if(r != OK) return r;

View File

@@ -37,7 +37,7 @@ PUBLIC int newmap(struct proc *caller, struct proc *rp, struct mem_map *map_ptr)
int r;
/* Fetch the memory map. */
if((r=data_copy(caller->p_endpoint, (vir_bytes) map_ptr,
SYSTEM, (vir_bytes) rp->p_memmap, sizeof(rp->p_memmap))) != OK) {
KERNEL, (vir_bytes) rp->p_memmap, sizeof(rp->p_memmap))) != OK) {
kprintf("newmap: data_copy failed! (%d)\n", r);
return r;
}

View File

@@ -71,7 +71,7 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
{
/* Copy privilege structure from caller */
if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &priv, sizeof(priv))) != OK)
KERNEL, (vir_bytes) &priv, sizeof(priv))) != OK)
return r;
/* See if the caller wants to assign a static privilege id. */
@@ -226,7 +226,7 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
/* Get the I/O range */
data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &io_range, sizeof(io_range));
KERNEL, (vir_bytes) &io_range, sizeof(io_range));
priv(rp)->s_flags |= CHECK_IO_PORT; /* Check I/O accesses */
i= priv(rp)->s_nr_io_range;
if (i >= NR_IO_RANGE)
@@ -248,7 +248,7 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
/* Get the memory range */
if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &mem_range, sizeof(mem_range))) != OK)
KERNEL, (vir_bytes) &mem_range, sizeof(mem_range))) != OK)
return r;
priv(rp)->s_flags |= CHECK_MEM; /* Check memory mappings */
i= priv(rp)->s_nr_mem_range;
@@ -270,7 +270,7 @@ PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
return EPERM;
data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &irq, sizeof(irq));
KERNEL, (vir_bytes) &irq, sizeof(irq));
priv(rp)->s_flags |= CHECK_IRQ; /* Check IRQs */
i= priv(rp)->s_nr_irq;

View File

@@ -83,7 +83,7 @@ endpoint_t *e_granter; /* new granter (magic grants) */
*/
if((r=data_copy(granter,
priv(granter_proc)->s_grant_table + sizeof(g)*grant,
SYSTEM, (vir_bytes) &g, sizeof(g))) != OK) {
KERNEL, (vir_bytes) &g, sizeof(g))) != OK) {
kprintf(
"verify_grant: grant verify: data_copy failed\n");
return EPERM;
@@ -366,7 +366,7 @@ PUBLIC int do_vsafecopy(struct proc * caller, message * m_ptr)
src.proc_nr_e = caller->p_endpoint;
src.offset = (vir_bytes) m_ptr->VSCP_VEC_ADDR;
src.segment = dst.segment = D;
dst.proc_nr_e = SYSTEM;
dst.proc_nr_e = KERNEL;
dst.offset = (vir_bytes) vec;
/* No. of vector elements. */

View File

@@ -32,7 +32,7 @@ PUBLIC int do_sigreturn(struct proc * caller, message * m_ptr)
/* Copy in the sigcontext structure. */
if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR,
SYSTEM, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
KERNEL, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK)
return r;
/* Restore user bits of psw from sc, maintain system bits from proc. */

View File

@@ -37,7 +37,7 @@ PUBLIC int do_sigsend(struct proc * caller, message * m_ptr)
/* Get the sigmsg structure into our address space. */
if((r=data_copy_vmcheck(caller, caller->p_endpoint,
(vir_bytes) m_ptr->SIG_CTXT_PTR, SYSTEM, (vir_bytes) &smsg,
(vir_bytes) m_ptr->SIG_CTXT_PTR, KERNEL, (vir_bytes) &smsg,
(phys_bytes) sizeof(struct sigmsg))) != OK)
return r;
@@ -57,7 +57,7 @@ PUBLIC int do_sigsend(struct proc * caller, message * m_ptr)
sc.sc_flags = 0 | rp->p_misc_flags & MF_FPU_INITIALIZED;
/* Copy the sigcontext structure to the user's stack. */
if((r=data_copy_vmcheck(caller, SYSTEM, (vir_bytes) &sc, m_ptr->SIG_ENDPT,
if((r=data_copy_vmcheck(caller, KERNEL, (vir_bytes) &sc, m_ptr->SIG_ENDPT,
(vir_bytes) scp, (vir_bytes) sizeof(struct sigcontext))) != OK)
return r;
@@ -106,7 +106,7 @@ PUBLIC int do_sigsend(struct proc * caller, message * m_ptr)
fr.sf_retadr = (void (*)()) smsg.sm_sigreturn;
/* Copy the sigframe structure to the user's stack. */
if((r=data_copy_vmcheck(caller, SYSTEM, (vir_bytes) &fr,
if((r=data_copy_vmcheck(caller, KERNEL, (vir_bytes) &fr,
m_ptr->SIG_ENDPT, (vir_bytes) frp,
(vir_bytes) sizeof(struct sigframe))) != OK)
return r;

View File

@@ -79,7 +79,7 @@ PUBLIC int do_sprofile(struct proc * caller, message * m_ptr)
stop_profile_clock();
data_copy(SYSTEM, (vir_bytes) &sprof_info,
data_copy(KERNEL, (vir_bytes) &sprof_info,
sprof_ep, sprof_info_addr_vir, sizeof(sprof_info));
return OK;

View File

@@ -27,7 +27,7 @@ PUBLIC int do_sysctl(struct proc * caller, message * m_ptr)
caller->p_endpoint, len);
return EINVAL;
}
if((s=data_copy_vmcheck(caller, caller->p_endpoint, buf, SYSTEM,
if((s=data_copy_vmcheck(caller, caller->p_endpoint, buf, KERNEL,
(vir_bytes) mybuf, len)) != OK) {
kprintf("do_sysctl: diag for %d: len %d: copy failed: %d\n",
caller->p_endpoint, len, s);

View File

@@ -54,7 +54,7 @@ PUBLIC int do_trace(struct proc * caller, message * m_ptr)
#define COPYTOPROC(seg, addr, myaddr, length) { \
struct vir_addr fromaddr, toaddr; \
int r; \
fromaddr.proc_nr_e = SYSTEM; \
fromaddr.proc_nr_e = KERNEL; \
toaddr.proc_nr_e = tr_proc_nr_e; \
fromaddr.offset = (myaddr); \
toaddr.offset = (addr); \
@@ -71,7 +71,7 @@ PUBLIC int do_trace(struct proc * caller, message * m_ptr)
struct vir_addr fromaddr, toaddr; \
int r; \
fromaddr.proc_nr_e = tr_proc_nr_e; \
toaddr.proc_nr_e = SYSTEM; \
toaddr.proc_nr_e = KERNEL; \
fromaddr.offset = (addr); \
toaddr.offset = (myaddr); \
fromaddr.segment = (seg); \

View File

@@ -67,7 +67,7 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
/* Copy (port,value)-pairs from user. */
if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->DIO_VEC_ADDR,
SYSTEM, (vir_bytes) vdevio_buf, bytes)) != OK)
KERNEL, (vir_bytes) vdevio_buf, bytes)) != OK)
return r;
privp= priv(caller);
@@ -104,19 +104,6 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
* the entire switch is wrapped in lock() and unlock() to prevent the I/O
* batch from being interrupted.
*/
#if 0
if(who_e == 71091) {
static int vd = 0;
if(vd++ < 100) {
kprintf("proc %d does vdevio no %d; type %d, direction %s\n",
who_e, vd, io_type, io_in ? "input" : "output");
kprintf("(");
for (i=0; i<vec_size; i++)
kprintf("%2d:0x%x,0x%x ", i, pvb[i].port, pvb[i].value);
kprintf(")\n");
}
}
#endif
lock;
switch (io_type) {
case _DIO_BYTE: /* byte values */
@@ -169,7 +156,7 @@ PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
/* Almost done, copy back results for input requests. */
if (io_in)
if((r=data_copy(SYSTEM, (vir_bytes) vdevio_buf,
if((r=data_copy(KERNEL, (vir_bytes) vdevio_buf,
caller->p_endpoint, (vir_bytes) m_ptr->DIO_VEC_ADDR,
(phys_bytes) bytes)) != OK)
return r;

View File

@@ -129,19 +129,19 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
switch(p->p_vmrequest.type) {
case VMSTYPE_KERNELCALL:
/* Put on restart chain. */
p->p_vmrequest.nextrestart = vmrestart;
vmrestart = p;
/*
* we will have to resume execution of the kernel call
* as soon the scheduler picks up this process again
*/
p->p_misc_flags |= MF_KCALL_RESUME;
break;
case VMSTYPE_DELIVERMSG:
vmassert(p->p_misc_flags & MF_DELIVERMSG);
vmassert(p == target);
vmassert(RTS_ISSET(p, RTS_VMREQUEST));
RTS_LOCK_UNSET(p, RTS_VMREQUEST);
break;
case VMSTYPE_MAP:
vmassert(RTS_ISSET(p, RTS_VMREQUEST));
RTS_LOCK_UNSET(p, RTS_VMREQUEST);
break;
default:
#if DEBUG_VMASSERT
@@ -152,7 +152,9 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
p->p_vmrequest.type);
}
RTS_LOCK_UNSET(p, RTS_VMREQUEST);
return OK;
case VMCTL_ENABLE_PAGING:
/*
* system task must not get preempted while switching to paging,

View File

@@ -63,7 +63,7 @@ PUBLIC struct boot_image image[] = {
/* process nr, pc, flags, qs, queue, stack, name */
{IDLE, NULL, 0, 0, 0, IDL_S, "idle" },
{CLOCK,clock_task, 0, 8, TASK_Q, TSK_S, "clock" },
{SYSTEM, sys_task, 0, 8, TASK_Q, TSK_S, "system"},
{SYSTEM, NULL, 0, 0, 0, IDL_S, "system"},
{HARDWARE, 0, 0, 8, TASK_Q, HRD_S, "kernel"},
{PM_PROC_NR, 0, 0, 32, 4, 0, "pm" },
{FS_PROC_NR, 0, 0, 32, 5, 0, "vfs" },