int sys_statectl(int request) { message m; m.CTL_REQUEST = request; return _kernel_call(SYS_STATECTL, &m); }
int sys_abort(int how) { /* Something awful has happened. Abandon ship. */ message m; m.m_lsys_krn_sys_abort.how = how; return(_kernel_call(SYS_ABORT, &m)); }
int sys_setgrant(cp_grant_t *grants, int ngrants) { message m; m.SG_ADDR = (char *) grants; m.SG_SIZE = ngrants; return _kernel_call(SYS_SETGRANT, &m); }
int sys_privctl(endpoint_t proc_ep, int request, void *p) { message m; m.CTL_ENDPT = proc_ep; m.CTL_REQUEST = request; m.CTL_ARG_PTR = p; return _kernel_call(SYS_PRIVCTL, &m); }
/*===========================================================================* * sys_safeunmap * *===========================================================================*/ PUBLIC int sys_safeunmap(int my_seg, vir_bytes my_address) { /* Requestor unmaps safemap. */ message copy_mess; copy_mess.SMAP_SEG = (void*) my_seg; copy_mess.SMAP_ADDRESS = my_address; return(_kernel_call(SYS_SAFEUNMAP, ©_mess)); }
/*===========================================================================* * sys_saferevmap_addr * *===========================================================================*/ PUBLIC int sys_saferevmap_addr(vir_bytes addr) { /* Grantor revokes safemap by address. */ message copy_mess; copy_mess.SMAP_FLAG = 0; copy_mess.SMAP_GID = addr; return(_kernel_call(SYS_SAFEREVMAP, ©_mess)); }
/*===========================================================================* * sys_saferevmap_gid * *===========================================================================*/ PUBLIC int sys_saferevmap_gid(cp_grant_id_t grant) { /* Grantor revokes safemap by grant id. */ message copy_mess; copy_mess.SMAP_FLAG = 1; copy_mess.SMAP_GID = grant; return(_kernel_call(SYS_SAFEREVMAP, ©_mess)); }
int sys_privquery_mem(endpoint_t proc_ep, phys_bytes start, phys_bytes len) { message m; m.CTL_ENDPT = proc_ep; m.CTL_REQUEST = SYS_PRIV_QUERY_MEM; m.CTL_PHYSSTART = start; m.CTL_PHYSLEN = len; return _kernel_call(SYS_PRIVCTL, &m); }
PUBLIC int sys_vsafecopy(struct vscp_vec *vec, int els) { /* Vectored variant of sys_safecopy*. */ message copy_mess; copy_mess.VSCP_VEC_ADDR = (char *) vec; copy_mess.VSCP_VEC_SIZE = els; return(_kernel_call(SYS_VSAFECOPY, ©_mess)); }
/*===========================================================================* * env_get_param * *===========================================================================*/ int env_get_param(const char *key, char *value, int max_len) { message m; static char mon_params[MULTIBOOT_PARAM_BUF_SIZE]; /* copy parameters here */ const char *key_value; int i, s; size_t 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 > (size_t) max_len) return(E2BIG); strcpy(value, key_value); return OK; } /* Get copy of boot monitor parameters. */ m.m_type = SYS_GETINFO; m.m_lsys_krn_sys_getinfo.request = GET_MONPARAMS; m.m_lsys_krn_sys_getinfo.endpt = SELF; m.m_lsys_krn_sys_getinfo.val_len = sizeof(mon_params); m.m_lsys_krn_sys_getinfo.val_ptr = (vir_bytes)mon_params; if ((s=_kernel_call(SYS_GETINFO, &m)) != OK) { printf("SYS_GETINFO: %d (size %zu)\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) > (size_t) max_len) return(E2BIG); /* Make the actual copy. */ strcpy(value, key_value); return(OK); }
int sys_memset(unsigned long pattern, phys_bytes base, phys_bytes bytes) { /* Zero a block of data. */ message mess; if (bytes == 0L) return(OK); mess.MEM_PTR = (char *) base; mess.MEM_COUNT = bytes; mess.MEM_PATTERN = pattern; return(_kernel_call(SYS_MEMSET, &mess)); }
int sys_newmap( endpoint_t proc_ep, /* process whose map is to be changed */ struct mem_map *ptr /* pointer to new map */ ) { /* A process has been assigned a new memory map. Tell the kernel. */ message m; m.PR_ENDPT = proc_ep; m.PR_MEM_PTR = (char *) ptr; return(_kernel_call(SYS_NEWMAP, &m)); }
int sys_schedule(endpoint_t proc_ep, int priority, int quantum, int cpu) { message m; m.SCHEDULING_ENDPOINT = proc_ep; m.SCHEDULING_PRIORITY = priority; m.SCHEDULING_QUANTUM = quantum; m.SCHEDULING_CPU = cpu; return(_kernel_call(SYS_SCHEDULE, &m)); }
int sys_safememset(endpoint_t dst_e, cp_grant_id_t gr_id, vir_bytes offset, int pattern, size_t len) { /* memset() a block of data using pattern */ message copy_mess; copy_mess.SMS_DST = dst_e; copy_mess.SMS_GID = gr_id; copy_mess.SMS_OFFSET = (long) offset; copy_mess.SMS_PATTERN = pattern; copy_mess.SMS_BYTES = (long) len; return(_kernel_call(SYS_SAFEMEMSET, ©_mess)); }
PUBLIC int sys_schedctl(unsigned flags, endpoint_t proc_ep, int priority, int quantum, int cpu) { message m; m.SCHEDCTL_FLAGS = (int) flags; m.SCHEDCTL_ENDPOINT = proc_ep; m.SCHEDCTL_PRIORITY = priority; m.SCHEDCTL_QUANTUM = quantum; m.SCHEDCTL_CPU = cpu; return(_kernel_call(SYS_SCHEDCTL, &m)); }
/* * Ask the kernel to schedule a synchronous alarm for the caller, using either * an absolute or a relative number of clock ticks. The new alarm replaces any * previously set alarm. If a relative expiry time of zero is given, the * current alarm is stopped. Return OK or a negative error code. On success, * optionally return the time left on the previous timer (TMR_NEVER if none was * set) and the current time. */ int sys_setalarm2(clock_t exp_time, int abs_time, clock_t * time_left, clock_t * uptime) { message m; int r; m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* expiration time */ m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */ if ((r = _kernel_call(SYS_SETALARM, &m)) != OK) return r; if (time_left != NULL) *time_left = m.m_lsys_krn_sys_setalarm.time_left; if (uptime != NULL) *uptime = m.m_lsys_krn_sys_setalarm.uptime; return OK; }
int sys_safecopyfrom(endpoint_t src_e, cp_grant_id_t gr_id, vir_bytes offset, vir_bytes address, size_t bytes, int my_seg) { /* Transfer a block of data for which the other process has previously * given permission. */ message copy_mess; copy_mess.SCP_FROM_TO = src_e; copy_mess.SCP_SEG = my_seg; copy_mess.SCP_GID = gr_id; copy_mess.SCP_OFFSET = (long) offset; copy_mess.SCP_ADDRESS = (char *) address; copy_mess.SCP_BYTES = (long) bytes; return(_kernel_call(SYS_SAFECOPYFROM, ©_mess)); }
/*===========================================================================* * sys_safemap * *===========================================================================*/ PUBLIC int sys_safemap(endpoint_t grantor, cp_grant_id_t grant, vir_bytes grant_offset, vir_bytes my_address, size_t bytes, int my_seg, int writable) { /* Map a block of data for which the other process has previously * granted permission. */ message copy_mess; copy_mess.SMAP_EP = grantor; copy_mess.SMAP_GID = grant; copy_mess.SMAP_OFFSET = grant_offset; copy_mess.SMAP_SEG = (void*) my_seg; copy_mess.SMAP_ADDRESS = my_address; copy_mess.SMAP_BYTES = bytes; copy_mess.SMAP_FLAG = writable; return(_kernel_call(SYS_SAFEMAP, ©_mess)); }
int sys_stop_cont(endpoint_t proc_ep, int signr){ message m; m.SIG_ENDPT = proc_ep; m.SIG_NUMBER = signr; return(_kernel_call(SYS_STOP_CONT, &m)); }