Add kernel(7) --firmware option.
This commit is contained in:
parent
58bab55351
commit
784481dab6
5 changed files with 41 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011-2018, 2021-2022 Jonas 'Sortie' Termansen.
|
||||
* Copyright (c) 2011-2018, 2021-2023 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -233,6 +233,13 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo_p)
|
|||
|
||||
if ( !(kernel_options = strdup(cmdline ? cmdline : "")) )
|
||||
Panic("Failed to allocate kernel command line");
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
// TODO: Detect EFI.
|
||||
kernel_firmware = "bios";
|
||||
#else
|
||||
#warning "Name your system firmware here"
|
||||
kernel_firmware = "unknown";
|
||||
#endif
|
||||
|
||||
int argmax = 1;
|
||||
argv = new char*[argmax + 1];
|
||||
|
@ -288,6 +295,20 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo_p)
|
|||
enable_network_drivers = true;
|
||||
else if ( !strcmp(arg, "--no-random-seed") )
|
||||
no_random_seed = true;
|
||||
else if ( !strncmp(arg, "--firmware=", strlen("--firmware=")) )
|
||||
{
|
||||
const char* firmware = arg + strlen("--firmware=");
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if ( !strcmp(firmware, "bios") || !strcmp(firmware, "pc") )
|
||||
kernel_firmware = "bios";
|
||||
else if ( !strcmp(firmware, "efi") )
|
||||
kernel_firmware = "efi";
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PanicF("Unsupported firmware option: %s", firmware);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::PrintF("\r\e[J");
|
||||
|
|
|
@ -34,20 +34,17 @@
|
|||
namespace Sortix {
|
||||
|
||||
char* kernel_options;
|
||||
const char* kernel_firmware;
|
||||
|
||||
static const char* KernelInfo(const char* req)
|
||||
{
|
||||
if ( strcmp(req, "name") == 0 ) { return BRAND_KERNEL_NAME; }
|
||||
if ( strcmp(req, "version") == 0 ) { return VERSIONSTR; }
|
||||
if ( strcmp(req, "tagline") == 0 ) { return BRAND_RELEASE_TAGLINE; }
|
||||
if ( strcmp(req, "options") == 0 ) { return kernel_options; }
|
||||
if ( strcmp(req, "builddate") == 0 ) { return __DATE__; }
|
||||
if ( strcmp(req, "buildtime") == 0 ) { return __TIME__; }
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if ( strcmp(req, "firmware") == 0 ) { return "bios"; }
|
||||
#else
|
||||
#warning "Name your system firmware here"
|
||||
#endif
|
||||
if ( strcmp(req, "name") == 0 ) return BRAND_KERNEL_NAME;
|
||||
if ( strcmp(req, "version") == 0 ) return VERSIONSTR;
|
||||
if ( strcmp(req, "tagline") == 0 ) return BRAND_RELEASE_TAGLINE;
|
||||
if ( strcmp(req, "options") == 0 ) return kernel_options;
|
||||
if ( strcmp(req, "builddate") == 0 ) return __DATE__;
|
||||
if ( strcmp(req, "buildtime") == 0 ) return __TIME__;
|
||||
if ( strcmp(req, "firmware") == 0 ) return kernel_firmware;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
namespace Sortix {
|
||||
|
||||
extern char* kernel_options;
|
||||
extern const char* kernel_firmware;
|
||||
|
||||
} // namespace Sortix
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
.Op Fl \-enable-em
|
||||
.Op Fl \-disable-network-drivers
|
||||
.Op Fl \-enable-network-drivers
|
||||
.Op Fl \-firmware Ns = Ns Oo Sy bios "|" Sy efi "|" pc Oc
|
||||
.Op Fl \-no-random-seed
|
||||
.Op Fl \-
|
||||
.Op Ar init ...
|
||||
|
@ -64,6 +65,14 @@ driver.
|
|||
.It Fl \-enable-network-drivers
|
||||
Do initialize network drivers.
|
||||
This is the default behavior.
|
||||
.It Fl \-firmware Ns = Ns Oo Sy bios "|" Sy efi "|" pc Oc
|
||||
Informs the kernel the system is booted using
|
||||
.Sy bios or
|
||||
.Sy efi .
|
||||
The
|
||||
.Sy pc
|
||||
value is a synonym for
|
||||
.Sy bios .
|
||||
.It Fl \-no-random-seed
|
||||
Don't warn if no random seed file was loaded by the bootloader (usually from
|
||||
.Pa /boot/random.seed ) .
|
||||
|
|
|
@ -30,7 +30,7 @@ The date on which the current kernel was built.
|
|||
.It Sy buildtime
|
||||
The time at which the current kernel was built.
|
||||
.It Sy firmware
|
||||
The firmware of the system (e.g. "bios" or "uefi")
|
||||
The firmware of the system (e.g. "bios" or "efi")
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
|
|
Loading…
Reference in a new issue