728f0f0c49
* 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
99 lines
2.5 KiB
C
99 lines
2.5 KiB
C
#include "sysutil.h"
|
|
#include <string.h>
|
|
|
|
PUBLIC int env_argc = 0;
|
|
PUBLIC char **env_argv = NULL;
|
|
|
|
FORWARD _PROTOTYPE( char *find_key, (const char *params, const char *key));
|
|
|
|
/*===========================================================================*
|
|
* env_setargs *
|
|
*===========================================================================*/
|
|
PUBLIC void env_setargs(arg_c, arg_v)
|
|
int arg_c;
|
|
char *arg_v[];
|
|
{
|
|
env_argc= arg_c;
|
|
env_argv= arg_v;
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* env_get_param *
|
|
*===========================================================================*/
|
|
PUBLIC int env_get_param(key, value, max_len)
|
|
char *key; /* which key to look up */
|
|
char *value; /* where to store value */
|
|
int max_len; /* maximum length of value */
|
|
{
|
|
message m;
|
|
static char mon_params[128*sizeof(char *)]; /* copy parameters here */
|
|
char *key_value;
|
|
int i, s, keylen;
|
|
|
|
if (key == NULL)
|
|
return EINVAL;
|
|
|
|
keylen= strlen(key);
|
|
for (i= 1; i<env_argc; i++)
|
|
{
|
|
if (strncmp(env_argv[i], key, keylen) != 0)
|
|
continue;
|
|
if (strlen(env_argv[i]) <= keylen)
|
|
continue;
|
|
if (env_argv[i][keylen] != '=')
|
|
continue;
|
|
key_value= env_argv[i]+keylen+1;
|
|
if (strlen(key_value)+1 > max_len)
|
|
return(E2BIG);
|
|
strcpy(value, key_value);
|
|
return OK;
|
|
}
|
|
|
|
/* Get copy of boot monitor parameters. */
|
|
m.m_type = SYS_GETINFO;
|
|
m.I_REQUEST = GET_MONPARAMS;
|
|
m.I_ENDPT = SELF;
|
|
m.I_VAL_LEN = sizeof(mon_params);
|
|
m.I_VAL_PTR = mon_params;
|
|
if ((s=_kernel_call(SYS_GETINFO, &m)) != OK) {
|
|
printf("SYS_GETINFO: %d (size %u)\n", s, sizeof(mon_params));
|
|
return(s);
|
|
}
|
|
|
|
/* We got a copy, now search requested key. */
|
|
if ((key_value = find_key(mon_params, key)) == NULL)
|
|
return(ESRCH);
|
|
|
|
/* Value found, see if it fits in the client's buffer. Callers assume that
|
|
* their buffer is unchanged on error, so don't make a partial copy.
|
|
*/
|
|
if ((strlen(key_value)+1) > max_len) return(E2BIG);
|
|
|
|
/* Make the actual copy. */
|
|
strcpy(value, key_value);
|
|
|
|
return(OK);
|
|
}
|
|
|
|
|
|
/*==========================================================================*
|
|
* find_key *
|
|
*==========================================================================*/
|
|
PRIVATE char *find_key(params,name)
|
|
const char *params;
|
|
const char *name;
|
|
{
|
|
register const char *namep;
|
|
register char *envp;
|
|
|
|
for (envp = (char *) params; *envp != 0;) {
|
|
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
|
|
;
|
|
if (*namep == '\0' && *envp == '=')
|
|
return(envp + 1);
|
|
while (*envp++ != 0)
|
|
;
|
|
}
|
|
return(NULL);
|
|
}
|
|
|