From: Jorrit Herder Date: Fri, 5 Aug 2005 18:57:20 +0000 (+0000) Subject: Fix to device table at FS. X-Git-Tag: v3.1.0~413 X-Git-Url: http://zhaoyanbai.com/repos/jquery-3.1.1.min.js?a=commitdiff_plain;h=941b5ebd1c4714d7fa3f141f5829cfab093f4344;p=minix.git Fix to device table at FS. BIOS and AT installed in /sbin. Floppy boot fixed. --- diff --git a/drivers/at_wini/Makefile b/drivers/at_wini/Makefile index 25ea6ec7d..7cac818c1 100644 --- a/drivers/at_wini/Makefile +++ b/drivers/at_wini/Makefile @@ -30,8 +30,8 @@ $(LIBDRIVER): cd $d/libdriver && $(MAKE) # install with other drivers -install: /usr/sbin/$(DRIVER) -/usr/sbin/$(DRIVER): $(DRIVER) +install: /sbin/$(DRIVER) +/sbin/$(DRIVER): $(DRIVER) install -o root -cs $? $@ # clean up local files diff --git a/drivers/bios_wini/Makefile b/drivers/bios_wini/Makefile index f2922fd97..d07ba8499 100644 --- a/drivers/bios_wini/Makefile +++ b/drivers/bios_wini/Makefile @@ -30,8 +30,8 @@ $(LIBDRIVER): cd $d/libdriver && $(MAKE) # install with other drivers -install: /usr/sbin/$(DRIVER) -/usr/sbin/$(DRIVER): $(DRIVER) +install: /sbin/$(DRIVER) +/sbin/$(DRIVER): $(DRIVER) install -o root -cs $? $@ # clean up local files diff --git a/drivers/printer/printer.c b/drivers/printer/printer.c index 0ec5cf198..bcbfe2642 100644 --- a/drivers/printer/printer.c +++ b/drivers/printer/printer.c @@ -148,8 +148,9 @@ PUBLIC void main(void) break; case DEV_WRITE: do_write(&pr_mess); break; case DEV_STATUS: do_status(&pr_mess); break; - case CANCEL : do_cancel(&pr_mess); break; - case HARD_INT : do_printer_output(); break; + case CANCEL: do_cancel(&pr_mess); break; + case HARD_INT: do_printer_output(); break; + case SYS_SIG: /* do nothing */ break; default: reply(TASK_REPLY, pr_mess.m_source, pr_mess.PROC_NR, EINVAL); } diff --git a/etc/rc b/etc/rc index 96debe7c6..32806b00a 100755 --- a/etc/rc +++ b/etc/rc @@ -54,7 +54,10 @@ start) # Start crucial system services. The floppy driver *must* be loaded # first, as it needs memory below 16MB in order to do ISA DMA. echo -n "Starting services:" - up floppy "" /dev/fd0 + if [ ! "`sysenv label`" = "FLOPPY" ] + then up floppy "" /dev/fd0 + else up at_wini "" /dev/c0d0 + fi up is "" up cmos "" /dev/cmos echo . diff --git a/include/minix/com.h b/include/minix/com.h index 8c2881d64..ffaebb2f3 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -31,9 +31,6 @@ /* Number of tasks. Note that NR_PROCS is defined in . */ #define NR_TASKS 4 -/* Magic numbers for controllers. Device to driver mapping is dynamic. */ -#define CTRLR(n) (NONE + (n)) - /* User-space processes, that is, device drivers, servers, and INIT. */ #define PM_PROC_NR 0 /* process manager */ #define FS_PROC_NR 1 /* file system */ diff --git a/include/minix/dmap.h b/include/minix/dmap.h index 5465be06f..05f967f22 100644 --- a/include/minix/dmap.h +++ b/include/minix/dmap.h @@ -42,6 +42,8 @@ extern struct dmap { # define BOOT_DEV 4 /* minor device for /dev/boot */ # define ZERO_DEV 5 /* minor device for /dev/zero */ +#define CTRLR(n) ((n)==0 ? 3 : (8 + 2*((n)-1))) /* magic formula */ + /* 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 */ diff --git a/kernel/clock.c b/kernel/clock.c index 1b47081d6..d1e378fe5 100755 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -90,24 +90,13 @@ PUBLIC void clock_task() /* Go get a message. */ receive(ANY, &m); - /* Handle the request. */ + /* Handle the request. Only clock ticks are expected. */ switch (m.m_type) { - case HARD_INT: - result = do_clocktick(&m); /* handle clock tick */ - break; - default: /* illegal message type */ - kprintf("Warning, illegal CLOCK request from %d.\n", m.m_source); - result = EBADREQUEST; - } - - /* Send reply, unless inhibited, e.g. by do_clocktick(). Use the kernel - * function lock_send() to prevent a system call trap. The destination - * is known to be blocked waiting for a message. - */ - if (result != EDONTREPLY) { - m.m_type = result; - if (OK != lock_send(m.m_source, &m)) - kprintf("Warning, CLOCK couldn't reply to %d.\n", m.m_source); + case HARD_INT: + result = do_clocktick(&m); /* handle clock tick */ + break; + default: /* illegal request type */ + kprintf("CLOCK: illegal request %d from %d.\n", m.m_type,m.m_source); } } } diff --git a/kernel/main.c b/kernel/main.c index 676fcf06e..f49ed7976 100755 --- a/kernel/main.c +++ b/kernel/main.c @@ -220,7 +220,11 @@ int how; */ kprintf("MINIX will now be shut down ...\n"); tmr_arg(&shutdown_timer)->ta_int = how; +#if DEAD_CODE /* timer hangs the boot monitor ... to be fixed! */ set_timer(&shutdown_timer, get_uptime() + HZ, shutdown); +#else + shutdown(&shutdown_timer); +#endif } @@ -238,7 +242,7 @@ timer_t *tp; u16_t magic; /* Now mask all interrupts, including the clock, and stop the clock. */ - outb(INT_CTLMASK, ~1); + outb(INT_CTLMASK, ~0); clock_stop(); if (mon_return && how != RBT_RESET) { diff --git a/kernel/proc.c b/kernel/proc.c index e66cd27be..0ac064492 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -105,7 +105,6 @@ message *m_ptr; /* pointer to message in the caller's space */ unsigned flags = call_nr & SYSCALL_FLAGS; /* get flags */ int mask_entry; /* bit to check in send mask */ int result; /* the system call's result */ - vir_bytes vb; /* message buffer pointer as vir_bytes */ vir_clicks vlo, vhi; /* virtual clicks containing message to send */ /* Check if the process has privileges for the requested call. Calls to the @@ -113,13 +112,17 @@ message *m_ptr; /* pointer to message in the caller's space */ * if the caller doesn't do receive(). */ if (! (priv(caller_ptr)->s_trap_mask & (1 << function)) || - (iskerneln(src_dst) && function != SENDREC)) - return(ECALLDENIED); + (iskerneln(src_dst) && function != SENDREC)) { + kprintf("sys_call: trap not allowed, function %d, caller %d\n", + function, proc_nr(caller_ptr)); + return(ECALLDENIED); /* call denied by trap mask */ + } /* Require a valid source and/ or destination process, unless echoing. */ if (! (isokprocn(src_dst) || src_dst == ANY || function == ECHO)) { - kprintf("sys_call: function %d, src_dst %d\n", function, src_dst); - return(EBADSRCDST); + kprintf("sys_call: invalid src_dst, src_dst %d, caller %d\n", + src_dst, proc_nr(caller_ptr)); + return(EBADSRCDST); /* invalid process number */ } /* If the call involves a message buffer, i.e., for SEND, RECEIVE, SENDREC, @@ -128,12 +131,15 @@ message *m_ptr; /* pointer to message in the caller's space */ * for machines which don't have the gap mapped. */ if (function & CHECK_PTR) { - vb = (vir_bytes) m_ptr; /* virtual clicks */ - vlo = vb >> CLICK_SHIFT; /* bottom of message */ - vhi = (vb + MESS_SIZE - 1) >> CLICK_SHIFT; /* top of message */ + vlo = (vir_bytes) m_ptr >> CLICK_SHIFT; + vhi = ((vir_bytes) m_ptr + MESS_SIZE - 1) >> CLICK_SHIFT; if (vlo < caller_ptr->p_memmap[D].mem_vir || vlo > vhi || vhi >= caller_ptr->p_memmap[S].mem_vir + - caller_ptr->p_memmap[S].mem_len) return(EFAULT); + caller_ptr->p_memmap[S].mem_len) { + kprintf("sys_call: invalid message pointer, function %d, caller %d\n", + function, proc_nr(caller_ptr)); + return(EFAULT); /* invalid message pointer */ + } } /* If the call is to send to a process, i.e., for SEND, SENDREC or NOTIFY, @@ -142,12 +148,16 @@ message *m_ptr; /* pointer to message in the caller's space */ */ if (function & CHECK_DST) { if (! get_sys_bit(priv(caller_ptr)->s_ipc_to, nr_to_id(src_dst))) { - kprintf("Warning, send_mask denied %d sending to %d\n", + kprintf("sys_call: ipc mask denied %d sending to %d\n", proc_nr(caller_ptr), src_dst); - return(ECALLDENIED); + return(ECALLDENIED); /* call denied by ipc mask */ } - if (isemptyn(src_dst)) return(EDEADDST); /* cannot send to the dead */ + if (isemptyn(src_dst)) { + kprintf("sys_call: dead destination, function %d, caller %d\n", + function, proc_nr(caller_ptr)); + return(EDEADDST); /* cannot send to the dead */ + } } /* Now check if the call is known and try to perform the request. The only diff --git a/servers/fs/dmap.c b/servers/fs/dmap.c index f85a04b05..9edacf15d 100644 --- a/servers/fs/dmap.c +++ b/servers/fs/dmap.c @@ -30,27 +30,28 @@ Driver enabled Open/Cls I/O Driver # Flags Device File -------------- -------- ------ ----------- ----- ------ ---- */ -struct dmap dmap[NR_DEVICES] = { - DT(1, no_dev, 0, 0, 0) /* 0 = not used */ - DT(1, gen_opcl, gen_io, MEM_PROC_NR, 0) /* 1 = /dev/mem */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /* 2 = /dev/fd0 */ - DT(NC(1), gen_opcl, gen_io, CTRLR(0), DMAP_MUTABLE) /* 3 = /dev/c0 */ - DT(1, tty_opcl, gen_io, TTY_PROC_NR, 0) /* 4 = /dev/tty00 */ - DT(1, ctty_opcl,ctty_io,TTY_PROC_NR, 0) /* 5 = /dev/tty */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /* 6 = /dev/lp */ +struct dmap dmap[NR_DEVICES]; /* actual map */ +PRIVATE struct dmap init_dmap[] = { + DT(1, no_dev, 0, 0, 0) /* 0 = not used */ + DT(1, gen_opcl, gen_io, MEM_PROC_NR, 0) /* 1 = /dev/mem */ + DT(0, no_dev, 0, 0, DMAP_MUTABLE) /* 2 = /dev/fd0 */ + DT(0, no_dev, 0, 0, DMAP_MUTABLE) /* 3 = /dev/c0 */ + DT(1, tty_opcl, gen_io, TTY_PROC_NR, 0) /* 4 = /dev/tty00 */ + DT(1, ctty_opcl,ctty_io, TTY_PROC_NR, 0) /* 5 = /dev/tty */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /* 6 = /dev/lp */ #if (MACHINE == IBM_PC) - DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */ - DT(NC(2), gen_opcl, gen_io, CTRLR(1), DMAP_MUTABLE) /* 8 = /dev/c1 */ - DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */ - DT(NC(3), gen_opcl, gen_io, CTRLR(2), DMAP_MUTABLE) /*10 = /dev/c2 */ - DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */ - DT(NC(4), gen_opcl, gen_io, CTRLR(3), DMAP_MUTABLE) /*12 = /dev/c3 */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*13 = /dev/audio */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*14 = /dev/mixer */ - DT(1, gen_opcl, gen_io, LOG_PROC_NR, 0) /*15 = /dev/klog */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*16 = /dev/random */ - DT(0, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*17 = /dev/cmos */ + DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /* 8 = /dev/c1 */ + DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */ + DT(0, no_dev, 0, 0, DMAP_MUTABLE) /*10 = /dev/c2 */ + DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*12 = /dev/c3 */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*13 = /dev/audio */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*14 = /dev/mixer */ + DT(1, gen_opcl, gen_io, LOG_PROC_NR, 0) /*15 = /dev/klog */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*16 = /dev/random */ + DT(0, no_dev, 0, NONE, DMAP_MUTABLE) /*17 = /dev/cmos */ #endif /* IBM_PC */ }; @@ -117,18 +118,37 @@ int style; /* style of the device */ } /*===========================================================================* - * map_controller * + * build_dmap * *===========================================================================*/ -PUBLIC void map_controller() +PUBLIC void build_dmap() { -/* 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. +/* Initialize the table with all device <-> driver mappings. Then, 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 nr, major = -1; int i,s; + struct dmap *dp; + + /* Build table with device <-> driver mappings. */ + for (i=0; idmap_opcl = init_dmap[i].dmap_opcl; + dp->dmap_io = init_dmap[i].dmap_io; + dp->dmap_driver = init_dmap[i].dmap_driver; + dp->dmap_flags = init_dmap[i].dmap_flags; + } else { /* no default */ + dp->dmap_opcl = no_dev; + dp->dmap_io = 0; + dp->dmap_driver = 0; + dp->dmap_flags = DMAP_MUTABLE; + } + } /* Get settings of 'controller' and 'driver' at the boot monitor. */ if ((s = env_get_param("label", driver, sizeof(driver))) != OK) @@ -143,21 +163,14 @@ PUBLIC void map_controller() 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); + major = CTRLR(nr); } else { panic(__FILE__,"monitor 'controller' syntax is 'c#' of 'fd'", NO_NUM); } /* Now try to set the actual mapping and report to the user. */ - if ((s=map_driver(i, DRVR_PROC_NR, STYLE_DEV)) != OK) + if ((s=map_driver(major, 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 97ee83162..77fdc0529 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_controller(); /* map boot driver onto controller */ + build_dmap(); /* build device table and map boot driver */ 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 9eaf914c0..22ef1cb7e 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_controller, (void) ); +_PROTOTYPE( void build_dmap, (void) ); _PROTOTYPE( int map_driver, (int major, int proc_nr, int dev_style) ); /* filedes.c */ diff --git a/servers/is/dmp_fs.c b/servers/is/dmp_fs.c index 76a20fae1..5b132eb5e 100644 --- a/servers/is/dmp_fs.c +++ b/servers/is/dmp_fs.c @@ -65,10 +65,11 @@ PUBLIC void dtab_dmp() getsysinfo(FS_PROC_NR, SI_DMAP_TAB, dmap); printf("File System (FS) device <-> driver mappings\n"); - printf("Dev File Open/Cls I/O Proc\n"); - printf("--- ---------- -------- ------ ----\n"); + printf("Major Proc\n"); + printf("----- ----\n"); for (i=0; i