2021-05-31 06:31:01 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2018-03-06 13:43:01 +03:00
|
|
|
|
2021-06-14 05:11:37 +03:00
|
|
|
#include "options.h"
|
2018-03-06 12:18:53 +03:00
|
|
|
#include "util.h"
|
2021-06-14 05:11:37 +03:00
|
|
|
#include "menu.h"
|
|
|
|
#include "text.h"
|
2018-03-06 12:18:53 +03:00
|
|
|
#include "multiboot.h"
|
2021-08-21 09:12:04 +03:00
|
|
|
#include "editor.h"
|
2018-03-06 12:18:53 +03:00
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Basic text strings */
|
2021-10-19 14:29:44 +03:00
|
|
|
#define BASE_VERSION "ToaruOS Bootloader v5.0"
|
2021-09-07 05:45:58 +03:00
|
|
|
char * VERSION_TEXT = BASE_VERSION
|
|
|
|
#ifdef EFI_PLATFORM
|
|
|
|
" (EFI)";
|
|
|
|
#else
|
|
|
|
" (BIOS)";
|
|
|
|
#endif
|
2021-08-21 02:07:20 +03:00
|
|
|
char * HELP_TEXT = "<Enter> to boot, <e> to edit, or select a menu option with \030/\031/\032/\033.";
|
2021-08-22 11:49:28 +03:00
|
|
|
char * HELP_TEXT_OPT = "<Enter> to toggle, or select another option with \030/\031/\032/\033.";
|
2021-06-14 05:11:37 +03:00
|
|
|
char * COPYRIGHT_TEXT = "ToaruOS is free software under the NCSA license.";
|
|
|
|
char * LINK_TEXT = "https://toaruos.org - https://github.com/klange/toaruos";
|
2018-06-09 12:56:00 +03:00
|
|
|
|
|
|
|
/* Boot command line strings */
|
2021-05-31 06:31:01 +03:00
|
|
|
#define DEFAULT_ROOT_CMDLINE "root=/dev/ram0 "
|
2018-06-09 12:05:09 +03:00
|
|
|
#define DEFAULT_GRAPHICAL_CMDLINE "start=live-session "
|
2018-08-14 05:39:26 +03:00
|
|
|
#define DEFAULT_SINGLE_CMDLINE "start=terminal\037-F "
|
2021-06-14 05:11:37 +03:00
|
|
|
#define DEFAULT_TEXT_CMDLINE "start=--vga vid=text "
|
2018-06-09 10:36:48 +03:00
|
|
|
#define DEFAULT_VID_CMDLINE "vid=auto,1440,900 "
|
2018-08-12 10:36:56 +03:00
|
|
|
#define MIGRATE_CMDLINE "migrate "
|
2018-07-06 04:40:49 +03:00
|
|
|
#define DEFAULT_HEADLESS_CMDLINE "start=--headless "
|
2018-06-09 10:36:48 +03:00
|
|
|
|
2018-06-29 07:55:03 +03:00
|
|
|
char * kernel_path = "KERNEL.";
|
2021-04-08 12:07:08 +03:00
|
|
|
char * ramdisk_path = "RAMDISK.IGZ";
|
2021-06-14 05:11:37 +03:00
|
|
|
char cmdline[1024] = {0};
|
2018-06-09 13:19:21 +03:00
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Names of the available boot modes. */
|
2021-06-14 05:11:37 +03:00
|
|
|
struct bootmode boot_mode_names[] = {
|
2018-07-07 04:56:14 +03:00
|
|
|
{1, "normal", "Normal Boot"},
|
2021-09-07 05:45:58 +03:00
|
|
|
{2, "video", "Configure Video Output"},
|
2018-07-07 04:56:14 +03:00
|
|
|
{3, "single", "Single-User Graphical Terminal"},
|
|
|
|
{4, "headless", "Headless"},
|
2021-11-04 14:44:22 +03:00
|
|
|
#ifndef EFI_PLATFORM
|
|
|
|
{5, "vga", "VGA Text Mode"},
|
|
|
|
#endif
|
2018-06-09 11:58:29 +03:00
|
|
|
};
|
|
|
|
|
2021-09-07 05:45:58 +03:00
|
|
|
int base_sel = 0;
|
2021-05-31 06:31:01 +03:00
|
|
|
|
2018-03-05 17:12:24 +03:00
|
|
|
int kmain() {
|
2021-09-07 05:45:58 +03:00
|
|
|
BOOT_SET();
|
2018-03-06 17:47:42 +03:00
|
|
|
|
2018-06-30 07:29:11 +03:00
|
|
|
BOOT_OPTION(_debug, 0, "Debug output",
|
2018-07-06 17:53:14 +03:00
|
|
|
"Enable debug output in the bootloader and enable the",
|
|
|
|
"serial debug log in the operating system itself.");
|
2018-06-09 11:58:29 +03:00
|
|
|
|
2021-08-21 01:55:48 +03:00
|
|
|
BOOT_OPTION(_smp, 1, "Enable SMP",
|
2021-08-16 13:30:46 +03:00
|
|
|
"SMP support may not be completely stable and can be",
|
|
|
|
"disabled with this option if desired.");
|
2018-06-09 11:58:29 +03:00
|
|
|
|
2018-06-30 07:29:11 +03:00
|
|
|
BOOT_OPTION(_vbox, 1, "VirtualBox Guest Additions",
|
2018-07-06 17:53:14 +03:00
|
|
|
"Enable integration with VirtualBox, including",
|
|
|
|
"automatic mode setting and absolute mouse pointer.");
|
2018-06-09 11:58:29 +03:00
|
|
|
|
2018-09-28 18:48:15 +03: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.");
|
|
|
|
|
2021-08-30 07:24:25 +03:00
|
|
|
BOOT_OPTION(_vmwareres, 1, "VMware guest size",
|
2018-09-28 18:48:15 +03:00
|
|
|
"(Requires VMware driver) Enables support for",
|
|
|
|
"automatically setting display size in VMware");
|
2018-06-09 11:58:29 +03:00
|
|
|
|
2021-08-21 01:55:48 +03:00
|
|
|
BOOT_OPTION(_qemubug, 0, "QEMU PS/2 workaround",
|
|
|
|
"Work around a bug in QEMU's PS/2 controller",
|
|
|
|
"prior to 6.0.50.");
|
|
|
|
|
2021-08-21 02:07:20 +03:00
|
|
|
BOOT_OPTION(_migrate, 1, "Writable root",
|
|
|
|
"Migrates the ramdisk from tarball to an in-memory",
|
|
|
|
"temporary filesystem at boot. Needed for packages.");
|
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
while (1) {
|
|
|
|
/* Loop over rendering the menu */
|
|
|
|
show_menu();
|
2018-06-09 10:36:48 +03:00
|
|
|
|
2021-09-07 05:45:58 +03:00
|
|
|
if (boot_mode == 2) {
|
|
|
|
extern int video_menu(void);
|
|
|
|
video_menu();
|
|
|
|
boot_edit = 0;
|
|
|
|
memset(cmdline, 0, 1024);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
/* Build our command line. */
|
|
|
|
strcat(cmdline, DEFAULT_ROOT_CMDLINE);
|
2018-06-29 07:55:03 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (_migrate) {
|
|
|
|
strcat(cmdline, MIGRATE_CMDLINE);
|
|
|
|
}
|
2018-06-09 10:36:48 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
char * _video_command_line = DEFAULT_VID_CMDLINE;
|
2018-03-06 17:47:42 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (boot_mode == 1) {
|
|
|
|
strcat(cmdline, DEFAULT_GRAPHICAL_CMDLINE);
|
|
|
|
strcat(cmdline, _video_command_line);
|
|
|
|
} else if (boot_mode == 3) {
|
|
|
|
strcat(cmdline, DEFAULT_SINGLE_CMDLINE);
|
|
|
|
strcat(cmdline, _video_command_line);
|
|
|
|
} else if (boot_mode == 4) {
|
|
|
|
strcat(cmdline, DEFAULT_HEADLESS_CMDLINE);
|
2021-11-04 14:44:22 +03:00
|
|
|
} else if (boot_mode == 5) {
|
|
|
|
strcat(cmdline, DEFAULT_TEXT_CMDLINE);
|
2021-08-21 09:12:04 +03:00
|
|
|
}
|
2018-06-09 10:36:48 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (_debug) {
|
|
|
|
txt_debug = 1;
|
2021-10-18 13:50:59 +03:00
|
|
|
strcat(cmdline, "debug ");
|
2021-08-21 09:12:04 +03:00
|
|
|
}
|
2018-06-30 07:29:11 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (!_vbox) {
|
|
|
|
strcat(cmdline, "novbox ");
|
|
|
|
}
|
2018-08-23 06:51:32 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (_vbox && !_vboxrects) {
|
|
|
|
strcat(cmdline, "novboxseamless ");
|
|
|
|
}
|
2018-08-23 06:51:32 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (_vbox && !_vboxpointer) {
|
|
|
|
strcat(cmdline, "novboxpointer ");
|
|
|
|
}
|
2018-09-28 18:48:15 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (_vmware && !_vmwareres) {
|
|
|
|
strcat(cmdline, "novmwareresset ");
|
|
|
|
}
|
2018-03-06 17:47:42 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
if (!_smp) {
|
|
|
|
strcat(cmdline, "nosmp ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_qemubug) {
|
|
|
|
strcat(cmdline, "sharedps2 ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!boot_edit) break;
|
|
|
|
if (boot_editor()) break;
|
2021-08-21 01:55:48 +03:00
|
|
|
|
2021-08-21 09:12:04 +03:00
|
|
|
boot_edit = 0;
|
|
|
|
memset(cmdline, 0, 1024);
|
2021-08-21 01:55:48 +03:00
|
|
|
}
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
boot();
|
2018-07-06 17:53:14 +03:00
|
|
|
|
|
|
|
while (1) {}
|
|
|
|
return 0;
|
2018-03-05 17:12:24 +03:00
|
|
|
}
|