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

@@ -7,6 +7,7 @@ LIBRARIES=libsys
libsys_FILES=" \
alloc_util.c \
assert.c \
kernel_call.c \
panic.c \
pci_attr_r16.c \
pci_attr_r32.c \

View File

@@ -17,5 +17,5 @@ PUBLIC int sys_abort(int how, ...)
}
va_end(ap);
return(_taskcall(SYSTASK, SYS_ABORT, &m));
return(_kernel_call(SYS_ABORT, &m));
}

View File

@@ -18,6 +18,6 @@ void *mem_ptr; /* location of allocated memory */
m.PROF_CTL_PTR = ctl_ptr;
m.PROF_MEM_PTR = mem_ptr;
return(_taskcall(SYSTASK, SYS_CPROF, &m));
return(_kernel_call(SYS_CPROF, &m));
}

View File

@@ -10,7 +10,7 @@ endpoint_t proc_ep; /* process number */
int result;
m.SIG_ENDPT = proc_ep;
result = _taskcall(SYSTASK, SYS_ENDKSIG, &m);
result = _kernel_call(SYS_ENDKSIG, &m);
return(result);
}

View File

@@ -8,7 +8,7 @@ endpoint_t proc_ep; /* number of process to allow I/O */
{
message m_iop;
m_iop.IO_ENDPT = proc_ep;
return _taskcall(SYSTASK, SYS_IOPENABLE, &m_iop);
return _kernel_call(SYS_IOPENABLE, &m_iop);
}

View File

@@ -14,5 +14,5 @@ vir_bytes initpc;
m.PR_STACK_PTR = ptr;
m.PR_NAME_PTR = prog_name;
m.PR_IP_PTR = (char *)initpc;
return(_taskcall(SYSTASK, SYS_EXEC, &m));
return(_kernel_call(SYS_EXEC, &m));
}

View File

@@ -13,5 +13,5 @@ endpoint_t proc_ep; /* which process has exited */
message m;
m.PR_ENDPT = proc_ep;
return(_taskcall(SYSTASK, SYS_EXIT, &m));
return(_kernel_call(SYS_EXIT, &m));
}

View File

@@ -17,7 +17,7 @@ vir_bytes *msgaddr;
m.PR_SLOT = child;
m.PR_MEM_PTR = (char *) map_ptr;
m.PR_FORK_FLAGS = flags;
r = _taskcall(SYSTASK, SYS_FORK, &m);
r = _kernel_call(SYS_FORK, &m);
*child_endpoint = m.PR_ENDPT;
*msgaddr = (vir_bytes) m.PR_FORK_MSGADDR;
return r;

View File

@@ -22,7 +22,7 @@ int len2; /* length or process nr */
m.I_VAL_PTR2 = ptr2;
m.I_VAL_LEN2_E = len2;
return(_taskcall(SYSTASK, SYS_GETINFO, &m));
return(_kernel_call(SYS_GETINFO, &m));
}
/*===========================================================================*
@@ -39,7 +39,7 @@ PUBLIC int sys_whoami(endpoint_t *who_ep, char *who_name, int len)
if(len < 2)
return EINVAL;
if((r = _taskcall(SYSTASK, SYS_GETINFO, &m)) != OK)
if((r = _kernel_call(SYS_GETINFO, &m)) != OK)
return r;
lenmin = MIN(len, sizeof(m.GIWHO_NAME)) - 1;

View File

@@ -10,7 +10,7 @@ sigset_t *k_sig_map; /* return signal map here */
message m;
int result;
result = _taskcall(SYSTASK, SYS_GETKSIG, &m);
result = _kernel_call(SYS_GETKSIG, &m);
*proc_ep = m.SIG_ENDPT;
*k_sig_map = (sigset_t) m.SIG_MAP;
return(result);

View File

@@ -14,7 +14,7 @@ int type; /* byte, word, long */
m_io.DIO_REQUEST = _DIO_INPUT | type;
m_io.DIO_PORT = port;
result = _taskcall(SYSTASK, SYS_DEVIO, &m_io);
result = _kernel_call(SYS_DEVIO, &m_io);
*value = m_io.DIO_VALUE;
return(result);
}

View File

@@ -11,7 +11,7 @@ struct reg86u *reg86p;
m.m1_p1= (char *)reg86p;
result = _taskcall(SYSTASK, SYS_INT86, &m);
result = _kernel_call(SYS_INT86, &m);
return(result);
}

View File

@@ -18,7 +18,7 @@ int *hook_id; /* ID of IRQ hook at kernel */
m_irq.IRQ_POLICY = policy;
m_irq.IRQ_HOOK_ID = *hook_id;
s = _taskcall(SYSTASK, SYS_IRQCTL, &m_irq);
s = _kernel_call(SYS_IRQCTL, &m_irq);
if (req == IRQ_SETPOLICY) *hook_id = m_irq.IRQ_HOOK_ID;
return(s);
}

View File

@@ -9,6 +9,6 @@ int signr; /* signal number: 1 - 16 */
m.SIG_ENDPT = proc_ep;
m.SIG_NUMBER = signr;
return(_taskcall(SYSTASK, SYS_KILL, &m));
return(_kernel_call(SYS_KILL, &m));
}

View File

@@ -11,6 +11,6 @@ PUBLIC int sys_memset(unsigned long pattern, phys_bytes base, phys_bytes bytes)
mess.MEM_COUNT = bytes;
mess.MEM_PATTERN = pattern;
return(_taskcall(SYSTASK, SYS_MEMSET, &mess));
return(_kernel_call(SYS_MEMSET, &mess));
}

View File

@@ -10,5 +10,5 @@ struct mem_map *ptr; /* pointer to new map */
m.PR_ENDPT = proc_ep;
m.PR_MEM_PTR = (char *) ptr;
return(_taskcall(SYSTASK, SYS_NEWMAP, &m));
return(_kernel_call(SYS_NEWMAP, &m));
}

View File

@@ -9,5 +9,5 @@ PUBLIC int sys_nice(endpoint_t proc_ep, int prio)
m.PR_ENDPT = proc_ep;
m.PR_PRIORITY = prio;
return(_taskcall(SYSTASK, SYS_NICE, &m));
return(_kernel_call(SYS_NICE, &m));
}

View File

@@ -14,6 +14,6 @@ int type; /* byte, word, long */
m_io.DIO_PORT = port;
m_io.DIO_VALUE = value;
return _taskcall(SYSTASK, SYS_DEVIO, &m_io);
return _kernel_call(SYS_DEVIO, &m_io);
}

View File

@@ -26,5 +26,5 @@ phys_bytes bytes; /* how many bytes */
copy_mess.CP_DST_SPACE = dst_seg;
copy_mess.CP_DST_ADDR = (long) dst_vir;
copy_mess.CP_NR_BYTES = (long) bytes;
return(_taskcall(SYSTASK, SYS_PHYSCOPY, &copy_mess));
return(_kernel_call(SYS_PHYSCOPY, &copy_mess));
}

View File

@@ -8,7 +8,7 @@ int sys_privctl(endpoint_t proc_ep, int request, void *p)
m.CTL_REQUEST = request;
m.CTL_ARG_PTR = p;
return _taskcall(SYSTASK, SYS_PRIVCTL, &m);
return _kernel_call(SYS_PRIVCTL, &m);
}
int sys_privquery_mem(endpoint_t proc_ep, phys_bytes start, phys_bytes len)
@@ -20,5 +20,5 @@ int sys_privquery_mem(endpoint_t proc_ep, phys_bytes start, phys_bytes len)
m.CTL_PHYSSTART = start;
m.CTL_PHYSLEN = len;
return _taskcall(SYSTASK, SYS_PRIVCTL, &m);
return _kernel_call(SYS_PRIVCTL, &m);
}

View File

@@ -12,6 +12,6 @@ void *mem_ptr; /* pointer to profiling table */
m.PROF_CTL_PTR = ctl_ptr;
m.PROF_MEM_PTR = mem_ptr;
return(_taskcall(SYSTASK, SYS_PROFBUF, &m));
return(_kernel_call(SYS_PROFBUF, &m));
}

View File

@@ -11,5 +11,5 @@ size_t size; /* Amount of data to read */
m.RDB_SIZE = size;
m.RDB_ADDR = address;
m.RDB_BUF = buf;
return(_taskcall(SYSTASK, SYS_READBIOS, &m));
return(_kernel_call(SYS_READBIOS, &m));
}

View File

@@ -11,5 +11,5 @@ PUBLIC int sys_runctl(endpoint_t proc_ep, int action, int flags)
m.RC_ACTION = action;
m.RC_FLAGS = flags;
return(_taskcall(SYSTASK, SYS_RUNCTL, &m));
return(_kernel_call(SYS_RUNCTL, &m));
}

View File

@@ -21,7 +21,7 @@ PUBLIC int sys_safecopyfrom(endpoint_t src_e,
copy_mess.SCP_ADDRESS = (char *) address;
copy_mess.SCP_BYTES = (long) bytes;
return(_taskcall(SYSTASK, SYS_SAFECOPYFROM, &copy_mess));
return(_kernel_call(SYS_SAFECOPYFROM, &copy_mess));
}
@@ -43,6 +43,6 @@ PUBLIC int sys_safecopyto(endpoint_t dst_e,
copy_mess.SCP_ADDRESS = (char *) address;
copy_mess.SCP_BYTES = (long) bytes;
return(_taskcall(SYSTASK, SYS_SAFECOPYTO, &copy_mess));
return(_kernel_call(SYS_SAFECOPYTO, &copy_mess));
}

View File

@@ -24,7 +24,7 @@ PUBLIC int sys_safemap(endpoint_t grantor, cp_grant_id_t grant,
copy_mess.SMAP_BYTES = bytes;
copy_mess.SMAP_FLAG = writable;
return(_taskcall(SYSTASK, SYS_SAFEMAP, &copy_mess));
return(_kernel_call(SYS_SAFEMAP, &copy_mess));
}
@@ -39,7 +39,7 @@ PUBLIC int sys_saferevmap_gid(cp_grant_id_t grant)
copy_mess.SMAP_FLAG = 1;
copy_mess.SMAP_GID = grant;
return(_taskcall(SYSTASK, SYS_SAFEREVMAP, &copy_mess));
return(_kernel_call(SYS_SAFEREVMAP, &copy_mess));
}
/*===========================================================================*
@@ -53,7 +53,7 @@ PUBLIC int sys_saferevmap_addr(vir_bytes addr)
copy_mess.SMAP_FLAG = 0;
copy_mess.SMAP_GID = addr;
return(_taskcall(SYSTASK, SYS_SAFEREVMAP, &copy_mess));
return(_kernel_call(SYS_SAFEREVMAP, &copy_mess));
}
/*===========================================================================*
@@ -67,6 +67,6 @@ PUBLIC int sys_safeunmap(int my_seg, vir_bytes my_address)
copy_mess.SMAP_SEG = (void*) my_seg;
copy_mess.SMAP_ADDRESS = my_address;
return(_taskcall(SYSTASK, SYS_SAFEUNMAP, &copy_mess));
return(_kernel_call(SYS_SAFEUNMAP, &copy_mess));
}

View File

@@ -21,6 +21,6 @@ vir_bytes offset; /* offset from grant */
m_io.DIO_VEC_SIZE = count;
m_io.DIO_OFFSET = offset;
return(_taskcall(SYSTASK, SYS_SDEVIO, &m_io));
return(_kernel_call(SYS_SDEVIO, &m_io));
}

View File

@@ -14,7 +14,7 @@ vir_bytes size; /* size of segment */
int s;
m.SEG_PHYS = phys;
m.SEG_SIZE = size;
s = _taskcall(SYSTASK, SYS_SEGCTL, &m);
s = _kernel_call(SYS_SEGCTL, &m);
*index = (int) m.SEG_INDEX;
*seg = (u16_t) m.SEG_SELECT;
*off = (vir_bytes) m.SEG_OFFSET;

View File

@@ -13,6 +13,6 @@ int abs_time; /* use absolute or relative expiration time */
message m;
m.ALRM_EXP_TIME = exp_time; /* the expiration time */
m.ALRM_ABS_TIME = abs_time; /* time is absolute? */
return _taskcall(SYSTASK, SYS_SETALARM, &m);
return _kernel_call(SYS_SETALARM, &m);
}

View File

@@ -10,5 +10,5 @@ int sys_setgrant(cp_grant_t *grants, int ngrants)
m.SG_ADDR = (char *) grants;
m.SG_SIZE = ngrants;
return _taskcall(SYSTASK, SYS_SETGRANT, &m);
return _kernel_call(SYS_SETGRANT, &m);
}

View File

@@ -12,7 +12,7 @@ struct sigmsg *sig_ctxt; /* POSIX style handling */
m.SIG_ENDPT = proc_ep;
m.SIG_CTXT_PTR = (char *) sig_ctxt;
result = _taskcall(SYSTASK, SYS_SIGRETURN, &m);
result = _kernel_call(SYS_SIGRETURN, &m);
return(result);
}

View File

@@ -12,7 +12,7 @@ struct sigmsg *sig_ctxt; /* POSIX style handling */
m.SIG_ENDPT = proc_ep;
m.SIG_CTXT_PTR = (char *) sig_ctxt;
result = _taskcall(SYSTASK, SYS_SIGSEND, &m);
result = _kernel_call(SYS_SIGSEND, &m);
return(result);
}

View File

@@ -22,7 +22,7 @@ void *mem_ptr; /* location of profiling memory */
m.PROF_CTL_PTR = ctl_ptr;
m.PROF_MEM_PTR = mem_ptr;
return(_taskcall(SYSTASK, SYS_SPROF, &m));
return(_kernel_call(SYS_SPROF, &m));
}
#endif

View File

@@ -7,6 +7,6 @@ time_t boottime; /* New boottime */
int r;
m.T_BOOTTIME = boottime;
r = _taskcall(SYSTASK, SYS_STIME, &m);
r = _kernel_call(SYS_STIME, &m);
return(r);
}

View File

@@ -9,7 +9,7 @@ PUBLIC int sys_sysctl(int code, char *arg1, int arg2)
m.SYSCTL_ARG1 = arg1;
m.SYSCTL_ARG2 = arg2;
return(_taskcall(SYSTASK, SYS_SYSCTL, &m));
return(_kernel_call(SYS_SYSCTL, &m));
}

View File

@@ -14,7 +14,7 @@ time_t *boottime; /* boot time */
int r;
m.T_ENDPT = proc_ep;
r = _taskcall(SYSTASK, SYS_TIMES, &m);
r = _kernel_call(SYS_TIMES, &m);
if (user_time) *user_time = m.T_USER_TIME;
if (sys_time) *sys_time = m.T_SYSTEM_TIME;
if (uptime) *uptime = m.T_BOOT_TICKS;

View File

@@ -12,7 +12,7 @@ long addr, *data_p;
m.CTL_REQUEST = req;
m.CTL_ADDRESS = addr;
if (data_p) m.CTL_DATA = *data_p;
r = _taskcall(SYSTASK, SYS_TRACE, &m);
r = _kernel_call(SYS_TRACE, &m);
if (data_p) *data_p = m.CTL_DATA;
return(r);
}

View File

@@ -18,7 +18,7 @@ phys_bytes *phys_addr; /* placeholder for result */
m.CP_SRC_ADDR = vir_addr;
m.CP_NR_BYTES = bytes;
result = _taskcall(SYSTASK, SYS_UMAP, &m);
result = _kernel_call(SYS_UMAP, &m);
*phys_addr = m.CP_DST_ADDR;
return(result);
}

View File

@@ -12,6 +12,6 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_INPUT | _DIO_BYTE;
m_io.DIO_VEC_ADDR = (char *) pvb_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -12,6 +12,6 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_INPUT | _DIO_LONG;
m_io.DIO_VEC_ADDR = (char *) pvl_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -13,6 +13,6 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_WORD | _DIO_INPUT;
m_io.DIO_VEC_ADDR = (char *) pvw_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -25,5 +25,5 @@ phys_bytes bytes; /* how many bytes */
copy_mess.CP_DST_SPACE = dst_seg;
copy_mess.CP_DST_ADDR = (long) dst_vir;
copy_mess.CP_NR_BYTES = (long) bytes;
return(_taskcall(SYSTASK, SYS_VIRCOPY, &copy_mess));
return(_kernel_call(SYS_VIRCOPY, &copy_mess));
}

View File

@@ -8,7 +8,7 @@ PUBLIC int sys_vmctl(endpoint_t who, int param, u32_t value)
m.SVMCTL_WHO = who;
m.SVMCTL_PARAM = param;
m.SVMCTL_VALUE = value;
r = _taskcall(SYSTASK, SYS_VMCTL, &m);
r = _kernel_call(SYS_VMCTL, &m);
return(r);
}
@@ -19,7 +19,7 @@ PUBLIC int sys_vmctl_get_pagefault_i386(endpoint_t *who, u32_t *cr2, u32_t *err)
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_GET_PAGEFAULT;
r = _taskcall(SYSTASK, SYS_VMCTL, &m);
r = _kernel_call(SYS_VMCTL, &m);
if(r == OK) {
*who = m.SVMCTL_PF_WHO;
*cr2 = m.SVMCTL_PF_I386_CR2;
@@ -35,7 +35,7 @@ PUBLIC int sys_vmctl_get_cr3_i386(endpoint_t who, u32_t *cr3)
m.SVMCTL_WHO = who;
m.SVMCTL_PARAM = VMCTL_I386_GETCR3;
r = _taskcall(SYSTASK, SYS_VMCTL, &m);
r = _kernel_call(SYS_VMCTL, &m);
if(r == OK) {
*cr3 = m.SVMCTL_VALUE;
}
@@ -51,7 +51,7 @@ PUBLIC int sys_vmctl_get_memreq(endpoint_t *who, vir_bytes *mem,
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_MEMREQ_GET;
r = _taskcall(SYSTASK, SYS_VMCTL, &m);
r = _kernel_call(SYS_VMCTL, &m);
if(r >= 0) {
*who = m.SVMCTL_MRG_TARGET;
*mem = m.SVMCTL_MRG_ADDR;
@@ -70,7 +70,7 @@ PUBLIC int sys_vmctl_enable_paging(struct mem_map *map)
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_ENABLE_PAGING;
m.SVMCTL_VALUE = (int) map;
return _taskcall(SYSTASK, SYS_VMCTL, &m);
return _kernel_call(SYS_VMCTL, &m);
}
PUBLIC int sys_vmctl_get_mapping(int index,
@@ -83,7 +83,7 @@ PUBLIC int sys_vmctl_get_mapping(int index,
m.SVMCTL_PARAM = VMCTL_KERN_PHYSMAP;
m.SVMCTL_VALUE = (int) index;
r = _taskcall(SYSTASK, SYS_VMCTL, &m);
r = _kernel_call(SYS_VMCTL, &m);
if(r != OK)
return r;
@@ -105,5 +105,5 @@ PUBLIC int sys_vmctl_reply_mapping(int index, vir_bytes addr)
m.SVMCTL_VALUE = index;
m.SVMCTL_MAP_VIR_ADDR = (char *) addr;
return _taskcall(SYSTASK, SYS_VMCTL, &m);
return _kernel_call(SYS_VMCTL, &m);
}

View File

@@ -11,7 +11,7 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_OUTPUT | _DIO_BYTE;
m_io.DIO_VEC_ADDR = (char *) pvb_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -12,6 +12,6 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_OUTPUT | _DIO_LONG;
m_io.DIO_VEC_ADDR = (char *) pvl_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -13,6 +13,6 @@ int nr_ports; /* nr of pairs to be processed */
m_io.DIO_REQUEST = _DIO_OUTPUT | _DIO_WORD;
m_io.DIO_VEC_ADDR = (char *) pvw_pairs;
m_io.DIO_VEC_SIZE = nr_ports;
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
return _kernel_call(SYS_VDEVIO, &m_io);
}

View File

@@ -12,7 +12,7 @@ PUBLIC int sys_vsafecopy(struct vscp_vec *vec, int els)
copy_mess.VSCP_VEC_ADDR = (char *) vec;
copy_mess.VSCP_VEC_SIZE = els;
return(_taskcall(SYSTASK, SYS_VSAFECOPY, &copy_mess));
return(_kernel_call(SYS_VSAFECOPY, &copy_mess));
}

View File

@@ -18,7 +18,7 @@ clock_t *oldval; /* if non-NULL, old value is stored here */
m.VT_SET = 0;
}
r = _taskcall(SYSTASK, SYS_VTIMER, &m);
r = _kernel_call(SYS_VTIMER, &m);
if (oldval != NULL) {
*oldval = m.VT_VALUE;