protos: Remove pointless returns added for autodetection
This commit is contained in:
parent
0af37b7cf0
commit
e5e125887b
@ -69,7 +69,6 @@ nested:
|
||||
getchar();
|
||||
|
||||
menu(false);
|
||||
__builtin_unreachable();
|
||||
/*
|
||||
fb_clear(&fbinfo);
|
||||
|
||||
|
@ -937,6 +937,4 @@ noreturn void boot(char *config) {
|
||||
}
|
||||
|
||||
panic(true, "Incorrect protocol specified for kernel.");
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <protos/chainload.h>
|
||||
#include <lib/part.h>
|
||||
#include <lib/config.h>
|
||||
@ -20,7 +21,7 @@
|
||||
#if bios == 1
|
||||
|
||||
__attribute__((noinline, section(".realmode")))
|
||||
static void spinup(uint8_t drive) {
|
||||
noreturn static void spinup(uint8_t drive) {
|
||||
struct idtr real_mode_idt;
|
||||
real_mode_idt.limit = 0x3ff;
|
||||
real_mode_idt.ptr = 0;
|
||||
@ -67,9 +68,11 @@ static void spinup(uint8_t drive) {
|
||||
: "a" (&real_mode_idt), "d" (drive)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void chainload(char *config) {
|
||||
noreturn void chainload(char *config) {
|
||||
uint64_t val;
|
||||
|
||||
int part; {
|
||||
@ -144,7 +147,7 @@ void bios_chainload_volume(struct volume *p) {
|
||||
|
||||
#elif uefi == 1
|
||||
|
||||
void chainload(char *config) {
|
||||
noreturn void chainload(char *config) {
|
||||
char *image_path = config_get_value(config, 0, "IMAGE_PATH");
|
||||
if (image_path == NULL)
|
||||
panic(true, "chainload: IMAGE_PATH not specified");
|
||||
@ -156,7 +159,7 @@ void chainload(char *config) {
|
||||
efi_chainload_file(config, image);
|
||||
}
|
||||
|
||||
void efi_chainload_file(char *config, struct file_handle *image) {
|
||||
noreturn void efi_chainload_file(char *config, struct file_handle *image) {
|
||||
EFI_STATUS status;
|
||||
|
||||
EFI_HANDLE efi_part_handle = image->efi_part_handle;
|
||||
|
@ -1,11 +1,13 @@
|
||||
#ifndef __PROTOS__CHAINLOAD_H__
|
||||
#define __PROTOS__CHAINLOAD_H__
|
||||
|
||||
void chainload(char *config);
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
noreturn void chainload(char *config);
|
||||
|
||||
#if uefi == 1
|
||||
#include <fs/file.h>
|
||||
void efi_chainload_file(char *config, struct file_handle *image);
|
||||
noreturn void efi_chainload_file(char *config, struct file_handle *image);
|
||||
#endif
|
||||
|
||||
#if bios == 1
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <protos/chainload_next.h>
|
||||
#include <protos/chainload.h>
|
||||
#include <lib/blib.h>
|
||||
@ -30,7 +31,7 @@ static void try(char *config, struct volume *v) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void chainload_next(char *config) {
|
||||
noreturn void chainload_next(char *config) {
|
||||
bool wrap = false;
|
||||
for (int i = boot_volume->is_optical ? 0 : (wrap = true, boot_volume->index + 1);
|
||||
boot_volume->is_optical ? true : i != boot_volume->index; i++) {
|
||||
@ -64,6 +65,4 @@ void chainload_next(char *config) {
|
||||
}
|
||||
|
||||
panic(true, "chainload_next: No other bootable device");
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __PROTOS__CHAINLOAD_NEXT_H__
|
||||
#define __PROTOS__CHAINLOAD_NEXT_H__
|
||||
|
||||
void chainload_next(char *config);
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
noreturn void chainload_next(char *config);
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <config.h>
|
||||
#include <lib/elf.h>
|
||||
#include <lib/blib.h>
|
||||
@ -33,9 +34,9 @@
|
||||
#define MAX_REQUESTS 128
|
||||
#define MAX_MEMMAP 256
|
||||
|
||||
pagemap_t build_pagemap(bool level5pg, struct elf_range *ranges, size_t ranges_count,
|
||||
uint64_t physical_base, uint64_t virtual_base,
|
||||
uint64_t direct_map_offset) {
|
||||
static pagemap_t build_pagemap(bool level5pg, struct elf_range *ranges, size_t ranges_count,
|
||||
uint64_t physical_base, uint64_t virtual_base,
|
||||
uint64_t direct_map_offset) {
|
||||
pagemap_t pagemap = new_pagemap(level5pg ? 5 : 4);
|
||||
|
||||
if (ranges_count == 0) {
|
||||
@ -132,33 +133,6 @@ extern symbol ImageBase;
|
||||
|
||||
extern symbol limine_spinup_32;
|
||||
|
||||
static noreturn void spinup(bool level5pg, pagemap_t *pagemap,
|
||||
uint64_t entry_point, uint64_t stack,
|
||||
uint32_t local_gdt) {
|
||||
#if bios == 1
|
||||
// If we're going 64, we might as well call this BIOS interrupt
|
||||
// to tell the BIOS that we are entering Long Mode, since it is in
|
||||
// the specification.
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0xec00;
|
||||
r.ebx = 0x02; // Long mode only
|
||||
rm_int(0x15, &r, &r);
|
||||
#endif
|
||||
|
||||
vmm_assert_nx();
|
||||
|
||||
pic_mask_all();
|
||||
io_apic_mask_all();
|
||||
|
||||
irq_flush_type = IRQ_PIC_APIC_FLUSH;
|
||||
|
||||
common_spinup(limine_spinup_32, 7,
|
||||
level5pg, (uint32_t)(uintptr_t)pagemap->top_level,
|
||||
(uint32_t)entry_point, (uint32_t)(entry_point >> 32),
|
||||
(uint32_t)stack, (uint32_t)(stack >> 32),
|
||||
local_gdt);
|
||||
}
|
||||
|
||||
static uint64_t physical_base, virtual_base, slide, direct_map_offset;
|
||||
static size_t requests_count;
|
||||
static void **requests;
|
||||
@ -250,7 +224,7 @@ static noreturn void fb_too_big(void) {
|
||||
" Please update kernel to the new requests, or file a bug report to the upstream kernel if necessary.");
|
||||
}
|
||||
|
||||
bool limine_load(char *config, char *cmdline) {
|
||||
noreturn void limine_load(char *config, char *cmdline) {
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
char *kernel_path = config_get_value(config, 0, "KERNEL_PATH");
|
||||
@ -271,8 +245,7 @@ bool limine_load(char *config, char *cmdline) {
|
||||
int bits = elf_bits(kernel);
|
||||
|
||||
if (bits == -1 || bits == 32) {
|
||||
printv("limine: Kernel in unrecognised format");
|
||||
return false;
|
||||
panic(true, "limine: Kernel in unrecognised format");
|
||||
}
|
||||
|
||||
// ELF loading
|
||||
@ -288,7 +261,7 @@ bool limine_load(char *config, char *cmdline) {
|
||||
&ranges, &ranges_count,
|
||||
true, &physical_base, &virtual_base, &image_size,
|
||||
&is_reloc)) {
|
||||
return false;
|
||||
panic(true, "limine: ELF64 load failure");
|
||||
}
|
||||
|
||||
kaslr = kaslr && is_reloc;
|
||||
@ -330,10 +303,6 @@ bool limine_load(char *config, char *cmdline) {
|
||||
}
|
||||
}
|
||||
|
||||
if (requests_count == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if 64 bit CPU
|
||||
if (!cpuid(0x80000001, 0, &eax, &ebx, &ecx, &edx) || !(edx & (1 << 29))) {
|
||||
panic(true, "limine: This CPU does not support 64-bit mode.");
|
||||
@ -988,8 +957,28 @@ FEAT_END
|
||||
|
||||
term_runtime = true;
|
||||
|
||||
spinup(want_5lv, &pagemap, entry_point,
|
||||
reported_addr(stack), (uintptr_t)local_gdt);
|
||||
#if bios == 1
|
||||
// If we're going 64, we might as well call this BIOS interrupt
|
||||
// to tell the BIOS that we are entering Long Mode, since it is in
|
||||
// the specification.
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0xec00;
|
||||
r.ebx = 0x02; // Long mode only
|
||||
rm_int(0x15, &r, &r);
|
||||
#endif
|
||||
|
||||
__builtin_unreachable();
|
||||
vmm_assert_nx();
|
||||
|
||||
pic_mask_all();
|
||||
io_apic_mask_all();
|
||||
|
||||
irq_flush_type = IRQ_PIC_APIC_FLUSH;
|
||||
|
||||
uint64_t reported_stack = reported_addr(stack);
|
||||
|
||||
common_spinup(limine_spinup_32, 7,
|
||||
want_5lv, (uint32_t)(uintptr_t)pagemap.top_level,
|
||||
(uint32_t)entry_point, (uint32_t)(entry_point >> 32),
|
||||
(uint32_t)reported_stack, (uint32_t)(reported_stack >> 32),
|
||||
(uint32_t)(uintptr_t)local_gdt);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef __PROTOS__LIMINE_H__
|
||||
#define __PROTOS__LIMINE_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
bool limine_load(char *config, char *cmdline);
|
||||
noreturn void limine_load(char *config, char *cmdline);
|
||||
|
||||
#endif
|
||||
|
@ -348,7 +348,7 @@ struct boot_params {
|
||||
|
||||
// End of Linux code
|
||||
|
||||
bool linux_load(char *config, char *cmdline) {
|
||||
noreturn void linux_load(char *config, char *cmdline) {
|
||||
struct file_handle *kernel_file;
|
||||
|
||||
char *kernel_path = config_get_value(config, 0, "KERNEL_PATH");
|
||||
@ -363,8 +363,7 @@ bool linux_load(char *config, char *cmdline) {
|
||||
|
||||
// validate signature
|
||||
if (signature != 0x53726448) {
|
||||
fclose(kernel_file);
|
||||
return false;
|
||||
panic(true, "linux: Invalid kernel signature");
|
||||
}
|
||||
|
||||
size_t setup_code_size = 0;
|
||||
@ -613,5 +612,6 @@ set_textmode:;
|
||||
|
||||
irq_flush_type = IRQ_PIC_ONLY_FLUSH;
|
||||
|
||||
common_spinup(linux_spinup, 2, (void *)kernel_load_addr, boot_params);
|
||||
common_spinup(linux_spinup, 2, (uint32_t)kernel_load_addr,
|
||||
(uint32_t)(uintptr_t)boot_params);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef __PROTOS__LINUX_H__
|
||||
#define __PROTOS__LINUX_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
bool linux_load(char *config, char *cmdline);
|
||||
noreturn void linux_load(char *config, char *cmdline);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <protos/multiboot1.h>
|
||||
#include <protos/multiboot.h>
|
||||
#include <config.h>
|
||||
@ -43,7 +44,7 @@ static void *mb1_info_alloc(void **mb1_info_raw, size_t size) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool multiboot1_load(char *config, char *cmdline) {
|
||||
noreturn void multiboot1_load(char *config, char *cmdline) {
|
||||
struct file_handle *kernel_file;
|
||||
|
||||
char *kernel_path = config_get_value(config, 0, "KERNEL_PATH");
|
||||
@ -72,8 +73,7 @@ bool multiboot1_load(char *config, char *cmdline) {
|
||||
}
|
||||
|
||||
if (header.magic != MULTIBOOT1_HEADER_MAGIC) {
|
||||
pmm_free(kernel_file, kernel_file_size);
|
||||
return false;
|
||||
panic(true, "multiboot1: Invalid magic");
|
||||
}
|
||||
|
||||
print("multiboot1: Loading kernel `%s`...\n", kernel_path);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
#define MULTIBOOT1_HEADER_MAGIC 0x1BADB002
|
||||
|
||||
@ -94,6 +94,6 @@ struct multiboot1_mmap_entry {
|
||||
uint32_t type;
|
||||
} __attribute__((packed));
|
||||
|
||||
bool multiboot1_load(char *config, char *cmdline);
|
||||
noreturn void multiboot1_load(char *config, char *cmdline);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdnoreturn.h>
|
||||
#include <protos/multiboot2.h>
|
||||
#include <protos/multiboot.h>
|
||||
#include <config.h>
|
||||
@ -58,7 +59,7 @@ static size_t get_multiboot2_info_size(
|
||||
|
||||
#define append_tag(P, TAG) ({ (P) += ALIGN_UP((TAG)->size, MULTIBOOT_TAG_ALIGN); })
|
||||
|
||||
bool multiboot2_load(char *config, char* cmdline) {
|
||||
noreturn void multiboot2_load(char *config, char* cmdline) {
|
||||
struct file_handle *kernel_file;
|
||||
|
||||
char *kernel_path = config_get_value(config, 0, "KERNEL_PATH");
|
||||
@ -85,8 +86,7 @@ bool multiboot2_load(char *config, char* cmdline) {
|
||||
}
|
||||
|
||||
if (header->magic != MULTIBOOT2_HEADER_MAGIC) {
|
||||
pmm_free(kernel_file, kernel_file_size);
|
||||
return false;
|
||||
panic(true, "multiboot2: Invalid magic");
|
||||
}
|
||||
|
||||
print("multiboot2: Loading kernel `%s`...\n", kernel_path);
|
||||
|
@ -23,9 +23,9 @@
|
||||
#define __PROTOS__MULTIBOOT2_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
bool multiboot2_load(char *config, char *cmdline);
|
||||
noreturn void multiboot2_load(char *config, char *cmdline);
|
||||
|
||||
/* How many bytes from the start of the file we search for the header. */
|
||||
#define MULTIBOOT_SEARCH 32768
|
||||
|
Loading…
Reference in New Issue
Block a user