misc: Change how bios and uefi macros are defined and tested

This commit is contained in:
mintsuki 2021-07-15 10:03:47 +02:00
parent d478a1b28b
commit 1aa5ae13fc
43 changed files with 121 additions and 121 deletions

View File

@ -70,12 +70,13 @@ INTERNAL_CFLAGS := \
-DLIMINE_VERSION='"$(LIMINE_VERSION)"' \
-DCOM_OUTPUT=$(COM_OUTPUT) \
-DE9_OUTPUT=$(E9_OUTPUT) \
-D$(TARGET)=1 \
-I. \
-I..
ifeq ($(TARGET), bios)
INTERNAL_CFLAGS += \
-Dbios=1 \
-Duefi=0 \
-m32 \
-march=i386 \
-fno-pie
@ -84,11 +85,15 @@ endif
ifeq ($(TARGET), uefi)
INTERNAL_CFLAGS32 := \
$(INTERNAL_CFLAGS) \
-Dbios=0 \
-Duefi=1 \
-m32 \
-march=i386 \
-fpie
INTERNAL_CFLAGS += \
-Dbios=0 \
-Duefi=1 \
-m64 \
-march=x86-64 \
-I../gnu-efi/inc \

View File

@ -6,7 +6,7 @@
#include <stdbool.h>
#include <lib/part.h>
#if defined (uefi)
#if uefi == 1
#include <efi.h>

View File

@ -2,15 +2,15 @@
#include <stddef.h>
#include <drivers/disk.h>
#include <lib/libc.h>
#if defined (bios)
#if bios == 1
# include <lib/real.h>
#elif defined (uefi)
#elif uefi == 1
# include <efi.h>
#endif
#include <lib/blib.h>
#include <mm/pmm.h>
#if defined(bios)
#if bios == 1
struct bios_drive_params {
uint16_t buf_size;
@ -194,7 +194,7 @@ void disk_create_index(void) {
#endif
#if defined (uefi)
#if uefi == 1
struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
EFI_STATUS status;

View File

@ -6,7 +6,7 @@
#include <lib/libc.h>
#include <lib/print.h>
#if defined (bios)
#if bios == 1
#include <lib/real.h>
@ -45,7 +45,7 @@ success:
#endif
#if defined (uefi)
#if uefi == 1
#include <efi.h>

View File

@ -1,4 +1,4 @@
#if defined (uefi)
#if uefi == 1
#include <efi.h>
#include <lib/blib.h>

View File

@ -1,7 +1,7 @@
#ifndef __DRIVERS__GOP_H__
#define __DRIVERS__GOP_H__
#if defined (uefi)
#if uefi == 1
#include <stdint.h>
#include <stdbool.h>

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <stddef.h>
#include <stdint.h>

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <stdint.h>
#include <stddef.h>

View File

@ -25,7 +25,7 @@ extern uint64_t stage3_build_id;
struct volume *boot_volume;
#if defined (bios)
#if bios == 1
bool stage3_loaded = false;
static bool stage3_found = false;

View File

@ -23,7 +23,7 @@
void stage3_common(void);
#if defined (uefi)
#if uefi == 1
__attribute__((naked))
EFI_STATUS efi_main(
__attribute__((unused)) EFI_HANDLE ImageHandle,
@ -78,7 +78,7 @@ void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
}
#endif
#if defined (bios)
#if bios == 1
__attribute__((section(".stage3_build_id")))
uint64_t stage3_build_id = BUILD_ID;
@ -119,9 +119,9 @@ void stage3_common(void) {
if (!strcmp(proto, "stivale")) {
stivale_load(config, cmdline);
} else if (!strcmp(proto, "stivale2")) {
#if defined (bios)
#if bios == 1
void *efi_system_table = NULL;
#elif defined (uefi)
#elif uefi == 1
void *efi_system_table = gST;
#endif

View File

@ -26,7 +26,7 @@ bool fs_get_guid(struct guid *guid, struct volume *part) {
int fopen(struct file_handle *ret, struct volume *part, const char *filename) {
ret->is_memfile = false;
#if defined (bios)
#if bios == 1
if (part->pxe) {
struct tftp_file_handle *fd = ext_mem_alloc(sizeof(struct tftp_file_handle));

View File

@ -14,7 +14,7 @@ uint8_t acpi_checksum(void *ptr, size_t size) {
return sum;
}
#if defined (bios)
#if bios == 1
void *acpi_get_rsdp(void) {
size_t ebda = EBDA;
@ -59,7 +59,7 @@ void acpi_get_smbios(void **smbios32, void **smbios64) {
#endif
#if defined (uefi)
#if uefi == 1
#include <efi.h>

View File

@ -9,7 +9,7 @@
#include <fs/file.h>
#include <mm/pmm.h>
#if defined (uefi)
#if uefi == 1
EFI_SYSTEM_TABLE *gST;
EFI_BOOT_SERVICES *gBS;
EFI_RUNTIME_SERVICES *gRT;
@ -70,7 +70,7 @@ uint64_t sqrt(uint64_t a_nInput) {
return res;
}
#if defined (uefi)
#if uefi == 1
bool efi_boot_services_exited = false;

View File

@ -6,11 +6,11 @@
#include <stdbool.h>
#include <fs/file.h>
#include <lib/part.h>
#if defined (uefi)
#if uefi == 1
# include <efi.h>
#endif
#if defined (uefi)
#if uefi == 1
extern EFI_SYSTEM_TABLE *gST;
extern EFI_BOOT_SERVICES *gBS;
extern EFI_RUNTIME_SERVICES *gRT;
@ -24,7 +24,7 @@ bool efi_exit_boot_services(void);
extern struct volume *boot_volume;
#if defined (bios)
#if bios == 1
extern bool stage3_loaded;
#endif

View File

@ -33,7 +33,7 @@ int init_config_disk(struct volume *part) {
return init_config(config_size);
}
#if defined (bios)
#if bios == 1
int init_config_pxe(void) {
struct tftp_file_handle cfg;
if (tftp_open(&cfg, 0, 69, "limine.cfg")) {

View File

@ -10,9 +10,9 @@ bool fb_init(struct fb_info *ret,
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
bool r;
#if defined (bios)
#if bios == 1
r = init_vbe(ret, target_width, target_height, target_bpp);
#elif defined (uefi)
#elif uefi == 1
r = init_gop(ret, target_width, target_height, target_bpp);
#endif

View File

@ -1,7 +1,7 @@
#include <lib/print.h>
#include <lib/real.h>
#include <lib/trace.h>
#if defined (uefi)
#if uefi == 1
# include <efi.h>
#endif
#include <lib/blib.h>
@ -22,10 +22,10 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
print("\n");
print_stacktrace(NULL);
#if defined (bios)
#if bios == 1
print("System halted.");
rm_hcf();
#elif defined (uefi)
#elif uefi == 1
if (efi_boot_services_exited == false) {
print("Press [ENTER] to return to firmware.");
while (getchar() != '\n');

View File

@ -5,7 +5,7 @@
#include <stddef.h>
#include <stdbool.h>
#include <lib/guid.h>
#if defined (uefi)
#if uefi == 1
# include <efi.h>
#endif
@ -14,9 +14,9 @@
#define END_OF_TABLE (-3)
struct volume {
#if defined (uefi)
#if uefi == 1
EFI_HANDLE efi_handle;
#elif defined (bios)
#elif bios == 1
int drive;
#endif
@ -53,7 +53,7 @@ int part_get(struct volume *part, struct volume *volume, int partition);
struct volume *volume_get_by_guid(struct guid *guid);
struct volume *volume_get_by_coord(bool optical, int drive, int partition);
#if defined (bios)
#if bios == 1
struct volume *volume_get_by_bios_drive(int drive);
#endif

View File

@ -2,7 +2,7 @@
#include <stdint.h>
#include <lib/part.h>
#include <drivers/disk.h>
#if defined (bios)
#if bios == 1
# include <lib/real.h>
#endif
#include <lib/libc.h>
@ -150,9 +150,9 @@ static int gpt_get_part(struct volume *ret, struct volume *volume, int partition
if (!memcmp(&entry.unique_partition_guid, &empty_guid, sizeof(struct guid)))
return NO_PARTITION;
#if defined (uefi)
#if uefi == 1
ret->efi_handle = volume->efi_handle;
#elif defined (bios)
#elif bios == 1
ret->drive = volume->drive;
#endif
ret->index = volume->index;
@ -210,9 +210,9 @@ static int mbr_get_logical_part(struct volume *ret, struct volume *extended_part
if (entry.type == 0)
return NO_PARTITION;
#if defined (uefi)
#if uefi == 1
ret->efi_handle = extended_part->efi_handle;
#elif defined (bios)
#elif bios == 1
ret->drive = extended_part->drive;
#endif
ret->index = extended_part->index;
@ -288,9 +288,9 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
struct volume extended_part = {0};
#if defined (uefi)
#if uefi == 1
extended_part.efi_handle = volume->efi_handle;
#elif defined (bios)
#elif bios == 1
extended_part.drive = volume->drive;
#endif
extended_part.index = volume->index;
@ -314,9 +314,9 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
if (entry.type == 0)
return NO_PARTITION;
#if defined (uefi)
#if uefi == 1
ret->efi_handle = volume->efi_handle;
#elif defined (bios)
#elif bios == 1
ret->drive = volume->drive;
#endif
ret->index = volume->index;
@ -384,7 +384,7 @@ struct volume *volume_get_by_coord(bool optical, int drive, int partition) {
return NULL;
}
#if defined (bios)
#if bios == 1
struct volume *volume_get_by_bios_drive(int drive) {
for (size_t i = 0; i < volume_index_i; i++) {
if (volume_index[i]->drive == drive) {

View File

@ -4,15 +4,15 @@
#include <lib/libc.h>
#include <lib/blib.h>
#include <lib/term.h>
#if defined (bios)
#if bios == 1
# include <lib/real.h>
#elif defined (uefi)
#elif uefi == 1
# include <efi.h>
#endif
int getchar_internal(uint8_t scancode, uint8_t ascii) {
switch (scancode) {
#if defined (bios)
#if bios == 1
case 0x44:
return GETCHAR_F10;
case 0x4b:
@ -35,7 +35,7 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return GETCHAR_PGDOWN;
case 0x01:
return GETCHAR_ESCAPE;
#elif defined (uefi)
#elif uefi == 1
case SCAN_F10:
return GETCHAR_F10;
case SCAN_LEFT:
@ -73,7 +73,7 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
return ascii;
}
#if defined (bios)
#if bios == 1
int getchar(void) {
again:;
struct rm_regs r = {0};
@ -91,7 +91,7 @@ int pit_sleep_and_quit_on_keypress(int seconds) {
}
#endif
#if defined (uefi)
#if uefi == 1
int getchar(void) {
again:;
EFI_INPUT_KEY key = {0};

View File

@ -12,7 +12,7 @@ void term_vbe(int width, int height) {
term_backend = NOT_READY;
if (!gterm_init(&term_rows, &term_cols, width, height)) {
#if defined (bios)
#if bios == 1
// Failed to set VBE properly, default to text mode
term_textmode();
#endif

View File

@ -33,7 +33,7 @@ void (*term_double_buffer_flush)(void);
int term_rows, term_cols;
#if defined (bios)
#if bios == 1
void term_textmode(void) {
term_backend = NOT_READY;

View File

@ -1,9 +1,9 @@
#include <stddef.h>
#include <stdint.h>
#include <lib/time.h>
#if defined (bios)
#if bios == 1
# include <lib/real.h>
#elif defined (uefi)
#elif uefi == 1
# include <efi.h>
#endif
#include <lib/blib.h>
@ -26,7 +26,7 @@ static uint64_t get_unix_epoch(uint8_t seconds, uint8_t minutes, uint8_t hours,
return (jdn_diff * (60 * 60 * 24)) + hours * 3600 + minutes * 60 + seconds;
}
#if defined (bios)
#if bios == 1
uint64_t time(void) {
struct rm_regs r = {0};
@ -49,7 +49,7 @@ uint64_t time(void) {
}
#endif
#if defined (uefi)
#if uefi == 1
uint64_t time(void) {
EFI_TIME time;
uefi_call_wrapper(gRT->GetTime, 2, &time, NULL);

View File

@ -8,9 +8,9 @@
#include <fs/file.h>
#include <mm/pmm.h>
#if defined (bios)
#if bios == 1
extern symbol stage2_map;
#elif defined (uefi)
#elif uefi == 1
extern symbol ImageBase;
#endif
@ -19,12 +19,12 @@ extern symbol full_map;
static char *trace_address(size_t *off, size_t addr) {
char *limine_map;
#if defined (bios)
#if bios == 1
if (!stage3_loaded)
limine_map = stage2_map;
else
limine_map = full_map;
#elif defined (uefi)
#elif uefi == 1
limine_map = full_map;
addr -= (size_t)ImageBase;
@ -48,9 +48,9 @@ static char *trace_address(size_t *off, size_t addr) {
void print_stacktrace(size_t *base_ptr) {
if (base_ptr == NULL) {
asm volatile (
#if defined (bios)
#if bios == 1
"movl %%ebp, %0"
#elif defined (uefi)
#elif uefi == 1
"movq %%rbp, %0"
#endif
: "=g"(base_ptr)

View File

@ -141,7 +141,7 @@ static bool uri_guid_dispatch(struct file_handle *fd, char *guid_str, char *path
return true;
}
#if defined (bios)
#if bios == 1
static bool uri_tftp_dispatch(struct file_handle *fd, char *root, char *path) {
uint32_t ip;
if (!strcmp(root, "")) {
@ -166,7 +166,7 @@ static bool uri_tftp_dispatch(struct file_handle *fd, char *root, char *path) {
#endif
static bool uri_boot_dispatch(struct file_handle *fd, char *s_part, char *path) {
#if defined (bios)
#if bios == 1
if (boot_volume->pxe)
return uri_tftp_dispatch(fd, s_part, path);
#endif
@ -222,7 +222,7 @@ bool uri_open(struct file_handle *fd, char *uri) {
ret = uri_guid_dispatch(fd, root, path);
} else if (!strcmp(resource, "uuid")) {
ret = uri_guid_dispatch(fd, root, path);
#if defined (bios)
#if bios == 1
} else if (!strcmp(resource, "tftp")) {
ret = uri_tftp_dispatch(fd, root, path);
#endif

View File

@ -516,9 +516,9 @@ char *menu(char **cmdline) {
}
// If there is GRAPHICS config key and the value is "yes", enable graphics
#if defined (bios)
#if bios == 1
char *graphics = config_get_value(NULL, 0, "GRAPHICS");
#elif defined (uefi)
#elif uefi == 1
char *graphics = "yes";
#endif
if (graphics != NULL && !strcmp(graphics, "yes")) {

View File

@ -20,7 +20,7 @@
extern struct e820_entry_t memmap[];
extern size_t memmap_entries;
#if defined (uefi)
#if uefi == 1
extern struct e820_entry_t untouched_memmap[];
extern size_t untouched_memmap_entries;
#endif
@ -37,7 +37,7 @@ void *ext_mem_alloc_type(size_t count, uint32_t type);
void *conv_mem_alloc(size_t count);
#if defined (uefi)
#if uefi == 1
void pmm_reclaim_uefi_mem(void);
void pmm_release_uefi_mem(void);
#endif

View File

@ -7,14 +7,14 @@
#include <lib/blib.h>
#include <lib/libc.h>
#include <lib/print.h>
#if defined (uefi)
#if uefi == 1
# include <efi.h>
#endif
#define PAGE_SIZE 4096
#define MEMMAP_MAX_ENTRIES 256
#if defined (bios)
#if bios == 1
extern symbol bss_end;
#endif
@ -51,7 +51,7 @@ void *conv_mem_alloc(size_t count) {
struct e820_entry_t memmap[MEMMAP_MAX_ENTRIES];
size_t memmap_entries = 0;
#if defined (uefi)
#if uefi == 1
struct e820_entry_t untouched_memmap[MEMMAP_MAX_ENTRIES];
size_t untouched_memmap_entries = 0;
#endif
@ -206,7 +206,7 @@ struct e820_entry_t *get_memmap(size_t *entries) {
return memmap;
}
#if defined (bios)
#if bios == 1
void init_memmap(void) {
for (size_t i = 0; i < e820_entries; i++) {
if (memmap_entries == MEMMAP_MAX_ENTRIES) {
@ -253,7 +253,7 @@ void init_memmap(void) {
}
#endif
#if defined (uefi)
#if uefi == 1
void init_memmap(void) {
EFI_STATUS status;
@ -472,14 +472,14 @@ void pmm_release_uefi_mem(void) {
}
#endif
#if defined (bios)
#if bios == 1
struct e820_entry_t *get_raw_memmap(size_t *entry_count) {
*entry_count = e820_entries;
return e820_map;
}
#endif
#if defined (uefi)
#if uefi == 1
struct e820_entry_t *get_raw_memmap(size_t *entry_count) {
size_t mmap_count = efi_mmap_size / efi_desc_size;
size_t mmap_len = mmap_count * sizeof(struct e820_entry_t);

View File

@ -13,11 +13,11 @@
#include <sys/idt.h>
#include <drivers/vga_textmode.h>
#include <mm/pmm.h>
#if defined (uefi)
#if uefi == 1
# include <efi.h>
#endif
#if defined (bios)
#if bios == 1
__attribute__((noinline))
__attribute__((section(".realmode")))
@ -107,7 +107,7 @@ void chainload(char *config) {
spinup(drive);
}
#elif defined (uefi)
#elif uefi == 1
void chainload(char *config) {
EFI_STATUS status;

View File

@ -513,9 +513,9 @@ void linux_load(char *config, char *cmdline) {
screen_info->blue_size = fbinfo.blue_mask_size;
screen_info->blue_pos = fbinfo.blue_mask_shift;
#if defined (bios)
#if bios == 1
screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB;
#elif defined (uefi)
#elif uefi == 1
screen_info->orig_video_isVGA = VIDEO_TYPE_EFI;
#endif
@ -534,7 +534,7 @@ void linux_load(char *config, char *cmdline) {
///////////////////////////////////////
// UEFI
///////////////////////////////////////
#if defined (uefi)
#if uefi == 1
efi_exit_boot_services();
memcpy(&boot_params->efi_info.efi_loader_signature, "EL64", 4);

View File

@ -206,9 +206,9 @@ void multiboot1_load(char *config, char *cmdline) {
multiboot1_info.fb_blue_mask_size = fbinfo.blue_mask_size;
multiboot1_info.fb_blue_mask_shift = fbinfo.blue_mask_shift;
} else if (header.fb_mode == 1) {
#if defined (uefi)
#if uefi == 1
panic("multiboot1: Cannot use text mode with UEFI.");
#elif defined (bios)
#elif bios == 1
int rows, cols;
init_vga_textmode(&rows, &cols, false);
@ -225,15 +225,15 @@ void multiboot1_load(char *config, char *cmdline) {
multiboot1_info.flags |= (1 << 12);
} else {
#if defined (uefi)
#if uefi == 1
panic("multiboot1: Cannot use text mode with UEFI.");
#elif defined (bios)
#elif bios == 1
int rows, cols;
init_vga_textmode(&rows, &cols, false);
#endif
}
#if defined (uefi)
#if uefi == 1
efi_exit_boot_services();
#endif

View File

@ -57,7 +57,7 @@ struct stivale_struct stivale_struct = {0};
void stivale_load(char *config, char *cmdline) {
// BIOS or UEFI?
#if defined (bios)
#if bios == 1
stivale_struct.flags |= (1 << 0);
#endif
@ -267,15 +267,15 @@ void stivale_load(char *config, char *cmdline) {
stivale_struct.fb_blue_mask_size = fbinfo.blue_mask_size;
stivale_struct.fb_blue_mask_shift = fbinfo.blue_mask_shift;
} else {
#if defined (uefi)
#if uefi == 1
panic("stivale: Cannot use text mode with UEFI.");
#elif defined (bios)
#elif bios == 1
int rows, cols;
init_vga_textmode(&rows, &cols, false);
#endif
}
#if defined (uefi)
#if uefi == 1
efi_exit_boot_services();
#endif
@ -351,7 +351,7 @@ pagemap_t stivale_build_pagemap(bool level5pg, bool unmap_null) {
return pagemap;
}
#if defined (uefi)
#if uefi == 1
extern symbol ImageBase;
#endif
@ -364,7 +364,7 @@ __attribute__((noreturn)) void stivale_spinup_32(
__attribute__((noreturn)) void stivale_spinup(
int bits, bool level5pg, pagemap_t *pagemap,
uint64_t entry_point, uint64_t _stivale_struct, uint64_t stack) {
#if defined (bios)
#if bios == 1
if (bits == 64) {
// 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

View File

@ -54,7 +54,7 @@ static void *get_tag(struct stivale2_header *s, uint64_t id) {
(S)->tags = REPORTED_ADDR((uint64_t)(uintptr_t)TAG); \
})
#if defined (bios)
#if bios == 1
extern symbol stivale2_term_write_entry;
#endif
@ -202,7 +202,7 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
struct stivale2_struct_tag_firmware *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_firmware));
tag->tag.identifier = STIVALE2_STRUCT_TAG_FIRMWARE_ID;
#if defined (bios)
#if bios == 1
tag->flags = 1 << 0; // bit 0 = BIOS boot
#endif
@ -362,10 +362,10 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
// We provide max allowed string length
tag->flags |= (1 << 1);
#if defined (bios)
#if bios == 1
tag->term_write = (uintptr_t)(void *)stivale2_term_write_entry;
tag->max_length = 4096;
#elif defined (uefi)
#elif uefi == 1
tag->term_write = (uintptr_t)term_write;
tag->max_length = 0;
#endif
@ -382,13 +382,8 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
fb = &_fb;
}
if (hdrtag != NULL || (avtag != NULL &&
#if defined (uefi)
true
#else
false
#endif
) || (avtag != NULL && avtag->preference == 0)) {
if (hdrtag != NULL || (avtag != NULL && uefi)
|| (avtag != NULL && avtag->preference == 0)) {
term_deinit();
if (fb_init(fb, req_width, req_height, req_bpp)) {
@ -416,9 +411,9 @@ skip_modeset:;
append_tag(&stivale2_struct, (struct stivale2_tag *)tag);
}
} else {
#if defined (uefi)
#if uefi == 1
panic("stivale2: Cannot use text mode with UEFI.");
#elif defined (bios)
#elif bios == 1
int rows, cols;
init_vga_textmode(&rows, &cols, false);
@ -452,7 +447,7 @@ skip_modeset:;
}
}
#if defined (bios)
#if bios == 1
//////////////////////////////////////////////
// Create PXE struct tag
//////////////////////////////////////////////
@ -486,7 +481,7 @@ skip_modeset:;
if (bits == 64)
pagemap = stivale_build_pagemap(want_5lv, unmap_null);
#if defined (uefi)
#if uefi == 1
efi_exit_boot_services();
#endif

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <lib/print.h>
#include <lib/real.h>

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <pxe/tftp.h>
#include <pxe/pxe.h>

View File

@ -1,4 +1,4 @@
#if defined (uefi)
#if uefi == 1
asm (
".section .sbat\n\t"

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <stdint.h>
#include <stddef.h>

View File

@ -1,4 +1,4 @@
#if defined (bios)
#if bios == 1
#include <stdint.h>
#include <stddef.h>

View File

@ -3,7 +3,7 @@
#include <lib/trace.h>
#include <lib/print.h>
#if defined (bios)
#if bios == 1
static const char *exception_names[] = {
"Division by 0",

View File

@ -5,10 +5,10 @@
struct gdtr {
uint16_t limit;
#if defined (uefi)
#if uefi == 1
uint64_t ptr;
#endif
#if defined (bios)
#if bios == 1
uint32_t ptr;
uint32_t pad;
#endif

View File

@ -59,13 +59,13 @@ static struct gdt_desc gdt_descs[] = {
}
};
#if defined (bios)
#if bios == 1
__attribute__((section(".realmode")))
#endif
struct gdtr gdt = {
sizeof(gdt_descs) - 1,
(uintptr_t)gdt_descs,
#if defined (bios)
#if bios == 1
0
#endif
};

View File

@ -3,7 +3,7 @@
#include <stdint.h>
#if defined (bios)
#if bios == 1
struct idtr {
uint16_t limit;

View File

@ -3,7 +3,7 @@
#include <sys/idt.h>
#include <lib/blib.h>
#if defined (bios)
#if bios == 1
static struct idt_entry idt_entries[32];