toaruos/boot/config.c

132 lines
3.5 KiB
C
Raw Normal View History

2021-05-31 12:31:01 +09:00
#include <stdint.h>
#include <stddef.h>
2018-03-06 19:43:01 +09:00
2021-06-14 11:11:37 +09:00
#include "options.h"
2018-03-06 18:18:53 +09:00
#include "util.h"
2021-06-14 11:11:37 +09:00
#include "menu.h"
#include "text.h"
2018-03-06 18:18:53 +09:00
#include "multiboot.h"
/* Basic text strings */
2021-05-31 12:31:01 +09:00
#define BASE_VERSION "ToaruOS Bootloader v3.0"
2021-06-14 11:11:37 +09:00
char * VERSION_TEXT = BASE_VERSION " (BIOS)";
char * HELP_TEXT = "Press <Enter> or select a menu option with \030/\031/\032/\033.";
char * COPYRIGHT_TEXT = "ToaruOS is free software under the NCSA license.";
char * LINK_TEXT = "https://toaruos.org - https://github.com/klange/toaruos";
/* Boot command line strings */
2021-05-31 12:31:01 +09:00
#define DEFAULT_ROOT_CMDLINE "root=/dev/ram0 "
2018-06-09 18:05:09 +09:00
#define DEFAULT_GRAPHICAL_CMDLINE "start=live-session "
#define DEFAULT_SINGLE_CMDLINE "start=terminal\037-F "
2021-06-14 11:11:37 +09:00
#define DEFAULT_TEXT_CMDLINE "start=--vga vid=text "
2018-06-09 16:36:48 +09:00
#define DEFAULT_VID_CMDLINE "vid=auto,1440,900 "
2018-07-12 10:53:36 +09:00
#define DEFAULT_PRESET_VID_CMDLINE "vid=preset "
2018-08-12 16:36:56 +09:00
#define MIGRATE_CMDLINE "migrate "
2018-07-06 10:40:49 +09:00
#define DEFAULT_HEADLESS_CMDLINE "start=--headless "
2018-06-09 16:36:48 +09:00
char * kernel_path = "KERNEL.";
2021-04-08 18:07:08 +09:00
char * ramdisk_path = "RAMDISK.IGZ";
2021-06-14 11:11:37 +09:00
char cmdline[1024] = {0};
2018-06-09 19:19:21 +09:00
/* Names of the available boot modes. */
2021-06-14 11:11:37 +09:00
struct bootmode boot_mode_names[] = {
2018-07-07 10:56:14 +09:00
{1, "normal", "Normal Boot"},
2021-06-14 11:11:37 +09:00
{2, "vga", "VGA Text Mode"},
2018-07-07 10:56:14 +09:00
{3, "single", "Single-User Graphical Terminal"},
{4, "headless", "Headless"},
2018-06-09 17:58:29 +09:00
};
2021-06-14 11:11:37 +09:00
int base_sel = BASE_SEL;
2018-06-09 17:58:29 +09:00
extern char _bss_start[];
extern char _bss_end[];
2021-05-31 12:31:01 +09:00
2018-03-05 23:12:24 +09:00
int kmain() {
memset(&_bss_start,0,(uintptr_t)&_bss_end-(uintptr_t)&_bss_start);
2018-03-06 23:47:42 +09:00
2018-06-30 13:29:11 +09:00
BOOT_OPTION(_debug, 0, "Debug output",
2018-07-06 23:53:14 +09:00
"Enable debug output in the bootloader and enable the",
"serial debug log in the operating system itself.");
2018-06-09 17:58:29 +09:00
2021-05-31 12:31:01 +09:00
BOOT_OPTION(_nosmp, 1, "Disable SMP",
"SMP support is experimental and buggy.",
"");
2018-06-09 17:58:29 +09:00
2018-06-30 13:29:11 +09:00
BOOT_OPTION(_vbox, 1, "VirtualBox Guest Additions",
2018-07-06 23:53:14 +09:00
"Enable integration with VirtualBox, including",
"automatic mode setting and absolute mouse pointer.");
2018-06-09 17:58:29 +09:00
2018-09-29 00:48:15 +09:00
BOOT_OPTION(_vboxrects, 0, "VirtualBox Seamless support",
"(Requires Guest Additions) Enables support for the",
"Seamless Desktop mode in VirtualBox.");
BOOT_OPTION(_vboxpointer, 1, "VirtualBox Pointer",
"(Requires Guest Additions) Enables support for the",
"VirtualBox hardware pointer mapping.");
BOOT_OPTION(_vmware, 1, "VMWare driver",
"Enable the VMware / QEMU absolute mouse pointer,",
"and optional guest scaling.");
BOOT_OPTION(_vmwareres, 0, "VMware guest size",
2018-09-29 00:48:15 +09:00
"(Requires VMware driver) Enables support for",
"automatically setting display size in VMware");
2018-06-09 17:58:29 +09:00
2018-06-30 13:29:11 +09:00
BOOT_OPTION(_migrate, 1, "Writable root",
"Migrates the ramdisk from tarball to an in-memory",
"temporary filesystem at boot. Needed for packages.");
2018-06-09 17:58:29 +09:00
/* Loop over rendering the menu */
show_menu();
2018-06-09 16:36:48 +09:00
/* Build our command line. */
2021-05-31 12:31:01 +09:00
strcat(cmdline, DEFAULT_ROOT_CMDLINE);
2018-12-03 11:04:06 +09:00
if (_migrate) {
strcat(cmdline, MIGRATE_CMDLINE);
2018-06-09 16:36:48 +09:00
}
2018-07-12 10:53:36 +09:00
char * _video_command_line = DEFAULT_VID_CMDLINE;
2018-07-07 10:56:14 +09:00
if (boot_mode == 1) {
2018-06-09 16:36:48 +09:00
strcat(cmdline, DEFAULT_GRAPHICAL_CMDLINE);
2018-07-12 10:53:36 +09:00
strcat(cmdline, _video_command_line);
2018-06-09 17:33:23 +09:00
} else if (boot_mode == 2) {
2018-07-07 10:56:14 +09:00
strcat(cmdline, DEFAULT_TEXT_CMDLINE);
} else if (boot_mode == 3) {
2018-06-09 17:33:23 +09:00
strcat(cmdline, DEFAULT_SINGLE_CMDLINE);
2018-07-12 10:53:36 +09:00
strcat(cmdline, _video_command_line);
2018-07-07 10:56:14 +09:00
} else if (boot_mode == 4) {
2018-07-06 10:40:49 +09:00
strcat(cmdline, DEFAULT_HEADLESS_CMDLINE);
2018-03-06 23:47:42 +09:00
}
2018-06-09 16:36:48 +09:00
if (_debug) {
2018-07-06 23:53:14 +09:00
txt_debug = 1;
2018-06-09 16:36:48 +09:00
}
2021-05-31 12:31:01 +09:00
if (!_vbox) {
strcat(cmdline, "novbox ");
2018-06-30 13:29:11 +09:00
}
if (_vbox && !_vboxrects) {
strcat(cmdline, "novboxseamless ");
}
if (_vbox && !_vboxpointer) {
strcat(cmdline, "novboxpointer ");
}
2018-09-29 00:48:15 +09:00
if (_vmware && !_vmwareres) {
strcat(cmdline, "novmwareresset ");
}
2021-05-31 12:31:01 +09:00
if (_nosmp) {
strcat(cmdline, "nosmp ");
2018-03-06 23:47:42 +09:00
}
boot();
2018-07-06 23:53:14 +09:00
while (1) {}
return 0;
2018-03-05 23:12:24 +09:00
}