From: Jorrit Herder Date: Thu, 4 Aug 2005 09:26:36 +0000 (+0000) Subject: Miscellaneous clean ups and fixes to the kernel. X-Git-Tag: v3.1.0~456 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.log?a=commitdiff_plain;h=e561081545b2f62d0e9722efff21533d6795f3ae;p=minix.git Miscellaneous clean ups and fixes to the kernel. Support for FLOPPY in boot image. (Set controller=fd at boot monitor.) Moved major device numbers to (maybe rename to dev.h?) --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 572cab717..2c5ff0e5a 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -149,7 +149,7 @@ struct command { #define MAX_SECS 127 /* but not to a 16 bit process */ #endif #define MAX_ERRORS 4 /* how often to try rd/wt before quitting */ -#define NR_DEVICES (MAX_DRIVES * DEV_PER_DRIVE) +#define NR_MINORS (MAX_DRIVES * DEV_PER_DRIVE) #define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS) #define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE) #define DELAY_USECS 1000 /* controller timeout in microseconds */ @@ -392,7 +392,7 @@ int device; /* Prepare for I/O on a device. */ w_device = device; - if (device < NR_DEVICES) { /* d0, d0p[0-3], d1, ... */ + if (device < NR_MINORS) { /* d0, d0p[0-3], d1, ... */ w_drive = device / DEV_PER_DRIVE; /* save drive number */ w_wn = &wini[w_drive]; w_dv = &w_wn->part[device % DEV_PER_DRIVE]; diff --git a/drivers/bios_wini/bios_wini.c b/drivers/bios_wini/bios_wini.c index c58e9cfda..87bd69192 100644 --- a/drivers/bios_wini/bios_wini.c +++ b/drivers/bios_wini/bios_wini.c @@ -38,7 +38,7 @@ /* Parameters for the disk drive. */ #define MAX_DRIVES 4 /* this driver supports 4 drives (d0 - d3)*/ #define MAX_SECS 255 /* bios can transfer this many sectors */ -#define NR_DEVICES (MAX_DRIVES * DEV_PER_DRIVE) +#define NR_MINORS (MAX_DRIVES * DEV_PER_DRIVE) #define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS) #define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE) @@ -108,7 +108,7 @@ int device; { /* Prepare for I/O on a device. */ - if (device < NR_DEVICES) { /* d0, d0p[0-3], d1, ... */ + if (device < NR_MINORS) { /* d0, d0p[0-3], d1, ... */ w_drive = device / DEV_PER_DRIVE; /* save drive number */ w_wn = &wini[w_drive]; w_dv = &w_wn->part[device % DEV_PER_DRIVE]; diff --git a/drivers/drivers.h b/drivers/drivers.h index a5812b12c..307906bce 100644 --- a/drivers/drivers.h +++ b/drivers/drivers.h @@ -10,6 +10,7 @@ #include /* MUST be second */ #include #include +#include #include #include #include diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 0cec43b89..4c24a4c33 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -181,8 +181,6 @@ PUBLIC void main(void) panic("TTY","Couldn't obtain kernel environment.", s); } - printf("User-level TTY driver alive!\n"); - while (TRUE) { /* Check for and handle any events on any of the ttys. */ diff --git a/etc/usr/rc b/etc/usr/rc index db863e99c..b90bfb21c 100644 --- a/etc/usr/rc +++ b/etc/usr/rc @@ -62,9 +62,9 @@ start) # Cleanup. rm -rf /tmp/. /usr/run/. /usr/spool/lpd/. /usr/spool/locks/. - echo -n "Starting " + # Start servers and drivers set at the boot monitor. + echo -n "Starting services:" up random "" /dev/random - echo . # load random number generator if [ -f $RANDOM_FILE ] @@ -74,11 +74,14 @@ start) dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null fi - # Start servers and drivers set at the boot monitor. - echo -n "Starting services:" - up rtl8139 "" - up fxp "" - up dpeth "" + # start only network drivers that are in use + for driver in rtl8139 fxp dpeth + do + if grep " $driver " /etc/inet.conf > /dev/null + then + up $driver + fi + done up inet "" up is "" up printer "" /dev/lp diff --git a/include/minix/com.h b/include/minix/com.h index d85f603f7..3ce68029b 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -48,32 +48,6 @@ #define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1) -/*===========================================================================* - * Major and minor device numbers * - *===========================================================================*/ - -/* Major and minor device numbers for MEMORY driver. */ -#define MEMORY_MAJOR 1 /* major device for memory devices */ -# define RAM_DEV 0 /* minor device for /dev/ram */ -# define MEM_DEV 1 /* minor device for /dev/mem */ -# define KMEM_DEV 2 /* minor device for /dev/kmem */ -# define NULL_DEV 3 /* minor device for /dev/null */ -# define BOOT_DEV 4 /* minor device for /dev/boot */ -# define ZERO_DEV 6 /* minor device for /dev/zero */ - -/* Full device numbers that are special to the boot monitor and FS. */ -# define DEV_RAM 0x0100 /* device number of /dev/ram */ -# define DEV_BOOT 0x0104 /* device number of /dev/boot */ - -#define TTY_MAJOR 4 /* major device for ttys */ -#define CTTY_MAJOR 5 /* major device for /dev/tty */ - -#define INET_MAJOR 7 /* major device for inet */ - -#define LOG_MAJOR 15 /* major device for log driver */ -# define IS_KLOG_DEV 0 /* minor device for /dev/klog */ - - /*===========================================================================* * Kernel notification types * *===========================================================================*/ diff --git a/include/minix/dmap.h b/include/minix/dmap.h index 2f82fe87a..1cacb17d4 100644 --- a/include/minix/dmap.h +++ b/include/minix/dmap.h @@ -4,6 +4,10 @@ #include #include +/*===========================================================================* + * Device <-> Driver Table * + *===========================================================================*/ + /* Device table. This table is indexed by major device number. It provides * the link between major device numbers and the routines that process them. * The table can be update dynamically. The field 'dmap_flags' describe an @@ -22,4 +26,34 @@ extern struct dmap { } dmap[]; +/*===========================================================================* + * Major and minor device numbers * + *===========================================================================*/ + +/* Total number of different devices. */ +#define NR_DEVICES 32 /* number of (major) devices */ + +/* Major and minor device numbers for MEMORY driver. */ +#define MEMORY_MAJOR 1 /* major device for memory devices */ +# define RAM_DEV 0 /* minor device for /dev/ram */ +# define MEM_DEV 1 /* minor device for /dev/mem */ +# define KMEM_DEV 2 /* minor device for /dev/kmem */ +# define NULL_DEV 3 /* minor device for /dev/null */ +# define BOOT_DEV 4 /* minor device for /dev/boot */ +# define ZERO_DEV 6 /* minor device for /dev/zero */ + +/* Full device numbers that are special to the boot monitor and FS. */ +# define DEV_RAM 0x0100 /* device number of /dev/ram */ +# define DEV_BOOT 0x0104 /* device number of /dev/boot */ + +#define FLOPPY_MAJOR 2 /* major device for floppy disks */ +#define TTY_MAJOR 4 /* major device for ttys */ +#define CTTY_MAJOR 5 /* major device for /dev/tty */ + +#define INET_MAJOR 7 /* major device for inet */ + +#define LOG_MAJOR 15 /* major device for log driver */ +# define IS_KLOG_DEV 0 /* minor device for /dev/klog */ + + #endif /* _DMAP_H */ diff --git a/kernel/clock.c b/kernel/clock.c index 0e24c1943..008039db3 100755 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -297,8 +297,5 @@ PUBLIC unsigned long read_clock() #endif /* (CHIP == INTEL) */ -#if (CHIP == M68000) -/* Initialize the timer C in the MFP 68901: implement init_clock() here. */ -#endif /* (CHIP == M68000) */ diff --git a/kernel/config.h b/kernel/config.h index e0aeb0709..88d69a3a1 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -5,7 +5,8 @@ * kernel buffers and to enable or disable debugging code, timing features, * and individual kernel calls. * - * Created: Jul 11, 2005 Jorrit N. Herder + * Changes: + * Jul 11, 2005 Created. (Jorrit N. Herder) */ /* In embedded and sensor applications, not all the kernel calls may be diff --git a/kernel/ipc.h b/kernel/ipc.h index e4ae8246e..ca53339ab 100644 --- a/kernel/ipc.h +++ b/kernel/ipc.h @@ -1,6 +1,9 @@ #ifndef IPC_H #define IPC_H +/* This header file defines constants for MINIX inter-process communication. + * These definitions are used in the file proc.c. + */ #include /* Masks and flags for system calls. */ diff --git a/kernel/priv.h b/kernel/priv.h index 1d4f8dddd..a51bcc0d4 100755 --- a/kernel/priv.h +++ b/kernel/priv.h @@ -8,7 +8,8 @@ * user processes share one structure. This setup provides a clear separation * between common and privileged process fields and is very space efficient. * - * Created: Jul 1, 2005 Jorrit N. Herder + * Changes: + * Jul 01, 2005 Created. (Jorrit N. Herder) */ #include #include "protect.h" diff --git a/kernel/proc.c b/kernel/proc.c index 9cae2905c..1de7c4476 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -13,12 +13,12 @@ * lock_sched: a process has run too long; schedule another one * * Changes: - * Jul 25, 2005 better protection in sys_call() (Jorrit N. Herder) - * May 26, 2005 optimized message passing functions (Jorrit N. Herder) + * Jul 25, 2005 protection and checks in sys_call() (Jorrit N. Herder) + * May 26, 2005 rewrite of message passing functions (Jorrit N. Herder) * May 24, 2005 new, queued NOTIFY system call (Jorrit N. Herder) * Oct 28, 2004 new, non-blocking SEND and RECEIVE (Jorrit N. Herder) * Oct 28, 2004 rewrite of sys_call() function (Jorrit N. Herder) - * Aug 19, 2004 generalized multilevel scheduling (Jorrit N. Herder) + * Aug 19, 2004 rewrite of multilevel scheduling (Jorrit N. Herder) * * The code here is critical to make everything work and is important for the * overall performance of the system. A large fraction of the code deals with diff --git a/kernel/proto.h b/kernel/proto.h index 2cb05fa6f..7a1e3c320 100755 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -36,15 +36,15 @@ _PROTOTYPE( void cstart, (U16_t cs, U16_t ds, U16_t mds, U16_t parmoff, U16_t parmsize) ); /* system.c */ +_PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) ); _PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) ); _PROTOTYPE( void cause_sig, (int proc_nr, int sig_nr) ); -_PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) ); -_PROTOTYPE( phys_bytes numap_local, (int proc_nr, vir_bytes vir_addr, - vir_bytes bytes) ); _PROTOTYPE( void sys_task, (void) ); _PROTOTYPE( void get_randomness, (int source) ); _PROTOTYPE( int virtual_copy, (struct vir_addr *src, struct vir_addr *dst, vir_bytes bytes) ); +#define numap_local(proc_nr, vir_addr, bytes) \ + umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes)) _PROTOTYPE( phys_bytes umap_local, (struct proc *rp, int seg, vir_bytes vir_addr, vir_bytes bytes) ); _PROTOTYPE( phys_bytes umap_remote, (struct proc *rp, int seg, diff --git a/kernel/system.c b/kernel/system.c index 714bf3732..8ab22bcaf 100755 --- a/kernel/system.c +++ b/kernel/system.c @@ -17,14 +17,15 @@ * umap_local: map virtual address in LOCAL_SEG to physical * umap_remote: map virtual address in REMOTE_SEG to physical * 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 * * Changes: + * 2004 to 2005 many new system calls (see system.h) (Jorrit N. Herder) + * Jul 20, 2005 send signal to services with message (Jorrit N. Herder) + * Jan 15, 2005 new, generalized virtual copy function (Jorrit N. Herder) * Oct 10, 2004 dispatch system calls from call vector (Jorrit N. Herder) * Sep 30, 2004 source code documentation updated (Jorrit N. Herder) - * 2004 to 2005 various new syscalls (see system.h) (Jorrit N. Herder) */ #include "kernel.h" @@ -121,11 +122,12 @@ PRIVATE void initialize(void) call_vec[i] = do_unused; } + /* Process management. */ map(SYS_FORK, do_fork); /* a process forked a new process */ - map(SYS_NEWMAP, do_newmap); /* set up a process memory map */ map(SYS_EXEC, do_exec); /* update process after execute */ map(SYS_EXIT, do_exit); /* clean up after process exit */ map(SYS_NICE, do_nice); /* set scheduling priority */ + map(SYS_PRIVCTL, do_privctl); /* system privileges control */ map(SYS_TRACE, do_trace); /* request a trace operation */ /* Signal handling. */ @@ -135,22 +137,17 @@ PRIVATE void initialize(void) map(SYS_SIGSEND, do_sigsend); /* start POSIX-style signal */ map(SYS_SIGRETURN, do_sigreturn); /* return from POSIX-style signal */ - /* Clock functionality. */ - map(SYS_TIMES, do_times); /* get uptime and process times */ - map(SYS_SETALARM, do_setalarm); /* schedule a synchronous alarm */ - /* Device I/O. */ map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */ map(SYS_DEVIO, do_devio); /* inb, inw, inl, outb, outw, outl */ map(SYS_SDEVIO, do_sdevio); /* phys_insb, _insw, _outsb, _outsw */ map(SYS_VDEVIO, do_vdevio); /* vector with devio requests */ - map(SYS_INT86, do_int86); /* BIOS call */ + map(SYS_INT86, do_int86); /* real-mode BIOS calls */ - /* System control. */ - map(SYS_ABORT, do_abort); /* abort MINIX */ - map(SYS_GETINFO, do_getinfo); /* request system information */ - map(SYS_PRIVCTL, do_privctl); /* system privileges control */ + /* Memory management. */ + map(SYS_NEWMAP, do_newmap); /* set up a process memory map */ map(SYS_SEGCTL, do_segctl); /* add segment and get selector */ + map(SYS_MEMSET, do_memset); /* write char to memory area */ /* Copying. */ map(SYS_UMAP, do_umap); /* map virtual to physical address */ @@ -158,7 +155,14 @@ PRIVATE void initialize(void) map(SYS_PHYSCOPY, do_physcopy); /* use physical addressing */ map(SYS_VIRVCOPY, do_virvcopy); /* vector with copy requests */ map(SYS_PHYSVCOPY, do_physvcopy); /* vector with copy requests */ - map(SYS_MEMSET, do_memset); /* write char to memory area */ + + /* Clock functionality. */ + map(SYS_TIMES, do_times); /* get uptime and process times */ + map(SYS_SETALARM, do_setalarm); /* schedule a synchronous alarm */ + + /* System control. */ + map(SYS_ABORT, do_abort); /* abort MINIX */ + map(SYS_GETINFO, do_getinfo); /* request system information */ } @@ -184,6 +188,7 @@ int proc_type; /* system or user process flag */ } else { rc->p_priv = &priv[USER_PRIV_ID]; /* use shared slot */ rc->p_priv->s_proc_nr = INIT_PROC_NR; /* set association */ + rc->p_priv->s_flags = 0; /* no initial flags */ } return(OK); } @@ -195,21 +200,18 @@ int proc_type; /* system or user process flag */ PUBLIC void get_randomness(source) int source; { -/* 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. - */ +/* On machines with the RDTSC (cycle counter read instruction - pentium + * and up), use that for high-resolution raw entropy gathering. Otherwise, + * use the realtime clock (tick resolution). + * + * Unfortunately this test is run-time - we don't want to bother with + * compiling different kernels for different machines. + * + * On machines without RDTSC, we use read_clock(). + */ int r_next; unsigned long tsc_high, tsc_low; - /* On machines with the RDTSC (cycle counter read instruction - pentium - * and up), use that for high-resolution raw entropy gathering. Otherwise, - * use the realtime clock (tick resolution). - * - * Unfortunately this test is run-time - we don't want to bother with - * compiling different kernels for different machines.. - * - * On machines without RDTSC, we use read_clock(). - */ source %= RANDOM_SOURCES; r_next= krandom.bin[source].r_next; if(machine.processor > 486) { @@ -300,7 +302,7 @@ vir_bytes bytes; /* # of bytes to be copied */ else if (vir_addr >= BASE_MEM_TOP && vir_addr + bytes <= UPPER_MEM_END) return (phys_bytes) vir_addr; -#if DEAD_CODE /* brutal fix for QEMU and Bochs, if above doesn't work */ +#if DEAD_CODE /* brutal fix, if the above is too restrictive */ if (vir_addr >= BIOS_MEM_BEGIN && vir_addr + bytes <= UPPER_MEM_END) return (phys_bytes) vir_addr; #endif @@ -368,22 +370,6 @@ vir_bytes bytes; /* # of bytes to be copied */ #endif } -/*==========================================================================* - * numap_local * - *==========================================================================*/ -PUBLIC phys_bytes numap_local(proc_nr, vir_addr, bytes) -int proc_nr; /* process number to be mapped */ -vir_bytes vir_addr; /* virtual address in bytes within D seg */ -vir_bytes bytes; /* # of bytes required in segment */ -{ -/* Do umap_local() starting from a process number instead of a pointer. - * This function is used by device drivers, so they need not know about the - * process table. To save time, there is no 'seg' parameter. The segment - * is always D. - */ - return(umap_local(proc_addr(proc_nr), D, vir_addr, bytes)); -} - /*===========================================================================* * umap_remote * diff --git a/kernel/system.h b/kernel/system.h index 3073bce69..d1564a6eb 100644 --- a/kernel/system.h +++ b/kernel/system.h @@ -13,6 +13,7 @@ /* Common includes for the system library. */ #include "kernel.h" +#include "proto.h" #include "proc.h" /* Default handler for unused kernel calls. */ diff --git a/kernel/system/do_devio.c b/kernel/system/do_devio.c index 03e6103c4..5d22d63b8 100644 --- a/kernel/system/do_devio.c +++ b/kernel/system/do_devio.c @@ -2,13 +2,10 @@ * m_type: SYS_DEVIO * * The parameters for this system call are: - * m2_i3: DIO_REQUEST (request input or output) - * m2_i1: DIO_TYPE (flag indicating byte, word, or long) - * m2_l1: DIO_PORT (port to read/ write) - * m2_l2: DIO_VALUE (value to write/ return value read) - * - * Author: - * Jorrit N. Herder + * m2_i3: DIO_REQUEST (request input or output) + * m2_i1: DIO_TYPE (flag indicating byte, word, or long) + * m2_l1: DIO_PORT (port to read/ write) + * m2_l2: DIO_VALUE (value to write/ return value read) */ #include "../system.h" diff --git a/kernel/system/do_fork.c b/kernel/system/do_fork.c index a68f65250..a1b0b6008 100644 --- a/kernel/system/do_fork.c +++ b/kernel/system/do_fork.c @@ -32,20 +32,6 @@ register message *m_ptr; /* pointer to request message */ rpc = proc_addr(m_ptr->PR_PROC_NR); if (isemptyp(rpp) || ! isemptyp(rpc)) return(EINVAL); -#if DEAD_CODE - /* If the parent is a privileged process, ensure the child process also gets - * its own privilege structure for accounting. This is the only part that can - * fail, so do this before allocating the process table slot. - */ - if (priv(rpp)->s_flags & SYS_PROC) { - if (OK != (i=get_priv(rpc, SYS_PROC))) return(i); /* get structure */ - for (i=0; i< BITMAP_CHUNKS(NR_SYS_PROCS); i++) /* remove pending: */ - priv(rpc)->s_notify_pending.chunk[i] = 0; /* - notifications */ - priv(rpc)->s_int_pending = 0; /* - interrupts */ - sigemptyset(&priv(rpc)->s_sig_pending); /* - signals */ - } -#endif - /* Copy parent 'proc' struct to child. And reinitialize some fields. */ #if (CHIP == INTEL) old_ldt_sel = rpc->p_ldt_sel; /* backup local descriptors */ diff --git a/kernel/system/do_getinfo.c b/kernel/system/do_getinfo.c index 8b09f572d..9159a79d1 100644 --- a/kernel/system/do_getinfo.c +++ b/kernel/system/do_getinfo.c @@ -7,9 +7,6 @@ * m1_i1: I_VAL_LEN (maximum length expected, optional) * m1_p2: I_VAL_PTR2 (second, optional pointer) * m1_i2: I_VAL_LEN2 (second length or process nr) - * - * Author: - * Jorrit N. Herder */ #include "../system.h" diff --git a/kernel/system/do_irqctl.c b/kernel/system/do_irqctl.c index 3833606ef..ae349c60c 100644 --- a/kernel/system/do_irqctl.c +++ b/kernel/system/do_irqctl.c @@ -7,9 +7,6 @@ * m5_i1: IRQ_POLICY (irq policy allows reenabling interrupts) * m5_l3: IRQ_HOOK_ID (provides index to be returned on interrupt) * ,, ,, (returns index of irq hook assigned at kernel) - * - * Author: - * Jorrit N. Herder */ #include "../system.h" diff --git a/kernel/system/do_privctl.c b/kernel/system/do_privctl.c index 3fbf495e4..003f16d91 100644 --- a/kernel/system/do_privctl.c +++ b/kernel/system/do_privctl.c @@ -48,7 +48,7 @@ message *m_ptr; /* pointer to request message */ */ if ((i=get_priv(rp, SYS_PROC)) != OK) return(i); priv_id = priv(rp)->s_id; /* backup privilege id */ - *priv(rp) = *priv(caller_ptr); /* copy privileges */ + *priv(rp) = *priv(caller_ptr); /* copy from caller */ priv(rp)->s_id = priv_id; /* restore privilege id */ priv(rp)->s_proc_nr = proc_nr; /* reassociate process nr */ diff --git a/kernel/system/do_segctl.c b/kernel/system/do_segctl.c index 5d1060097..9b29e5f22 100644 --- a/kernel/system/do_segctl.c +++ b/kernel/system/do_segctl.c @@ -7,9 +7,6 @@ * m4_l1: SEG_SELECT (return segment selector here) * m4_l2: SEG_OFFSET (return offset within segment here) * m4_l5: SEG_INDEX (return index into remote memory map here) - * - * Author: - * Jorrit N. Herder */ #include "../system.h" #include "../protect.h" diff --git a/kernel/table.c b/kernel/table.c index 0bf9d0bb8..2c15deb5c 100755 --- a/kernel/table.c +++ b/kernel/table.c @@ -22,7 +22,7 @@ * include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c). * * Changes: - * Nov 10, 2004 removed controller->driver mappings (Jorrit N. Herder) + * Aug 02, 2005 minimal boot image and cleanup (Jorrit N. Herder) * Oct 17, 2004 updated above and tasktab comments (Jorrit N. Herder) * May 01, 2004 changed struct for system image (Jorrit N. Herder) */ @@ -37,26 +37,26 @@ /* Define stack sizes for the kernel tasks included in the system image. */ #define NO_STACK 0 #define SMALL_STACK (128 * sizeof(char *)) -#define IDLE_S SMALL_STACK /* 3 intr, 3 temps, 4 db for Intel */ -#define HRDW_S NO_STACK /* dummy task, uses kernel stack */ -#define TASK_S SMALL_STACK /* system and clock task */ +#define IDL_S SMALL_STACK /* 3 intr, 3 temps, 4 db for Intel */ +#define HRD_S NO_STACK /* dummy task, uses kernel stack */ +#define TSK_S SMALL_STACK /* system and clock task */ /* Stack space for all the task stacks. Declared as (char *) to align it. */ -#define TOT_STACK_SPACE (IDLE_S + HRDW_S + (2 * TASK_S)) +#define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S)) PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; /* Define flags for the various process types. */ -#define IDLE_F (BILLABLE | SYS_PROC) /* idle task */ -#define TASK_F (SYS_PROC) /* kernel tasks */ -#define SERV_F (PREEMPTIBLE | SYS_PROC) /* system services */ -#define USER_F (PREEMPTIBLE | BILLABLE) /* user processes */ +#define IDL_F (BILLABLE | SYS_PROC) /* idle task */ +#define TSK_F (SYS_PROC) /* kernel tasks */ +#define SRV_F (PREEMPTIBLE | SYS_PROC) /* system services */ +#define USR_F (PREEMPTIBLE | BILLABLE) /* user processes */ /* Define system call traps for the various process types. These call masks * determine what system call traps a process is allowed to make. */ -#define TASK_T (1 << RECEIVE) /* clock and system */ -#define SERV_T (~0) /* system services */ -#define USER_T ((1 << SENDREC) | (1 << ECHO)) /* user processes */ +#define TSK_T (1 << RECEIVE) /* clock and system */ +#define SRV_T (~0) /* system services */ +#define USR_T ((1 << SENDREC) | (1 << ECHO)) /* user processes */ /* Send masks determine to whom processes can send messages or notifications. * The values here are used for the processes in the boot image. We rely on @@ -69,11 +69,10 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; * "BITCHUNK_BITS - NR_TASKS", because a bitchunk_t field is used to store * the send masks in the table that describes that processes in the image. */ -#define SERV_M (~0) -#define SYST_M (~0) -#define USER_M (s(PM_PROC_NR)|s(FS_PROC_NR)|s(SM_PROC_NR)) -#define DRIV_M (USER_M | \ - s(SYSTEM)|s(CLOCK)|s(LOG_PROC_NR)|s(TTY_PROC_NR)) +#define SRV_M (~0) +#define SYS_M (~0) +#define USR_M (s(PM_PROC_NR)|s(FS_PROC_NR)|s(SM_PROC_NR)) +#define DRV_M (USR_M | s(SYSTEM)|s(CLOCK)|s(LOG_PROC_NR)|s(TTY_PROC_NR)) /* Sanity check to make sure the send masks can be set. */ extern int dummy[(BITCHUNK_BITS-NR_TASKS > INIT_PROC_NR) ? 1 : -1]; @@ -87,19 +86,19 @@ extern int dummy[(BITCHUNK_BITS-NR_TASKS > INIT_PROC_NR) ? 1 : -1]; * initial program counter and stack size is also provided for kernel tasks. */ PUBLIC struct boot_image image[] = { -/* process nr, pc, flags, qs, queue, stack, traps, ipc mask, name */ - { IDLE, idle_task, IDLE_F, 32, IDLE_Q, IDLE_S, 0, 0, "IDLE" }, - { CLOCK, clock_task, TASK_F, 0, TASK_Q, TASK_S, TASK_T, 0, "CLOCK" }, - { SYSTEM, sys_task, TASK_F, 0, TASK_Q, TASK_S, TASK_T, 0, "SYSTEM" }, - { HARDWARE, 0, TASK_F, 0, TASK_Q, HRDW_S, 0, 0, "KERNEL" }, - { PM_PROC_NR, 0, SERV_F, 16, 3, 0, SERV_T, SERV_M, "pm" }, - { FS_PROC_NR, 0, SERV_F, 16, 4, 0, SERV_T, SERV_M, "fs" }, - { SM_PROC_NR, 0, SERV_F, 16, 3, 0, SERV_T, SYST_M, "sm" }, - { TTY_PROC_NR, 0, SERV_F, 16, 1, 0, SERV_T, SYST_M, "tty" }, - { MEM_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, DRIV_M, "memory" }, - { LOG_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, SYST_M, "log" }, - { DRVR_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, DRIV_M, "driver" }, - { INIT_PROC_NR, 0, USER_F, 8, USER_Q, 0, USER_T, USER_M, "init" }, +/* process nr, pc, flags, qs, queue, stack, traps, ipc, sys, name */ + { IDLE, idle_task, IDL_F, 32, IDLE_Q, IDL_S, 0, 0, 0, "IDLE" }, + { CLOCK,clock_task, TSK_F, 0, TASK_Q, TSK_S, TSK_T, 0, 0, "CLOCK" }, + { SYSTEM, sys_task, TSK_F, 0, TASK_Q, TSK_S, TSK_T, 0, 0, "SYSTEM" }, + { HARDWARE, 0, TSK_F, 0, TASK_Q, HRD_S, 0, 0, 0, "KERNEL" }, + { PM_PROC_NR, 0, SRV_F, 16, 3, 0, SRV_T, SRV_M, ~0, "pm" }, + { FS_PROC_NR, 0, SRV_F, 16, 4, 0, SRV_T, SRV_M, ~0, "fs" }, + { SM_PROC_NR, 0, SRV_F, 16, 3, 0, SRV_T, SYS_M, ~0, "sm" }, + { TTY_PROC_NR, 0, SRV_F, 16, 1, 0, SRV_T, SYS_M, ~0, "tty" }, + { MEM_PROC_NR, 0, SRV_F, 16, 2, 0, SRV_T, DRV_M, ~0, "memory" }, + { LOG_PROC_NR, 0, SRV_F, 16, 2, 0, SRV_T, SYS_M, ~0, "log" }, + { DRVR_PROC_NR, 0, SRV_F, 16, 2, 0, SRV_T, DRV_M, ~0, "driver" }, + { INIT_PROC_NR, 0, USR_F, 8, USER_Q, 0, USR_T, USR_M, 0, "init" }, }; /* Verify the size of the system image table at compile time. If the number diff --git a/kernel/type.h b/kernel/type.h index 5db894229..12e3d41ce 100755 --- a/kernel/type.h +++ b/kernel/type.h @@ -17,8 +17,9 @@ struct boot_image { char quantum; /* quantum (tick count) */ int priority; /* scheduling priority */ int stksize; /* stack size for tasks */ - short call_mask; /* allowed system calls */ + short call_mask; /* allowed system call traps */ bitchunk_t send_mask; /* send mask protection */ + long sys_mask; /* system call protection */ char proc_name[P_NAME_LEN]; /* name in process table */ }; diff --git a/kernel/utility.c b/kernel/utility.c index ceb11ba43..981fe0eb2 100755 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -1,9 +1,9 @@ /* This file contains a collection of miscellaneous procedures: - * panic: abort MINIX due to a fatal error - * kprintf: diagnostic output for the kernel + * panic: abort MINIX due to a fatal error + * kprintf: diagnostic output for the kernel * * Changes: - * simple printing to circular buffer (Jorrit N. Herder) + * Dec 10, 2004 kernel printing to circular buffer (Jorrit N. Herder) * * This file contains the routines that take care of kernel messages, i.e., * diagnostic output within the kernel. Kernel messages are not directly diff --git a/servers/fs/const.h b/servers/fs/const.h index fc46429f4..ea01d0574 100644 --- a/servers/fs/const.h +++ b/servers/fs/const.h @@ -9,8 +9,6 @@ #define NR_SUPERS 8 /* # slots in super block table */ #define NR_LOCKS 8 /* # slots in the file locking table */ -#define NR_DEVICES 17 /* # slots in the device <-> driver table */ - /* The type of sizeof may be (unsigned) long. Use the following macro for * taking the sizes of small objects so that there are no surprises like * (small) long constants being passed to routines expecting an int. diff --git a/servers/fs/dmap.c b/servers/fs/dmap.c index dbf158341..0e9afbea8 100644 --- a/servers/fs/dmap.c +++ b/servers/fs/dmap.c @@ -117,37 +117,50 @@ int style; /* style of the device */ } /*===========================================================================* - * map_controllers * + * map_controller * *===========================================================================*/ -PUBLIC void map_controllers() +PUBLIC void map_controller() { -/* Map the boot drivers to a controller and update the dmap table to that +/* Map the boot driver to a controller and update the dmap table to that * selection. The boot driver and the controller it handles are set at the * boot monitor. */ char driver[16]; char *controller = "c##"; - int number; + int nr, major = -1; int i,s; + + /* Get settings of 'controller' and 'driver' at the boot monitor. */ if ((s = get_mon_param("label", driver, sizeof(driver))) != OK) panic(__FILE__,"couldn't get boot monitor parameter 'driver'", s); if ((s = get_mon_param("controller", controller, sizeof(controller))) != OK) panic(__FILE__,"couldn't get boot monitor parameter 'controller'", s); - if (controller[0] != 'c' || ! isdigit(controller[1])) - panic(__FILE__,"monitor parameter 'controller' syntax is 'c#'", NO_NUM); - if ((number = (unsigned) atoi(&controller[1])) > NR_CTRLRS) - panic(__FILE__,"monitor parameter 'controller' maximum is", NR_CTRLRS); - - for (i=0; i< NR_DEVICES; i++) { /* find controller */ - if (dmap[i].dmap_driver == CTRLR(number)) { - if ((s=map_driver(i, DRVR_PROC_NR, STYLE_DEV)) != OK) - panic(__FILE__,"map_driver failed",s); - printf("Boot medium driver: %s driver mapped onto controller c%d.\n", - driver, number); - return; /* success! */ + + /* Determine major number to map driver onto. */ + if (controller[0] == 'f' && controller[1] == 'd') { + major = FLOPPY_MAJOR; + } + else if (controller[0] == 'c' && isdigit(controller[1])) { + if ((nr = (unsigned) atoi(&controller[1])) > NR_CTRLRS) + panic(__FILE__,"monitor 'controller' maximum 'c#' is", NR_CTRLRS); + for (i=0; i< NR_DEVICES; i++) { /* find controller */ + if (dmap[i].dmap_driver == CTRLR(nr)) { + major = i; + break; + } } + if ((unsigned) major >= NR_DEVICES) + panic(__FILE__, "cannot find controller in dmap, number", nr); + } + else { + panic(__FILE__,"monitor 'controller' syntax is 'c#' of 'fd'", NO_NUM); } - panic(__FILE__, "cannot find controller in dmap, number", number); + + /* Now try to set the actual mapping and report to the user. */ + if ((s=map_driver(i, DRVR_PROC_NR, STYLE_DEV)) != OK) + panic(__FILE__,"map_driver failed",s); + printf("Boot medium driver: %s driver mapped onto controller %s.\n", + driver, controller); } diff --git a/servers/fs/main.c b/servers/fs/main.c index 4d032f81a..37e006dd0 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -225,7 +225,7 @@ PRIVATE void fs_init() who = FS_PROC_NR; buf_pool(); /* initialize buffer pool */ - map_controllers(); /* map controller devices to drivers */ + map_controller(); /* map boot driver onto controller */ load_ram(); /* init RAM disk, load if it is root */ load_super(root_dev); /* load super block for root device */ init_select(); /* init select() structures */ diff --git a/servers/fs/proto.h b/servers/fs/proto.h index 6a7cc0d6e..81cb74cc0 100644 --- a/servers/fs/proto.h +++ b/servers/fs/proto.h @@ -48,7 +48,7 @@ _PROTOTYPE( int do_fkey_pressed, (void) ); /* dmap.c */ _PROTOTYPE( int do_devctl, (void) ); -_PROTOTYPE( void map_controllers, (void) ); +_PROTOTYPE( void map_controller, (void) ); _PROTOTYPE( int map_driver, (int major, int proc_nr, int dev_style) ); /* filedes.c */ diff --git a/tools/Makefile b/tools/Makefile index de661089b..d24edbdc4 100755 --- a/tools/Makefile +++ b/tools/Makefile @@ -19,6 +19,7 @@ PROGRAMS= ../kernel/kernel \ ../drivers/log/log \ AT:../drivers/at_wini/at_wini \ BIOS:../drivers/bios_wini/bios_wini \ + FLOPPY:../drivers/floppy/floppy \ ../servers/init/init \ # bootdev.img