make getsysinfo() a system-land call
This commit is contained in:
parent
d299a6422b
commit
354da24f5b
@ -69,8 +69,8 @@
|
|||||||
#define REBOOT 76
|
#define REBOOT 76
|
||||||
#define SVRCTL 77
|
#define SVRCTL 77
|
||||||
#define SYSUNAME 78
|
#define SYSUNAME 78
|
||||||
#define GETSYSINFO 79 /* to PM, VFS, RS, or DS */
|
#define GETSYSINFO 79 /* to PM or VFS (obsolete) */
|
||||||
#define GETDENTS 80 /* to FS */
|
#define GETDENTS 80 /* to VFS */
|
||||||
#define LLSEEK 81 /* to VFS */
|
#define LLSEEK 81 /* to VFS */
|
||||||
#define FSTATFS 82 /* to VFS */
|
#define FSTATFS 82 /* to VFS */
|
||||||
#define STATVFS 83 /* to VFS */
|
#define STATVFS 83 /* to VFS */
|
||||||
@ -87,7 +87,7 @@
|
|||||||
#define FTRUNCATE 94 /* to VFS */
|
#define FTRUNCATE 94 /* to VFS */
|
||||||
#define FCHMOD 95 /* to VFS */
|
#define FCHMOD 95 /* to VFS */
|
||||||
#define FCHOWN 96 /* to VFS */
|
#define FCHOWN 96 /* to VFS */
|
||||||
#define GETSYSINFO_UP 97 /* to PM or VFS */
|
#define GETSYSINFO_UP 97 /* to PM (obsolete) */
|
||||||
#define SPROF 98 /* to PM */
|
#define SPROF 98 /* to PM */
|
||||||
#define CPROF 99 /* to PM */
|
#define CPROF 99 /* to PM */
|
||||||
|
|
||||||
|
@ -877,8 +877,10 @@
|
|||||||
#define PM_NUID m2_i1
|
#define PM_NUID m2_i1
|
||||||
#define PM_NGID m2_i2
|
#define PM_NGID m2_i2
|
||||||
|
|
||||||
/* Field names for GETSYSINFO_UP (PM). */
|
/* Field names for GETSYSINFO_UP (PM) (obsolete). */
|
||||||
#define SIU_WHAT m2_i1
|
#define SIU_WHAT m2_i1
|
||||||
|
# define SIU_LOADINFO 1 /* retrieve load info data */
|
||||||
|
# define SIU_SYSTEMHZ 2 /* retrieve system clock frequency */
|
||||||
#define SIU_LEN m2_i2
|
#define SIU_LEN m2_i2
|
||||||
#define SIU_WHERE m2_p1
|
#define SIU_WHERE m2_p1
|
||||||
|
|
||||||
@ -902,6 +904,14 @@
|
|||||||
# define GCOV_BUFF_P m1_p1
|
# define GCOV_BUFF_P m1_p1
|
||||||
# define GCOV_BUFF_SZ m1_i1
|
# define GCOV_BUFF_SZ m1_i1
|
||||||
|
|
||||||
|
/* Common request to several system servers: retrieve system information.
|
||||||
|
* The GETSYSINFO userland call is an (old and deprecated) alias of this, so do
|
||||||
|
* not change the fields or old userland applications may break.
|
||||||
|
*/
|
||||||
|
#define COMMON_GETSYSINFO (COMMON_RQ_BASE+2)
|
||||||
|
# define SI_WHAT m1_i1
|
||||||
|
# define SI_WHERE m1_p1
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* Messages for VM server *
|
* Messages for VM server *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -6,15 +6,15 @@
|
|||||||
#include <minix/type.h>
|
#include <minix/type.h>
|
||||||
|
|
||||||
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
|
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
|
||||||
_PROTOTYPE( int minix_getkproctab, (void *pr, int nprocs, int assert));
|
|
||||||
_PROTOTYPE( ssize_t getsysinfo_up, (endpoint_t who, int what, size_t size,
|
|
||||||
void *where));
|
|
||||||
|
|
||||||
#define SIU_LOADINFO 1 /* retrieve load info data */
|
/* What system info to retrieve with sysgetinfo(). */
|
||||||
#define SIU_SYSTEMHZ 2 /* retrieve system clock frequency */
|
#define SI_PROC_TAB 2 /* copy of entire process table */
|
||||||
#define SIU_IDLETSC 3 /* retrieve cumulative idle timestamp count */
|
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
|
||||||
|
#define SI_DATA_STORE 5 /* get copy of data store mappings */
|
||||||
/* Exported system parameters. */
|
#define SI_SUBSCRIPTION 6 /* get copy of data store subscriptions */
|
||||||
|
#define SI_LOADINFO 7 /* get copy of load average structure */
|
||||||
|
#define SI_CALL_STATS 9 /* system call statistics */
|
||||||
|
#define SI_PROCPUB_TAB 11 /* copy of public entries of process table */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -198,20 +198,5 @@ struct k_randomness {
|
|||||||
} bin[RANDOM_SOURCES];
|
} bin[RANDOM_SOURCES];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* information on PCI devices */
|
|
||||||
|
|
||||||
#define PCIINFO_ENTRY_SIZE 80
|
|
||||||
|
|
||||||
struct pciinfo_entry {
|
|
||||||
u16_t pie_vid;
|
|
||||||
u16_t pie_did;
|
|
||||||
char pie_name[PCIINFO_ENTRY_SIZE];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pciinfo {
|
|
||||||
size_t pi_count;
|
|
||||||
struct pciinfo_entry pi_entries[NR_PCIDEV];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _TYPE_H */
|
#endif /* _TYPE_H */
|
||||||
|
|
||||||
|
@ -41,20 +41,6 @@
|
|||||||
#define _PM_SEG_FLAG (1L << 30) /* for read() and write() to FS by PM */
|
#define _PM_SEG_FLAG (1L << 30) /* for read() and write() to FS by PM */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* What system info to retrieve with sysgetinfo(). */
|
|
||||||
#define SI_KINFO 0 /* get kernel info via PM */
|
|
||||||
#define SI_PROC_ADDR 1 /* address of process table */
|
|
||||||
#define SI_PROC_TAB 2 /* copy of entire process table */
|
|
||||||
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
|
|
||||||
#define SI_MEM_ALLOC 4 /* get memory allocation data */
|
|
||||||
#define SI_DATA_STORE 5 /* get copy of data store mappings */
|
|
||||||
#define SI_SUBSCRIPTION 6 /* get copy of data store subscriptions */
|
|
||||||
#define SI_LOADINFO 7 /* get copy of load average structure */
|
|
||||||
#define SI_KPROC_TAB 8 /* copy of kernel process table */
|
|
||||||
#define SI_CALL_STATS 9 /* system call statistics */
|
|
||||||
#define SI_PCI_INFO 10 /* get kernel info via PM */
|
|
||||||
#define SI_PROCPUB_TAB 11 /* copy of public entries of process table */
|
|
||||||
|
|
||||||
/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
|
/* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
|
||||||
#include <sys/null.h>
|
#include <sys/null.h>
|
||||||
|
|
||||||
@ -198,7 +184,6 @@ _PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
|
|
||||||
_PROTOTYPE( int getsigset, (sigset_t *sigset) );
|
_PROTOTYPE( int getsigset, (sigset_t *sigset) );
|
||||||
_PROTOTYPE( int getprocnr, (void) );
|
_PROTOTYPE( int getprocnr, (void) );
|
||||||
_PROTOTYPE( int getnprocnr, (pid_t pid) );
|
_PROTOTYPE( int getnprocnr, (pid_t pid) );
|
||||||
|
@ -20,7 +20,6 @@ SRCS+= \
|
|||||||
_getpprocnr.c \
|
_getpprocnr.c \
|
||||||
_getprocnr.c \
|
_getprocnr.c \
|
||||||
_getsigset.c \
|
_getsigset.c \
|
||||||
_getsysinfo.c \
|
|
||||||
_lseek64.c \
|
_lseek64.c \
|
||||||
_mapdriver.c \
|
_mapdriver.c \
|
||||||
_mcontext.c \
|
_mcontext.c \
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
|
|
||||||
#include <lib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <timers.h>
|
|
||||||
#include <minix/endpoint.h>
|
|
||||||
#define getsysinfo _getsysinfo
|
|
||||||
#define getsysinfo_up _getsysinfo_up
|
|
||||||
#include <minix/sysinfo.h>
|
|
||||||
#include <minix/const.h>
|
|
||||||
|
|
||||||
#include <minix/ipc.h>
|
|
||||||
#include <minix/com.h>
|
|
||||||
#include <minix/sysinfo.h>
|
|
||||||
#include <minix/config.h>
|
|
||||||
#include <minix/type.h>
|
|
||||||
#include <minix/const.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <machine/archtypes.h>
|
|
||||||
#include "../../../kernel/proc.h"
|
|
||||||
|
|
||||||
PUBLIC int getsysinfo(who, what, where)
|
|
||||||
endpoint_t who; /* from whom to request info */
|
|
||||||
int what; /* what information is requested */
|
|
||||||
void *where; /* where to put it */
|
|
||||||
{
|
|
||||||
message m;
|
|
||||||
m.m1_i1 = what;
|
|
||||||
m.m1_p1 = where;
|
|
||||||
if (_syscall(who, GETSYSINFO, &m) < 0) return(-1);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
PUBLIC int minix_getkproctab(void *vpr, int nprocs, int assert)
|
|
||||||
{
|
|
||||||
int r, i, fail = 0;
|
|
||||||
struct proc *pr = vpr;
|
|
||||||
|
|
||||||
if((r=getsysinfo(PM_PROC_NR, SI_KPROC_TAB, pr)) < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
for(i = 0; i < nprocs; i++) {
|
|
||||||
if(pr[i].p_magic != PMAGIC) {
|
|
||||||
fail = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!fail)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(assert) {
|
|
||||||
fprintf(stderr, "%s: process table failed sanity check.\n", getprogname());
|
|
||||||
fprintf(stderr, "is kernel out of sync?\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = ENOSYS;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unprivileged variant of getsysinfo. */
|
|
||||||
PUBLIC ssize_t getsysinfo_up(who, what, size, where)
|
|
||||||
endpoint_t who; /* from whom to request info */
|
|
||||||
int what; /* what information is requested */
|
|
||||||
size_t size; /* input and output size */
|
|
||||||
void *where; /* where to put it */
|
|
||||||
{
|
|
||||||
message m;
|
|
||||||
m.SIU_WHAT = what;
|
|
||||||
m.SIU_WHERE = where;
|
|
||||||
m.SIU_LEN = size;
|
|
||||||
return _syscall(who, GETSYSINFO_UP, &m);
|
|
||||||
}
|
|
||||||
|
|
@ -56,7 +56,6 @@ SRCS+= \
|
|||||||
getpprocnr.S \
|
getpprocnr.S \
|
||||||
getprocnr.S \
|
getprocnr.S \
|
||||||
getsigset.S \
|
getsigset.S \
|
||||||
getsysinfo.S \
|
|
||||||
getuid.S \
|
getuid.S \
|
||||||
ioctl.S \
|
ioctl.S \
|
||||||
isatty.S \
|
isatty.S \
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#include <machine/asm.h>
|
|
||||||
|
|
||||||
IMPORT(_getsysinfo)
|
|
||||||
ENTRY(getsysinfo)
|
|
||||||
jmp _C_LABEL(_getsysinfo)
|
|
||||||
|
|
||||||
IMPORT(_getsysinfo_up)
|
|
||||||
ENTRY(getsysinfo_up)
|
|
||||||
jmp _C_LABEL(_getsysinfo_up)
|
|
||||||
|
|
@ -5,6 +5,7 @@ LIB= sys
|
|||||||
SRCS= \
|
SRCS= \
|
||||||
alloc_util.c \
|
alloc_util.c \
|
||||||
assert.c \
|
assert.c \
|
||||||
|
getsysinfo.c \
|
||||||
kernel_call.c \
|
kernel_call.c \
|
||||||
panic.c \
|
panic.c \
|
||||||
pci_attr_r16.c \
|
pci_attr_r16.c \
|
||||||
|
@ -6,21 +6,19 @@
|
|||||||
* getidle();
|
* getidle();
|
||||||
* ...
|
* ...
|
||||||
* idleperc = getidle();
|
* idleperc = getidle();
|
||||||
* printf("CPU usage: %lg%%\n", 100.0 - idleperc);
|
* if (idleperc >= 0.0)
|
||||||
|
* printf("CPU usage: %lg%%\n", 100.0 - idleperc);
|
||||||
*
|
*
|
||||||
* This routine goes through PM to get the idle time, rather than making the
|
* Notes:
|
||||||
* sys_getinfo() call to the kernel directly. This means that it can be used
|
* - This functionality can only be used by system processes.
|
||||||
* by non-system processes as well, but it will incur some extra overhead in
|
* - The kernel has to be compiled with CONFIG_IDLE_TSC support.
|
||||||
* the system case. The overhead does not end up being measured, because the
|
* - Only one getidle() run is allowed per process at a time.
|
||||||
* system is clearly not idle while the system calls are being made. In any
|
|
||||||
* case, for this reason, only one getidle() run is allowed at a time.
|
|
||||||
*
|
*
|
||||||
* Note that the kernel has to be compiled with CONFIG_IDLE_TSC support.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _MINIX 1
|
#define _MINIX 1
|
||||||
#define _SYSTEM 1
|
#define _SYSTEM 1
|
||||||
#include <minix/sysinfo.h>
|
#include <lib.h>
|
||||||
#include <minix/u64.h>
|
#include <minix/u64.h>
|
||||||
#include <minix/sysutil.h>
|
#include <minix/sysutil.h>
|
||||||
|
|
||||||
@ -52,8 +50,7 @@ double getidle(void)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!running) {
|
if (!running) {
|
||||||
r = getsysinfo_up(PM_PROC_NR, SIU_IDLETSC, sizeof(idle), &idle);
|
if ((r = sys_getidletsc(&idle)) != OK)
|
||||||
if (r != sizeof(idle))
|
|
||||||
return -1.0;
|
return -1.0;
|
||||||
|
|
||||||
running = 1;
|
running = 1;
|
||||||
@ -67,8 +64,7 @@ double getidle(void)
|
|||||||
|
|
||||||
running = 0;
|
running = 0;
|
||||||
|
|
||||||
r = getsysinfo_up(PM_PROC_NR, SIU_IDLETSC, sizeof(idle2), &idle2);
|
if ((r = sys_getidletsc(&idle2)) != OK)
|
||||||
if (r != sizeof(idle2))
|
|
||||||
return -1.0;
|
return -1.0;
|
||||||
|
|
||||||
idelta = sub64(idle2, idle);
|
idelta = sub64(idle2, idle);
|
||||||
|
16
lib/libsys/getsysinfo.c
Normal file
16
lib/libsys/getsysinfo.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include <lib.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
|
#include <minix/com.h>
|
||||||
|
|
||||||
|
PUBLIC int getsysinfo(who, what, where)
|
||||||
|
endpoint_t who; /* from whom to request info */
|
||||||
|
int what; /* what information is requested */
|
||||||
|
void *where; /* where to put it */
|
||||||
|
{
|
||||||
|
message m;
|
||||||
|
m.SI_WHAT = what;
|
||||||
|
m.SI_WHERE = where;
|
||||||
|
if (_syscall(who, COMMON_GETSYSINFO, &m) < 0) return(-1);
|
||||||
|
return(0);
|
||||||
|
}
|
@ -11,7 +11,7 @@ pci_dev_name.c
|
|||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
PUBLIC char *pci_dev_name(u16_t vid, u16_t did)
|
PUBLIC char *pci_dev_name(u16_t vid, u16_t did)
|
||||||
{
|
{
|
||||||
static char name[PCIINFO_ENTRY_SIZE]; /* We need a better interface for this */
|
static char name[80]; /* We need a better interface for this */
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
cp_grant_id_t gid;
|
cp_grant_id_t gid;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/ds.h>
|
#include <minix/ds.h>
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
#include <minix/sysutil.h>
|
#include <minix/sysutil.h>
|
||||||
#include <minix/keymap.h>
|
#include <minix/keymap.h>
|
||||||
#include <minix/bitmap.h>
|
#include <minix/bitmap.h>
|
||||||
@ -29,7 +30,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
@ -72,7 +72,7 @@ PUBLIC int main(int argc, char **argv)
|
|||||||
case DS_SNAPSHOT:
|
case DS_SNAPSHOT:
|
||||||
result = do_snapshot(&m);
|
result = do_snapshot(&m);
|
||||||
break;
|
break;
|
||||||
case GETSYSINFO:
|
case COMMON_GETSYSINFO:
|
||||||
result = do_getsysinfo(&m);
|
result = do_getsysinfo(&m);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <minix/const.h>
|
#include <minix/const.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
#include <minix/sysutil.h>
|
#include <minix/sysutil.h>
|
||||||
#include <minix/keymap.h>
|
#include <minix/keymap.h>
|
||||||
#include <minix/bitmap.h>
|
#include <minix/bitmap.h>
|
||||||
@ -25,7 +26,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
|
@ -128,6 +128,9 @@ PUBLIC int main()
|
|||||||
else
|
else
|
||||||
result= ENOSYS;
|
result= ENOSYS;
|
||||||
break;
|
break;
|
||||||
|
case COMMON_GETSYSINFO:
|
||||||
|
result = do_getsysinfo();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* Else, if the system call number is valid, perform the
|
/* Else, if the system call number is valid, perform the
|
||||||
* call.
|
* call.
|
||||||
|
@ -60,8 +60,6 @@ PRIVATE char *uts_tbl[] = {
|
|||||||
PUBLIC unsigned long calls_stats[NCALLS];
|
PUBLIC unsigned long calls_stats[NCALLS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FORWARD _PROTOTYPE( int getpciinfo, (struct pciinfo *pciinfo) );
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_procstat *
|
* do_procstat *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
@ -160,7 +158,6 @@ PUBLIC int do_getsysinfo()
|
|||||||
vir_bytes src_addr, dst_addr;
|
vir_bytes src_addr, dst_addr;
|
||||||
struct kinfo kinfo;
|
struct kinfo kinfo;
|
||||||
struct loadinfo loadinfo;
|
struct loadinfo loadinfo;
|
||||||
struct pciinfo pciinfo;
|
|
||||||
static struct proc proctab[NR_PROCS+NR_TASKS];
|
static struct proc proctab[NR_PROCS+NR_TASKS];
|
||||||
size_t len;
|
size_t len;
|
||||||
int s, r;
|
int s, r;
|
||||||
@ -174,38 +171,25 @@ PUBLIC int do_getsysinfo()
|
|||||||
return EPERM;
|
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) {
|
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 */
|
case SI_PROC_TAB: /* copy entire process table */
|
||||||
src_addr = (vir_bytes) mproc;
|
src_addr = (vir_bytes) mproc;
|
||||||
len = sizeof(struct mproc) * NR_PROCS;
|
len = sizeof(struct mproc) * NR_PROCS;
|
||||||
break;
|
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 */
|
case SI_LOADINFO: /* loadinfo is obtained via PM */
|
||||||
sys_getloadinfo(&loadinfo);
|
sys_getloadinfo(&loadinfo);
|
||||||
src_addr = (vir_bytes) &loadinfo;
|
src_addr = (vir_bytes) &loadinfo;
|
||||||
len = sizeof(struct loadinfo);
|
len = sizeof(struct loadinfo);
|
||||||
break;
|
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
|
#if ENABLE_SYSCALL_STATS
|
||||||
case SI_CALL_STATS:
|
case SI_CALL_STATS:
|
||||||
src_addr = (vir_bytes) calls_stats;
|
src_addr = (vir_bytes) calls_stats;
|
||||||
@ -230,9 +214,11 @@ PUBLIC int do_getsysinfo_up()
|
|||||||
vir_bytes src_addr, dst_addr;
|
vir_bytes src_addr, dst_addr;
|
||||||
struct loadinfo loadinfo;
|
struct loadinfo loadinfo;
|
||||||
size_t len, real_len;
|
size_t len, real_len;
|
||||||
u64_t idle_tsc;
|
|
||||||
int s;
|
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) {
|
switch(m_in.SIU_WHAT) {
|
||||||
case SIU_LOADINFO: /* loadinfo is obtained via PM */
|
case SIU_LOADINFO: /* loadinfo is obtained via PM */
|
||||||
if ((s = sys_getloadinfo(&loadinfo)) != OK)
|
if ((s = sys_getloadinfo(&loadinfo)) != OK)
|
||||||
@ -244,12 +230,6 @@ PUBLIC int do_getsysinfo_up()
|
|||||||
src_addr = (vir_bytes) &system_hz;
|
src_addr = (vir_bytes) &system_hz;
|
||||||
real_len = sizeof(system_hz);
|
real_len = sizeof(system_hz);
|
||||||
break;
|
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:
|
default:
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
}
|
}
|
||||||
@ -580,45 +560,3 @@ char *brk_addr;
|
|||||||
_brksize = brk_addr;
|
_brksize = brk_addr;
|
||||||
return 0;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <minix/const.h>
|
#include <minix/const.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
#include <minix/sysutil.h>
|
#include <minix/sysutil.h>
|
||||||
#include <minix/keymap.h>
|
#include <minix/keymap.h>
|
||||||
#include <minix/bitmap.h>
|
#include <minix/bitmap.h>
|
||||||
@ -46,7 +47,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -91,7 +91,7 @@ PUBLIC int main(void)
|
|||||||
* Handle the request and send a reply to the caller.
|
* Handle the request and send a reply to the caller.
|
||||||
*/
|
*/
|
||||||
else {
|
else {
|
||||||
if (call_nr != GETSYSINFO &&
|
if (call_nr != COMMON_GETSYSINFO &&
|
||||||
(call_nr < RS_RQ_BASE || call_nr >= RS_RQ_BASE+0x100))
|
(call_nr < RS_RQ_BASE || call_nr >= RS_RQ_BASE+0x100))
|
||||||
{
|
{
|
||||||
/* Ignore invalid requests. Do not try to reply. */
|
/* Ignore invalid requests. Do not try to reply. */
|
||||||
@ -111,7 +111,8 @@ PUBLIC int main(void)
|
|||||||
case RS_UPDATE: result = do_update(&m); break;
|
case RS_UPDATE: result = do_update(&m); break;
|
||||||
case RS_CLONE: result = do_clone(&m); break;
|
case RS_CLONE: result = do_clone(&m); break;
|
||||||
case RS_EDIT: result = do_edit(&m); break;
|
case RS_EDIT: result = do_edit(&m); break;
|
||||||
case GETSYSINFO: result = do_getsysinfo(&m); break;
|
case COMMON_GETSYSINFO:
|
||||||
|
result = do_getsysinfo(&m); break;
|
||||||
case RS_LOOKUP: result = do_lookup(&m); break;
|
case RS_LOOKUP: result = do_lookup(&m); break;
|
||||||
/* Ready messages. */
|
/* Ready messages. */
|
||||||
case RS_INIT: result = do_init_ready(&m); break;
|
case RS_INIT: result = do_init_ready(&m); break;
|
||||||
|
@ -130,18 +130,14 @@ message *m; /* request/reply message pointer */
|
|||||||
/* Initialize global variables for the nested call */
|
/* Initialize global variables for the nested call */
|
||||||
set_globals(m);
|
set_globals(m);
|
||||||
|
|
||||||
/* Perform the nested call */
|
/* Perform the nested call - only getsysinfo() is allowed right now */
|
||||||
if (call_nr < 0 || call_nr >= NCALLS) {
|
if (call_nr == COMMON_GETSYSINFO) {
|
||||||
|
r = do_getsysinfo();
|
||||||
|
} else {
|
||||||
printf("VFS: invalid nested call %d from FS %d\n", call_nr,
|
printf("VFS: invalid nested call %d from FS %d\n", call_nr,
|
||||||
who_e);
|
who_e);
|
||||||
|
|
||||||
r = ENOSYS;
|
r = ENOSYS;
|
||||||
} else {
|
|
||||||
#if ENABLE_SYSCALL_STATS
|
|
||||||
calls_stats[call_nr]++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
r = (*call_vec[call_nr])();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store the result, and restore original global variables */
|
/* Store the result, and restore original global variables */
|
||||||
|
@ -162,7 +162,10 @@ PUBLIC int main(void)
|
|||||||
error= do_mapdriver();
|
error= do_mapdriver();
|
||||||
if (error != SUSPEND) reply(who_e, error);
|
if (error != SUSPEND) reply(who_e, error);
|
||||||
break;
|
break;
|
||||||
|
case COMMON_GETSYSINFO:
|
||||||
|
error= do_getsysinfo();
|
||||||
|
if (error != SUSPEND) reply(who_e, error);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* Call the internal function that does the work. */
|
/* Call the internal function that does the work. */
|
||||||
if (call_nr < 0 || call_nr >= NCALLS) {
|
if (call_nr < 0 || call_nr >= NCALLS) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <minix/safecopies.h>
|
#include <minix/safecopies.h>
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
|
#include <minix/sysinfo.h>
|
||||||
#include <minix/u64.h>
|
#include <minix/u64.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#include <sys/svrctl.h>
|
#include <sys/svrctl.h>
|
||||||
@ -72,12 +73,15 @@ PUBLIC int do_getsysinfo()
|
|||||||
|
|
||||||
if (!super_user) return(EPERM);
|
if (!super_user) 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("VFS: obsolete call of do_getsysinfo() by proc %d\n",
|
||||||
|
fp->fp_endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
switch(m_in.info_what) {
|
switch(m_in.info_what) {
|
||||||
case SI_PROC_ADDR:
|
|
||||||
proc_addr = &fproc[0];
|
|
||||||
src_addr = (vir_bytes) &proc_addr;
|
|
||||||
len = sizeof(struct fproc *);
|
|
||||||
break;
|
|
||||||
case SI_PROC_TAB:
|
case SI_PROC_TAB:
|
||||||
src_addr = (vir_bytes) fproc;
|
src_addr = (vir_bytes) fproc;
|
||||||
len = sizeof(struct fproc) * NR_PROCS;
|
len = sizeof(struct fproc) * NR_PROCS;
|
||||||
|
@ -112,7 +112,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
|||||||
do_ftruncate, /* 94 = truncate */
|
do_ftruncate, /* 94 = truncate */
|
||||||
do_chmod, /* 95 = fchmod */
|
do_chmod, /* 95 = fchmod */
|
||||||
do_chown, /* 96 = fchown */
|
do_chown, /* 96 = fchown */
|
||||||
no_sys, /* 97 = getsysinfo_up */
|
no_sys, /* 97 = (getsysinfo_up) */
|
||||||
no_sys, /* 98 = (sprofile) */
|
no_sys, /* 98 = (sprofile) */
|
||||||
no_sys, /* 99 = (cprofile) */
|
no_sys, /* 99 = (cprofile) */
|
||||||
/* THE MINIX3 ABI ENDS HERE */
|
/* THE MINIX3 ABI ENDS HERE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user