2020-09-02 09:55:56 +02:00
|
|
|
#include <lib/term.h>
|
2019-05-31 05:47:13 +02:00
|
|
|
#include <lib/real.h>
|
2020-01-22 05:02:12 +01:00
|
|
|
#include <lib/blib.h>
|
2020-03-25 21:05:14 +01:00
|
|
|
#include <lib/libc.h>
|
2020-04-15 13:21:44 +02:00
|
|
|
#include <lib/part.h>
|
2020-01-22 07:13:19 +01:00
|
|
|
#include <lib/config.h>
|
2020-11-15 17:56:10 +01:00
|
|
|
#include <lib/trace.h>
|
2020-09-18 20:02:10 +02:00
|
|
|
#include <sys/e820.h>
|
2020-10-15 11:35:49 +02:00
|
|
|
#include <sys/a20.h>
|
2020-05-10 00:38:27 +02:00
|
|
|
#include <lib/print.h>
|
2020-04-14 05:20:55 +02:00
|
|
|
#include <fs/file.h>
|
2020-03-25 01:04:18 +01:00
|
|
|
#include <lib/elf.h>
|
2020-09-20 12:03:44 +02:00
|
|
|
#include <mm/pmm.h>
|
2020-09-27 17:39:30 +02:00
|
|
|
#include <mm/mtrr.h>
|
2020-03-25 21:05:14 +01:00
|
|
|
#include <protos/stivale.h>
|
2020-08-11 17:43:39 +02:00
|
|
|
#include <protos/stivale2.h>
|
2020-04-19 10:14:49 +02:00
|
|
|
#include <protos/linux.h>
|
2020-05-06 17:00:41 +02:00
|
|
|
#include <protos/chainload.h>
|
2020-06-05 20:27:52 +02:00
|
|
|
#include <menu.h>
|
2020-11-05 01:37:45 +01:00
|
|
|
#include <pxe/pxe.h>
|
|
|
|
#include <pxe/tftp.h>
|
2020-12-27 00:27:47 +01:00
|
|
|
#include <lib/tinf.h>
|
2020-04-21 18:27:05 +02:00
|
|
|
|
2020-12-27 00:27:47 +01:00
|
|
|
void entry(uint8_t _boot_drive, int pxe_boot, void *_tinf_gzip_uncompress) {
|
2020-10-17 06:23:11 +02:00
|
|
|
boot_drive = _boot_drive;
|
2020-12-27 00:27:47 +01:00
|
|
|
tinf_gzip_uncompress = _tinf_gzip_uncompress;
|
2020-10-17 06:23:11 +02:00
|
|
|
|
2020-12-29 01:01:38 +01:00
|
|
|
booted_from_pxe = pxe_boot;
|
|
|
|
|
2020-09-27 17:39:30 +02:00
|
|
|
mtrr_save();
|
|
|
|
|
2020-09-02 09:55:56 +02:00
|
|
|
term_textmode();
|
2020-01-25 02:05:19 +01:00
|
|
|
|
2020-08-29 20:02:16 +02:00
|
|
|
print("Limine " LIMINE_VERSION "\n\n");
|
2020-04-24 18:26:08 +02:00
|
|
|
|
2020-10-15 11:35:49 +02:00
|
|
|
if (!a20_enable())
|
|
|
|
panic("Could not enable A20 line");
|
|
|
|
|
2020-11-05 01:37:45 +01:00
|
|
|
init_e820();
|
|
|
|
init_memmap();
|
2020-11-09 14:29:53 +01:00
|
|
|
|
2020-12-06 16:43:38 +01:00
|
|
|
part_create_index();
|
|
|
|
|
2020-11-05 01:37:45 +01:00
|
|
|
if (pxe_boot) {
|
|
|
|
pxe_init();
|
2020-12-09 13:02:05 +01:00
|
|
|
if (init_config_pxe()) {
|
|
|
|
panic("Failed to load config file");
|
2020-04-15 13:21:44 +02:00
|
|
|
}
|
2020-12-09 13:02:05 +01:00
|
|
|
print("Config loaded via PXE\n");
|
2020-11-05 01:37:45 +01:00
|
|
|
} else {
|
|
|
|
print("Boot drive: %x\n", boot_drive);
|
|
|
|
// Look for config file.
|
|
|
|
print("Searching for config file...\n");
|
|
|
|
for (int i = 0; ; i++) {
|
2020-11-09 15:04:53 +01:00
|
|
|
struct part part;
|
|
|
|
int ret = part_get(&part, boot_drive, i);
|
|
|
|
switch (ret) {
|
|
|
|
case INVALID_TABLE:
|
|
|
|
panic("Partition table of boot drive is invalid.");
|
|
|
|
case END_OF_TABLE:
|
|
|
|
panic("Config file not found.");
|
|
|
|
case NO_PARTITION:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!init_config_disk(&part)) {
|
|
|
|
print("Config file found and loaded.\n");
|
2020-12-09 13:02:05 +01:00
|
|
|
boot_partition = i;
|
2020-11-09 15:04:53 +01:00
|
|
|
break;
|
2020-01-22 07:13:19 +01:00
|
|
|
}
|
2020-01-22 01:55:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-15 17:56:10 +01:00
|
|
|
trace_init();
|
|
|
|
|
2020-11-16 23:31:03 +01:00
|
|
|
char *cmdline;
|
|
|
|
char *config = menu(&cmdline);
|
2020-09-02 09:55:56 +02:00
|
|
|
|
2020-11-27 19:33:34 +01:00
|
|
|
char *proto = config_get_value(config, 0, "PROTOCOL");
|
|
|
|
if (proto == NULL) {
|
2020-11-01 10:31:35 +01:00
|
|
|
panic("PROTOCOL not specified");
|
2020-04-25 20:33:26 +02:00
|
|
|
}
|
2020-01-22 01:55:40 +01:00
|
|
|
|
2020-09-02 10:31:39 +02:00
|
|
|
if (!strcmp(proto, "stivale")) {
|
2020-11-16 23:31:03 +01:00
|
|
|
stivale_load(config, cmdline);
|
2020-09-02 10:31:39 +02:00
|
|
|
} else if (!strcmp(proto, "stivale2")) {
|
2020-12-10 14:10:47 +01:00
|
|
|
stivale2_load(config, cmdline, pxe_boot);
|
2020-09-02 10:31:39 +02:00
|
|
|
} else if (!strcmp(proto, "linux")) {
|
2020-11-16 23:31:03 +01:00
|
|
|
linux_load(config, cmdline);
|
2020-09-02 10:31:39 +02:00
|
|
|
} else if (!strcmp(proto, "chainload")) {
|
2020-11-16 23:31:03 +01:00
|
|
|
chainload(config);
|
2020-03-25 21:05:14 +01:00
|
|
|
} else {
|
2020-04-24 18:26:08 +02:00
|
|
|
panic("Invalid protocol specified");
|
2020-03-25 21:05:14 +01:00
|
|
|
}
|
2020-04-15 13:21:44 +02:00
|
|
|
}
|