#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined (uefi) __attribute__((ms_abi)) EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { (void)ImageHandle; gST = SystemTable; gBS = SystemTable->BootServices; gRT = SystemTable->RuntimeServices; print("hello world\n"); for (;;); } #endif __attribute__((section(".stage3_build_id"))) uint64_t stage3_build_id = BUILD_ID; __attribute__((noreturn)) __attribute__((section(".stage3_entry"))) void stage3_entry(int boot_from) { mtrr_save(); switch (boot_from) { case BOOT_FROM_HDD: case BOOT_FROM_CD: { struct volume boot_volume; volume_get_by_coord(&boot_volume, boot_drive, -1); struct volume part = boot_volume; for (int i = 0; ; i++) { if (!init_config_disk(&part)) { print("Config file found and loaded.\n"); boot_partition = i - 1; break; } int ret = part_get(&part, &boot_volume, i); switch (ret) { case INVALID_TABLE: case END_OF_TABLE: panic("Config file not found."); } } break; case BOOT_FROM_PXE: pxe_init(); if (init_config_pxe()) { panic("Failed to load config file"); } print("Config loaded via PXE\n"); break; } } char *cmdline; char *config = menu(&cmdline); char *proto = config_get_value(config, 0, "PROTOCOL"); if (proto == NULL) { panic("PROTOCOL not specified"); } if (!strcmp(proto, "stivale")) { stivale_load(config, cmdline); } else if (!strcmp(proto, "stivale2")) { stivale2_load(config, cmdline, booted_from_pxe); } else if (!strcmp(proto, "linux")) { linux_load(config, cmdline); } else if (!strcmp(proto, "chainload")) { chainload(config); } else { panic("Invalid protocol specified"); } for (;;); }