Get defaults for the boot device (and flags) from the file
"boot.config" (relative to the root directory on the 'a' partition on the first BSD slice) if it exists. If it doesn't exist, then the only visible changes should be that the kernel name isn't reset to "/kernel" after looking it up fails and that the default name is now "kernel". The new function readfile() can be used for other things: - reading help messages. - reading splash screens. - reading userconfig info.
This commit is contained in:
parent
30c218bf14
commit
8363c19687
@ -62,8 +62,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#define ouraddr (BOOTSEG << 4) /* XXX */
|
||||
|
||||
#define BOOT_CONFIG_SIZE 512
|
||||
#define NAMEBUF_LEN (8*1024)
|
||||
|
||||
static char boot_config[BOOT_CONFIG_SIZE];
|
||||
#ifdef NAMEBLOCK
|
||||
char *dflt_name;
|
||||
#endif
|
||||
@ -74,6 +76,7 @@ int loadflags;
|
||||
|
||||
static void getbootdev(char *ptr, int *howto);
|
||||
static void loadprog(void);
|
||||
static void readfile(char *path, char *buf, size_t nbytes);
|
||||
|
||||
/* NORETURN */
|
||||
void
|
||||
@ -151,8 +154,16 @@ boot(int drive)
|
||||
name = dflt_name;
|
||||
} else
|
||||
#endif /*NAMEBLOCK*/
|
||||
name = "kernel";
|
||||
readfile("boot.config", boot_config, BOOT_CONFIG_SIZE);
|
||||
getbootdev(boot_config, &loadflags);
|
||||
if (namebuf[0] != '\0')
|
||||
printf("boot.config: %s", boot_config);
|
||||
/*
|
||||
* XXX parsing of `name' is in openrd(), so the defaults aren't
|
||||
* updated to match the config (if any) before printing the prompt.
|
||||
*/
|
||||
loadstart:
|
||||
name = "/kernel";
|
||||
/* print this all each time.. (saves space to do so) */
|
||||
/* If we have looped, use the previous entries as defaults */
|
||||
printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n"
|
||||
@ -163,7 +174,17 @@ loadstart:
|
||||
dosdev & 0x7f, devs[maj], unit, name);
|
||||
|
||||
loadflags &= RB_SERIAL; /* clear all, but leave serial console */
|
||||
getbootdev(namebuf, &loadflags);
|
||||
|
||||
/*
|
||||
* Be paranoid and make doubly sure that the input buffer is empty.
|
||||
*/
|
||||
if (loadflags & RB_SERIAL)
|
||||
init_serial();
|
||||
|
||||
if (!gets(namebuf))
|
||||
putchar('\n');
|
||||
else
|
||||
getbootdev(namebuf, &loadflags);
|
||||
ret = openrd();
|
||||
if (ret != 0) {
|
||||
if (ret > 0)
|
||||
@ -306,28 +327,39 @@ loadprog(void)
|
||||
(int)&bootinfo + ouraddr);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
readfile(char *path, char *buf, size_t nbytes)
|
||||
{
|
||||
int openstatus;
|
||||
|
||||
buf[0] = '\0';
|
||||
name = path;
|
||||
openstatus = openrd();
|
||||
if (openstatus != 0) {
|
||||
if (openstatus > 0)
|
||||
printf("Can't find file %s\n", name);
|
||||
} else {
|
||||
/* XXX no way to determine file size. */
|
||||
read(buf, nbytes);
|
||||
}
|
||||
buf[nbytes - 1] = '\0';
|
||||
#if 0
|
||||
pcpy(buf, (void *)0x800, nbytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
getbootdev(char *ptr, int *howto)
|
||||
{
|
||||
char c;
|
||||
|
||||
/*
|
||||
* Be paranoid and make doubly sure that the input buffer is empty.
|
||||
*/
|
||||
if (*howto & RB_SERIAL)
|
||||
init_serial();
|
||||
|
||||
if (!gets(ptr)) {
|
||||
putchar('\n');
|
||||
return;
|
||||
}
|
||||
while ((c = *ptr) != '\0') {
|
||||
nextarg:
|
||||
while (c == ' ')
|
||||
while (c == ' ' || c == '\n')
|
||||
c = *++ptr;
|
||||
if (c == '-')
|
||||
while ((c = *++ptr) != '\0') {
|
||||
if (c == ' ')
|
||||
if (c == ' ' || c == '\n')
|
||||
goto nextarg;
|
||||
if (c == 'C')
|
||||
*howto |= RB_CDROM;
|
||||
@ -358,7 +390,7 @@ nextarg:
|
||||
return;
|
||||
name = ptr;
|
||||
while (*++ptr != '\0') {
|
||||
if (*ptr == ' ') {
|
||||
if (*ptr == ' ' || *ptr == '\n') {
|
||||
*ptr++ = '\0';
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user