Various updates.
* Removed some variants of the SYS_GETINFO calls from the kernel; replaced them with new PM and utils libary functionality. Fixed bugs in utils library that used old get_kenv() variant. * Implemented a buffer in the kernel to gather random data. Memory driver periodically checks this for /dev/random. A better random algorithm can now be implemented in the driver. Removed SYS_RANDOM; the SYS_GETINFO call is used instead. * Remove SYS_KMALLOC from the kernel. Memory allocation can now be done at the process manager with new 'other' library functions.
This commit is contained in:
parent
4904a5537a
commit
f2a85e58d9
|
|
@ -25,4 +25,5 @@
|
|||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,17 +19,21 @@
|
|||
|
||||
#include "../drivers.h"
|
||||
#include "../libdriver/driver.h"
|
||||
#include <sys/ioc_memory.h>
|
||||
#include "../../kernel/const.h"
|
||||
#include "../../kernel/type.h"
|
||||
#include <sys/ioc_memory.h>
|
||||
|
||||
#define NR_DEVS 7 /* number of minor devices */
|
||||
#define KRANDOM_PERIOD 10 /* ticks between krandom calls */
|
||||
|
||||
PRIVATE struct device m_geom[NR_DEVS]; /* base and size of each device */
|
||||
PRIVATE int m_seg[NR_DEVS]; /* segment index of each device */
|
||||
PRIVATE int m_device; /* current device */
|
||||
PRIVATE struct kinfo kinfo; /* need kernel info */
|
||||
PRIVATE struct machine machine; /* need machine info */
|
||||
PRIVATE struct kinfo kinfo; /* kernel information */
|
||||
PRIVATE struct machine machine; /* machine information */
|
||||
PRIVATE struct randomness krandom; /* randomness from the kernel */
|
||||
|
||||
extern int errno; /* error number for PM calls */
|
||||
|
||||
FORWARD _PROTOTYPE( char *m_name, (void) );
|
||||
FORWARD _PROTOTYPE( struct device *m_prepare, (int device) );
|
||||
|
|
@ -39,6 +43,7 @@ FORWARD _PROTOTYPE( int m_do_open, (struct driver *dp, message *m_ptr) );
|
|||
FORWARD _PROTOTYPE( void m_init, (void) );
|
||||
FORWARD _PROTOTYPE( int m_ioctl, (struct driver *dp, message *m_ptr) );
|
||||
FORWARD _PROTOTYPE( void m_geometry, (struct partition *entry) );
|
||||
FORWARD _PROTOTYPE( void m_random, (struct driver *dp) );
|
||||
|
||||
/* Entry points to this driver. */
|
||||
PRIVATE struct driver m_dtab = {
|
||||
|
|
@ -51,16 +56,16 @@ PRIVATE struct driver m_dtab = {
|
|||
nop_cleanup, /* no need to clean up */
|
||||
m_geometry, /* memory device "geometry" */
|
||||
nop_stop, /* no need to clean up on shutdown */
|
||||
nop_alarm, /* ignore leftover alarms */
|
||||
m_random, /* get randomness from kernel */
|
||||
};
|
||||
|
||||
/* Buffer for the /dev/zero null byte feed. */
|
||||
#define ZERO_BUF_SIZE 1024
|
||||
PRIVATE char zero[ZERO_BUF_SIZE];
|
||||
PRIVATE char dev_zero[ZERO_BUF_SIZE];
|
||||
|
||||
/* Buffer for the /dev/random number generator. */
|
||||
#define RANDOM_BUF_SIZE 1024
|
||||
PRIVATE char random[RANDOM_BUF_SIZE];
|
||||
PRIVATE char dev_random[RANDOM_BUF_SIZE];
|
||||
|
||||
|
||||
#define click_to_round_k(n) \
|
||||
|
|
@ -171,16 +176,15 @@ unsigned nr_req; /* length of request vector */
|
|||
|
||||
/* Random number generator. Character instead of block device. */
|
||||
case RANDOM_DEV:
|
||||
printf("MEMORY: please note /dev/random is NOT yet random!\n");
|
||||
left = count;
|
||||
while (left > 0) {
|
||||
chunk = (left > RANDOM_BUF_SIZE) ? RANDOM_BUF_SIZE : left;
|
||||
if (opcode == DEV_GATHER) {
|
||||
sys_vircopy(SELF, D, (vir_bytes) random,
|
||||
sys_vircopy(SELF, D, (vir_bytes) dev_random,
|
||||
proc_nr, D, user_vir, chunk);
|
||||
} else if (opcode == DEV_SCATTER) {
|
||||
sys_vircopy(proc_nr, D, user_vir,
|
||||
SELF, D, (vir_bytes) random, chunk);
|
||||
SELF, D, (vir_bytes) dev_random, chunk);
|
||||
}
|
||||
left -= chunk;
|
||||
}
|
||||
|
|
@ -192,7 +196,7 @@ unsigned nr_req; /* length of request vector */
|
|||
left = count;
|
||||
while (left > 0) {
|
||||
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) dev_zero,
|
||||
proc_nr, D, user_vir, chunk)))
|
||||
report("MEM","sys_vircopy failed", s);
|
||||
left -= chunk;
|
||||
|
|
@ -268,14 +272,17 @@ PRIVATE void m_init()
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize /dev/random and /dev/zero. */
|
||||
/* Initialize /dev/zero. Simply write zeros into the buffer. */
|
||||
for (i=0; i<ZERO_BUF_SIZE; i++) {
|
||||
zero[i] = '\0';
|
||||
}
|
||||
for (i=0; i<RANDOM_BUF_SIZE; i++) {
|
||||
random[i] = 'a' + i % 256;
|
||||
dev_zero[i] = '\0';
|
||||
}
|
||||
|
||||
/* Initialize /dev/random. Seed the buffer and get kernel randomness. */
|
||||
for (i=0; i<RANDOM_BUF_SIZE; i++) {
|
||||
dev_random[i] = 'a' + i % 256; /* from file in future !!! */
|
||||
}
|
||||
m_random(NULL); /* also set periodic timer */
|
||||
|
||||
/* Set up memory ranges for /dev/mem. */
|
||||
#if (CHIP == INTEL)
|
||||
if (OK != (s=sys_getmachine(&machine))) {
|
||||
|
|
@ -328,21 +335,10 @@ message *m_ptr; /* pointer to control message */
|
|||
|
||||
/* Try to allocate a piece of memory for the RAM disk. */
|
||||
ramdev_size = m_ptr->POSITION;
|
||||
|
||||
printf("MEM: about to send to PM (ramdev_size %u)\n", ramdev_size);
|
||||
m.m_type = MEM_ALLOC;
|
||||
m.m4_l1 = ramdev_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)))
|
||||
panic("MEM","Couldn't allocate kernel memory", s);
|
||||
if (allocmem(ramdev_size, &ramdev_base) < 0) return(ENOMEM);
|
||||
dv->dv_base = cvul64(ramdev_base);
|
||||
dv->dv_size = cvul64(ramdev_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,
|
||||
ramdev_base, ramdev_size))) {
|
||||
panic("MEM","Couldn't install remote segment.",s);
|
||||
|
|
@ -357,6 +353,33 @@ message *m_ptr; /* pointer to control message */
|
|||
}
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* m_random *
|
||||
*============================================================================*/
|
||||
PRIVATE void m_random(dp)
|
||||
struct driver *dp; /* pointer to driver structure */
|
||||
{
|
||||
/* Fetch random information from the kernel to update /dev/random. */
|
||||
struct randomness krandom;
|
||||
static unsigned long *next_ptr = (unsigned long *) &dev_random[0];
|
||||
int i,s;
|
||||
if (OK != (s=sys_getrandomness(&krandom)))
|
||||
report("MEM", "sys_getrandomness failed", s);
|
||||
|
||||
i= (krandom.r_next + RANDOM_ELEMENTS -1) % RANDOM_ELEMENTS;
|
||||
while (krandom.r_size -- > 0) {
|
||||
*next_ptr = krandom.r_buf[i]; /* set dev_random data */
|
||||
next_ptr ++; /* proceed to next */
|
||||
if ((next_ptr - (unsigned long *) &dev_random[RANDOM_BUF_SIZE-1]) >=
|
||||
RANDOM_ELEMENTS) next_ptr = (unsigned long *) &dev_random[0];
|
||||
i = (i + 1) % RANDOM_ELEMENTS; /* next kernel random data */
|
||||
}
|
||||
|
||||
/* Schedule new alarm for next m_random call. */
|
||||
if (OK != (s=sys_syncalrm(SELF, KRANDOM_PERIOD, 0)))
|
||||
report("MEM", "sys_syncalarm failed", s);
|
||||
}
|
||||
|
||||
/*============================================================================*
|
||||
* m_geometry *
|
||||
*============================================================================*/
|
||||
|
|
|
|||
|
|
@ -522,7 +522,11 @@ static void rl_pci_conf()
|
|||
rep->re_name[8] += i;
|
||||
rep->re_seen= FALSE;
|
||||
envvar[sizeof(RL_ENVVAR)-1]= '0'+i;
|
||||
#if DEAD_CODE
|
||||
if (0 == sys_getkenv(envvar, strlen(envvar), val, sizeof(val)) &&
|
||||
#else
|
||||
if (0 == get_mon_param(envvar, val, sizeof(val)) &&
|
||||
#endif
|
||||
! env_prefix(envvar, "pci")) {
|
||||
env_panic(envvar);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,7 +503,9 @@ int scode; /* scan code for a function key */
|
|||
}
|
||||
|
||||
printf(" %sShift-F%d: ", i+1<10? " ":"", i+1);
|
||||
if (sfkey_obs[i] != NONE) {
|
||||
if (i==0) {
|
||||
printf("%-14.14s", "<reserved by TTY>");
|
||||
} else if (sfkey_obs[i] != NONE) {
|
||||
if ((s=sys_getproc(&proc, sfkey_obs[i]))!=OK)
|
||||
printf("sys_getproc: %d\n", s);
|
||||
printf("%-14.14s", proc.p_name);
|
||||
|
|
|
|||
|
|
@ -71,5 +71,5 @@
|
|||
#define GETPROCNR 80 /* to PM */
|
||||
|
||||
#define FSTATFS 82 /* to FS */
|
||||
#define MEM_ALLOC 83 /* to PM */
|
||||
#define MEM_FREE 84 /* to PM */
|
||||
#define ALLOCMEM 83 /* to PM */
|
||||
#define FREEMEM 84 /* to PM */
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@
|
|||
# define SYS_ABORT 9 /* sys_abort() */
|
||||
# define SYS_KILL 10 /* sys_kill(proc_nr, sig) */
|
||||
# define SYS_UMAP 11 /* sys_umap(proc_nr, etc) */
|
||||
# define SYS_RANDOM 12 /* sys_random(...) */
|
||||
|
||||
# define SYS_TRACE 13 /* sys_trace(req,pid,addr,data) */
|
||||
|
||||
# define SYS_SIGNALRM 15 /* sys_signalrm(proc_nr, ticks) */
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
# define SYS_DEVIO 23 /* sys_devio(port, value) */
|
||||
# define SYS_VDEVIO 24 /* sys_vdevio(buf_ptr, nr_ports) */
|
||||
# define SYS_IRQCTL 25 /* sys_irqctl() */
|
||||
# define SYS_KMALLOC 26 /* sys_kmalloc(size, phys_base) */
|
||||
|
||||
# define SYS_IOPENABLE 27 /* sys_enable_iop() */
|
||||
# define SYS_SEGCTL 28 /* sys_segctl(*idx, *seg, *off, phys, size) */
|
||||
# define SYS_EXIT 29 /* sys_exit(status) */
|
||||
|
|
@ -220,7 +220,7 @@
|
|||
# define SYS_PHYSZERO 33 /* sys_physzero(addr,count) */
|
||||
#define NR_SYS_CALLS 34 /* number of system calls */
|
||||
|
||||
/* Field names for SYS_MEM, SYS_KMALLOC. */
|
||||
/* Field names for SYS_SEGCTL. */
|
||||
#define MEM_CHUNK_BASE m4_l1 /* physical base address */
|
||||
#define MEM_CHUNK_SIZE m4_l2 /* size of mem chunk */
|
||||
#define MEM_TOT_SIZE m4_l3 /* total memory size */
|
||||
|
|
@ -306,8 +306,8 @@
|
|||
#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 */
|
||||
# define GET_PROCNR 3 /* find nr of process with name */
|
||||
# define GET_PROCTAB 2 /* get kernel process table */
|
||||
# define GET_RANDOMNESS 3 /* get randomness buffer */
|
||||
# define GET_MONPARAMS 4 /* get monitor parameters */
|
||||
# define GET_KENV 5 /* get kernel environment string */
|
||||
# define GET_IRQHOOKS 6 /* get the IRQ table */
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ _PROTOTYPE(int sys_umap, (int proc_nr, int seg, vir_bytes vir_addr,
|
|||
_PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
|
||||
phys_bytes phys, vir_bytes size));
|
||||
_PROTOTYPE(int sys_enable_iop, (int proc_nr) );
|
||||
_PROTOTYPE(int sys_kmalloc, (size_t size, phys_bytes *phys_base) );
|
||||
|
||||
/* Shorthands for sys_getinfo() system call. */
|
||||
#define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0)
|
||||
|
|
@ -117,14 +116,12 @@ _PROTOTYPE(int sys_kmalloc, (size_t size, phys_bytes *phys_base) );
|
|||
#define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
|
||||
#define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0)
|
||||
#define sys_getproc(dst,nr) sys_getinfo(GET_PROC, dst, 0,0, nr)
|
||||
#define sys_getprocnr(dst,k,kl) sys_getinfo(GET_PROCNR, dst, 0,k,kl)
|
||||
#define sys_getrandomness(dst) sys_getinfo(GET_RANDOMNESS, dst, 0,0,0)
|
||||
#define sys_getimage(dst) sys_getinfo(GET_IMAGE, dst, 0,0,0)
|
||||
#define sys_getirqhooks(dst) sys_getinfo(GET_IRQHOOKS, dst, 0,0,0)
|
||||
#define sys_getmemchunks(dst) sys_getinfo(GET_MEMCHUNKS, dst, 0,0,0)
|
||||
#define sys_getmonparams(v,vl) sys_getinfo(GET_MONPARAMS, v,vl, 0,0)
|
||||
#define sys_getkenv(k,kl,v,vl) sys_getinfo(GET_KENV, v,vl, k,kl)
|
||||
#define sys_getschedinfo(v1,v2) sys_getinfo(GET_SCHEDINFO, v1,0, v2,0)
|
||||
#define sys_getkaddr(dst) sys_getinfo(GET_KADDRESSES, dst, 0,0,0)
|
||||
#define sys_getlocktimings(dst) sys_getinfo(GET_LOCKTIMING, dst, 0,0,0)
|
||||
_PROTOTYPE(int sys_getinfo, (int request, void *val_ptr, int val_len,
|
||||
void *key_ptr, int key_len) );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
#ifndef _TYPE_H
|
||||
#define _TYPE_H
|
||||
|
||||
#ifndef _CONFIG_H
|
||||
#include <minix/config.h>
|
||||
#endif
|
||||
|
||||
#ifndef _TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
|
@ -102,9 +106,6 @@ struct kinfo {
|
|||
phys_bytes bootdev_size;
|
||||
phys_bytes params_base; /* parameters passed by boot monitor */
|
||||
phys_bytes params_size;
|
||||
long nr_ntf_pending;
|
||||
long lock_notify;
|
||||
long lock_send;
|
||||
int nr_procs; /* number of user processes */
|
||||
int nr_tasks; /* number of kernel tasks */
|
||||
char version[8]; /* kernel version number */
|
||||
|
|
|
|||
|
|
@ -125,6 +125,9 @@ _PROTOTYPE( int unlink, (const char *_path) );
|
|||
_PROTOTYPE( ssize_t write, (int _fd, const void *_buf, size_t _n) );
|
||||
|
||||
#ifdef _MINIX
|
||||
#ifndef _TYPE_H
|
||||
#include <minix/type.h>
|
||||
#endif
|
||||
_PROTOTYPE( int brk, (char *_addr) );
|
||||
_PROTOTYPE( int chroot, (const char *_name) );
|
||||
_PROTOTYPE( int mknod, (const char *_name, Mode_t _mode, Dev_t _addr) );
|
||||
|
|
@ -145,6 +148,8 @@ _PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
|
|||
_PROTOTYPE( int getsysinfo, (int who, int what, void *where) );
|
||||
_PROTOTYPE( int getprocnr, (int *proc_nr) );
|
||||
_PROTOTYPE( int findproc, (char *proc_name, int *proc_nr) );
|
||||
_PROTOTYPE( int allocmem, (phys_bytes size, phys_bytes *base) );
|
||||
_PROTOTYPE( int freemem, (phys_bytes size, phys_bytes base) );
|
||||
#endif
|
||||
|
||||
_PROTOTYPE( int setcache, (int kb));
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
/* How many bytes should the circular buffer for kernel diagnostics. */
|
||||
#define KMESS_BUF_SIZE 256
|
||||
|
||||
/* How many bytes for (port,value)-pairs vector to copy in. */
|
||||
#define VDEVIO_BUF_SIZE 128
|
||||
/* Maximum size in bytes for (port,value)-pairs vector to copy in. */
|
||||
#define VDEVIO_BUF_SIZE 64
|
||||
|
||||
/* How many elements in vector of virtual copy requests. */
|
||||
#define VCOPY_VEC_SIZE 16
|
||||
|
|
@ -41,6 +41,9 @@
|
|||
/* How many buffers for notification messages should there be? */
|
||||
#define NR_NOTIFY_BUFS 32
|
||||
|
||||
/* Buffer to gather randomness. How many entries before wrapping? */
|
||||
#define RANDOM_ELEMENTS 32
|
||||
|
||||
/* Constants and macros for bit map manipulation. */
|
||||
#define BITCHUNK_BITS (sizeof(bitchunk_t) * CHAR_BIT)
|
||||
#define BITMAP_CHUNKS(nr_bits) (((nr_bits)+BITCHUNK_BITS-1)/BITCHUNK_BITS)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
/* This file contains a simple exception handler. Exceptions in user
|
||||
* processes are converted to signals. Exceptions in the kernel, MM and
|
||||
* FS cause a panic.
|
||||
*
|
||||
* Changes:
|
||||
* Sep 28, 2004: skip_stop_sequence on exceptions in system processes
|
||||
*/
|
||||
|
||||
#include "kernel.h"
|
||||
|
|
@ -78,7 +75,7 @@ unsigned vec_nr;
|
|||
* notification ...
|
||||
*/
|
||||
if (istaskp(saved_proc)) { /* serious problem */
|
||||
skip_stop_sequence = TRUE; /* directly shutdown */
|
||||
kernel_exception = TRUE; /* directly shutdown */
|
||||
panic("exception in a kernel task", NO_NUM);
|
||||
} else {
|
||||
clear_proc(saved_proc->p_nr);
|
||||
|
|
|
|||
40
kernel/glo.h
40
kernel/glo.h
|
|
@ -1,32 +1,30 @@
|
|||
/* Global variables used in the kernel. This file contains the declarations;
|
||||
* storage space for the variables is allocated in table.c, because EXTERN is
|
||||
* defined as extern unless the _TABLE definition is seen.
|
||||
* defined as extern unless the _TABLE definition is seen. We rely on the
|
||||
* compiler's default initialization (0) for several global variables.
|
||||
*/
|
||||
#ifdef _TABLE
|
||||
#undef EXTERN
|
||||
#define EXTERN
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
#include <minix/config.h>
|
||||
|
||||
/* MINIX' shutdown sequence uses watchdog timers to stop system services. The
|
||||
* flag shutting_down must be initialized to FALSE. We rely on the compiler's
|
||||
* default initialization (0) of global variables here.
|
||||
*/
|
||||
EXTERN char skip_stop_sequence; /* set to TRUE in case of an exception() */
|
||||
EXTERN char shutting_down; /* TRUE if the system is shutting down */
|
||||
/* Variables relating to shutting down MINIX. */
|
||||
EXTERN char kernel_exception; /* TRUE after system exceptions */
|
||||
EXTERN char shutting_down; /* TRUE if shutting down */
|
||||
EXTERN struct proc *shutdown_process; /* process awaiting shutdown of */
|
||||
EXTERN timer_t shutdown_timer; /* watchdog function called after timeout */
|
||||
EXTERN timer_t shutdown_timer; /* timer for watchdog function */
|
||||
|
||||
/* Kernel information structures. This groups vital kernel information. */
|
||||
EXTERN phys_bytes aout; /* address of a.out headers */
|
||||
EXTERN struct kinfo kinfo; /* kernel information for users */
|
||||
EXTERN struct machine machine; /* machine information for users */
|
||||
EXTERN struct kmessages kmess; /* diagnostic messages in kernel */
|
||||
EXTERN phys_bytes aout; /* address of a.out headers */
|
||||
EXTERN struct kinfo kinfo; /* kernel information for users */
|
||||
EXTERN struct machine machine; /* machine information for users */
|
||||
EXTERN struct kmessages kmess; /* diagnostic messages in kernel */
|
||||
EXTERN struct randomness krandom; /* gather kernel random information */
|
||||
EXTERN struct memory mem[NR_MEMS]; /* base and size of chunks of memory */
|
||||
|
||||
/* Process scheduling info and kernel entry count. */
|
||||
/* Process scheduling information and the kernel reentry count. */
|
||||
EXTERN struct proc *proc_ptr; /* pointer to currently running process */
|
||||
EXTERN struct proc *next_ptr; /* pointer to next process to run */
|
||||
EXTERN char k_reenter; /* kernel reentry count (entry count less 1) */
|
||||
|
|
@ -43,21 +41,21 @@ EXTERN bitchunk_t notify_bitmap[BITMAP_CHUNKS(NR_NOTIFY_BUFS)];
|
|||
EXTERN irq_hook_t irq_hooks[NR_IRQ_HOOKS]; /* hooks for general use */
|
||||
EXTERN irq_hook_t *irq_handlers[NR_IRQ_VECTORS];/* list of IRQ handlers */
|
||||
EXTERN int irq_actids[NR_IRQ_VECTORS]; /* IRQ ID bits active */
|
||||
EXTERN int irq_use; /* bit map of all in-use irq's */
|
||||
EXTERN int irq_use; /* map of all in-use irq's */
|
||||
|
||||
/* lock() timing data. */
|
||||
/* Data structure to store lock() timing data. */
|
||||
#if ENABLE_LOCK_TIMING
|
||||
EXTERN struct lock_timedata timingdata[TIMING_CATEGORIES];
|
||||
#endif
|
||||
|
||||
/* Miscellaneous. */
|
||||
EXTERN reg_t mon_ss, mon_sp; /* monitor stack */
|
||||
EXTERN int mon_return; /* true if return to the monitor possible */
|
||||
EXTERN reg_t mon_ss, mon_sp; /* boot monitor stack */
|
||||
EXTERN int mon_return; /* true if we can return to monitor */
|
||||
|
||||
/* Variables that are initialized elsewhere are just extern here. */
|
||||
extern struct system_image image[]; /* system image processes (table.c) */
|
||||
extern char *t_stack[]; /* stack space for kernel tasks (table.c) */
|
||||
extern struct segdesc_s gdt[]; /* protected mode global descriptor (protect.c) */
|
||||
extern struct system_image image[]; /* system image processes */
|
||||
extern char *t_stack[]; /* task stack space */
|
||||
extern struct segdesc_s gdt[]; /* global descriptor table */
|
||||
|
||||
EXTERN _PROTOTYPE( void (*level0_func), (void) );
|
||||
#endif /* (CHIP == INTEL) */
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ int how; /* 0 = halt, 1 = reboot, 2 = panic!, ... */
|
|||
*/
|
||||
shutting_down = TRUE; /* flag for sys_exit() */
|
||||
tmr_arg(&shutdown_timer)->ta_int = how; /* pass how in timer */
|
||||
if (skip_stop_sequence) { /* set in exception() */
|
||||
if (kernel_exception) { /* set in exception() */
|
||||
kprintf("\nAn exception occured; skipping stop sequence.\n", NO_ARG);
|
||||
shutdown(&shutdown_timer); /* TTY isn't scheduled */
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -442,7 +442,6 @@ message *m_ptr; /* pointer to message buffer */
|
|||
struct proc *caller_ptr;
|
||||
|
||||
lock(0, "notify");
|
||||
kinfo.lock_notify ++;
|
||||
caller_ptr = (k_reenter >= 0) ? proc_addr(HARDWARE) : proc_ptr;
|
||||
result = mini_notify(caller_ptr, dst, m_ptr);
|
||||
unlock(0);
|
||||
|
|
@ -654,7 +653,6 @@ message *m_ptr; /* pointer to message buffer */
|
|||
/* Safe gateway to mini_send() for tasks. */
|
||||
int result;
|
||||
lock(2, "send");
|
||||
kinfo.lock_send ++;
|
||||
result = mini_send(proc_ptr, dst, m_ptr, NON_BLOCKING);
|
||||
unlock(2);
|
||||
return(result);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ _PROTOTYPE( void clear_proc, (int proc_nr) );
|
|||
_PROTOTYPE( phys_bytes numap_local, (int proc_nr, vir_bytes vir_addr,
|
||||
vir_bytes bytes) );
|
||||
_PROTOTYPE( void sys_task, (void) );
|
||||
_PROTOTYPE( void get_randomness, (void) );
|
||||
_PROTOTYPE( int virtual_copy, (struct vir_addr *src, struct vir_addr *dst,
|
||||
vir_bytes bytes) );
|
||||
_PROTOTYPE( phys_bytes umap_local, (struct proc *rp, int seg,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* umap_bios: map virtual address in BIOS_SEG to physical
|
||||
* numap_local: umap_local D segment from proc nr instead of pointer
|
||||
* virtual_copy: copy bytes from one virtual address to another
|
||||
* get_randomness: accumulate randomness in a buffer
|
||||
* generic_handler: interrupt handler for user-level device drivers
|
||||
*
|
||||
* Changes:
|
||||
|
|
@ -152,7 +153,6 @@ PRIVATE void initialize(void)
|
|||
map(SYS_VDEVIO, do_vdevio); /* vector with devio requests */
|
||||
|
||||
/* Server and driver control. */
|
||||
map(SYS_KMALLOC, do_kmalloc); /* request chunk of free memory */
|
||||
map(SYS_SEGCTL, do_segctl); /* add segment and get selector */
|
||||
map(SYS_IOPENABLE, do_iopenable); /* enable CPU I/O protection bits */
|
||||
map(SYS_SVRCTL, do_svrctl); /* kernel control functions */
|
||||
|
|
@ -169,7 +169,6 @@ PRIVATE void initialize(void)
|
|||
/* Miscellaneous. */
|
||||
map(SYS_ABORT, do_abort); /* abort MINIX */
|
||||
map(SYS_GETINFO, do_getinfo); /* request system information */
|
||||
map(SYS_RANDOM, do_random); /* request kernel random data */
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
@ -262,6 +261,20 @@ int proc_nr; /* slot of process to clean up */
|
|||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* get_randomness *
|
||||
*===========================================================================*/
|
||||
PUBLIC void get_randomness()
|
||||
{
|
||||
/* Gather random information with help of the CPU's cycle counter. Only use
|
||||
* the lowest bytes because the highest bytes won't differ that much.
|
||||
*/
|
||||
unsigned long tsc_high;
|
||||
read_tsc(&tsc_high, &krandom.r_buf[krandom.r_next]);
|
||||
if (krandom.r_size < RANDOM_ELEMENTS) krandom.r_size ++;
|
||||
krandom.r_next = (krandom.r_next + 1 ) % RANDOM_ELEMENTS;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* generic_handler *
|
||||
|
|
@ -272,8 +285,15 @@ irq_hook_t *hook;
|
|||
/* This function handles hardware interrupt in a simple and generic way. All
|
||||
* interrupts are transformed into messages to a driver. The IRQ line will be
|
||||
* reenabled if the policy says so.
|
||||
* In addition, the interrupt handler gathers random information in a buffer
|
||||
* by timestamping the interrupts.
|
||||
*/
|
||||
message m;
|
||||
|
||||
/* Gather random information. */
|
||||
get_randomness();
|
||||
|
||||
/* Build notification message and return. */
|
||||
m.NOTIFY_TYPE = HARD_INT;
|
||||
m.NOTIFY_ARG = hook->irq;
|
||||
lock_notify(hook->proc_nr, &m);
|
||||
|
|
|
|||
|
|
@ -31,11 +31,9 @@ _PROTOTYPE( int do_umap, (message *m_ptr) );
|
|||
_PROTOTYPE( int do_unused, (message *m_ptr) ); /* miscellaneous */
|
||||
_PROTOTYPE( int do_abort, (message *m_ptr) );
|
||||
_PROTOTYPE( int do_getinfo, (message *m_ptr) );
|
||||
_PROTOTYPE( int do_random, (message *m_ptr) );
|
||||
|
||||
_PROTOTYPE( int do_exit, (message *m_ptr) ); /* system control */
|
||||
_PROTOTYPE( int do_svrctl, (message *m_ptr) );
|
||||
_PROTOTYPE( int do_kmalloc, (message *m_ptr) );
|
||||
_PROTOTYPE( int do_iopenable, (message *m_ptr) );
|
||||
_PROTOTYPE( int do_segctl, (message *m_ptr) );
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,6 @@ message *m; /* pointer to request message */
|
|||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_random *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_random(m)
|
||||
message *m; /* pointer to request message */
|
||||
{
|
||||
return(ENOSYS); /* no yet implemented */
|
||||
}
|
||||
|
||||
|
||||
/* The system call implemented in this file:
|
||||
* m_type: SYS_ABORT
|
||||
|
|
@ -131,6 +122,7 @@ register message *m_ptr; /* pointer to request message */
|
|||
length);
|
||||
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
||||
phys_copy(src_phys, dst_phys, length);
|
||||
/* fall through */
|
||||
}
|
||||
case GET_PROCTAB: {
|
||||
length = sizeof(struct proc) * (NR_PROCS + NR_TASKS);
|
||||
|
|
@ -139,49 +131,22 @@ register message *m_ptr; /* pointer to request message */
|
|||
}
|
||||
case GET_PROC: {
|
||||
nr = (m_ptr->I_KEY_LEN == SELF) ? m_ptr->m_source : m_ptr->I_KEY_LEN;
|
||||
if (! isokprocn(nr)) return(EINVAL);
|
||||
if (! isokprocn(nr)) return(EINVAL); /* validate request */
|
||||
length = sizeof(struct proc);
|
||||
src_phys = vir2phys(proc_addr(nr));
|
||||
break;
|
||||
}
|
||||
case GET_MONPARAMS: {
|
||||
src_phys = kinfo.params_base; /* already is a physical address! */
|
||||
src_phys = kinfo.params_base; /* already is a physical */
|
||||
length = kinfo.params_size;
|
||||
break;
|
||||
}
|
||||
case GET_PROCNR: {
|
||||
if (m_ptr->I_KEY_LEN == 0) { /* get own process nr */
|
||||
/* GET_PROCNR functionality will be moved to the Process Manager! */
|
||||
kprintf("GET_PROCNR (own) from %d\n", m_ptr->m_source);
|
||||
src_phys = vir2phys(&proc_nr);
|
||||
length = sizeof(int);
|
||||
} else { /* lookup nr by name */
|
||||
int proc_found = FALSE;
|
||||
struct proc *pp;
|
||||
struct vir_addr vsrc, vdst;
|
||||
char key[8]; /* storage for process name to lookup */
|
||||
/* GET_PROCNR functionality will be moved to the Process Manager! */
|
||||
kprintf("GET_PROCNR (by name) from %d\n", m_ptr->m_source);
|
||||
proc_nr = m_ptr->m_source; /* only caller can request copy */
|
||||
if (m_ptr->I_KEY_LEN > sizeof(key)) return(EINVAL);
|
||||
vsrc.proc_nr = proc_nr; vsrc.segment = D; vsrc.offset = (vir_bytes) m_ptr->I_KEY_PTR;
|
||||
vdst.proc_nr = SYSTASK, vdst.segment = D; vdst.offset = (vir_bytes) key;
|
||||
if (virtual_copy(&vsrc, &vdst, m_ptr->I_KEY_LEN) != OK) return(EFAULT);
|
||||
#if DEAD_CODE
|
||||
if (vir_copy(proc_nr, (vir_bytes) m_ptr->I_KEY_PTR, SYSTASK,
|
||||
(vir_bytes) key, m_ptr->I_KEY_LEN) != OK) return(EFAULT);
|
||||
#endif
|
||||
for (pp=BEG_PROC_ADDR; pp<END_PROC_ADDR; pp++) {
|
||||
if (kstrncmp(pp->p_name, key, m_ptr->I_KEY_LEN) == 0) {
|
||||
src_phys = vir2phys(&(pp->p_nr));
|
||||
length = sizeof(int);
|
||||
proc_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! proc_found) return(ESRCH);
|
||||
}
|
||||
break;
|
||||
case GET_RANDOMNESS: {
|
||||
struct randomness copy = krandom; /* copy to keep counters */
|
||||
krandom.r_next = krandom.r_size = 0; /* invalidate random data */
|
||||
length = sizeof(struct randomness);
|
||||
src_phys = vir2phys(©);
|
||||
break;
|
||||
}
|
||||
case GET_KMESSAGES: {
|
||||
length = sizeof(struct kmessages);
|
||||
|
|
|
|||
|
|
@ -219,38 +219,3 @@ register message *m_ptr; /* pointer to request message */
|
|||
}
|
||||
|
||||
|
||||
/* The system call implemented in this file:
|
||||
* m_type: SYS_KMALLOC
|
||||
*
|
||||
* The parameters for this system call are:
|
||||
* m4_l2: MEM_CHUNK_SIZE (request a buffer of this size)
|
||||
* m4_l1: MEM_CHUNK_BASE (return physical address on success)
|
||||
*
|
||||
* Author:
|
||||
* Jorrit N. Herder <jnherder@cs.vu.nl>
|
||||
*/
|
||||
|
||||
/*===========================================================================*
|
||||
* do_kmalloc *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_kmalloc(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Request a (DMA) buffer to be allocated in one of the memory chunks. */
|
||||
phys_clicks tot_clicks;
|
||||
struct memory *memp;
|
||||
|
||||
kprintf("SYS_KMALLOC called by %d\n", m_ptr->m_source);
|
||||
|
||||
tot_clicks = (m_ptr->MEM_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;
|
||||
m_ptr->MEM_CHUNK_BASE = (memp->base + memp->size) << CLICK_SHIFT;
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ struct kmessages {
|
|||
char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
|
||||
};
|
||||
|
||||
struct randomness {
|
||||
int r_next; /* next index to write */
|
||||
int r_size; /* number of random elements */
|
||||
unsigned long r_buf[RANDOM_ELEMENTS]; /* buffer for random info */
|
||||
};
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
typedef unsigned reg_t; /* machine register */
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ LIBRARY = ../libc.a
|
|||
all: $(LIBRARY)
|
||||
|
||||
OBJECTS = \
|
||||
$(LIBRARY)(_allocmem.o) \
|
||||
$(LIBRARY)(_freemem.o) \
|
||||
$(LIBRARY)(_brk.o) \
|
||||
$(LIBRARY)(_reboot.o) \
|
||||
$(LIBRARY)(_seekdir.o) \
|
||||
|
|
@ -64,6 +66,12 @@ $(LIBRARY): $(OBJECTS)
|
|||
aal cr $@ *.o
|
||||
rm *.o
|
||||
|
||||
$(LIBRARY)(_allocmem.o): _allocmem.c
|
||||
$(CC1) _allocmem.c
|
||||
|
||||
$(LIBRARY)(_freemem.o): _freemem.c
|
||||
$(CC1) _freemem.c
|
||||
|
||||
$(LIBRARY)(_brk.o): _brk.c
|
||||
$(CC1) _brk.c
|
||||
|
||||
|
|
|
|||
16
lib/other/_allocmem.c
Normal file
16
lib/other/_allocmem.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <lib.h>
|
||||
#define allocmem _allocmem
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
PUBLIC int allocmem(size, base)
|
||||
phys_bytes size; /* size of mem chunk requested */
|
||||
phys_bytes *base; /* return base address */
|
||||
{
|
||||
message m;
|
||||
m.m4_l1 = size;
|
||||
if (_syscall(MM, ALLOCMEM, &m) < 0) return(-1);
|
||||
*base = m.m4_l2;
|
||||
return(0);
|
||||
}
|
||||
|
||||
16
lib/other/_freemem.c
Normal file
16
lib/other/_freemem.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <lib.h>
|
||||
#define freemem _freemem
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
PUBLIC int freemem(size, base)
|
||||
phys_bytes size; /* size of mem chunk requested */
|
||||
phys_bytes base; /* base address of mem chunk */
|
||||
{
|
||||
message m;
|
||||
m.m4_l1 = size;
|
||||
m.m4_l2 = base;
|
||||
if (_syscall(MM, FREEMEM, &m) < 0) return(-1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
@ -9,6 +9,8 @@ OBJECTS = \
|
|||
$(LIBRARY)(_exit.o) \
|
||||
$(LIBRARY)(access.o) \
|
||||
$(LIBRARY)(alarm.o) \
|
||||
$(LIBRARY)(allocmem.o) \
|
||||
$(LIBRARY)(freemem.o) \
|
||||
$(LIBRARY)(brk.o) \
|
||||
$(LIBRARY)(cfgetispeed.o) \
|
||||
$(LIBRARY)(cfgetospeed.o) \
|
||||
|
|
@ -117,6 +119,12 @@ $(LIBRARY)(access.o): access.s
|
|||
$(LIBRARY)(alarm.o): alarm.s
|
||||
$(CC1) alarm.s
|
||||
|
||||
$(LIBRARY)(allocmem.o): allocmem.s
|
||||
$(CC1) allocmem.s
|
||||
|
||||
$(LIBRARY)(freemem.o): freemem.s
|
||||
$(CC1) freemem.s
|
||||
|
||||
$(LIBRARY)(brk.o): brk.s
|
||||
$(CC1) brk.s
|
||||
|
||||
|
|
|
|||
7
lib/syscall/allocmem.s
Normal file
7
lib/syscall/allocmem.s
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.sect .text
|
||||
.extern __allocmem
|
||||
.define _allocmem
|
||||
.align 2
|
||||
|
||||
_allocmem:
|
||||
jmp __allocmem
|
||||
7
lib/syscall/freemem.s
Normal file
7
lib/syscall/freemem.s
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
.sect .text
|
||||
.extern __freemem
|
||||
.define _freemem
|
||||
.align 2
|
||||
|
||||
_freemem:
|
||||
jmp __freemem
|
||||
|
|
@ -26,7 +26,6 @@ OBJECTS = \
|
|||
$(LIBSYS)(sys_xit.o) \
|
||||
$(LIBSYS)(sys_sdevio.o) \
|
||||
$(LIBSYS)(sys_getinfo.o) \
|
||||
$(LIBSYS)(sys_kmalloc.o) \
|
||||
$(LIBSYS)(sys_irqctl.o) \
|
||||
$(LIBSYS)(sys_eniop.o) \
|
||||
$(LIBSYS)(sys_segctl.o) \
|
||||
|
|
@ -96,9 +95,6 @@ $(LIBSYS)(sys_sdevio.o): sys_sdevio.c
|
|||
$(LIBSYS)(sys_getinfo.o): sys_getinfo.c
|
||||
$(CC1) sys_getinfo.c
|
||||
|
||||
$(LIBSYS)(sys_kmalloc.o): sys_kmalloc.c
|
||||
$(CC1) sys_kmalloc.c
|
||||
|
||||
$(LIBSYS)(sys_irqctl.o): sys_irqctl.c
|
||||
$(CC1) sys_irqctl.c
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* printf() - kernel printf() Author: Kees J. Bot
|
||||
/* printf() - system services printf() Author: Kees J. Bot
|
||||
* 15 Jan 1994
|
||||
*/
|
||||
#define nil 0
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int c;
|
|||
m.DIAG_PRINT_BUF = print_buf;
|
||||
m.DIAG_PROC_NR = SELF;
|
||||
m.m_type = DIAGNOSTICS;
|
||||
if (_sendrec(TTY, &m) != 0) {
|
||||
if (_sendrec(IS_PROC_NR, &m) != 0) {
|
||||
m.m1_i1 = 2;
|
||||
m.m1_i2 = buf_count;
|
||||
m.m1_p1 = print_buf;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ char *key; /* environment variable whose value is bogus */
|
|||
{
|
||||
static char value[EP_BUF_SIZE] = "<unknown>";
|
||||
int s;
|
||||
if ((s=sys_getkenv(key, strlen(key), value, sizeof(value))) == 0) {
|
||||
if ((s=get_mon_param(key, value, sizeof(value))) == 0) {
|
||||
if (s != ESRCH) /* only error allowed */
|
||||
printf("WARNING: sys_getkenv() failed in env_panic(): %d\n", s);
|
||||
printf("WARNING: get_mon_param() failed in env_panic(): %d\n", s);
|
||||
}
|
||||
printf("Bad environment setting: '%s = %s'\n", key, value);
|
||||
panic("","", NO_NUM);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ long min, max; /* minimum and maximum values for the parameter */
|
|||
|
||||
if ((s=get_mon_param(env, value, sizeof(value))) != 0) {
|
||||
if (s == ESRCH) return(EP_UNSET); /* only error allowed */
|
||||
printf("WARNING: sys_getkenv() failed in env_parse(): %d\n",s);
|
||||
printf("WARNING: get_mon_param() failed in env_parse(): %d\n",s);
|
||||
return(EP_EGETKENV);
|
||||
}
|
||||
val = value;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ char *prefix; /* prefix to test for */
|
|||
int s;
|
||||
size_t n;
|
||||
|
||||
if ((s = sys_getkenv(env, strlen(env), value, sizeof(value))) != 0) {
|
||||
if ((s = get_mon_param(env, value, sizeof(value))) != 0) {
|
||||
if (s != ESRCH) /* only error allowed */
|
||||
printf("WARNING: sys_getkenv() failed in env_prefix(): %d\n", s);
|
||||
printf("WARNING: get_mon_param() failed in env_prefix(): %d\n", s);
|
||||
}
|
||||
n = strlen(prefix);
|
||||
return(value != NULL
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
* Changes:
|
||||
* Mar 23, 2005 allow arbitrary partitions as RAM disk (Jorrit N. Herder)
|
||||
* Jan 10, 2005 register fkeys with TTY for debug dumps (Jorrit N. Herder)
|
||||
*/
|
||||
|
||||
struct super_block; /* proto.h needs to know this */
|
||||
|
|
@ -65,9 +64,6 @@ PUBLIC void main()
|
|||
if (call_nr == HARD_STOP) {
|
||||
do_sync();
|
||||
sys_exit(0); /* never returns */
|
||||
} else if (call_nr == FKEY_PRESSED) {
|
||||
do_fkey_pressed();
|
||||
continue; /* get work again */
|
||||
}
|
||||
|
||||
/* Call the internal function that does the work. */
|
||||
|
|
@ -229,14 +225,6 @@ PRIVATE void fs_init()
|
|||
rfp->fp_workdir = rip;
|
||||
}
|
||||
}
|
||||
|
||||
/* Register function keys with TTY. */
|
||||
for (key=SF5; key<=SF6; key++) {
|
||||
if ((i=fkey_enable(key))!=OK) {
|
||||
printf("Warning: FS couldn't register Shift+F%d key: %d\n",
|
||||
key-SF1+1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ Copyright 1995 Philip Homburg
|
|||
#define ZERO 0 /* Used to comment out initialization code that does nothing. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <minix/type.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ Copyright 1995 Philip Homburg
|
|||
#define _MINIX 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -21,6 +20,7 @@ Copyright 1995 Philip Homburg
|
|||
#include <minix/config.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <unistd.h>
|
||||
#include "inet_config.h"
|
||||
|
||||
#define CRAMPED (_EM_WSIZE==2) /* 64K code and data is quite cramped. */
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* down.
|
||||
*/
|
||||
|
||||
#include <minix/type.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
|||
|
|
@ -55,13 +55,8 @@ struct system_image image[IMAGE_SIZE];
|
|||
*===========================================================================*/
|
||||
PUBLIC int do_fkey_pressed(message *m)
|
||||
{
|
||||
#if DEAD_CODE
|
||||
if (F1 <= m->FKEY_CODE && m->FKEY_CODE <= F12) {
|
||||
switch(m->FKEY_CODE) {
|
||||
#else
|
||||
if (F1 <= m->NOTIFY_ARG && m->NOTIFY_ARG <= F12) {
|
||||
switch(m->NOTIFY_ARG) {
|
||||
#endif
|
||||
case F1: proctab_dmp(); break;
|
||||
case F2: memmap_dmp(); break;
|
||||
case F3: image_dmp(); break;
|
||||
|
|
@ -77,12 +72,15 @@ PUBLIC int do_fkey_pressed(message *m)
|
|||
case F11: memchunks_dmp(); break;
|
||||
case F12: sched_dmp(); break;
|
||||
default:
|
||||
#if DEAD_CODE
|
||||
printf("IS: unhandled notification for F%d\n", m->FKEY_NUM);
|
||||
#else
|
||||
printf("IS: unhandled notify for F%d (code %d)\n",
|
||||
m->NOTIFY_FLAGS, m->NOTIFY_ARG);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (SF1 <= m->NOTIFY_ARG && m->NOTIFY_ARG <= SF12) {
|
||||
switch(m->NOTIFY_ARG) {
|
||||
default:
|
||||
printf("IS: unhandled notify for Shift-F%d (code %d)\n",
|
||||
m->NOTIFY_FLAGS, m->NOTIFY_ARG);
|
||||
}
|
||||
}
|
||||
return(EDONTREPLY);
|
||||
|
|
@ -379,9 +377,6 @@ PRIVATE void kenv_dmp()
|
|||
printf("- bootdev_size: %5u\n", kinfo.bootdev_size);
|
||||
printf("- params_base: %5u\n", kinfo.params_base);
|
||||
printf("- params_size: %5u\n", kinfo.params_size);
|
||||
printf("- notify_pending:%8u\n", kinfo.nr_ntf_pending);
|
||||
printf("- lock_notify: %6u\n", kinfo.lock_notify);
|
||||
printf("- lock_send: %6u\n", kinfo.lock_send);
|
||||
printf("- nr_procs: %3u\n", kinfo.nr_procs);
|
||||
printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
|
||||
printf("- version: %.6s\n", kinfo.version);
|
||||
|
|
|
|||
|
|
@ -100,6 +100,12 @@ PRIVATE void init_server()
|
|||
(key-F1+1), r);
|
||||
}
|
||||
}
|
||||
for (key=SF1; key<=SF12; key++) {
|
||||
if ((r=fkey_enable(key)) != OK) {
|
||||
printf("IS: WARNING: couldn't register SF%d key: %d\n",
|
||||
(key-SF1+1), r);
|
||||
}
|
||||
}
|
||||
|
||||
/* Display status message ... */
|
||||
printf("IS: information service is alive and kicking; press F1-F12 for dumps\n");
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ PRIVATE phys_clicks swap_base; /* memory offset chosen as swap base */
|
|||
PRIVATE phys_clicks swap_maxsize;/* maximum amount of swap "memory" possible */
|
||||
PRIVATE struct mproc *in_queue; /* queue of processes wanting to swap in */
|
||||
PRIVATE struct mproc *outswap = &mproc[0]; /* outswap candidate? */
|
||||
#else /* !SWAP */
|
||||
#else /* ! ENABLE_SWAP */
|
||||
#define swap_base ((phys_clicks) -1)
|
||||
#endif /* !SWAP */
|
||||
#endif /* ENABLE_SWAP */
|
||||
|
||||
FORWARD _PROTOTYPE( void del_slot, (struct hole *prev_ptr, struct hole *hp) );
|
||||
FORWARD _PROTOTYPE( void merge, (struct hole *hp) );
|
||||
|
|
@ -65,7 +65,6 @@ phys_clicks clicks; /* amount of memory requested */
|
|||
* always on a click boundary. This procedure is called when memory is
|
||||
* needed for FORK or EXEC. Swap other processes out if needed.
|
||||
*/
|
||||
|
||||
register struct hole *hp, *prev_ptr;
|
||||
phys_clicks old_base;
|
||||
|
||||
|
|
@ -104,7 +103,6 @@ phys_clicks clicks; /* number of clicks to free */
|
|||
* to the hole list. If it is contiguous with an existing hole on either end,
|
||||
* it is merged with the hole or holes.
|
||||
*/
|
||||
|
||||
register struct hole *hp, *new_ptr, *prev_ptr;
|
||||
|
||||
if (clicks == 0) return;
|
||||
|
|
@ -151,7 +149,6 @@ register struct hole *hp; /* pointer to hole entry to be removed */
|
|||
* the numbers of holes in memory, and requiring the elimination of one
|
||||
* entry in the hole list.
|
||||
*/
|
||||
|
||||
if (hp == hole_head)
|
||||
hole_head = hp->h_next;
|
||||
else
|
||||
|
|
@ -172,7 +169,6 @@ register struct hole *hp; /* ptr to hole to merge with its successors */
|
|||
* either or both ends. The pointer 'hp' points to the first of a series of
|
||||
* three holes that can potentially all be merged together.
|
||||
*/
|
||||
|
||||
register struct hole *next_ptr;
|
||||
|
||||
/* If 'hp' points to the last hole, no merging is possible. If it does not,
|
||||
|
|
@ -230,7 +226,7 @@ phys_clicks *free; /* memory size summaries */
|
|||
|
||||
/* Ask the kernel for chunks of physical memory and allocate holes. */
|
||||
*free = 0;
|
||||
for (i=0; i<NR_MEMS; i++) {
|
||||
for (i=NR_MEMS-1; i>=0; i--) {
|
||||
if (mem[i].size > 0) {
|
||||
free_mem(mem[i].base, mem[i].size);
|
||||
*free += mem[i].size;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ PUBLIC void main()
|
|||
check_sig(-1, SIGKILL); /* kill all processes */
|
||||
sys_exit(0);
|
||||
/* never reached */
|
||||
} else if (call_nr == FKEY_PRESSED) { /* create debug dump */
|
||||
(void) do_fkey_pressed();
|
||||
result = SUSPEND; /* don't reply */
|
||||
} else if (call_nr == KSIG_PENDING) { /* signals pending */
|
||||
(void) ksig_pending();
|
||||
result = SUSPEND; /* don't reply */
|
||||
|
|
@ -217,11 +214,4 @@ PRIVATE void pm_init()
|
|||
printf("System services=%uK ", click_to_round_k(minix_clicks));
|
||||
printf("Available=%uK\n\n", click_to_round_k(free_clicks));
|
||||
|
||||
/* Register function keys with TTY for debug dumps. */
|
||||
for (key=SF7; key<=SF8; key++) {
|
||||
if ((i=fkey_enable(key))!=OK) {
|
||||
printf("Warning: PM couldn't register Shift+F%d key: %d\n",
|
||||
key-SF1+1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,13 @@ FORWARD _PROTOTYPE( char *find_key, (const char *params, const char *key));
|
|||
/* PM gets a copy of all boot monitor parameters. */
|
||||
PRIVATE char monitor_params[128*sizeof(char *)];
|
||||
|
||||
/*=====================================================================*
|
||||
* do_memalloc *
|
||||
*=====================================================================*/
|
||||
PUBLIC int do_memalloc()
|
||||
/*===========================================================================*
|
||||
* do_allocmem *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_allocmem()
|
||||
{
|
||||
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);
|
||||
|
|
@ -40,11 +39,17 @@ PUBLIC int do_memalloc()
|
|||
return(OK);
|
||||
}
|
||||
|
||||
/*=====================================================================*
|
||||
* do_memfree *
|
||||
*=====================================================================*/
|
||||
PUBLIC int do_memfree()
|
||||
/*===========================================================================*
|
||||
* do_freemem *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_freemem()
|
||||
{
|
||||
vir_clicks mem_clicks;
|
||||
phys_clicks mem_base;
|
||||
|
||||
mem_clicks = (m_in.memsize + CLICK_SIZE -1 ) >> CLICK_SHIFT;
|
||||
mem_base = (m_in.membase + CLICK_SIZE -1 ) >> CLICK_SHIFT;
|
||||
free_mem(mem_base, mem_clicks);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ _PROTOTYPE( int do_reboot, (void) );
|
|||
_PROTOTYPE( int do_getsysinfo, (void) );
|
||||
_PROTOTYPE( int do_getprocnr, (void) );
|
||||
_PROTOTYPE( int do_svrctl, (void) );
|
||||
_PROTOTYPE( int do_memalloc, (void) );
|
||||
_PROTOTYPE( int do_memfree, (void) );
|
||||
_PROTOTYPE( int do_allocmem, (void) );
|
||||
_PROTOTYPE( int do_freemem, (void) );
|
||||
_PROTOTYPE( int do_mstats, (void) );
|
||||
|
||||
#if (MACHINE == MACINTOSH)
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
|||
do_getprocnr, /* 80 = getprocnr */
|
||||
no_sys, /* 81 = unused */
|
||||
no_sys, /* 82 = fstatfs */
|
||||
do_memalloc, /* 83 = memalloc */
|
||||
do_memfree, /* 84 = memfree */
|
||||
do_allocmem, /* 83 = memalloc */
|
||||
do_freemem, /* 84 = memfree */
|
||||
};
|
||||
/* This should not fail with "array size is negative": */
|
||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user