Created new findproc system call to the PM (to replace similar kernel
functionality). Currently working on memory allocation (not yet finished).
This commit is contained in:
parent
f926f1209d
commit
e782e76944
|
@ -30,9 +30,7 @@ PRIVATE int m_seg[NR_DEVS]; /* segment index of each device */
|
||||||
PRIVATE int m_device; /* current device */
|
PRIVATE int m_device; /* current device */
|
||||||
PRIVATE struct kinfo kinfo; /* need kernel info */
|
PRIVATE struct kinfo kinfo; /* need kernel info */
|
||||||
PRIVATE struct machine machine; /* need machine info */
|
PRIVATE struct machine machine; /* need machine info */
|
||||||
PRIVATE struct memory mem[NR_MEMS]; /* physical memory chunks */
|
|
||||||
|
|
||||||
FORWARD _PROTOTYPE( int alloc_mem, (phys_bytes size, phys_bytes *base) );
|
|
||||||
FORWARD _PROTOTYPE( char *m_name, (void) );
|
FORWARD _PROTOTYPE( char *m_name, (void) );
|
||||||
FORWARD _PROTOTYPE( struct device *m_prepare, (int device) );
|
FORWARD _PROTOTYPE( struct device *m_prepare, (int device) );
|
||||||
FORWARD _PROTOTYPE( int m_transfer, (int proc_nr, int opcode, off_t position,
|
FORWARD _PROTOTYPE( int m_transfer, (int proc_nr, int opcode, off_t position,
|
||||||
|
@ -196,7 +194,7 @@ unsigned nr_req; /* length of request vector */
|
||||||
chunk = (left > ZERO_BUF_SIZE) ? ZERO_BUF_SIZE : left;
|
chunk = (left > ZERO_BUF_SIZE) ? ZERO_BUF_SIZE : left;
|
||||||
if (OK != (s=sys_vircopy(SELF, D, (vir_bytes) zero,
|
if (OK != (s=sys_vircopy(SELF, D, (vir_bytes) zero,
|
||||||
proc_nr, D, user_vir, chunk)))
|
proc_nr, D, user_vir, chunk)))
|
||||||
printf("MEMORY: sys_vircopy failed: %d\n", s);
|
report("MEM","sys_vircopy failed", s);
|
||||||
left -= chunk;
|
left -= chunk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +230,7 @@ message *m_ptr;
|
||||||
#if (CHIP == INTEL) && ENABLE_USERPRIV && ENABLE_USERIOPL
|
#if (CHIP == INTEL) && ENABLE_USERPRIV && ENABLE_USERIOPL
|
||||||
if (m_device == MEM_DEV || m_device == KMEM_DEV) {
|
if (m_device == MEM_DEV || m_device == KMEM_DEV) {
|
||||||
sys_enable_iop(m_ptr->PROC_NR);
|
sys_enable_iop(m_ptr->PROC_NR);
|
||||||
printf("MEMORY: sys_enable_iop for proc nr %d.\n", m_ptr->PROC_NR);
|
report("MEM", "sys_enable_iop for proc nr", m_ptr->PROC_NR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -248,10 +246,6 @@ PRIVATE void m_init()
|
||||||
/* Initialize this task. All minor devices are initialized one by one. */
|
/* Initialize this task. All minor devices are initialized one by one. */
|
||||||
int i, s;
|
int i, s;
|
||||||
|
|
||||||
/* Get memory addresses from the kernel. */
|
|
||||||
if (OK != (s=sys_getmemchunks(&mem))) {
|
|
||||||
panic("MEM","Couldn't get memory chunks.",s);
|
|
||||||
}
|
|
||||||
if (OK != (s=sys_getkinfo(&kinfo))) {
|
if (OK != (s=sys_getkinfo(&kinfo))) {
|
||||||
panic("MEM","Couldn't get kernel information.",s);
|
panic("MEM","Couldn't get kernel information.",s);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +299,7 @@ PRIVATE void m_init()
|
||||||
#endif /* !(CHIP == INTEL) */
|
#endif /* !(CHIP == INTEL) */
|
||||||
|
|
||||||
/* Initialization succeeded. Print welcome message. */
|
/* Initialization succeeded. Print welcome message. */
|
||||||
printf("User-space memory driver (RAM disk, etc.) has been initialized.\n");
|
report("MEM","user-space memory driver has been initialized.", NO_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,23 +321,28 @@ message *m_ptr; /* pointer to control message */
|
||||||
/* FS wants to create a new RAM disk with the given size. */
|
/* FS wants to create a new RAM disk with the given size. */
|
||||||
phys_bytes ramdev_size;
|
phys_bytes ramdev_size;
|
||||||
phys_bytes ramdev_base;
|
phys_bytes ramdev_base;
|
||||||
|
message m;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
if (m_ptr->PROC_NR != FS_PROC_NR) return(EPERM);
|
if (m_ptr->PROC_NR != FS_PROC_NR) return(EPERM);
|
||||||
|
|
||||||
/* Try to allocate a piece of memory for the RAM disk. */
|
/* Try to allocate a piece of memory for the RAM disk. */
|
||||||
ramdev_size = m_ptr->POSITION;
|
ramdev_size = m_ptr->POSITION;
|
||||||
if (OK != (s=alloc_mem(ramdev_size, &ramdev_base)))
|
|
||||||
panic("MEM","Couldn't allocate kernel memory", s);
|
printf("MEM: about to send to PM (ramdev_size %u)\n", ramdev_size);
|
||||||
dv->dv_base = cvul64(ramdev_base);
|
m.m_type = MEM_ALLOC;
|
||||||
dv->dv_size = cvul64(ramdev_size);
|
m.m4_l1 = ramdev_size;
|
||||||
printf("Test MEM: base 0x%06x, size 0x%06x\n", dv->dv_base, dv->dv_size);
|
if (OK != (s=sendrec(PM_PROC_NR, &m)))
|
||||||
|
report("MEM", "Couldn't sendrec to PM", s);
|
||||||
|
dv->dv_size = cvul64(m.m4_l1);
|
||||||
|
dv->dv_base = cvul64(m.m4_l2);
|
||||||
|
printf("MEM: PM (s=%d) gave base 0x%06x, size 0x%06x\n", s, dv->dv_base, dv->dv_size);
|
||||||
|
|
||||||
if (OK != (s=sys_kmalloc(ramdev_size, &ramdev_base)))
|
if (OK != (s=sys_kmalloc(ramdev_size, &ramdev_base)))
|
||||||
panic("MEM","Couldn't allocate kernel memory", s);
|
panic("MEM","Couldn't allocate kernel memory", s);
|
||||||
dv->dv_base = cvul64(ramdev_base);
|
dv->dv_base = cvul64(ramdev_base);
|
||||||
dv->dv_size = cvul64(ramdev_size);
|
dv->dv_size = cvul64(ramdev_size);
|
||||||
printf("Real MEM: base 0x%06x, size 0x%06x\n", dv->dv_base, dv->dv_size);
|
printf("MEM allocated: base 0x%06x, size 0x%06x\n", dv->dv_base, dv->dv_size);
|
||||||
if (OK != (s=sys_segctl(&m_seg[RAM_DEV], (u16_t *) &s, (vir_bytes *) &s,
|
if (OK != (s=sys_segctl(&m_seg[RAM_DEV], (u16_t *) &s, (vir_bytes *) &s,
|
||||||
ramdev_base, ramdev_size))) {
|
ramdev_base, ramdev_size))) {
|
||||||
panic("MEM","Couldn't install remote segment.",s);
|
panic("MEM","Couldn't install remote segment.",s);
|
||||||
|
@ -370,26 +369,4 @@ struct partition *entry;
|
||||||
entry->sectors = 32;
|
entry->sectors = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* malloc_mem *
|
|
||||||
*===========================================================================*/
|
|
||||||
PRIVATE int alloc_mem(chunk_size, chunk_base)
|
|
||||||
phys_bytes chunk_size; /* number of bytes requested */
|
|
||||||
phys_bytes *chunk_base; /* base of memory area found */
|
|
||||||
{
|
|
||||||
/* Request a piece of memory from one of the free memory chunks. */
|
|
||||||
phys_clicks tot_clicks;
|
|
||||||
struct memory *memp;
|
|
||||||
|
|
||||||
tot_clicks = (chunk_size+ CLICK_SIZE-1) >> CLICK_SHIFT;
|
|
||||||
memp = &mem[NR_MEMS];
|
|
||||||
while ((--memp)->size < tot_clicks) {
|
|
||||||
if (memp == mem) {
|
|
||||||
return(ENOMEM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memp->size -= tot_clicks;
|
|
||||||
*chunk_base = (memp->base + memp->size) << CLICK_SHIFT;
|
|
||||||
return(OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define NCALLS 83 /* number of system calls allowed */
|
#define NCALLS 85 /* number of system calls allowed */
|
||||||
|
|
||||||
#define EXIT 1
|
#define EXIT 1
|
||||||
#define FORK 2
|
#define FORK 2
|
||||||
|
@ -62,12 +62,14 @@
|
||||||
#define SIGPROCMASK 74
|
#define SIGPROCMASK 74
|
||||||
#define SIGRETURN 75
|
#define SIGRETURN 75
|
||||||
|
|
||||||
#define REBOOT 76
|
#define REBOOT 76 /* to PM */
|
||||||
|
|
||||||
/* MINIX specific calls, e.g., to support system services. */
|
/* MINIX specific calls, e.g., to support system services. */
|
||||||
#define SVRCTL 77
|
#define SVRCTL 77
|
||||||
#define CMOSTIME 78
|
#define CMOSTIME 78 /* to FS */
|
||||||
#define GETSYSINFO 79 /* to MM or FS */
|
#define GETSYSINFO 79 /* to PM or FS */
|
||||||
#define GETPROCNR 80 /* to MM */
|
#define GETPROCNR 80 /* to PM */
|
||||||
|
|
||||||
#define FSTATFS 82
|
#define FSTATFS 82 /* to FS */
|
||||||
|
#define MEM_ALLOC 83 /* to PM */
|
||||||
|
#define MEM_FREE 84 /* to PM */
|
||||||
|
|
|
@ -144,6 +144,7 @@ _PROTOTYPE( int fttyslot, (int _fd) );
|
||||||
_PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
|
_PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
|
||||||
_PROTOTYPE( int getsysinfo, (int who, int what, void *where) );
|
_PROTOTYPE( int getsysinfo, (int who, int what, void *where) );
|
||||||
_PROTOTYPE( int getprocnr, (int *proc_nr) );
|
_PROTOTYPE( int getprocnr, (int *proc_nr) );
|
||||||
|
_PROTOTYPE( int findproc, (char *proc_name, int *proc_nr) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_PROTOTYPE( int setcache, (int kb));
|
_PROTOTYPE( int setcache, (int kb));
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
allow(1, IS_PROC_NR) /* output diagnostics */ \
|
allow(1, IS_PROC_NR) /* output diagnostics */ \
|
||||||
allow(1, SYSTASK) \
|
allow(1, SYSTASK) \
|
||||||
allow(1, TTY) \
|
allow(1, TTY) \
|
||||||
|
allow(1, MEMORY) \
|
||||||
allow(1, CLOCK) \
|
allow(1, CLOCK) \
|
||||||
allow(1, INIT_PROC_NR) \
|
allow(1, INIT_PROC_NR) \
|
||||||
allow(1, FS_PROC_NR) \
|
allow(1, FS_PROC_NR) \
|
||||||
|
@ -136,6 +137,7 @@
|
||||||
allow(1, SYSTASK) /* system functionality needed */ \
|
allow(1, SYSTASK) /* system functionality needed */ \
|
||||||
allow(1, CLOCK) /* check clock alarms */ \
|
allow(1, CLOCK) /* check clock alarms */ \
|
||||||
allow(1, TTY) /* output diagnostics */ \
|
allow(1, TTY) /* output diagnostics */ \
|
||||||
|
allow(1, PM_PROC_NR) /* PM alloc mem */ \
|
||||||
allow(1, FS_PROC_NR) /* FS is interface to the driver */
|
allow(1, FS_PROC_NR) /* FS is interface to the driver */
|
||||||
|
|
||||||
#define PRN_SENDMASK \
|
#define PRN_SENDMASK \
|
||||||
|
|
|
@ -16,6 +16,7 @@ OBJECTS = \
|
||||||
$(LIBRARY)(_svrctl.o) \
|
$(LIBRARY)(_svrctl.o) \
|
||||||
$(LIBRARY)(_getsysinfo.o) \
|
$(LIBRARY)(_getsysinfo.o) \
|
||||||
$(LIBRARY)(_getprocnr.o) \
|
$(LIBRARY)(_getprocnr.o) \
|
||||||
|
$(LIBRARY)(_findproc.o) \
|
||||||
$(LIBRARY)(asynchio.o) \
|
$(LIBRARY)(asynchio.o) \
|
||||||
$(LIBRARY)(configfile.o) \
|
$(LIBRARY)(configfile.o) \
|
||||||
$(LIBRARY)(crypt.o) \
|
$(LIBRARY)(crypt.o) \
|
||||||
|
@ -78,6 +79,9 @@ $(LIBRARY)(_svrctl.o): _svrctl.c
|
||||||
$(LIBRARY)(_getprocnr.o): _getprocnr.c
|
$(LIBRARY)(_getprocnr.o): _getprocnr.c
|
||||||
$(CC1) _getprocnr.c
|
$(CC1) _getprocnr.c
|
||||||
|
|
||||||
|
$(LIBRARY)(_findproc.o): _findproc.c
|
||||||
|
$(CC1) _findproc.c
|
||||||
|
|
||||||
$(LIBRARY)(_getsysinfo.o): _getsysinfo.c
|
$(LIBRARY)(_getsysinfo.o): _getsysinfo.c
|
||||||
$(CC1) _getsysinfo.c
|
$(CC1) _getsysinfo.c
|
||||||
|
|
||||||
|
|
19
lib/other/_findproc.c
Normal file
19
lib/other/_findproc.c
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include <lib.h>
|
||||||
|
#define findproc _findproc
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
PUBLIC int findproc(proc_name, proc_nr)
|
||||||
|
char *proc_name; /* name of process to search for */
|
||||||
|
int *proc_nr; /* return process number here */
|
||||||
|
{
|
||||||
|
message m;
|
||||||
|
|
||||||
|
m.m1_p1 = proc_name;
|
||||||
|
m.m1_i1 = strlen(proc_name) + 1;
|
||||||
|
if (_syscall(MM, GETPROCNR, &m) < 0) return(-1);
|
||||||
|
*proc_nr = m.m1_i1;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ PUBLIC int getprocnr(proc_nr)
|
||||||
int *proc_nr; /* return process number here */
|
int *proc_nr; /* return process number here */
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
|
m.m1_i1 = 0; /* tell PM to get own process nr */
|
||||||
if (_syscall(MM, GETPROCNR, &m) < 0) return(-1);
|
if (_syscall(MM, GETPROCNR, &m) < 0) return(-1);
|
||||||
*proc_nr = m.m1_i1;
|
*proc_nr = m.m1_i1;
|
||||||
return(0);
|
return(0);
|
||||||
|
|
|
@ -44,6 +44,7 @@ OBJECTS = \
|
||||||
$(LIBRARY)(getppid.o) \
|
$(LIBRARY)(getppid.o) \
|
||||||
$(LIBRARY)(getuid.o) \
|
$(LIBRARY)(getuid.o) \
|
||||||
$(LIBRARY)(getprocnr.o) \
|
$(LIBRARY)(getprocnr.o) \
|
||||||
|
$(LIBRARY)(findproc.o) \
|
||||||
$(LIBRARY)(ioctl.o) \
|
$(LIBRARY)(ioctl.o) \
|
||||||
$(LIBRARY)(isatty.o) \
|
$(LIBRARY)(isatty.o) \
|
||||||
$(LIBRARY)(kill.o) \
|
$(LIBRARY)(kill.o) \
|
||||||
|
@ -218,6 +219,9 @@ $(LIBRARY)(getppid.o): getppid.s
|
||||||
$(LIBRARY)(getprocnr.o): getprocnr.s
|
$(LIBRARY)(getprocnr.o): getprocnr.s
|
||||||
$(CC1) getprocnr.s
|
$(CC1) getprocnr.s
|
||||||
|
|
||||||
|
$(LIBRARY)(findproc.o): findproc.s
|
||||||
|
$(CC1) findproc.s
|
||||||
|
|
||||||
$(LIBRARY)(getuid.o): getuid.s
|
$(LIBRARY)(getuid.o): getuid.s
|
||||||
$(CC1) getuid.s
|
$(CC1) getuid.s
|
||||||
|
|
||||||
|
|
7
lib/syscall/findproc.s
Normal file
7
lib/syscall/findproc.s
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.sect .text
|
||||||
|
.extern __findproc
|
||||||
|
.define _findproc
|
||||||
|
.align 2
|
||||||
|
|
||||||
|
_findproc:
|
||||||
|
jmp __findproc
|
|
@ -7,6 +7,7 @@
|
||||||
#include "fproc.h"
|
#include "fproc.h"
|
||||||
#include "dmap.h"
|
#include "dmap.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/utils.h>
|
#include <minix/utils.h>
|
||||||
|
|
||||||
|
@ -142,8 +143,11 @@ PUBLIC void map_controllers()
|
||||||
for (dp = drivertab;
|
for (dp = drivertab;
|
||||||
dp < drivertab + sizeof(drivertab)/sizeof(drivertab[0]); dp++) {
|
dp < drivertab + sizeof(drivertab)/sizeof(drivertab[0]); dp++) {
|
||||||
if (strcmp(ctrlr_type, dp->wini_type) == 0) { /* found driver name */
|
if (strcmp(ctrlr_type, dp->wini_type) == 0) { /* found driver name */
|
||||||
|
#if DEAD_CODE
|
||||||
if ((s=sys_getprocnr(&proc_nr, /* lookup proc nr */
|
if ((s=sys_getprocnr(&proc_nr, /* lookup proc nr */
|
||||||
dp->proc_name, strlen(dp->proc_name)+1)) == OK) {
|
dp->proc_name, strlen(dp->proc_name)+1)) == OK) {
|
||||||
|
#endif
|
||||||
|
if ((s=findproc(dp->proc_name, &proc_nr)) == OK) {
|
||||||
for (i=0; i< max_major; i++) { /* find mapping */
|
for (i=0; i< max_major; i++) { /* find mapping */
|
||||||
if (dmap[i].dmap_driver == CTRLR(c)) {
|
if (dmap[i].dmap_driver == CTRLR(c)) {
|
||||||
if (map_driver(i, proc_nr, STYLE_DEV) == OK) {
|
if (map_driver(i, proc_nr, STYLE_DEV) == OK) {
|
||||||
|
|
|
@ -96,7 +96,6 @@ PRIVATE void get_work()
|
||||||
/* Normally wait for new input. However, if 'reviving' is
|
/* Normally wait for new input. However, if 'reviving' is
|
||||||
* nonzero, a suspended process must be awakened.
|
* nonzero, a suspended process must be awakened.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
register struct fproc *rp;
|
register struct fproc *rp;
|
||||||
|
|
||||||
if (reviving != 0) {
|
if (reviving != 0) {
|
||||||
|
@ -174,10 +173,35 @@ PRIVATE void fs_init()
|
||||||
{
|
{
|
||||||
/* Initialize global variables, tables, etc. */
|
/* Initialize global variables, tables, etc. */
|
||||||
register struct inode *rip;
|
register struct inode *rip;
|
||||||
|
register struct fproc *rfp;
|
||||||
int key, s, i;
|
int key, s, i;
|
||||||
message mess;
|
message mess;
|
||||||
|
|
||||||
/* Certain relations must hold for the file system to work at all. Some
|
/* Initialize the process table with help of the process manager messages.
|
||||||
|
* Expect one message for each system process with its slot number and pid.
|
||||||
|
* When no more processes follow, the magic process number NONE is sent.
|
||||||
|
* Then, stop and synchronize with the PM.
|
||||||
|
*/
|
||||||
|
do {
|
||||||
|
if (OK != (s=receive(PM_PROC_NR, &mess)))
|
||||||
|
panic(__FILE__,"FS couldn't receive from PM", s);
|
||||||
|
if (NONE == mess.PR_PROC_NR) break;
|
||||||
|
|
||||||
|
rfp = &fproc[mess.PR_PROC_NR];
|
||||||
|
rfp->fp_pid = mess.PR_PID;
|
||||||
|
rfp->fp_realuid = (uid_t) SYS_UID;
|
||||||
|
rfp->fp_effuid = (uid_t) SYS_UID;
|
||||||
|
rfp->fp_realgid = (gid_t) SYS_GID;
|
||||||
|
rfp->fp_effgid = (gid_t) SYS_GID;
|
||||||
|
rfp->fp_umask = ~0;
|
||||||
|
|
||||||
|
} while (TRUE); /* continue until process NONE */
|
||||||
|
mess.m_type = OK; /* tell PM that we succeeded */
|
||||||
|
s=send(PM_PROC_NR, &mess); /* send synchronization message */
|
||||||
|
|
||||||
|
|
||||||
|
/* All process table entries have been set. Continue with FS initialization.
|
||||||
|
* Certain relations must hold for the file system to work at all. Some
|
||||||
* extra block_size requirements are checked at super-block-read-in time.
|
* extra block_size requirements are checked at super-block-read-in time.
|
||||||
*/
|
*/
|
||||||
if (OPEN_MAX > 127) panic(__FILE__,"OPEN_MAX > 127", NO_NUM);
|
if (OPEN_MAX > 127) panic(__FILE__,"OPEN_MAX > 127", NO_NUM);
|
||||||
|
@ -190,37 +214,21 @@ PRIVATE void fs_init()
|
||||||
fp = (struct fproc *) NULL;
|
fp = (struct fproc *) NULL;
|
||||||
who = FS_PROC_NR;
|
who = FS_PROC_NR;
|
||||||
|
|
||||||
map_controllers(); /* map controller devices to drivers */
|
|
||||||
buf_pool(); /* initialize buffer pool */
|
buf_pool(); /* initialize buffer pool */
|
||||||
|
map_controllers(); /* map controller devices to drivers */
|
||||||
load_ram(); /* init RAM disk, load if it is root */
|
load_ram(); /* init RAM disk, load if it is root */
|
||||||
load_super(root_dev); /* load super block for root device */
|
load_super(root_dev); /* load super block for root device */
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the process table with help of the process manager messages.
|
/* The root device can now be accessed; set process directories. */
|
||||||
* Expect one message for each system process with its slot number and pid.
|
for (rfp=&fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) {
|
||||||
* When no more processes follow, the magic process number NONE is sent.
|
if (rfp->fp_pid != PID_FREE) {
|
||||||
* Then, stop and synchronize with the PM.
|
rip = get_inode(root_dev, ROOT_INODE);
|
||||||
*/
|
dup_inode(rip);
|
||||||
do {
|
rfp->fp_rootdir = rip;
|
||||||
if (OK != (s=receive(PM_PROC_NR, &mess)))
|
rfp->fp_workdir = rip;
|
||||||
panic(__FILE__,"FS couldn't receive from PM", s);
|
}
|
||||||
if (NONE == mess.PR_PROC_NR) break;
|
}
|
||||||
|
|
||||||
fp = &fproc[mess.PR_PROC_NR];
|
|
||||||
fp->fp_pid = mess.PR_PID;
|
|
||||||
rip = get_inode(root_dev, ROOT_INODE);
|
|
||||||
dup_inode(rip);
|
|
||||||
fp->fp_rootdir = rip;
|
|
||||||
fp->fp_workdir = rip;
|
|
||||||
fp->fp_realuid = (uid_t) SYS_UID;
|
|
||||||
fp->fp_effuid = (uid_t) SYS_UID;
|
|
||||||
fp->fp_realgid = (gid_t) SYS_GID;
|
|
||||||
fp->fp_effgid = (gid_t) SYS_GID;
|
|
||||||
fp->fp_umask = ~0;
|
|
||||||
|
|
||||||
} while (TRUE); /* continue until process NONE */
|
|
||||||
mess.m_type = OK; /* tell PM that we succeeded */
|
|
||||||
s=send(PM_PROC_NR, &mess); /* send synchronization message */
|
|
||||||
|
|
||||||
/* Register function keys with TTY. */
|
/* Register function keys with TTY. */
|
||||||
for (key=SF5; key<=SF6; key++) {
|
for (key=SF5; key<=SF6; key++) {
|
||||||
|
|
|
@ -100,6 +100,8 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
||||||
no_sys, /* 80 = unused */
|
no_sys, /* 80 = unused */
|
||||||
no_sys, /* 81 = unused */
|
no_sys, /* 81 = unused */
|
||||||
do_fstatfs, /* 82 = fstatfs */
|
do_fstatfs, /* 82 = fstatfs */
|
||||||
|
no_sys, /* 83 = memalloc */
|
||||||
|
no_sys, /* 84 = memfree */
|
||||||
};
|
};
|
||||||
/* This should not fail with "array size is negative": */
|
/* This should not fail with "array size is negative": */
|
||||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||||
|
|
|
@ -175,8 +175,11 @@ PRIVATE void nw_init()
|
||||||
if (svrctl(SYSSIGNON, (void *) NULL) == -1) pause();
|
if (svrctl(SYSSIGNON, (void *) NULL) == -1) pause();
|
||||||
|
|
||||||
/* Our new identity as a server. */
|
/* Our new identity as a server. */
|
||||||
|
#if DEAD_CODE
|
||||||
if (get_proc_nr(&this_proc, NULL) != OK)
|
if (get_proc_nr(&this_proc, NULL) != OK)
|
||||||
ip_panic(( "unable to find own process nr\n"));
|
#endif
|
||||||
|
if (getprocnr(&this_proc) != OK)
|
||||||
|
ip_panic(( "unable to get own process nr\n"));
|
||||||
|
|
||||||
/* Register the device group. */
|
/* Register the device group. */
|
||||||
device.dev= ip_dev;
|
device.dev= ip_dev;
|
||||||
|
|
|
@ -19,6 +19,8 @@ Copyright 1995 Philip Homburg
|
||||||
#include "generic/sr.h"
|
#include "generic/sr.h"
|
||||||
|
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
|
#define _MINIX
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
THIS_FILE
|
THIS_FILE
|
||||||
|
|
||||||
|
@ -39,8 +41,10 @@ PUBLIC void osdep_eth_init()
|
||||||
for (i= 0, eth_port= eth_port_table, ecp= eth_conf;
|
for (i= 0, eth_port= eth_port_table, ecp= eth_conf;
|
||||||
i<eth_conf_nr; i++, eth_port++, ecp++)
|
i<eth_conf_nr; i++, eth_port++, ecp++)
|
||||||
{
|
{
|
||||||
printf("INET: sys_getprocnr() for %s\n", ecp->ec_task);
|
#if DEAD_CODE
|
||||||
r = sys_getprocnr(&tasknr, ecp->ec_task, strlen(ecp->ec_task));
|
r = sys_getprocnr(&tasknr, ecp->ec_task, strlen(ecp->ec_task));
|
||||||
|
#endif
|
||||||
|
r = findproc(ecp->ec_task, &tasknr);
|
||||||
if (r != OK)
|
if (r != OK)
|
||||||
{
|
{
|
||||||
ip_panic(( "unable to find task %s: %d\n",
|
ip_panic(( "unable to find task %s: %d\n",
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
* The entry points into this file are:
|
* The entry points into this file are:
|
||||||
* do_reboot: kill all processes, then reboot system
|
* do_reboot: kill all processes, then reboot system
|
||||||
* do_svrctl: process manager control
|
* do_svrctl: process manager control
|
||||||
* do_getsysinfo: request copy of PM data structure
|
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
|
||||||
* do_getprocnr: get process slot number (like getpid)
|
* do_getprocnr: lookup process slot number (Jorrit N. Herder)
|
||||||
|
* do_memalloc: allocate a chunk of memory (Jorrit N. Herder)
|
||||||
|
* do_memfree: deallocate a chunk of memory (Jorrit N. Herder)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
|
@ -22,6 +24,30 @@ FORWARD _PROTOTYPE( char *find_key, (const char *params, const char *key));
|
||||||
/* PM gets a copy of all boot monitor parameters. */
|
/* PM gets a copy of all boot monitor parameters. */
|
||||||
PRIVATE char monitor_params[128*sizeof(char *)];
|
PRIVATE char monitor_params[128*sizeof(char *)];
|
||||||
|
|
||||||
|
/*=====================================================================*
|
||||||
|
* do_memalloc *
|
||||||
|
*=====================================================================*/
|
||||||
|
PUBLIC int do_memalloc()
|
||||||
|
{
|
||||||
|
vir_clicks mem_clicks;
|
||||||
|
phys_clicks mem_base;
|
||||||
|
printf("PM got request to allocate %u KB\n", m_in.memsize);
|
||||||
|
|
||||||
|
mem_clicks = (m_in.memsize + CLICK_SIZE -1 ) >> CLICK_SHIFT;
|
||||||
|
mem_base = alloc_mem(mem_clicks);
|
||||||
|
if (mem_base == NO_MEM) return(ENOMEM);
|
||||||
|
mp->mp_reply.membase = (phys_bytes) (mem_base << CLICK_SHIFT);
|
||||||
|
return(OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=====================================================================*
|
||||||
|
* do_memfree *
|
||||||
|
*=====================================================================*/
|
||||||
|
PUBLIC int do_memfree()
|
||||||
|
{
|
||||||
|
return(OK);
|
||||||
|
}
|
||||||
|
|
||||||
/*=====================================================================*
|
/*=====================================================================*
|
||||||
* do_getsysinfo *
|
* do_getsysinfo *
|
||||||
*=====================================================================*/
|
*=====================================================================*/
|
||||||
|
@ -36,7 +62,29 @@ PUBLIC int do_getsysinfo()
|
||||||
*=====================================================================*/
|
*=====================================================================*/
|
||||||
PUBLIC int do_getprocnr()
|
PUBLIC int do_getprocnr()
|
||||||
{
|
{
|
||||||
mp->mp_reply.procnr = who;
|
register struct mproc *rmp;
|
||||||
|
static char search_key[PROC_NAME_LEN];
|
||||||
|
int key_len;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if (m_in.namelen > 0) { /* lookup process by name */
|
||||||
|
key_len = MAX(m_in.namelen, PROC_NAME_LEN);
|
||||||
|
if (OK != (s=sys_datacopy(who, (vir_bytes) m_in.addr,
|
||||||
|
SELF, (vir_bytes) search_key, key_len)))
|
||||||
|
return(s);
|
||||||
|
search_key[key_len] = '\0'; /* terminate for safety */
|
||||||
|
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||||
|
if (rmp->mp_flags & IN_USE &&
|
||||||
|
strncmp(rmp->mp_name, search_key, key_len)==0) {
|
||||||
|
mp->mp_reply.procnr = (int) (rmp - mproc);
|
||||||
|
return(OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(ESRCH);
|
||||||
|
}
|
||||||
|
else { /* return own process number */
|
||||||
|
mp->mp_reply.procnr = who;
|
||||||
|
}
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#define svrctl_req m2_i1
|
#define svrctl_req m2_i1
|
||||||
#define svrctl_argp m2_p1
|
#define svrctl_argp m2_p1
|
||||||
#define stime m2_l1
|
#define stime m2_l1
|
||||||
|
#define memsize m4_l1
|
||||||
|
#define membase m4_l2
|
||||||
|
|
||||||
/* The following names are synonyms for the variables in a reply message. */
|
/* The following names are synonyms for the variables in a reply message. */
|
||||||
#define reply_res m_type
|
#define reply_res m_type
|
||||||
|
|
|
@ -56,6 +56,8 @@ _PROTOTYPE( int do_reboot, (void) );
|
||||||
_PROTOTYPE( int do_getsysinfo, (void) );
|
_PROTOTYPE( int do_getsysinfo, (void) );
|
||||||
_PROTOTYPE( int do_getprocnr, (void) );
|
_PROTOTYPE( int do_getprocnr, (void) );
|
||||||
_PROTOTYPE( int do_svrctl, (void) );
|
_PROTOTYPE( int do_svrctl, (void) );
|
||||||
|
_PROTOTYPE( int do_memalloc, (void) );
|
||||||
|
_PROTOTYPE( int do_memfree, (void) );
|
||||||
_PROTOTYPE( int do_mstats, (void) );
|
_PROTOTYPE( int do_mstats, (void) );
|
||||||
|
|
||||||
#if (MACHINE == MACINTOSH)
|
#if (MACHINE == MACINTOSH)
|
||||||
|
|
|
@ -98,7 +98,9 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
||||||
do_getsysinfo, /* 79 = getsysinfo */
|
do_getsysinfo, /* 79 = getsysinfo */
|
||||||
do_getprocnr, /* 80 = getprocnr */
|
do_getprocnr, /* 80 = getprocnr */
|
||||||
no_sys, /* 81 = unused */
|
no_sys, /* 81 = unused */
|
||||||
no_sys, /* 82 = unused */
|
no_sys, /* 82 = fstatfs */
|
||||||
|
do_memalloc, /* 83 = memalloc */
|
||||||
|
do_memfree, /* 84 = memfree */
|
||||||
};
|
};
|
||||||
/* This should not fail with "array size is negative": */
|
/* This should not fail with "array size is negative": */
|
||||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#define NIL_MPROC ((struct mproc *) 0)
|
#define NIL_MPROC ((struct mproc *) 0)
|
||||||
|
|
||||||
FORWARD _PROTOTYPE( struct mproc *findproc, (pid_t lpid) );
|
FORWARD _PROTOTYPE( struct mproc *find_proc, (pid_t lpid) );
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_trace *
|
* do_trace *
|
||||||
|
@ -46,7 +46,7 @@ PUBLIC int do_trace()
|
||||||
mp->mp_reply.reply_trace = 0;
|
mp->mp_reply.reply_trace = 0;
|
||||||
return(OK);
|
return(OK);
|
||||||
}
|
}
|
||||||
if ((child=findproc(m_in.pid))==NIL_MPROC || !(child->mp_flags & STOPPED)) {
|
if ((child=find_proc(m_in.pid))==NIL_MPROC || !(child->mp_flags & STOPPED)) {
|
||||||
return(ESRCH);
|
return(ESRCH);
|
||||||
}
|
}
|
||||||
/* all the other calls are made by the parent fork of the debugger to
|
/* all the other calls are made by the parent fork of the debugger to
|
||||||
|
@ -75,9 +75,9 @@ PUBLIC int do_trace()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* findproc *
|
* find_proc *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
PRIVATE struct mproc *findproc(lpid)
|
PRIVATE struct mproc *find_proc(lpid)
|
||||||
pid_t lpid;
|
pid_t lpid;
|
||||||
{
|
{
|
||||||
register struct mproc *rmp;
|
register struct mproc *rmp;
|
||||||
|
|
Loading…
Reference in a new issue