Message type for SYS_GETINFO and SYS_GETWHOAMI
Change-Id: I9cea3f65b29e30555c8b47865e12c7d19a74a3c3
This commit is contained in:
parent
f1dff35292
commit
dcb7493a05
5 changed files with 71 additions and 50 deletions
|
@ -313,7 +313,6 @@
|
|||
#define CP_FLAG_TRY 0x01 /* do not transparently map */
|
||||
|
||||
/* Field names for SYS_GETINFO. */
|
||||
#define I_REQUEST m7_i3 /* what info to get */
|
||||
# define GET_KINFO 0 /* get kernel information structure */
|
||||
# define GET_IMAGE 1 /* get system image table */
|
||||
# define GET_PROCTAB 2 /* get kernel process table */
|
||||
|
@ -338,16 +337,6 @@
|
|||
# define GET_CPUINFO 23 /* get information about cpus */
|
||||
# define GET_REGS 24 /* get general process registers */
|
||||
# define GET_RUSAGE 25 /* get resource usage */
|
||||
#define I_ENDPT m7_i4 /* calling process (may only be SELF) */
|
||||
#define I_VAL_PTR m7_p1 /* virtual address at caller */
|
||||
#define I_VAL_LEN m7_i1 /* max length of value */
|
||||
#define I_VAL_PTR2 m7_p2 /* second virtual address */
|
||||
#define I_VAL_LEN2_E m7_i2 /* second length, or proc nr */
|
||||
|
||||
/* GET_WHOAMI fields. */
|
||||
#define GIWHO_EP m3_i1
|
||||
#define GIWHO_NAME m3_ca1
|
||||
#define GIWHO_PRIVFLAGS m3_i2
|
||||
|
||||
/* Field names for SYS_TIMES. */
|
||||
#define T_ENDPT m4_l1 /* process to request time info for */
|
||||
|
|
|
@ -719,6 +719,26 @@ typedef struct {
|
|||
} mess_lsys_krn_sys_copy;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_copy);
|
||||
|
||||
typedef struct {
|
||||
int request;
|
||||
endpoint_t endpt;
|
||||
vir_bytes val_ptr;
|
||||
int val_len;
|
||||
vir_bytes val_ptr2;
|
||||
int val_len2_e;
|
||||
|
||||
uint8_t padding[32];
|
||||
} mess_lsys_krn_sys_getinfo;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_getinfo);
|
||||
|
||||
typedef struct {
|
||||
endpoint_t endpt;
|
||||
int privflags;
|
||||
char name[48];
|
||||
|
||||
} mess_krn_lsys_sys_getwhoami;
|
||||
_ASSERT_MSG_SIZE(mess_krn_lsys_sys_getwhoami);
|
||||
|
||||
typedef struct {
|
||||
endpoint_t endpt;
|
||||
|
||||
|
@ -1468,6 +1488,7 @@ typedef struct {
|
|||
mess_sigcalls m_sigcalls;
|
||||
|
||||
mess_krn_lsys_schedule m_krn_lsys_schedule;
|
||||
mess_krn_lsys_sys_getwhoami m_krn_lsys_sys_getwhoami;
|
||||
mess_krn_lsys_sys_irqctl m_krn_lsys_sys_irqctl;
|
||||
mess_krn_lsys_sys_umap m_krn_lsys_sys_umap;
|
||||
mess_krn_lsys_sys_vumap m_krn_lsys_sys_vumap;
|
||||
|
@ -1549,6 +1570,7 @@ typedef struct {
|
|||
mess_lsys_krn_schedule m_lsys_krn_schedule;
|
||||
mess_lsys_krn_sys_abort m_lsys_krn_sys_abort;
|
||||
mess_lsys_krn_sys_copy m_lsys_krn_sys_copy;
|
||||
mess_lsys_krn_sys_getinfo m_lsys_krn_sys_getinfo;
|
||||
mess_lsys_krn_sys_iopenable m_lsys_krn_sys_iopenable;
|
||||
mess_lsys_krn_sys_irqctl m_lsys_krn_sys_irqctl;
|
||||
mess_lsys_krn_sys_memset m_lsys_krn_sys_memset;
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
* m_type: SYS_GETINFO
|
||||
*
|
||||
* The parameters for this kernel call are:
|
||||
* m1_i3: I_REQUEST (what info to get)
|
||||
* m1_p1: I_VAL_PTR (where to put it)
|
||||
* m1_i1: I_VAL_LEN (maximum length expected, optional)
|
||||
* m1_p2: I_VAL_PTR2 (second, optional pointer)
|
||||
* m1_i2: I_VAL_LEN2_E (second length or process nr)
|
||||
* m_lsys_krn_sys_getinfo.request (what info to get)
|
||||
* m_lsys_krn_sys_getinfo.val_ptr (where to put it)
|
||||
* m_lsys_krn_sys_getinfo.val_len (maximum length expected, optional)
|
||||
* m_lsys_krn_sys_getinfo.val_ptr2 (second, optional pointer)
|
||||
* m_lsys_krn_sys_getinfo.val_len2_e (second length or process nr)
|
||||
*
|
||||
* Upon return of the GETWHOAMI request the following parameters are used:
|
||||
* m_krn_lsys_sys_getwhoami.endpt (the caller endpoint)
|
||||
* m_krn_lsys_sys_getwhoami.privflags (the caller priviledes)
|
||||
* m_krn_lsys_sys_getwhoami.name (the caller process name)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
@ -50,7 +56,7 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
struct rusage r_usage;
|
||||
|
||||
/* Set source address and length based on request type. */
|
||||
switch (m_ptr->I_REQUEST) {
|
||||
switch (m_ptr->m_lsys_krn_sys_getinfo.request) {
|
||||
case GET_MACHINE: {
|
||||
length = sizeof(struct machine);
|
||||
src_vir = (vir_bytes) &machine;
|
||||
|
@ -98,24 +104,24 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
break;
|
||||
}
|
||||
case GET_PROC: {
|
||||
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
||||
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
||||
nr_e = (m_ptr->m_lsys_krn_sys_getinfo.val_len2_e == SELF) ?
|
||||
caller->p_endpoint : m_ptr->m_lsys_krn_sys_getinfo.val_len2_e;
|
||||
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
||||
length = sizeof(struct proc);
|
||||
src_vir = (vir_bytes) proc_addr(nr);
|
||||
break;
|
||||
}
|
||||
case GET_PRIV: {
|
||||
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
||||
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
||||
nr_e = (m_ptr->m_lsys_krn_sys_getinfo.val_len2_e == SELF) ?
|
||||
caller->p_endpoint : m_ptr->m_lsys_krn_sys_getinfo.val_len2_e;
|
||||
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
||||
length = sizeof(struct priv);
|
||||
src_vir = (vir_bytes) priv_addr(nr_to_id(nr));
|
||||
break;
|
||||
}
|
||||
case GET_REGS: {
|
||||
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
||||
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
||||
nr_e = (m_ptr->m_lsys_krn_sys_getinfo.val_len2_e == SELF) ?
|
||||
caller->p_endpoint : m_ptr->m_lsys_krn_sys_getinfo.val_len2_e;
|
||||
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
||||
p = proc_addr(nr);
|
||||
length = sizeof(p->p_reg);
|
||||
|
@ -124,12 +130,12 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
}
|
||||
case GET_WHOAMI: {
|
||||
int len;
|
||||
/* GET_WHOAMI uses m3 and only uses the message contents for info. */
|
||||
m_ptr->GIWHO_EP = caller->p_endpoint;
|
||||
len = MIN(sizeof(m_ptr->GIWHO_NAME), sizeof(caller->p_name))-1;
|
||||
strncpy(m_ptr->GIWHO_NAME, caller->p_name, len);
|
||||
m_ptr->GIWHO_NAME[len] = '\0';
|
||||
m_ptr->GIWHO_PRIVFLAGS = priv(caller)->s_flags;
|
||||
m_ptr->m_krn_lsys_sys_getwhoami.endpt = caller->p_endpoint;
|
||||
len = MIN(sizeof(m_ptr->m_krn_lsys_sys_getwhoami.name),
|
||||
sizeof(caller->p_name))-1;
|
||||
strncpy(m_ptr->m_krn_lsys_sys_getwhoami.name, caller->p_name, len);
|
||||
m_ptr->m_krn_lsys_sys_getwhoami.name[len] = '\0';
|
||||
m_ptr->m_krn_lsys_sys_getwhoami.privflags = priv(caller)->s_flags;
|
||||
return OK;
|
||||
}
|
||||
case GET_MONPARAMS: {
|
||||
|
@ -151,7 +157,7 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
break;
|
||||
}
|
||||
case GET_RANDOMNESS_BIN: {
|
||||
int bin = m_ptr->I_VAL_LEN2_E;
|
||||
int bin = m_ptr->m_lsys_krn_sys_getinfo.val_len2_e;
|
||||
|
||||
if(bin < 0 || bin >= RANDOM_SOURCES) {
|
||||
printf("SYSTEM: GET_RANDOMNESS_BIN: %d out of range\n", bin);
|
||||
|
@ -185,8 +191,8 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
struct proc *target = NULL;
|
||||
int target_slot = 0;
|
||||
u64_t usec;
|
||||
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
||||
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
||||
nr_e = (m_ptr->m_lsys_krn_sys_getinfo.val_len2_e == SELF) ?
|
||||
caller->p_endpoint : m_ptr->m_lsys_krn_sys_getinfo.val_len2_e;
|
||||
|
||||
if (!isokendpt(nr_e, &target_slot))
|
||||
return EINVAL;
|
||||
|
@ -208,14 +214,18 @@ int do_getinfo(struct proc * caller, message * m_ptr)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
printf("do_getinfo: invalid request %d\n", m_ptr->I_REQUEST);
|
||||
printf("do_getinfo: invalid request %d\n",
|
||||
m_ptr->m_lsys_krn_sys_getinfo.request);
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (m_ptr->m_lsys_krn_sys_getinfo.val_len > 0 &&
|
||||
length > m_ptr->m_lsys_krn_sys_getinfo.val_len)
|
||||
return (E2BIG);
|
||||
|
||||
r = data_copy_vmcheck(caller, KERNEL, src_vir, caller->p_endpoint,
|
||||
(vir_bytes) m_ptr->I_VAL_PTR, length);
|
||||
m_ptr->m_lsys_krn_sys_getinfo.val_ptr, length);
|
||||
|
||||
if(r != OK) return r;
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ int env_get_param(const char *key, char *value, int max_len)
|
|||
|
||||
/* 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;
|
||||
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 = mon_params;
|
||||
if ((s=_kernel_call(SYS_GETINFO, &m)) != OK) {
|
||||
printf("SYS_GETINFO: %d (size %u)\n", s, sizeof(mon_params));
|
||||
return(s);
|
||||
|
|
|
@ -15,12 +15,12 @@ int len2; /* length or process nr */
|
|||
{
|
||||
message m;
|
||||
|
||||
m.I_REQUEST = request;
|
||||
m.I_ENDPT = SELF; /* always store values at caller */
|
||||
m.I_VAL_PTR = ptr;
|
||||
m.I_VAL_LEN = len;
|
||||
m.I_VAL_PTR2 = ptr2;
|
||||
m.I_VAL_LEN2_E = len2;
|
||||
m.m_lsys_krn_sys_getinfo.request = request;
|
||||
m.m_lsys_krn_sys_getinfo.endpt = SELF; /* always store values at caller */
|
||||
m.m_lsys_krn_sys_getinfo.val_ptr = ptr;
|
||||
m.m_lsys_krn_sys_getinfo.val_len = len;
|
||||
m.m_lsys_krn_sys_getinfo.val_ptr2 = ptr2;
|
||||
m.m_lsys_krn_sys_getinfo.val_len2_e = len2;
|
||||
|
||||
return(_kernel_call(SYS_GETINFO, &m));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int sys_whoami(endpoint_t *who_ep, char *who_name, int len,
|
|||
int r;
|
||||
int lenmin;
|
||||
|
||||
m.I_REQUEST = GET_WHOAMI;
|
||||
m.m_lsys_krn_sys_getinfo.request = GET_WHOAMI;
|
||||
|
||||
if(len < 2)
|
||||
return EINVAL;
|
||||
|
@ -43,12 +43,12 @@ int sys_whoami(endpoint_t *who_ep, char *who_name, int len,
|
|||
if((r = _kernel_call(SYS_GETINFO, &m)) != OK)
|
||||
return r;
|
||||
|
||||
lenmin = MIN((size_t) len, sizeof(m.GIWHO_NAME)) - 1;
|
||||
lenmin = MIN((size_t) len, sizeof(m.m_krn_lsys_sys_getwhoami.name)) - 1;
|
||||
|
||||
strncpy(who_name, m.GIWHO_NAME, lenmin);
|
||||
strncpy(who_name, m.m_krn_lsys_sys_getwhoami.name, lenmin);
|
||||
who_name[lenmin] = '\0';
|
||||
*who_ep = m.GIWHO_EP;
|
||||
*priv_flags = m.GIWHO_PRIVFLAGS;
|
||||
*who_ep = m.m_krn_lsys_sys_getwhoami.endpt;
|
||||
*priv_flags = m.m_krn_lsys_sys_getwhoami.privflags;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue