minix/kernel/system/do_sysctl.c
Tomas Hruby 728f0f0c49 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
2010-02-09 15:20:09 +00:00

54 lines
1.5 KiB
C

/* The kernel call implemented in this file:
* m_type: SYS_SYSCTL
*
* The parameters for this kernel call are:
* SYSCTL_CODE request
* and then request-specific arguments in SYSCTL_ARG1 and SYSCTL_ARG2.
*/
#include "../system.h"
/*===========================================================================*
* do_sysctl *
*===========================================================================*/
PUBLIC int do_sysctl(struct proc * caller, message * m_ptr)
{
vir_bytes len, buf;
static char mybuf[DIAG_BUFSIZE];
int s, i, proc_nr;
switch (m_ptr->SYSCTL_CODE) {
case SYSCTL_CODE_DIAG:
buf = (vir_bytes) m_ptr->SYSCTL_ARG1;
len = (vir_bytes) m_ptr->SYSCTL_ARG2;
if(len < 1 || len > DIAG_BUFSIZE) {
kprintf("do_sysctl: diag for %d: len %d out of range\n",
caller->p_endpoint, len);
return EINVAL;
}
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);
return s;
}
for(i = 0; i < len; i++)
kputc(mybuf[i]);
kputc(END_OF_KMESS);
return OK;
case SYSCTL_CODE_STACKTRACE:
if(!isokendpt(m_ptr->SYSCTL_ARG2, &proc_nr))
return EINVAL;
proc_stacktrace(proc_addr(proc_nr));
return OK;
default:
kprintf("do_sysctl: invalid request %d\n", m_ptr->SYSCTL_CODE);
return(EINVAL);
}
minix_panic("do_sysctl: can't happen", NO_NUM);
return(OK);
}