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).
This commit is contained in:
Jorrit Herder 2005-08-03 16:06:35 +00:00
parent c12b74dad5
commit 89cf745fe2
12 changed files with 77 additions and 95 deletions

1
etc/rc
View file

@ -31,6 +31,7 @@ esac
case $action in case $action in
start) start)
echo ""
echo "Multiuser startup in progress ..." echo "Multiuser startup in progress ..."
# National keyboard? # National keyboard?

View file

@ -41,9 +41,8 @@
#define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */ #define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */
#define LOG_PROC_NR 4 /* log device driver */ #define LOG_PROC_NR 4 /* log device driver */
#define TTY_PROC_NR 5 /* terminal (TTY) driver */ #define TTY_PROC_NR 5 /* terminal (TTY) driver */
#define AT_PROC_NR 6 /* AT Winchester */ #define DRVR_PROC_NR 6 /* device driver for boot medium */
#define BIOS_PROC_NR 7 /* BIOS disk device */ #define INIT_PROC_NR 7 /* init -- goes multiuser */
#define INIT_PROC_NR 8 /* init -- goes multiuser */
/* Number of processes contained in the system image. */ /* Number of processes contained in the system image. */
#define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1) #define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1)

View file

@ -14,6 +14,10 @@
*/ */
#define vir2phys(vir) (kinfo.data_base + (vir_bytes) (vir)) #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 /* 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'. * itself. So it translates '&struct_ptr->field' back to 'struct_ptr'.
*/ */

View file

@ -24,27 +24,4 @@
#define CHECK_SRC 0x02 /* 0 0 1 0 : validate message source */ #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 */ #endif /* IPC_H */

View file

@ -173,7 +173,7 @@ PRIVATE void announce(void)
#if (CHIP == INTEL) #if (CHIP == INTEL)
/* Real mode, or 16/32-bit protected mode? */ /* 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"); machine.protected ? "32-bit protected" : "real");
#endif #endif
} }

View file

@ -65,10 +65,10 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
kinfo.kmem_base = vir2phys(0); kinfo.kmem_base = vir2phys(0);
kinfo.kmem_size = (phys_bytes) &end; 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")); machine.processor=atoi(get_value(params, "processor"));
/* Decide if mode is protected for older machines. */
#if _WORD_SIZE == 2 #if _WORD_SIZE == 2
machine.protected = machine.processor >= 286; machine.protected = machine.processor >= 286;
#endif #endif
@ -83,7 +83,7 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
} }
/* Type of VDU: */ /* 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, "ega") == 0) machine.vdu_ega = TRUE;
if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE; if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE;

View file

@ -58,6 +58,26 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
#define SERV_T (~0) /* system services */ #define SERV_T (~0) /* system services */
#define USER_T ((1 << SENDREC) | (1 << ECHO)) /* user processes */ #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 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 * 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" }, { 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" }, { 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" }, { 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" }, { DRVR_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, DRIV_M, "driver" },
{ BIOS_PROC_NR, 0, SERV_F, 16, 2, 0, SERV_T, SYST_M, "bios" },
{ INIT_PROC_NR, 0, USER_F, 8, USER_Q, 0, USER_T, USER_M, "init" }, { INIT_PROC_NR, 0, USER_F, 8, USER_Q, 0, USER_T, USER_M, "init" },
}; };

View file

@ -6,6 +6,8 @@
#include "fs.h" #include "fs.h"
#include "fproc.h" #include "fproc.h"
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <minix/com.h> #include <minix/com.h>
#include "param.h" #include "param.h"
@ -119,59 +121,33 @@ int style; /* style of the device */
*===========================================================================*/ *===========================================================================*/
PUBLIC void map_controllers() PUBLIC void map_controllers()
{ {
/* Map drivers to controllers and update the dmap table to that selection. /* Map the boot drivers to a controller and update the dmap table to that
* For each controller, the environment variable set by the boot monitor is * selection. The boot driver and the controller it handles are set at the
* analyzed to see what type of Winchester disk is attached. * boot monitor.
* Finally, the process number of the driver is looked up, and, if found, is
* installed in the dmap table.
*/ */
static char ctrlr_nr[] = "c0"; /* controller currently analyzed */ char driver[16];
char ctrlr_type[8]; /* type of Winchester disk */ char *controller = "c##";
int i, c, s; int number;
int proc_nr=0; /* process number of driver */ int i,s;
struct drivertab *dp; if ((s = get_mon_param("label", driver, sizeof(driver))) != OK)
struct drivertab { panic(__FILE__,"couldn't get boot monitor parameter 'driver'", s);
char wini_type[8]; if ((s = get_mon_param("controller", controller, sizeof(controller))) != OK)
char proc_name[8]; panic(__FILE__,"couldn't get boot monitor parameter 'controller'", s);
} drivertab[] = { if (controller[0] != 'c' || ! isdigit(controller[1]))
{ "at", "boot" }, /* AT Winchester */ panic(__FILE__,"monitor parameter 'controller' syntax is 'c#'", NO_NUM);
{ "bios", "bios" }, /* BIOS Winchester */ if ((number = (unsigned) atoi(&controller[1])) > NR_CTRLRS)
{ "esdi", "..." }, panic(__FILE__,"monitor parameter 'controller' maximum is", NR_CTRLRS);
{ "xt", "..." },
{ "aha1540", "..." }, for (i=0; i< NR_DEVICES; i++) { /* find controller */
{ "dosfile", "..." }, if (dmap[i].dmap_driver == CTRLR(number)) {
{ "fatfile", "..." }, 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",
for (c=0; c < NR_CTRLRS; c++) { driver, number);
return; /* success! */
/* 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
}
}
}
} }
}
} }
panic(__FILE__, "cannot find controller in dmap, number", number);
} }

View file

@ -365,7 +365,7 @@ PRIVATE void load_ram(void)
return; return;
/* Copy the blocks one at a time from the image to the RAM disk. */ /* 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_mode = I_BLOCK_SPECIAL; /* temp inode for rahead() */
inode[0].i_size = LONG_MAX; 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. */ /* Commit changes to RAM so dev_io will see it. */
do_sync(); do_sync();
printf("\rRAM disk of %u kb loaded.\33[K", ram_size_kb); printf("\rRAM disk of %u KB loaded onto /dev/ram.", ram_size_kb);
if (root_dev == DEV_RAM) printf(" RAM disk is used as root FS."); if (root_dev == DEV_RAM) printf(" Using RAM disk as root FS.");
printf("\n\n"); printf("\n");
/* Invalidate and close the image device. */ /* Invalidate and close the image device. */
invalidate(image_dev); invalidate(image_dev);

View file

@ -146,7 +146,7 @@ PRIVATE void pm_init()
SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 }; SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 };
static char ign_sigs[] = { SIGCHLD }; static char ign_sigs[] = { SIGCHLD };
static int protected[] = {PM_PROC_NR, FS_PROC_NR, SM_PROC_NR, 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 struct mproc *rmp;
register char *sig_ptr; register char *sig_ptr;
phys_clicks total_clicks, minix_clicks, free_clicks; phys_clicks total_clicks, minix_clicks, free_clicks;
@ -258,10 +258,9 @@ PRIVATE void pm_init()
printf("Parsing memory:"); printf("Parsing memory:");
mem_init(mem_chunks, &free_clicks); mem_init(mem_chunks, &free_clicks);
total_clicks = minix_clicks + free_clicks; total_clicks = minix_clicks + free_clicks;
printf(" total=%uK", click_to_round_k(total_clicks)); printf(" total %u KB,", click_to_round_k(total_clicks));
printf(" system=%uK", click_to_round_k(minix_clicks)); printf(" system %u KB,", click_to_round_k(minix_clicks));
printf(" available=%uK", click_to_round_k(free_clicks)); printf(" available %u KB.\n", click_to_round_k(free_clicks));
printf(".\n\n");
} }

View file

@ -79,6 +79,9 @@ PUBLIC int do_start(message *m_ptr)
if ((major_nr = m_ptr->SRV_DEV_MAJOR) > 0) { /* set driver map */ if ((major_nr = m_ptr->SRV_DEV_MAJOR) > 0) { /* set driver map */
dev_style = STYLE_DEV; dev_style = STYLE_DEV;
if ((s=mapdriver(child_proc_nr, major_nr, dev_style)) < 0) { 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); report("SM", "couldn't map driver", errno);
} }
} }

View file

@ -7,6 +7,9 @@ MDEC= /usr/mdec
MAKE= exec make -$(MAKEFLAGS) MAKE= exec make -$(MAKEFLAGS)
# specify the programs that are part of the system image # 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 \ PROGRAMS= ../kernel/kernel \
../servers/pm/pm \ ../servers/pm/pm \
../servers/fs/fs \ ../servers/fs/fs \
@ -14,11 +17,12 @@ PROGRAMS= ../kernel/kernel \
../drivers/tty/tty \ ../drivers/tty/tty \
../drivers/memory/memory \ ../drivers/memory/memory \
../drivers/log/log \ ../drivers/log/log \
../drivers/at_wini/at_wini \ AT:../drivers/at_wini/at_wini \
../drivers/bios_wini/bios_wini \ BIOS:../drivers/bios_wini/bios_wini \
../servers/init/init \ ../servers/init/init \
# bootdev.img # bootdev.img
usage: usage:
@echo " " >&2 @echo " " >&2
@echo "Master Makefile to create new MINIX configuration." >& 2 @echo "Master Makefile to create new MINIX configuration." >& 2
@ -55,7 +59,7 @@ image: programs
includes: includes:
cd ../include && $(MAKE) install cd ../include && $(MAKE) install
depend: depend: includes
cd ../ && $(MAKE) depend cd ../ && $(MAKE) depend
programs: includes programs: includes