From 89cf745fe2bab3f8db737f76324b8147fc42ab1f Mon Sep 17 00:00:00 2001 From: Jorrit Herder Date: Wed, 3 Aug 2005 16:06:35 +0000 Subject: [PATCH] Single boot driver loaded, while multiple can be included in the boot image. The user needs to set label=... to choose the driver of his or her choice. This driver will be mapped onto the controller that is set in controller=... Minor cleanup of kernel source code (boot image table now is static). --- etc/rc | 1 + include/minix/com.h | 5 ++- kernel/const.h | 4 +++ kernel/ipc.h | 23 -------------- kernel/main.c | 2 +- kernel/start.c | 8 ++--- kernel/table.c | 23 ++++++++++++-- servers/fs/dmap.c | 76 +++++++++++++++----------------------------- servers/fs/main.c | 8 ++--- servers/pm/main.c | 9 +++--- servers/sm/manager.c | 3 ++ tools/Makefile | 10 ++++-- 12 files changed, 77 insertions(+), 95 deletions(-) diff --git a/etc/rc b/etc/rc index 50b496506..4312e1372 100755 --- a/etc/rc +++ b/etc/rc @@ -31,6 +31,7 @@ esac case $action in start) + echo "" echo "Multiuser startup in progress ..." # National keyboard? diff --git a/include/minix/com.h b/include/minix/com.h index 60b66f0e0..d85f603f7 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -41,9 +41,8 @@ #define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */ #define LOG_PROC_NR 4 /* log device driver */ #define TTY_PROC_NR 5 /* terminal (TTY) driver */ -#define AT_PROC_NR 6 /* AT Winchester */ -#define BIOS_PROC_NR 7 /* BIOS disk device */ -#define INIT_PROC_NR 8 /* init -- goes multiuser */ +#define DRVR_PROC_NR 6 /* device driver for boot medium */ +#define INIT_PROC_NR 7 /* init -- goes multiuser */ /* Number of processes contained in the system image. */ #define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1) diff --git a/kernel/const.h b/kernel/const.h index 9225de17f..4bff11036 100755 --- a/kernel/const.h +++ b/kernel/const.h @@ -14,6 +14,10 @@ */ #define vir2phys(vir) (kinfo.data_base + (vir_bytes) (vir)) +/* Map a process number to a privilege structure id. Used at boot time. */ +#define s_nr_to_id(n) (NR_TASKS + (n) + 1) +#define s(n) (1 << s_nr_to_id(n)) + /* Translate a pointer to a field in a structure to a pointer to the structure * itself. So it translates '&struct_ptr->field' back to 'struct_ptr'. */ diff --git a/kernel/ipc.h b/kernel/ipc.h index 88e6a1770..e4ae8246e 100644 --- a/kernel/ipc.h +++ b/kernel/ipc.h @@ -24,27 +24,4 @@ #define CHECK_SRC 0x02 /* 0 0 1 0 : validate message source */ -/* 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 - * the initialization code in main() to match the s_nr_to_id() mapping for the - * processes in the boot image, so that the send mask that is defined here - * can be directly copied onto map[0] of the actual send mask. Privilege - * structure 0 is shared by user processes. - * - * Note that process numbers in the boot image should not be higher than - * "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 s_nr_to_id(n) (NR_TASKS + (n) + 1) -#define s(n) (1 << s_nr_to_id(n)) -#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)) - -/* Sanity check to make sure the send masks can be set. */ -extern int dummy[(BITCHUNK_BITS-NR_TASKS > INIT_PROC_NR) ? 1 : -1]; - - #endif /* IPC_H */ diff --git a/kernel/main.c b/kernel/main.c index 9436542cb..242f24e2f 100755 --- a/kernel/main.c +++ b/kernel/main.c @@ -173,7 +173,7 @@ PRIVATE void announce(void) #if (CHIP == INTEL) /* Real mode, or 16/32-bit protected mode? */ - kprintf("Executing in %s mode\n\n", + kprintf("Executing in %s mode.\n\n", machine.protected ? "32-bit protected" : "real"); #endif } diff --git a/kernel/start.c b/kernel/start.c index 1f9472bda..db733bd12 100755 --- a/kernel/start.c +++ b/kernel/start.c @@ -65,10 +65,10 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */ kinfo.kmem_base = vir2phys(0); kinfo.kmem_size = (phys_bytes) &end; - /* Processor? 86, 186, 286, 386, ... */ + /* Processor? 86, 186, 286, 386, ... + * Decide if mode is protected for older machines. + */ machine.processor=atoi(get_value(params, "processor")); - - /* Decide if mode is protected for older machines. */ #if _WORD_SIZE == 2 machine.protected = machine.processor >= 286; #endif @@ -83,7 +83,7 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */ } /* Type of VDU: */ - value = get_value(params, "video"); /* EGA or VGA video unit */ + value = get_value(params, "video"); /* EGA or VGA video unit */ if (strcmp(value, "ega") == 0) machine.vdu_ega = TRUE; if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE; diff --git a/kernel/table.c b/kernel/table.c index fd88b26ee..0bf9d0bb8 100755 --- a/kernel/table.c +++ b/kernel/table.c @@ -58,6 +58,26 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; #define SERV_T (~0) /* system services */ #define USER_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 + * the initialization code in main() to match the s_nr_to_id() mapping for the + * processes in the boot image, so that the send mask that is defined here + * can be directly copied onto map[0] of the actual send mask. Privilege + * structure 0 is shared by user processes. + * + * Note that process numbers in the boot image should not be higher than + * "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)) + +/* Sanity check to make sure the send masks can be set. */ +extern int dummy[(BITCHUNK_BITS-NR_TASKS > INIT_PROC_NR) ? 1 : -1]; + /* The system image table lists all programs that are part of the boot image. * The order of the entries here MUST agree with the order of the programs @@ -78,8 +98,7 @@ PUBLIC struct boot_image image[] = { { 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" }, - { AT_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, DRIV_M, "boot" }, - { BIOS_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, SYST_M, "bios" }, + { 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" }, }; diff --git a/servers/fs/dmap.c b/servers/fs/dmap.c index 44982b1a0..dbf158341 100644 --- a/servers/fs/dmap.c +++ b/servers/fs/dmap.c @@ -6,6 +6,8 @@ #include "fs.h" #include "fproc.h" #include +#include +#include #include #include #include "param.h" @@ -119,59 +121,33 @@ int style; /* style of the device */ *===========================================================================*/ PUBLIC void map_controllers() { -/* Map drivers to controllers and update the dmap table to that selection. - * For each controller, the environment variable set by the boot monitor is - * analyzed to see what type of Winchester disk is attached. - * Finally, the process number of the driver is looked up, and, if found, is - * installed in the dmap table. +/* Map the boot drivers 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. */ - static char ctrlr_nr[] = "c0"; /* controller currently analyzed */ - char ctrlr_type[8]; /* type of Winchester disk */ - int i, c, s; - int proc_nr=0; /* process number of driver */ - struct drivertab *dp; - struct drivertab { - char wini_type[8]; - char proc_name[8]; - } drivertab[] = { - { "at", "boot" }, /* AT Winchester */ - { "bios", "bios" }, /* BIOS Winchester */ - { "esdi", "..." }, - { "xt", "..." }, - { "aha1540", "..." }, - { "dosfile", "..." }, - { "fatfile", "..." }, - }; - - for (c=0; c < NR_CTRLRS; c++) { - - /* See if there is a mapping for this controller. */ - ctrlr_nr[1] = '0' + c; - if ((s = get_mon_param(ctrlr_nr, ctrlr_type, 8)) != OK) { - if (s != ESRCH) panic(__FILE__,"couldn't get monitor param", s); - continue; - } - - /* If there is a mapping, look up the driver with the given name. */ - for (dp = drivertab; - dp < drivertab + sizeof(drivertab)/sizeof(drivertab[0]); dp++) { - if (strcmp(ctrlr_type, dp->wini_type) == 0) { /* found driver name */ - if ((s=findproc(dp->proc_name, &proc_nr)) == OK) { - for (i=0; i< NR_DEVICES; i++) { /* find mapping */ - if (dmap[i].dmap_driver == CTRLR(c)) { - if ((s=map_driver(i, proc_nr, STYLE_DEV)) != OK) { - panic(__FILE__,"map_driver failed",s); - } -#if VERBOSE - printf("FS: controller %s (%s) mapped to %s driver (nr %d)\n", - ctrlr_nr, dp->wini_type, dp->proc_name, dmap[i].dmap_driver); -#endif - } - } - } + char driver[16]; + char *controller = "c##"; + int number; + int i,s; + 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! */ } - } } + panic(__FILE__, "cannot find controller in dmap, number", number); } diff --git a/servers/fs/main.c b/servers/fs/main.c index 97857db5e..ad229b7aa 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -365,7 +365,7 @@ PRIVATE void load_ram(void) return; /* Copy the blocks one at a time from the image to the RAM disk. */ - printf("Loading RAM disk.\33[23CLoaded: 0K "); + printf("Loading RAM disk onto /dev/ram:\33[23CLoaded: 0K "); inode[0].i_mode = I_BLOCK_SPECIAL; /* temp inode for rahead() */ inode[0].i_size = LONG_MAX; @@ -403,9 +403,9 @@ PRIVATE void load_ram(void) /* Commit changes to RAM so dev_io will see it. */ do_sync(); - printf("\rRAM disk of %u kb loaded.\33[K", ram_size_kb); - if (root_dev == DEV_RAM) printf(" RAM disk is used as root FS."); - printf("\n\n"); + printf("\rRAM disk of %u KB loaded onto /dev/ram.", ram_size_kb); + if (root_dev == DEV_RAM) printf(" Using RAM disk as root FS."); + printf("\n"); /* Invalidate and close the image device. */ invalidate(image_dev); diff --git a/servers/pm/main.c b/servers/pm/main.c index 308be8bde..2952edcfc 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -146,7 +146,7 @@ PRIVATE void pm_init() SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 }; static char ign_sigs[] = { SIGCHLD }; static int protected[] = {PM_PROC_NR, FS_PROC_NR, SM_PROC_NR, - TTY_PROC_NR, AT_PROC_NR, MEM_PROC_NR}; + TTY_PROC_NR, DRVR_PROC_NR, MEM_PROC_NR}; register struct mproc *rmp; register char *sig_ptr; phys_clicks total_clicks, minix_clicks, free_clicks; @@ -258,10 +258,9 @@ PRIVATE void pm_init() printf("Parsing memory:"); mem_init(mem_chunks, &free_clicks); total_clicks = minix_clicks + free_clicks; - printf(" total=%uK", click_to_round_k(total_clicks)); - printf(" system=%uK", click_to_round_k(minix_clicks)); - printf(" available=%uK", click_to_round_k(free_clicks)); - printf(".\n\n"); + printf(" total %u KB,", click_to_round_k(total_clicks)); + printf(" system %u KB,", click_to_round_k(minix_clicks)); + printf(" available %u KB.\n", click_to_round_k(free_clicks)); } diff --git a/servers/sm/manager.c b/servers/sm/manager.c index 6af6a83f9..47a01e734 100644 --- a/servers/sm/manager.c +++ b/servers/sm/manager.c @@ -79,6 +79,9 @@ PUBLIC int do_start(message *m_ptr) if ((major_nr = m_ptr->SRV_DEV_MAJOR) > 0) { /* set driver map */ dev_style = STYLE_DEV; if ((s=mapdriver(child_proc_nr, major_nr, dev_style)) < 0) { + + printf("SM: '%s %s', major %d, pid %d, proc_nr %d", + command, arg_buf, major_nr, child_pid, child_proc_nr); report("SM", "couldn't map driver", errno); } } diff --git a/tools/Makefile b/tools/Makefile index 90ab4bfc4..de661089b 100755 --- a/tools/Makefile +++ b/tools/Makefile @@ -7,6 +7,9 @@ MDEC= /usr/mdec MAKE= exec make -$(MAKEFLAGS) # specify the programs that are part of the system image +# only one boot medium driver can actually be loaded, +# use labels to include multiple driver and set a label +# at the boot monitor to select one PROGRAMS= ../kernel/kernel \ ../servers/pm/pm \ ../servers/fs/fs \ @@ -14,11 +17,12 @@ PROGRAMS= ../kernel/kernel \ ../drivers/tty/tty \ ../drivers/memory/memory \ ../drivers/log/log \ - ../drivers/at_wini/at_wini \ - ../drivers/bios_wini/bios_wini \ + AT:../drivers/at_wini/at_wini \ + BIOS:../drivers/bios_wini/bios_wini \ ../servers/init/init \ # bootdev.img + usage: @echo " " >&2 @echo "Master Makefile to create new MINIX configuration." >& 2 @@ -55,7 +59,7 @@ image: programs includes: cd ../include && $(MAKE) install -depend: +depend: includes cd ../ && $(MAKE) depend programs: includes -- 2.44.0