make getsysinfo() a system-land call

This commit is contained in:
David van Moolenbroek
2010-09-14 21:50:05 +00:00
parent d299a6422b
commit 354da24f5b
24 changed files with 89 additions and 240 deletions
+12 -74
View File
@@ -60,8 +60,6 @@ PRIVATE char *uts_tbl[] = {
PUBLIC unsigned long calls_stats[NCALLS];
#endif
FORWARD _PROTOTYPE( int getpciinfo, (struct pciinfo *pciinfo) );
/*===========================================================================*
* do_procstat *
*===========================================================================*/
@@ -160,7 +158,6 @@ PUBLIC int do_getsysinfo()
vir_bytes src_addr, dst_addr;
struct kinfo kinfo;
struct loadinfo loadinfo;
struct pciinfo pciinfo;
static struct proc proctab[NR_PROCS+NR_TASKS];
size_t len;
int s, r;
@@ -174,38 +171,25 @@ PUBLIC int do_getsysinfo()
return EPERM;
}
/* This call should no longer be used by user applications. In the future,
* requests from non-system processes should be denied. For now, just warn.
*/
if (call_nr == GETSYSINFO)
{
printf("PM: obsolete call of do_getsysinfo() by proc %d '%s'\n",
mp->mp_endpoint, mp->mp_name);
}
switch(m_in.info_what) {
case SI_KINFO: /* kernel info is obtained via PM */
sys_getkinfo(&kinfo);
src_addr = (vir_bytes) &kinfo;
len = sizeof(struct kinfo);
break;
case SI_PROC_ADDR: /* get address of PM process table */
proc_addr = &mproc[0];
src_addr = (vir_bytes) &proc_addr;
len = sizeof(struct mproc *);
break;
case SI_PROC_TAB: /* copy entire process table */
src_addr = (vir_bytes) mproc;
len = sizeof(struct mproc) * NR_PROCS;
break;
case SI_KPROC_TAB: /* copy entire process table */
if((r=sys_getproctab(proctab)) != OK)
return r;
src_addr = (vir_bytes) proctab;
len = sizeof(proctab);
break;
case SI_LOADINFO: /* loadinfo is obtained via PM */
sys_getloadinfo(&loadinfo);
src_addr = (vir_bytes) &loadinfo;
len = sizeof(struct loadinfo);
break;
case SI_PCI_INFO: /* PCI info is obtained via PM */
if ((r=getpciinfo(&pciinfo)) != OK)
return r;
src_addr = (vir_bytes) &pciinfo;
len = sizeof(struct pciinfo);
break;
#if ENABLE_SYSCALL_STATS
case SI_CALL_STATS:
src_addr = (vir_bytes) calls_stats;
@@ -230,9 +214,11 @@ PUBLIC int do_getsysinfo_up()
vir_bytes src_addr, dst_addr;
struct loadinfo loadinfo;
size_t len, real_len;
u64_t idle_tsc;
int s;
printf("PM: obsolete call of do_getsysinfo_up() by proc %d '%s'\n",
mp->mp_endpoint, mp->mp_name);
switch(m_in.SIU_WHAT) {
case SIU_LOADINFO: /* loadinfo is obtained via PM */
if ((s = sys_getloadinfo(&loadinfo)) != OK)
@@ -244,12 +230,6 @@ PUBLIC int do_getsysinfo_up()
src_addr = (vir_bytes) &system_hz;
real_len = sizeof(system_hz);
break;
case SIU_IDLETSC:
if ((s = sys_getidletsc(&idle_tsc)) != OK)
return s;
src_addr = (vir_bytes) &idle_tsc;
real_len = sizeof(idle_tsc);
break;
default:
return(EINVAL);
}
@@ -580,45 +560,3 @@ char *brk_addr;
_brksize = brk_addr;
return 0;
}
/*===========================================================================*
* getpciinfo *
*===========================================================================*/
PRIVATE int getpciinfo(pciinfo)
struct pciinfo *pciinfo;
{
int devind, r;
struct pciinfo_entry *entry;
char *name;
u16_t vid, did;
/* look up PCI process number */
pci_init();
/* start enumerating devices */
entry = pciinfo->pi_entries;
r = pci_first_dev(&devind, &vid, &did);
while (r)
{
/* fetch device name */
name = pci_dev_name(vid, did);
if (!name)
name = "";
/* store device information in table */
assert((char *) entry < (char *) (pciinfo + 1));
entry->pie_vid = vid;
entry->pie_did = did;
strncpy(entry->pie_name, name, sizeof(entry->pie_name));
entry->pie_name[sizeof(entry->pie_name) - 1] = 0;
entry++;
/* continue with the next device */
r = pci_next_dev(&devind, &vid, &did);
}
/* store number of entries */
pciinfo->pi_count = entry - pciinfo->pi_entries;
return OK;
}