protos: Remove pointless returns added for autodetection

This commit is contained in:
mintsuki 2022-07-13 07:40:53 +02:00
parent f592fdeb9c
commit b373ba0a8f
14 changed files with 38 additions and 41 deletions

View File

@ -69,7 +69,6 @@ nested:
getchar();
menu(false);
__builtin_unreachable();
/*
fb_clear(&fbinfo);

View File

@ -939,6 +939,4 @@ noreturn void boot(char *config) {
}
panic(true, "Incorrect protocol specified for kernel.");
__builtin_unreachable();
}

View File

@ -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; {
@ -186,7 +189,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");
@ -198,7 +201,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;

View File

@ -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

View File

@ -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();
}

View File

@ -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

View File

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdnoreturn.h>
#include <config.h>
#include <protos/stivale.h>
#include <protos/stivale2.h>
@ -121,7 +122,7 @@ static void term_write_shim(uint64_t context, uint64_t buf, uint64_t count) {
term_write(buf, count);
}
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");
@ -142,8 +143,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
@ -159,7 +159,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;
@ -201,10 +201,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.");
@ -741,6 +737,4 @@ FEAT_END
stivale_spinup(64, want_5lv, &pagemap, entry_point, 0,
reported_addr(stack), true, true, (uintptr_t)local_gdt);
__builtin_unreachable();
}

View File

@ -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

View File

@ -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;
@ -626,5 +625,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);
}

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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