2018-03-06 13:43:01 +03:00
|
|
|
//#define __DEBUG__
|
|
|
|
|
2018-03-06 12:18:53 +03:00
|
|
|
#include "types.h"
|
|
|
|
#include "ata.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "atapi_imp.h"
|
|
|
|
#include "iso9660.h"
|
|
|
|
#include "elf.h"
|
|
|
|
#include "multiboot.h"
|
2018-06-09 12:56:00 +03:00
|
|
|
#include "kbd.h"
|
|
|
|
#include "options.h"
|
2018-03-06 12:18:53 +03:00
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Basic text strings */
|
|
|
|
#define VERSION_TEXT "ToaruOS-NIH Bootloader v1.2"
|
|
|
|
#define HELP_TEXT "Press <Enter> or select a menu option with \030/\031."
|
|
|
|
#define COPYRIGHT_TEXT "ToaruOS is free software under the NCSA license."
|
|
|
|
#define LINK_TEXT "https://toaruos.org - https://gitlab.com/toaruos"
|
|
|
|
|
|
|
|
/* Boot command line strings */
|
2018-06-09 10:36:48 +03:00
|
|
|
#define DEFAULT_ROOT_CMDLINE "root=/dev/ram0,nocache "
|
2018-06-09 12:05:09 +03:00
|
|
|
#define DEFAULT_GRAPHICAL_CMDLINE "start=live-session "
|
2018-06-09 11:33:23 +03:00
|
|
|
#define DEFAULT_SINGLE_CMDLINE "start=terminal "
|
2018-06-09 10:36:48 +03:00
|
|
|
#define DEFAULT_TEXT_CMDLINE "start=--vga "
|
|
|
|
#define DEFAULT_VID_CMDLINE "vid=auto,1440,900 "
|
|
|
|
#define MIGRATE_CMDLINE "start=--migrate _"
|
|
|
|
#define DEBUG_LOG_CMDLINE "logtoserial=3 "
|
|
|
|
|
2018-06-09 13:19:21 +03:00
|
|
|
#define KERNEL_PATH "KERNEL."
|
|
|
|
#define RAMDISK_PATH "RAMDISK.IMG"
|
|
|
|
#define MODULE_DIRECTORY "MOD"
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Where to dump kernel data while loading */
|
2018-03-06 12:18:53 +03:00
|
|
|
#define KERNEL_LOAD_START 0x300000
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Module file names - need to be ordered. */
|
2018-03-06 12:52:57 +03:00
|
|
|
static char * modules[] = {
|
2018-03-06 17:47:42 +03:00
|
|
|
"ZERO.KO", // 0
|
|
|
|
"RANDOM.KO", // 1
|
|
|
|
"SERIAL.KO", // 2
|
|
|
|
"DEBUG_SH.KO", // 3
|
|
|
|
"PROCFS.KO", // 4
|
|
|
|
"TMPFS.KO", // 5
|
|
|
|
"ATA.KO", // 6
|
|
|
|
"EXT2.KO", // 7
|
|
|
|
"ISO9660.KO", // 8
|
|
|
|
"PS2KBD.KO", // 9
|
|
|
|
"PS2MOUSE.KO", // 10
|
|
|
|
"LFBVIDEO.KO", // 11
|
|
|
|
"VBOXGUES.KO", // 12
|
|
|
|
"VMWARE.KO", // 13
|
|
|
|
"VIDSET.KO", // 14
|
|
|
|
"PACKETFS.KO", // 15
|
|
|
|
"SND.KO", // 16
|
|
|
|
"AC97.KO", // 17
|
|
|
|
"NET.KO", // 18
|
|
|
|
"PCNET.KO", // 19
|
|
|
|
"RTL.KO", // 20
|
|
|
|
"E1000.KO", // 21
|
2018-05-04 07:11:06 +03:00
|
|
|
"PCSPKR.KO", // 22
|
2018-03-06 12:18:53 +03:00
|
|
|
0
|
|
|
|
};
|
2018-03-06 12:52:57 +03:00
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Names of the available boot modes. */
|
2018-06-09 11:58:29 +03:00
|
|
|
static char * boot_mode_names[] = {
|
|
|
|
"Normal Boot",
|
|
|
|
"VGA Text Mode",
|
|
|
|
"Single-User Graphical Terminal",
|
|
|
|
};
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* More bootloader implementation that depends on the module config */
|
|
|
|
#include "moremultiboot.h"
|
2018-06-09 11:58:29 +03:00
|
|
|
|
2018-03-05 17:12:24 +03:00
|
|
|
int kmain() {
|
2018-06-09 12:56:00 +03:00
|
|
|
|
|
|
|
/* Boot options - configurable values */
|
2018-03-06 17:47:42 +03:00
|
|
|
|
2018-06-09 11:58:29 +03:00
|
|
|
BOOT_OPTION(_debug, 0, "Enable debug output.",
|
|
|
|
"Enable debug output in the bootloader and enable the",
|
|
|
|
"serial debug log in the operating system itself.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_legacy_ata, 0, "Enable legacy ATA driver.",
|
|
|
|
"Enable the legacy ATA driver, which does not support",
|
|
|
|
"ATAPI or use DMA. May be necessary in some virtual machines.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_normal_ata, 1, "Enable DMA ATA driver.",
|
|
|
|
"Enable the normal, DMA-capable ATA driver. This is the default.",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
BOOT_OPTION(_debug_shell, 1, "Enable debug shell.",
|
|
|
|
"Enable the kernel debug shell. This can be accessed using",
|
|
|
|
"the `kdebug` application.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_video, 1, "Enable video modules.",
|
|
|
|
"Enable the video modules. These are needed to modeset",
|
|
|
|
"and provide a framebuffer for the UI.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_vbox, 1, "Enable VirtualBox Guest Additions.",
|
|
|
|
"Enable integration with VirtualBox, including",
|
|
|
|
"automatic mode setting and absolute mouse pointer.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_vmware, 1, "Enable VMWare mouse driver.",
|
|
|
|
"Enable the VMware / QEMU absolute mouse pointer.",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
BOOT_OPTION(_sound, 1, "Enable audio drivers.",
|
|
|
|
"Enable the audio subsystem and AC'97 drivers.",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
BOOT_OPTION(_net, 1, "Enable network drivers.",
|
|
|
|
"Enable the IPv4 network subsystem and various",
|
|
|
|
"network interface drivers.");
|
|
|
|
|
|
|
|
BOOT_OPTION(_migrate, 1, "Enable writable root.",
|
|
|
|
"Migrates the ramdisk from ext2 to an in-memory",
|
|
|
|
"temporary filesystem at boot.");
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Loop over rendering the menu */
|
|
|
|
show_menu();
|
2018-06-09 10:36:48 +03:00
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Build our command line. */
|
2018-06-09 10:36:48 +03:00
|
|
|
strcat(cmdline, DEFAULT_ROOT_CMDLINE);
|
|
|
|
|
|
|
|
if (_migrate) {
|
|
|
|
strcat(cmdline, MIGRATE_CMDLINE);
|
|
|
|
}
|
|
|
|
|
2018-03-06 17:47:42 +03:00
|
|
|
if (boot_mode == 0) {
|
2018-06-09 10:36:48 +03:00
|
|
|
strcat(cmdline, DEFAULT_GRAPHICAL_CMDLINE);
|
|
|
|
strcat(cmdline, DEFAULT_VID_CMDLINE);
|
2018-03-06 17:47:42 +03:00
|
|
|
} else if (boot_mode == 1) {
|
2018-06-09 10:36:48 +03:00
|
|
|
strcat(cmdline, DEFAULT_TEXT_CMDLINE);
|
2018-06-09 11:33:23 +03:00
|
|
|
} else if (boot_mode == 2) {
|
|
|
|
strcat(cmdline, DEFAULT_SINGLE_CMDLINE);
|
|
|
|
strcat(cmdline, DEFAULT_VID_CMDLINE);
|
2018-03-06 17:47:42 +03:00
|
|
|
}
|
|
|
|
|
2018-06-09 10:36:48 +03:00
|
|
|
if (_debug) {
|
|
|
|
strcat(cmdline, DEBUG_LOG_CMDLINE);
|
|
|
|
}
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
/* Configure modules */
|
2018-03-06 17:47:42 +03:00
|
|
|
if (!_normal_ata) {
|
|
|
|
modules[6] = "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_legacy_ata) {
|
|
|
|
modules[6] = "ATAOLD.KO";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_debug_shell) {
|
|
|
|
modules[3] = "NONE";
|
|
|
|
modules[14] = "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_video) {
|
|
|
|
modules[11] = "NONE";
|
|
|
|
modules[12] = "NONE";
|
|
|
|
modules[13] = "NONE";
|
2018-03-07 07:34:31 +03:00
|
|
|
modules[14] = "NONE";
|
2018-03-06 17:47:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!_vmware) {
|
|
|
|
modules[13] = "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_vbox) {
|
|
|
|
modules[12] = "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_sound) {
|
|
|
|
modules[16] = "NONE";
|
|
|
|
modules[17] = "NONE";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_net) {
|
|
|
|
modules[18] = "NONE";
|
|
|
|
modules[19] = "NONE";
|
|
|
|
modules[20] = "NONE";
|
|
|
|
modules[21] = "NONE";
|
|
|
|
}
|
|
|
|
|
2018-06-09 12:56:00 +03:00
|
|
|
boot();
|
2018-03-05 17:12:24 +03:00
|
|
|
}
|