Update code which creates bootinfo.
This commit is contained in:
parent
7b40715e82
commit
78bcb999c4
@ -35,8 +35,93 @@
|
||||
#include <machine/bootinfo.h>
|
||||
#include "bootstrap.h"
|
||||
|
||||
/*
|
||||
* Return a 'boothowto' value corresponding to the kernel arguments in
|
||||
* (kargs) and any relevant environment variables.
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
const char *ev;
|
||||
int mask;
|
||||
} howto_names[] = {
|
||||
{"boot_askname", RB_ASKNAME},
|
||||
{"boot_cdrom", RB_CDROM},
|
||||
{"boot_userconfig", RB_CONFIG},
|
||||
{"boot_ddb", RB_KDB},
|
||||
{"boot_gdb", RB_GDB},
|
||||
{"boot_single", RB_SINGLE},
|
||||
{"boot_verbose", RB_VERBOSE},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
extern char *ski_fmtdev(void *vdev);
|
||||
|
||||
int
|
||||
bi_getboothowto(char *kargs)
|
||||
{
|
||||
char *cp;
|
||||
int howto;
|
||||
int active;
|
||||
int i;
|
||||
|
||||
/* Parse kargs */
|
||||
howto = 0;
|
||||
if (kargs != NULL) {
|
||||
cp = kargs;
|
||||
active = 0;
|
||||
while (*cp != 0) {
|
||||
if (!active && (*cp == '-')) {
|
||||
active = 1;
|
||||
} else if (active)
|
||||
switch (*cp) {
|
||||
case 'a':
|
||||
howto |= RB_ASKNAME;
|
||||
break;
|
||||
case 'c':
|
||||
howto |= RB_CONFIG;
|
||||
break;
|
||||
case 'C':
|
||||
howto |= RB_CDROM;
|
||||
break;
|
||||
case 'd':
|
||||
howto |= RB_KDB;
|
||||
break;
|
||||
case 'm':
|
||||
howto |= RB_MUTE;
|
||||
break;
|
||||
case 'g':
|
||||
howto |= RB_GDB;
|
||||
break;
|
||||
case 'h':
|
||||
howto |= RB_SERIAL;
|
||||
break;
|
||||
case 'r':
|
||||
howto |= RB_DFLTROOT;
|
||||
break;
|
||||
case 's':
|
||||
howto |= RB_SINGLE;
|
||||
break;
|
||||
case 'v':
|
||||
howto |= RB_VERBOSE;
|
||||
break;
|
||||
default:
|
||||
active = 0;
|
||||
break;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
/* get equivalents from the environment */
|
||||
for (i = 0; howto_names[i].ev != NULL; i++)
|
||||
if (getenv(howto_names[i].ev) != NULL)
|
||||
howto |= howto_names[i].mask;
|
||||
if (!strcmp(getenv("console"), "comconsole"))
|
||||
howto |= RB_SERIAL;
|
||||
if (!strcmp(getenv("console"), "nullconsole"))
|
||||
howto |= RB_MUTE;
|
||||
return(howto);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the environment into the load area starting at (addr).
|
||||
* Each variable is formatted as <name>=<value>, with a single nul
|
||||
@ -150,7 +235,7 @@ bi_copymodules(vm_offset_t addr)
|
||||
* - Module metadata are formatted and placed in kernel space.
|
||||
*/
|
||||
int
|
||||
bi_load(struct bootinfo *bi, struct preloaded_file *fp)
|
||||
bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
|
||||
{
|
||||
char *rootdevname;
|
||||
struct ski_devdesc *rootdev;
|
||||
@ -161,6 +246,17 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp)
|
||||
vm_offset_t ssym, esym;
|
||||
struct file_metadata *md;
|
||||
|
||||
/*
|
||||
* Version 1 bootinfo.
|
||||
*/
|
||||
bi->bi_magic = BOOTINFO_MAGIC;
|
||||
bi->bi_version = 1;
|
||||
|
||||
/*
|
||||
* Calculate boothowto.
|
||||
*/
|
||||
bi->bi_boothowto = bi_getboothowto(fp->f_args);
|
||||
|
||||
/*
|
||||
* Allow the environment variable 'rootdev' to override the supplied device
|
||||
* This should perhaps go to MI code and/or have $rootdev tested/set by
|
||||
|
@ -90,7 +90,6 @@
|
||||
#define _KERNEL
|
||||
|
||||
static int elf_exec(struct preloaded_file *amp);
|
||||
int bi_load(struct bootinfo *, struct preloaded_file *);
|
||||
|
||||
struct file_format ia64_elf = { elf_loadfile, elf_exec };
|
||||
|
||||
|
@ -74,6 +74,10 @@ extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len);
|
||||
extern int ski_boot(void);
|
||||
extern int ski_autoload(void);
|
||||
|
||||
struct bootinfo;
|
||||
struct preloaded_file;
|
||||
extern int bi_load(struct bootinfo *, struct preloaded_file *);
|
||||
|
||||
#define SSC_CONSOLE_INIT 20
|
||||
#define SSC_GETCHAR 21
|
||||
#define SSC_PUTCHAR 31
|
||||
|
@ -35,8 +35,93 @@
|
||||
#include <machine/bootinfo.h>
|
||||
#include "bootstrap.h"
|
||||
|
||||
/*
|
||||
* Return a 'boothowto' value corresponding to the kernel arguments in
|
||||
* (kargs) and any relevant environment variables.
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
const char *ev;
|
||||
int mask;
|
||||
} howto_names[] = {
|
||||
{"boot_askname", RB_ASKNAME},
|
||||
{"boot_cdrom", RB_CDROM},
|
||||
{"boot_userconfig", RB_CONFIG},
|
||||
{"boot_ddb", RB_KDB},
|
||||
{"boot_gdb", RB_GDB},
|
||||
{"boot_single", RB_SINGLE},
|
||||
{"boot_verbose", RB_VERBOSE},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
extern char *ski_fmtdev(void *vdev);
|
||||
|
||||
int
|
||||
bi_getboothowto(char *kargs)
|
||||
{
|
||||
char *cp;
|
||||
int howto;
|
||||
int active;
|
||||
int i;
|
||||
|
||||
/* Parse kargs */
|
||||
howto = 0;
|
||||
if (kargs != NULL) {
|
||||
cp = kargs;
|
||||
active = 0;
|
||||
while (*cp != 0) {
|
||||
if (!active && (*cp == '-')) {
|
||||
active = 1;
|
||||
} else if (active)
|
||||
switch (*cp) {
|
||||
case 'a':
|
||||
howto |= RB_ASKNAME;
|
||||
break;
|
||||
case 'c':
|
||||
howto |= RB_CONFIG;
|
||||
break;
|
||||
case 'C':
|
||||
howto |= RB_CDROM;
|
||||
break;
|
||||
case 'd':
|
||||
howto |= RB_KDB;
|
||||
break;
|
||||
case 'm':
|
||||
howto |= RB_MUTE;
|
||||
break;
|
||||
case 'g':
|
||||
howto |= RB_GDB;
|
||||
break;
|
||||
case 'h':
|
||||
howto |= RB_SERIAL;
|
||||
break;
|
||||
case 'r':
|
||||
howto |= RB_DFLTROOT;
|
||||
break;
|
||||
case 's':
|
||||
howto |= RB_SINGLE;
|
||||
break;
|
||||
case 'v':
|
||||
howto |= RB_VERBOSE;
|
||||
break;
|
||||
default:
|
||||
active = 0;
|
||||
break;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
/* get equivalents from the environment */
|
||||
for (i = 0; howto_names[i].ev != NULL; i++)
|
||||
if (getenv(howto_names[i].ev) != NULL)
|
||||
howto |= howto_names[i].mask;
|
||||
if (!strcmp(getenv("console"), "comconsole"))
|
||||
howto |= RB_SERIAL;
|
||||
if (!strcmp(getenv("console"), "nullconsole"))
|
||||
howto |= RB_MUTE;
|
||||
return(howto);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the environment into the load area starting at (addr).
|
||||
* Each variable is formatted as <name>=<value>, with a single nul
|
||||
@ -150,7 +235,7 @@ bi_copymodules(vm_offset_t addr)
|
||||
* - Module metadata are formatted and placed in kernel space.
|
||||
*/
|
||||
int
|
||||
bi_load(struct bootinfo *bi, struct preloaded_file *fp)
|
||||
bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
|
||||
{
|
||||
char *rootdevname;
|
||||
struct ski_devdesc *rootdev;
|
||||
@ -161,6 +246,17 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp)
|
||||
vm_offset_t ssym, esym;
|
||||
struct file_metadata *md;
|
||||
|
||||
/*
|
||||
* Version 1 bootinfo.
|
||||
*/
|
||||
bi->bi_magic = BOOTINFO_MAGIC;
|
||||
bi->bi_version = 1;
|
||||
|
||||
/*
|
||||
* Calculate boothowto.
|
||||
*/
|
||||
bi->bi_boothowto = bi_getboothowto(fp->f_args);
|
||||
|
||||
/*
|
||||
* Allow the environment variable 'rootdev' to override the supplied device
|
||||
* This should perhaps go to MI code and/or have $rootdev tested/set by
|
||||
|
@ -90,7 +90,6 @@
|
||||
#define _KERNEL
|
||||
|
||||
static int elf_exec(struct preloaded_file *amp);
|
||||
int bi_load(struct bootinfo *, struct preloaded_file *);
|
||||
|
||||
struct file_format ia64_elf = { elf_loadfile, elf_exec };
|
||||
|
||||
|
@ -74,6 +74,10 @@ extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len);
|
||||
extern int ski_boot(void);
|
||||
extern int ski_autoload(void);
|
||||
|
||||
struct bootinfo;
|
||||
struct preloaded_file;
|
||||
extern int bi_load(struct bootinfo *, struct preloaded_file *);
|
||||
|
||||
#define SSC_CONSOLE_INIT 20
|
||||
#define SSC_GETCHAR 21
|
||||
#define SSC_PUTCHAR 31
|
||||
|
Loading…
x
Reference in New Issue
Block a user