:: commit c44f514738e3994860a6ffb0264a6569dcad326e

mintsuki <mintsuki@protonmail.com> — 2022-09-02 00:29

parents: 1d325927d7

misc: Rename UEFI and BIOS define macros

diff --git a/common/GNUmakefile b/common/GNUmakefile
index e3a24f7d..136dce2b 100644
--- a/common/GNUmakefile
+++ b/common/GNUmakefile
@@ -63,8 +63,7 @@ ifeq ($(TARGET),bios)
         -mtune=generic \
         -mabi=sysv \
         -mno-80387 \
-        -Dbios=1 \
-        -Duefi=0
+        -DBIOS
 endif
 
 ifeq ($(TARGET),uefi-x86-64)
@@ -79,8 +78,7 @@ ifeq ($(TARGET),uefi-x86-64)
         -mno-sse \
         -mno-sse2 \
         -mno-red-zone \
-        -Dbios=0 \
-        -Duefi=1 \
+        -DUEFI \
         -DGNU_EFI_USE_MS_ABI \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64'
@@ -94,8 +92,7 @@ ifeq ($(TARGET),uefi-ia32)
         -mtune=generic \
         -mabi=sysv \
         -mno-80387 \
-        -Dbios=0 \
-        -Duefi=1 \
+        -DUEFI \
         -DGNU_EFI_USE_MS_ABI \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32'
@@ -106,8 +103,7 @@ ifeq ($(TARGET),uefi-aarch64)
         -fpie \
         -mtune=generic \
         -mgeneral-regs-only \
-        -Dbios=0 \
-        -Duefi=1 \
+        -DUEFI \
         -DGNU_EFI_USE_MS_ABI \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
         -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/aarch64'
diff --git a/common/drivers/disk.h b/common/drivers/disk.h
index 419d185d..b551c480 100644
--- a/common/drivers/disk.h
+++ b/common/drivers/disk.h
@@ -6,7 +6,7 @@
 #include <stdbool.h>
 #include <lib/part.h>
 
-#if uefi == 1
+#if defined (UEFI)
 
 #include <efi.h>
 
diff --git a/common/drivers/disk.s2.c b/common/drivers/disk.s2.c
index 7b0222ac..a9f66436 100644
--- a/common/drivers/disk.s2.c
+++ b/common/drivers/disk.s2.c
@@ -3,9 +3,9 @@
 #include <stdalign.h>
 #include <drivers/disk.h>
 #include <lib/libc.h>
-#if bios == 1
+#if defined (BIOS)
 #  include <lib/real.h>
-#elif uefi == 1
+#elif defined (UEFI)
 #  include <efi.h>
 #endif
 #include <lib/misc.h>
@@ -19,7 +19,7 @@
 
 #define MAX_VOLUMES 64
 
-#if bios == 1
+#if defined (BIOS)
 
 struct bios_drive_params {
     uint16_t buf_size;
@@ -263,7 +263,7 @@ void disk_create_index(void) {
 
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 
 int disk_read_sectors(struct volume *volume, void *buf, uint64_t block, size_t count) {
     EFI_STATUS status;
diff --git a/common/drivers/edid.c b/common/drivers/edid.c
index c8cf95a4..5fcb05a3 100644
--- a/common/drivers/edid.c
+++ b/common/drivers/edid.c
@@ -6,7 +6,7 @@
 #include <lib/libc.h>
 #include <lib/print.h>
 
-#if bios == 1
+#if defined (BIOS)
 
 #include <lib/real.h>
 
@@ -45,7 +45,7 @@ success:
 
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 
 #include <efi.h>
 
diff --git a/common/drivers/gop.c b/common/drivers/gop.c
index 2226ba5a..18b8734f 100644
--- a/common/drivers/gop.c
+++ b/common/drivers/gop.c
@@ -1,4 +1,4 @@
-#if uefi == 1
+#if defined (UEFI)
 
 #include <stdint.h>
 #include <stddef.h>
diff --git a/common/drivers/gop.h b/common/drivers/gop.h
index 147b5dfa..bbc44207 100644
--- a/common/drivers/gop.h
+++ b/common/drivers/gop.h
@@ -1,7 +1,7 @@
 #ifndef __DRIVERS__GOP_H__
 #define __DRIVERS__GOP_H__
 
-#if uefi == 1
+#if defined (UEFI)
 
 #include <stdint.h>
 #include <stdbool.h>
diff --git a/common/drivers/serial.h b/common/drivers/serial.h
index c716054a..119ad476 100644
--- a/common/drivers/serial.h
+++ b/common/drivers/serial.h
@@ -5,7 +5,7 @@
 
 void serial_out(uint8_t b);
 
-#if bios == 1
+#if defined (BIOS)
 int serial_in(void);
 #endif
 
diff --git a/common/drivers/serial.s2.c b/common/drivers/serial.s2.c
index ac14ad08..340cda0b 100644
--- a/common/drivers/serial.s2.c
+++ b/common/drivers/serial.s2.c
@@ -4,13 +4,13 @@
 #include <drivers/serial.h>
 #include <sys/cpu.h>
 #include <lib/misc.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
 static bool serial_initialised = false;
 
-#if uefi == 1
+#if defined (UEFI)
 static EFI_SERIAL_IO_PROTOCOL *serial_protocol;
 #endif
 
@@ -19,7 +19,7 @@ static void serial_initialise(void) {
         return;
     }
 
-#if uefi == 1
+#if defined (UEFI)
     EFI_STATUS status;
 
     EFI_GUID serial_guid = EFI_SERIAL_IO_PROTOCOL_GUID;
@@ -32,7 +32,7 @@ static void serial_initialise(void) {
     serial_protocol->Reset(serial_protocol);
 #endif
 
-#if bios == 1
+#if defined (BIOS)
     // Init com1
     outb(0x3f8 + 3, 0x00);
     outb(0x3f8 + 1, 0x00);
@@ -48,7 +48,7 @@ static void serial_initialise(void) {
 }
 
 void serial_out(uint8_t b) {
-#if uefi == 1
+#if defined (UEFI)
     if (efi_boot_services_exited) {
         return;
     }
@@ -56,16 +56,16 @@ void serial_out(uint8_t b) {
 
     serial_initialise();
 
-#if uefi == 1
+#if defined (UEFI)
     UINTN bsize = 1;
     serial_protocol->Write(serial_protocol, &bsize, &b);
-#elif bios == 1
+#elif defined (BIOS)
     while ((inb(0x3f8 + 5) & 0x20) == 0);
     outb(0x3f8, b);
 #endif
 }
 
-#if bios == 1
+#if defined (BIOS)
 int serial_in(void) {
     serial_initialise();
 
diff --git a/common/drivers/vbe.c b/common/drivers/vbe.c
index f16925f1..7273f471 100644
--- a/common/drivers/vbe.c
+++ b/common/drivers/vbe.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <stddef.h>
 #include <stdint.h>
diff --git a/common/drivers/vga_textmode.c b/common/drivers/vga_textmode.c
index 1a51cb36..9ed7da42 100644
--- a/common/drivers/vga_textmode.c
+++ b/common/drivers/vga_textmode.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <stdint.h>
 #include <stddef.h>
diff --git a/common/entry.s2.c b/common/entry.s2.c
index 0e5996b2..76d41194 100644
--- a/common/entry.s2.c
+++ b/common/entry.s2.c
@@ -26,7 +26,7 @@
 
 struct volume *boot_volume;
 
-#if bios == 1
+#if defined (BIOS)
 
 bool stage3_loaded = false;
 static bool stage3_found = false;
diff --git a/common/entry.s3.c b/common/entry.s3.c
index 75aed3b1..cb41fa5c 100644
--- a/common/entry.s3.c
+++ b/common/entry.s3.c
@@ -25,7 +25,7 @@
 
 void stage3_common(void);
 
-#if uefi == 1
+#if defined (UEFI)
 extern symbol __image_base;
 
 noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
diff --git a/common/fs/ext2.s2.c b/common/fs/ext2.s2.c
index 9c13f112..976296d1 100644
--- a/common/fs/ext2.s2.c
+++ b/common/fs/ext2.s2.c
@@ -540,7 +540,7 @@ struct file_handle *ext2_open(struct volume *part, const char *path) {
     handle->close = (void *)ext2_close;
     handle->size = ret->size;
     handle->vol = part;
-#if uefi == 1
+#if defined (UEFI)
     handle->efi_part_handle = part->efi_part_handle;
 #endif
 
diff --git a/common/fs/fat32.s2.c b/common/fs/fat32.s2.c
index 457dbc69..d1c83a6a 100644
--- a/common/fs/fat32.s2.c
+++ b/common/fs/fat32.s2.c
@@ -507,7 +507,7 @@ struct file_handle *fat32_open(struct volume *part, const char *path) {
             handle->close = (void *)fat32_close;
             handle->size = ret->size_bytes;
             handle->vol = part;
-#if uefi == 1
+#if defined (UEFI)
             handle->efi_part_handle = part->efi_part_handle;
 #endif
 
diff --git a/common/fs/file.h b/common/fs/file.h
index b7101787..6f5f682b 100644
--- a/common/fs/file.h
+++ b/common/fs/file.h
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdbool.h>
 #include <lib/part.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
@@ -23,7 +23,7 @@ struct file_handle {
     void     (*read)(void *fd, void *buf, uint64_t loc, uint64_t count);
     void     (*close)(void *fd);
     uint64_t   size;
-#if uefi == 1
+#if defined (UEFI)
     EFI_HANDLE efi_part_handle;
 #endif
     bool pxe;
diff --git a/common/fs/file.s2.c b/common/fs/file.s2.c
index 730ec93d..f58dfaf4 100644
--- a/common/fs/file.s2.c
+++ b/common/fs/file.s2.c
@@ -49,7 +49,7 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
 
     struct file_handle *ret;
 
-#if bios == 1
+#if defined (BIOS)
     if (part->pxe) {
         if ((ret = tftp_open(0, 69, filename)) == NULL) {
             return NULL;
diff --git a/common/fs/iso9660.s2.c b/common/fs/iso9660.s2.c
index 822e2966..670787f9 100644
--- a/common/fs/iso9660.s2.c
+++ b/common/fs/iso9660.s2.c
@@ -280,7 +280,7 @@ struct file_handle *iso9660_open(struct volume *vol, const char *path) {
     handle->close = (void *)iso9660_close;
     handle->size = ret->size;
     handle->vol = vol;
-#if uefi == 1
+#if defined (UEFI)
     handle->efi_part_handle = vol->efi_part_handle;
 #endif
 
diff --git a/common/lib/acpi.c b/common/lib/acpi.c
index c1a1ad95..d9dbde25 100644
--- a/common/lib/acpi.c
+++ b/common/lib/acpi.c
@@ -14,7 +14,7 @@ uint8_t acpi_checksum(void *ptr, size_t size) {
     return sum;
 }
 
-#if bios == 1
+#if defined (BIOS)
 
 void *acpi_get_rsdp(void) {
     size_t ebda = EBDA;
@@ -78,7 +78,7 @@ void acpi_get_smbios(void **smbios32, void **smbios64) {
 
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 
 #include <efi.h>
 
diff --git a/common/lib/acpi.h b/common/lib/acpi.h
index 24fe0241..f9d69b4a 100644
--- a/common/lib/acpi.h
+++ b/common/lib/acpi.h
@@ -7,7 +7,7 @@
 
 #define EBDA (ebda_get())
 
-#if bios == 1
+#if defined (BIOS)
 static inline uintptr_t ebda_get(void) {
     uintptr_t ebda = (uintptr_t)mminw(0x40e) << 4;
 
diff --git a/common/lib/config.c b/common/lib/config.c
index e5b78a75..c270d8dc 100644
--- a/common/lib/config.c
+++ b/common/lib/config.c
@@ -41,7 +41,7 @@ int init_config_disk(struct volume *part) {
     return init_config(config_size);
 }
 
-#if bios == 1
+#if defined (BIOS)
 int init_config_pxe(void) {
     struct file_handle *f;
     if ((f = tftp_open(0, 69, "limine.cfg")) == NULL) {
diff --git a/common/lib/fb.c b/common/lib/fb.c
index ae0e9d70..f291e01d 100644
--- a/common/lib/fb.c
+++ b/common/lib/fb.c
@@ -10,9 +10,9 @@ bool fb_init(struct fb_info *ret,
              uint64_t target_width, uint64_t target_height, uint16_t target_bpp) {
     bool r;
 
-#if bios == 1
+#if defined (BIOS)
     r = init_vbe(ret, target_width, target_height, target_bpp);
-#elif uefi == 1
+#elif defined (UEFI)
     r = init_gop(ret, target_width, target_height, target_bpp);
 #endif
 
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index 0b68dd2d..339caa56 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -602,7 +602,7 @@ static char *last_config = NULL;
 
 bool gterm_init(char *config, size_t *_rows, size_t *_cols, size_t width, size_t height) {
     if (current_video_mode >= 0
-#if bios == 1
+#if defined (BIOS)
      && current_video_mode != 0x03
 #endif
      && fbinfo.default_res == true
@@ -619,7 +619,7 @@ bool gterm_init(char *config, size_t *_rows, size_t *_cols, size_t width, size_t
     }
 
     if (current_video_mode >= 0
-#if bios == 1
+#if defined (BIOS)
      && current_video_mode != 0x03
 #endif
      && fbinfo.framebuffer_width == width
diff --git a/common/lib/misc.c b/common/lib/misc.c
index a0bf75dd..b1f18efe 100644
--- a/common/lib/misc.c
+++ b/common/lib/misc.c
@@ -9,7 +9,7 @@
 #include <fs/file.h>
 #include <mm/pmm.h>
 
-#if uefi == 1
+#if defined (UEFI)
 EFI_SYSTEM_TABLE *gST;
 EFI_BOOT_SERVICES *gBS;
 EFI_RUNTIME_SERVICES *gRT;
@@ -166,7 +166,7 @@ uint32_t hex2bin(uint8_t *str, uint32_t size) {
     return value;
 }
 
-#if uefi == 1
+#if defined (UEFI)
 
 no_unwind bool efi_boot_services_exited = false;
 
diff --git a/common/lib/misc.h b/common/lib/misc.h
index 8e8d50ef..8517dc21 100644
--- a/common/lib/misc.h
+++ b/common/lib/misc.h
@@ -8,11 +8,11 @@
 #include <fs/file.h>
 #include <lib/part.h>
 #include <lib/libc.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 extern EFI_SYSTEM_TABLE *gST;
 extern EFI_BOOT_SERVICES *gBS;
 extern EFI_RUNTIME_SERVICES *gRT;
@@ -29,7 +29,7 @@ extern const char bsd_2_clause[];
 
 extern struct volume *boot_volume;
 
-#if bios == 1
+#if defined (BIOS)
 extern bool stage3_loaded;
 #endif
 
diff --git a/common/lib/panic.s2.c b/common/lib/panic.s2.c
index c2387263..3d93aa3c 100644
--- a/common/lib/panic.s2.c
+++ b/common/lib/panic.s2.c
@@ -4,7 +4,7 @@
 #include <lib/print.h>
 #include <lib/real.h>
 #include <lib/trace.h>
-#if uefi == 1
+#if defined (UEFI)
 #   include <efi.h>
 #endif
 #include <lib/misc.h>
@@ -30,7 +30,7 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
     is_nested = true;
 
     if (
-#if bios == 1
+#if defined (BIOS)
       stage3_loaded == true &&
 #endif
       term_backend == NOT_READY) {
@@ -43,11 +43,11 @@ nested:
         term_fallback();
     }
 
-#if bios == 1
+#if defined (BIOS)
     if (stage3_loaded) {
 #endif
         print("\033[31mPANIC\033[37;1m\033[0m: ");
-#if bios == 1
+#if defined (BIOS)
     } else {
         print("PANIC: ");
     }
@@ -60,7 +60,7 @@ nested:
     print_stacktrace(NULL);
 
     if (
-#if bios == 1
+#if defined (BIOS)
       stage3_loaded == true &&
 #endif
       allow_menu == true) {
@@ -77,10 +77,10 @@ nested:
         gBS->Exit(efi_image_handle, EFI_ABORTED, 0, NULL);
 */
     } else {
-#if bios == 1
+#if defined (BIOS)
         print("Press CTRL+ALT+DEL to reboot.");
         rm_hcf();
-#elif uefi == 1
+#elif defined (UEFI)
         print("System halted.");
         for (;;) {
 #if defined (__x86_64__) || defined (__i386__)
diff --git a/common/lib/part.h b/common/lib/part.h
index f5230fae..4f0c4352 100644
--- a/common/lib/part.h
+++ b/common/lib/part.h
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdbool.h>
 #include <lib/guid.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
@@ -14,7 +14,7 @@
 #define END_OF_TABLE  (-3)
 
 struct volume {
-#if uefi == 1
+#if defined (UEFI)
     EFI_HANDLE efi_handle;
     EFI_HANDLE efi_part_handle;
     EFI_BLOCK_IO *block_io;
@@ -22,7 +22,7 @@ struct volume {
     bool unique_sector_valid;
     uint64_t unique_sector;
     uint32_t unique_sector_crc32;
-#elif bios == 1
+#elif defined (BIOS)
     int drive;
 #endif
 
@@ -68,7 +68,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_fslabel(char *fslabel);
 struct volume *volume_get_by_coord(bool optical, int drive, int partition);
-#if bios == 1
+#if defined (BIOS)
 struct volume *volume_get_by_bios_drive(int drive);
 #endif
 
diff --git a/common/lib/part.s2.c b/common/lib/part.s2.c
index e236af00..3d3eff7e 100644
--- a/common/lib/part.s2.c
+++ b/common/lib/part.s2.c
@@ -2,7 +2,7 @@
 #include <stdint.h>
 #include <lib/part.h>
 #include <drivers/disk.h>
-#if bios == 1
+#if defined (BIOS)
 #  include <lib/real.h>
 #endif
 #include <lib/libc.h>
@@ -198,10 +198,10 @@ 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 uefi == 1
+#if defined (UEFI)
     ret->efi_handle  = volume->efi_handle;
     ret->block_io    = volume->block_io;
-#elif bios == 1
+#elif defined (BIOS)
     ret->drive       = volume->drive;
 #endif
     ret->fastest_xfer_size = volume->fastest_xfer_size;
@@ -320,10 +320,10 @@ static int mbr_get_logical_part(struct volume *ret, struct volume *extended_part
     if (entry.type == 0)
         return NO_PARTITION;
 
-#if uefi == 1
+#if defined (UEFI)
     ret->efi_handle  = extended_part->efi_handle;
     ret->block_io    = extended_part->block_io;
-#elif bios == 1
+#elif defined (BIOS)
     ret->drive       = extended_part->drive;
 #endif
     ret->fastest_xfer_size = extended_part->fastest_xfer_size;
@@ -374,10 +374,10 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
 
             struct volume extended_part = {0};
 
-#if uefi == 1
+#if defined (UEFI)
             extended_part.efi_handle  = volume->efi_handle;
             extended_part.block_io    = volume->block_io;
-#elif bios == 1
+#elif defined (BIOS)
             extended_part.drive       = volume->drive;
 #endif
             extended_part.fastest_xfer_size = volume->fastest_xfer_size;
@@ -402,10 +402,10 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
     if (entry.type == 0)
         return NO_PARTITION;
 
-#if uefi == 1
+#if defined (UEFI)
     ret->efi_handle  = volume->efi_handle;
     ret->block_io    = volume->block_io;
-#elif bios == 1
+#elif defined (BIOS)
     ret->drive       = volume->drive;
 #endif
     ret->fastest_xfer_size = volume->fastest_xfer_size;
@@ -493,7 +493,7 @@ struct volume *volume_get_by_coord(bool optical, int drive, int partition) {
     return NULL;
 }
 
-#if bios == 1
+#if defined (BIOS)
 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) {
diff --git a/common/lib/print.s2.c b/common/lib/print.s2.c
index 799d4093..deae50fc 100644
--- a/common/lib/print.s2.c
+++ b/common/lib/print.s2.c
@@ -5,13 +5,13 @@
 #include <lib/misc.h>
 #include <lib/term.h>
 #include <lib/libc.h>
-#if bios == 1
+#if defined (BIOS)
 #include <lib/real.h>
 #endif
 #include <sys/cpu.h>
 #include <drivers/serial.h>
 
-#if bios == 1
+#if defined (BIOS)
 static void s2_print(const char *s, size_t len) {
     for (size_t i = 0; i < len; i++) {
         struct rm_regs r = {0};
@@ -199,11 +199,11 @@ void vprint(const char *fmt, va_list args) {
     }
 
 out:
-#if bios == 1
+#if defined (BIOS)
     if (stage3_loaded) {
 #endif
         term_write((uint64_t)(uintptr_t)print_buf, print_buf_i);
-#if bios == 1
+#if defined (BIOS)
     } else {
         s2_print(print_buf, print_buf_i);
     }
diff --git a/common/lib/readline.c b/common/lib/readline.c
index 651d22d4..c523a58c 100644
--- a/common/lib/readline.c
+++ b/common/lib/readline.c
@@ -5,9 +5,9 @@
 #include <lib/misc.h>
 #include <lib/term.h>
 #include <lib/print.h>
-#if bios == 1
+#if defined (BIOS)
 #  include <lib/real.h>
-#elif uefi == 1
+#elif defined (UEFI)
 #  include <efi.h>
 #endif
 #include <drivers/serial.h>
@@ -24,7 +24,7 @@ int getchar(void) {
 
 int getchar_internal(uint8_t scancode, uint8_t ascii, uint32_t shift_state) {
     switch (scancode) {
-#if bios == 1
+#if defined (BIOS)
         case 0x44:
             return GETCHAR_F10;
         case 0x4b:
@@ -47,7 +47,7 @@ int getchar_internal(uint8_t scancode, uint8_t ascii, uint32_t shift_state) {
             return GETCHAR_PGDOWN;
         case 0x01:
             return GETCHAR_ESCAPE;
-#elif uefi == 1
+#elif defined (UEFI)
         case SCAN_F10:
             return GETCHAR_F10;
         case SCAN_LEFT:
@@ -98,7 +98,7 @@ int getchar_internal(uint8_t scancode, uint8_t ascii, uint32_t shift_state) {
     return ascii;
 }
 
-#if bios == 1
+#if defined (BIOS)
 int _pit_sleep_and_quit_on_keypress(uint32_t ticks);
 
 static int input_sequence(void) {
@@ -194,7 +194,7 @@ again:
 }
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 static int input_sequence(bool ext,
                    EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *exproto,
                    EFI_SIMPLE_TEXT_IN_PROTOCOL *sproto) {
diff --git a/common/lib/readline.h b/common/lib/readline.h
index fea81766..d354e94c 100644
--- a/common/lib/readline.h
+++ b/common/lib/readline.h
@@ -15,10 +15,10 @@
 #define GETCHAR_F10          (-19)
 #define GETCHAR_ESCAPE       (-20)
 
-#if bios == 1
+#if defined (BIOS)
 #   define GETCHAR_RCTRL 0x4
 #   define GETCHAR_LCTRL GETCHAR_RCTRL
-#elif uefi == 1
+#elif defined (UEFI)
 #   define GETCHAR_RCTRL EFI_RIGHT_CONTROL_PRESSED
 #   define GETCHAR_LCTRL EFI_LEFT_CONTROL_PRESSED
 #endif
diff --git a/common/lib/term.c b/common/lib/term.c
index c236e782..9d317d2a 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -32,7 +32,7 @@ void term_vbe(char *config, size_t width, size_t height) {
     }
 
     if (!gterm_init(config, &term_rows, &term_cols, width, height)) {
-#if bios == 1
+#if defined (BIOS)
         // Failed to set VBE properly, default to text mode
         term_textmode();
 #endif
@@ -138,7 +138,7 @@ void term_reinit(void) {
     term_autoflush = true;
 }
 
-#if bios == 1
+#if defined (BIOS)
 void term_textmode(void) {
     term_deinit();
 
diff --git a/common/lib/term.s2.c b/common/lib/term.s2.c
index a23bd047..a5bf47bf 100644
--- a/common/lib/term.s2.c
+++ b/common/lib/term.s2.c
@@ -42,7 +42,7 @@ void (*term_full_refresh)(void);
 
 // --- fallback ---
 
-#if bios == 1
+#if defined (BIOS)
 static void fallback_raw_putchar(uint8_t c) {
     struct rm_regs r = {0};
     r.eax = 0x0e00 | c;
@@ -87,7 +87,7 @@ static void fallback_get_cursor_pos(size_t *x, size_t *y) {
     *y = r.edx >> 8;
 }
 
-#elif uefi == 1
+#elif defined (UEFI)
 static int cursor_x = 0, cursor_y = 0;
 
 static void fallback_raw_putchar(uint8_t c) {
@@ -137,12 +137,12 @@ static void fallback_get_cursor_pos(size_t *x, size_t *y) {
 #endif
 
 void term_fallback(void) {
-#if uefi == 1
+#if defined (UEFI)
     if (!efi_boot_services_exited) {
         gST->ConOut->Reset(gST->ConOut, false);
         gST->ConOut->SetMode(gST->ConOut, 0);
         cursor_x = cursor_y = 0;
-#elif bios == 1
+#elif defined (BIOS)
         fallback_clear(true);
 #endif
         term_notready();
@@ -151,7 +151,7 @@ void term_fallback(void) {
         set_cursor_pos = fallback_set_cursor_pos;
         get_cursor_pos = fallback_get_cursor_pos;
         term_backend = FALLBACK;
-#if uefi == 1
+#if defined (UEFI)
     }
 #endif
 }
diff --git a/common/lib/time.c b/common/lib/time.c
index 8052b9e9..5e0dabcc 100644
--- a/common/lib/time.c
+++ b/common/lib/time.c
@@ -1,9 +1,9 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <lib/time.h>
-#if bios == 1
+#if defined (BIOS)
 #  include <lib/real.h>
-#elif uefi == 1
+#elif defined (UEFI)
 #  include <efi.h>
 #endif
 #include <lib/misc.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 bios == 1
+#if defined (BIOS)
 uint64_t time(void) {
     struct rm_regs r;
 
@@ -60,7 +60,7 @@ again:
 }
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 uint64_t time(void) {
     EFI_TIME time;
     gRT->GetTime(&time, NULL);
diff --git a/common/lib/trace.s2.c b/common/lib/trace.s2.c
index 8f40ebda..6017d78b 100644
--- a/common/lib/trace.s2.c
+++ b/common/lib/trace.s2.c
@@ -8,9 +8,9 @@
 #include <fs/file.h>
 #include <mm/pmm.h>
 
-#if bios == 1
+#if defined (BIOS)
 extern symbol stage2_map;
-#elif uefi == 1
+#elif defined (UEFI)
 extern symbol __image_base;
 #endif
 
@@ -19,12 +19,12 @@ extern symbol full_map;
 static char *trace_address(size_t *off, size_t addr) {
     char *limine_map;
 
-#if bios == 1
+#if defined (BIOS)
     if (!stage3_loaded)
         limine_map = stage2_map;
     else
         limine_map = full_map;
-#elif uefi == 1
+#elif defined (UEFI)
     limine_map = full_map;
 
     addr -= (size_t)__image_base;
diff --git a/common/lib/uri.c b/common/lib/uri.c
index ce2a5506..dce0433a 100644
--- a/common/lib/uri.c
+++ b/common/lib/uri.c
@@ -141,7 +141,7 @@ static struct file_handle *uri_fslabel_dispatch(char *fslabel, char *path) {
     return fopen(volume, path);
 }
 
-#if bios == 1
+#if defined (BIOS)
 static struct file_handle *uri_tftp_dispatch(char *root, char *path) {
     uint32_t ip;
     if (!strcmp(root, "")) {
@@ -162,7 +162,7 @@ static struct file_handle *uri_tftp_dispatch(char *root, char *path) {
 #endif
 
 static struct file_handle *uri_boot_dispatch(char *s_part, char *path) {
-#if bios == 1
+#if defined (BIOS)
     if (boot_volume->pxe)
         return uri_tftp_dispatch(s_part, path);
 #endif
@@ -217,7 +217,7 @@ struct file_handle *uri_open(char *uri) {
         ret = uri_guid_dispatch(root, path);
     } else if (!strcmp(resource, "fslabel")) {
         ret = uri_fslabel_dispatch(root, path);
-#if bios == 1
+#if defined (BIOS)
     } else if (!strcmp(resource, "tftp")) {
         ret = uri_tftp_dispatch(root, path);
 #endif
diff --git a/common/menu.c b/common/menu.c
index cf34814f..644dadcd 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -537,40 +537,40 @@ static size_t print_tree(const char *shift, size_t level, size_t base_index, siz
 static struct memmap_entry *rewound_memmap = NULL;
 static size_t rewound_memmap_entries = 0;
 static uint8_t *rewound_data;
-#if bios == 1
+#if defined (BIOS)
 static uint8_t *rewound_s2_data;
 #endif
 
 extern symbol data_begin;
 extern symbol data_end;
-#if bios == 1
+#if defined (BIOS)
 extern symbol s2_data_begin;
 extern symbol s2_data_end;
 #endif
 
 noreturn void _menu(bool timeout_enabled) {
     size_t data_size = (uintptr_t)data_end - (uintptr_t)data_begin;
-#if bios == 1
+#if defined (BIOS)
     size_t s2_data_size = (uintptr_t)s2_data_end - (uintptr_t)s2_data_begin;
 #endif
 
     if (rewound_memmap != NULL) {
         memcpy(data_begin, rewound_data, data_size);
-#if bios == 1
+#if defined (BIOS)
         memcpy(s2_data_begin, rewound_s2_data, s2_data_size);
 #endif
         memcpy(memmap, rewound_memmap, rewound_memmap_entries * sizeof(struct memmap_entry));
         memmap_entries = rewound_memmap_entries;
     } else {
         rewound_data = ext_mem_alloc(data_size);
-#if bios == 1
+#if defined (BIOS)
         rewound_s2_data = ext_mem_alloc(s2_data_size);
 #endif
         rewound_memmap = ext_mem_alloc(256 * sizeof(struct memmap_entry));
         memcpy(rewound_memmap, memmap, memmap_entries * sizeof(struct memmap_entry));
         rewound_memmap_entries = memmap_entries;
         memcpy(rewound_data, data_begin, data_size);
-#if bios == 1
+#if defined (BIOS)
         memcpy(rewound_s2_data, s2_data_begin, s2_data_size);
 #endif
     }
@@ -655,9 +655,9 @@ noreturn void _menu(bool timeout_enabled) {
     }
 
     // If there is GRAPHICS config key and the value is "yes", enable graphics
-#if bios == 1
+#if defined (BIOS)
     char *graphics = config_get_value(NULL, 0, "GRAPHICS");
-#elif uefi == 1
+#elif defined (UEFI)
     char *graphics = "yes";
 #endif
 
@@ -671,7 +671,7 @@ reterm:
 
         term_vbe(NULL, req_width, req_height);
     } else {
-#if bios == 1
+#if defined (BIOS)
         term_textmode();
 #endif
     }
@@ -825,7 +825,7 @@ timeout_aborted:
                 }
                 if (term_backend == NOT_READY) {
                     term_vbe(NULL, 0, 0);
-#if bios == 1
+#if defined (BIOS)
                     if (term_backend == NOT_READY) {
                         term_textmode();
                     }
diff --git a/common/mm/pmm.c b/common/mm/pmm.c
index 8e0625e4..e64fa5b0 100644
--- a/common/mm/pmm.c
+++ b/common/mm/pmm.c
@@ -9,7 +9,7 @@ void pmm_randomise_memory(void) {
         if (memmap[i].type != MEMMAP_USABLE)
             continue;
 
-#if bios == 1
+#if defined (BIOS)
         // We're not going to randomise memory above 4GiB from protected mode,
         // are we?
         if (memmap[i].base >= 0x100000000) {
diff --git a/common/mm/pmm.h b/common/mm/pmm.h
index f5d693ef..dc12315a 100644
--- a/common/mm/pmm.h
+++ b/common/mm/pmm.h
@@ -29,12 +29,12 @@ struct meminfo {
 
 struct meminfo mmap_get_info(size_t mmap_count, struct memmap_entry *mmap);
 
-#if bios == 1
+#if defined (BIOS)
 extern struct memmap_entry memmap[];
 extern size_t memmap_entries;
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 extern struct memmap_entry *memmap;
 extern size_t memmap_entries;
 #endif
@@ -58,7 +58,7 @@ void *conv_mem_alloc(size_t count);
 
 void pmm_free(void *ptr, size_t length);
 
-#if uefi == 1
+#if defined (UEFI)
 void pmm_release_uefi_mem(void);
 #endif
 
diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index ff19107b..cb690cad 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -7,13 +7,13 @@
 #include <lib/misc.h>
 #include <lib/libc.h>
 #include <lib/print.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
 #define PAGE_SIZE   4096
 
-#if bios == 1
+#if defined (BIOS)
 extern symbol bss_end;
 #endif
 
@@ -47,14 +47,14 @@ void *conv_mem_alloc(size_t count) {
     }
 }
 
-#if bios == 1
+#if defined (BIOS)
 #define memmap_max_entries ((size_t)512)
 
 struct memmap_entry memmap[memmap_max_entries];
 size_t memmap_entries = 0;
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 static size_t memmap_max_entries;
 
 struct memmap_entry *memmap;
@@ -221,12 +221,12 @@ del_mm1:
     *_count = count;
 }
 
-#if uefi == 1
+#if defined (UEFI)
 static void pmm_reclaim_uefi_mem(struct memmap_entry *m, size_t *_count);
 #endif
 
 struct memmap_entry *get_memmap(size_t *entries) {
-#if uefi == 1
+#if defined (UEFI)
     pmm_reclaim_uefi_mem(memmap, &memmap_entries);
 #endif
 
@@ -239,7 +239,7 @@ struct memmap_entry *get_memmap(size_t *entries) {
     return memmap;
 }
 
-#if bios == 1
+#if defined (BIOS)
 void init_memmap(void) {
     for (size_t i = 0; i < e820_entries; i++) {
         if (memmap_entries == memmap_max_entries) {
@@ -279,7 +279,7 @@ void init_memmap(void) {
 }
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 extern symbol __image_base;
 extern symbol __image_end;
 
@@ -515,14 +515,14 @@ void pmm_release_uefi_mem(void) {
 }
 #endif
 
-#if bios == 1
+#if defined (BIOS)
 struct memmap_entry *get_raw_memmap(size_t *entry_count) {
     *entry_count = e820_entries;
     return e820_map;
 }
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 struct memmap_entry *get_raw_memmap(size_t *entry_count) {
     pmm_reclaim_uefi_mem(untouched_memmap, &untouched_memmap_entries);
     *entry_count = untouched_memmap_entries;
diff --git a/common/protos/chainload.c b/common/protos/chainload.c
index a60aa9b8..80c57877 100644
--- a/common/protos/chainload.c
+++ b/common/protos/chainload.c
@@ -14,11 +14,11 @@
 #include <sys/idt.h>
 #include <drivers/vga_textmode.h>
 #include <mm/pmm.h>
-#if uefi == 1
+#if defined (UEFI)
 #  include <efi.h>
 #endif
 
-#if bios == 1
+#if defined (BIOS)
 
 __attribute__((noinline, section(".realmode")))
 noreturn static void spinup(uint8_t drive) {
@@ -187,7 +187,7 @@ void bios_chainload_volume(struct volume *p) {
     spinup(p->drive);
 }
 
-#elif uefi == 1
+#elif defined (UEFI)
 
 noreturn void chainload(char *config) {
     char *image_path = config_get_value(config, 0, "IMAGE_PATH");
diff --git a/common/protos/chainload.h b/common/protos/chainload.h
index aa4beac1..b930e897 100644
--- a/common/protos/chainload.h
+++ b/common/protos/chainload.h
@@ -5,12 +5,12 @@
 
 noreturn void chainload(char *config);
 
-#if uefi == 1
+#if defined (UEFI)
 #include <fs/file.h>
 noreturn void efi_chainload_file(char *config, struct file_handle *image);
 #endif
 
-#if bios == 1
+#if defined (BIOS)
 #include <lib/part.h>
 void bios_chainload_volume(struct volume *v);
 #endif
diff --git a/common/protos/chainload_next.c b/common/protos/chainload_next.c
index ac2648ad..4d4b5a19 100644
--- a/common/protos/chainload_next.c
+++ b/common/protos/chainload_next.c
@@ -7,14 +7,14 @@
 #include <lib/print.h>
 #include <lib/part.h>
 
-#if bios == 1
+#if defined (BIOS)
 static void try(char *config, struct volume *v) {
     (void)config;
     bios_chainload_volume(v);
 }
 #endif
 
-#if uefi == 1
+#if defined (UEFI)
 static void try(char *config, struct volume *v) {
     for (int i = 0; i <= v->max_partition + 1; i++) {
         struct file_handle *image;
diff --git a/common/protos/limine.c b/common/protos/limine.c
index a899bb02..f565743a 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -515,7 +515,7 @@ FEAT_START
 FEAT_END
 
 
-#if uefi == 1
+#if defined (UEFI)
     // EFI system table feature
 FEAT_START
     struct limine_efi_system_table_request *est_request = get_request(LIMINE_EFI_SYSTEM_TABLE_REQUEST);
@@ -539,7 +539,7 @@ FEAT_START
         break; // next feature
     }
 
-#if uefi == 1
+#if defined (UEFI)
     struct limine_dtb_response *dtb_response =
         ext_mem_alloc(sizeof(struct limine_dtb_response));
 
@@ -858,7 +858,7 @@ FEAT_END
     pagemap = build_pagemap(want_5lv, ranges, ranges_count,
                             physical_base, virtual_base, direct_map_offset);
 
-#if uefi == 1
+#if defined (UEFI)
     efi_exit_boot_services();
 #endif
 
@@ -994,7 +994,7 @@ FEAT_END
     term_runtime = true;
 
 #if defined (__x86_64__) || defined (__i386__)
-#if bios == 1
+#if defined (BIOS)
     // 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.
diff --git a/common/protos/linux.c b/common/protos/linux.c
index 89132aca..5671a395 100644
--- a/common/protos/linux.c
+++ b/common/protos/linux.c
@@ -499,7 +499,7 @@ noreturn void linux_load(char *config, char *cmdline) {
 
     struct screen_info *screen_info = &boot_params->screen_info;
 
-#if bios == 1
+#if defined (BIOS)
     {
     char *textmode_str = config_get_value(config, 0, "TEXTMODE");
     bool textmode = textmode_str != NULL && strcmp(textmode_str, "yes") == 0;
@@ -516,13 +516,13 @@ noreturn void linux_load(char *config, char *cmdline) {
         parse_resolution(&req_width, &req_height, &req_bpp, resolution);
 
     struct fb_info fbinfo;
-#if uefi == 1
+#if defined (UEFI)
     gop_force_16 = true;
 #endif
     if (!fb_init(&fbinfo, req_width, req_height, req_bpp)) {
-#if uefi == 1
+#if defined (UEFI)
         panic(true, "linux: Unable to set video mode");
-#elif bios == 1
+#elif defined (BIOS)
 set_textmode:;
         size_t rows, cols;
         init_vga_textmode(&rows, &cols, false);
@@ -556,7 +556,7 @@ set_textmode:;
 
         if (fbinfo.framebuffer_addr > (uint64_t)0xffffffff) {
             screen_info->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
-#if uefi == 1
+#if defined (UEFI)
             screen_info->orig_video_isVGA = VIDEO_TYPE_EFI;
 #endif
         }
@@ -577,7 +577,7 @@ set_textmode:;
     ///////////////////////////////////////
     // UEFI
     ///////////////////////////////////////
-#if uefi == 1
+#if defined (UEFI)
     efi_exit_boot_services();
 
 #if defined (__x86_64__)
diff --git a/common/protos/multiboot1.c b/common/protos/multiboot1.c
index 763e2d1b..8f119576 100644
--- a/common/protos/multiboot1.c
+++ b/common/protos/multiboot1.c
@@ -313,9 +313,9 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
 
             struct fb_info fbinfo;
             if (!fb_init(&fbinfo, req_width, req_height, req_bpp)) {
-#if uefi == 1
+#if defined (UEFI)
                 panic(true, "multiboot1: Failed to set video mode");
-#elif bios == 1
+#elif defined (BIOS)
                 size_t rows, cols;
                 init_vga_textmode(&rows, &cols, false);
 
@@ -341,7 +341,7 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
                 multiboot1_info->fb_blue_mask_shift  = fbinfo.blue_mask_shift;
             }
         } else {
-#if uefi == 1
+#if defined (UEFI)
             print("multiboot1: Warning: Cannot use text mode with UEFI\n");
             struct fb_info fbinfo;
             if (!fb_init(&fbinfo, 0, 0, 0)) {
@@ -359,7 +359,7 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
             multiboot1_info->fb_green_mask_shift = fbinfo.green_mask_shift;
             multiboot1_info->fb_blue_mask_size   = fbinfo.blue_mask_size;
             multiboot1_info->fb_blue_mask_shift  = fbinfo.blue_mask_shift;
-#elif bios == 1
+#elif defined (BIOS)
             size_t rows, cols;
             init_vga_textmode(&rows, &cols, false);
 
@@ -374,9 +374,9 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
 
         multiboot1_info->flags |= (1 << 12);
     } else {
-#if uefi == 1
+#if defined (UEFI)
         panic(true, "multiboot1: Cannot use text mode with UEFI.");
-#elif bios == 1
+#elif defined (BIOS)
         size_t rows, cols;
         init_vga_textmode(&rows, &cols, false);
 #endif
@@ -387,7 +387,7 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
     void *reloc_stub = ext_mem_alloc(reloc_stub_size);
     memcpy(reloc_stub, multiboot_reloc_stub, reloc_stub_size);
 
-#if uefi == 1
+#if defined (UEFI)
     efi_exit_boot_services();
 #endif
 
diff --git a/common/protos/multiboot2.c b/common/protos/multiboot2.c
index f5ae0630..64b4f544 100644
--- a/common/protos/multiboot2.c
+++ b/common/protos/multiboot2.c
@@ -46,7 +46,7 @@ static size_t get_multiboot2_info_size(
         ALIGN_UP(smbios_tag_size, MULTIBOOT_TAG_ALIGN) +                                                                // SMBIOS
         ALIGN_UP(sizeof(struct multiboot_tag_basic_meminfo), MULTIBOOT_TAG_ALIGN) +                                     // basic memory info
         ALIGN_UP(sizeof(struct multiboot_tag_mmap) + sizeof(struct multiboot_mmap_entry) * 256, MULTIBOOT_TAG_ALIGN) +  // MMAP
-        #if uefi == 1
+        #if defined (UEFI)
             ALIGN_UP(sizeof(struct multiboot_tag_efi_mmap) + (efi_desc_size * 256), MULTIBOOT_TAG_ALIGN) +              // EFI MMAP
             #if defined (__i386__)
                 ALIGN_UP(sizeof(struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN) +                                     // EFI system table 32
@@ -133,7 +133,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
                         case MULTIBOOT_TAG_TYPE_MMAP:
                         case MULTIBOOT_TAG_TYPE_SMBIOS:
                         case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
-                        #if uefi == 1
+                        #if defined (UEFI)
                             case MULTIBOOT_TAG_TYPE_EFI_MMAP:
                             #if defined (__i386__)
                                 case MULTIBOOT_TAG_TYPE_EFI32:
@@ -466,7 +466,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
     //////////////////////////////////////////////
     // Create EFI image handle tag
     //////////////////////////////////////////////
-#if uefi == 1
+#if defined (UEFI)
     {
     #if defined (__i386__)
         struct multiboot_tag_efi64_ih *tag = (struct multiboot_tag_efi64_ih *)(mb2_info + info_idx);
@@ -507,7 +507,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
 
             struct fb_info fbinfo;
             if (!fb_init(&fbinfo, req_width, req_height, req_bpp)) {
-#if bios == 1
+#if defined (BIOS)
                 size_t rows, cols;
                 init_vga_textmode(&rows, &cols, false);
 
@@ -517,7 +517,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
                 tag->common.framebuffer_height = rows;
                 tag->common.framebuffer_bpp = 16;
                 tag->common.framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
-#elif uefi == 1
+#elif defined (UEFI)
                 panic(true, "multiboot2: Failed to set video mode");
 #endif
             } else {
@@ -536,7 +536,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
                 tag->framebuffer_blue_mask_size = fbinfo.blue_mask_size;
             }
         } else {
-#if uefi == 1
+#if defined (UEFI)
             print("multiboot2: Warning: Cannot use text mode with UEFI\n");
             struct fb_info fbinfo;
             if (!fb_init(&fbinfo, 0, 0, 0)) {
@@ -555,7 +555,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
             tag->framebuffer_green_mask_size = fbinfo.green_mask_size;
             tag->framebuffer_blue_field_position = fbinfo.blue_mask_shift;
             tag->framebuffer_blue_mask_size = fbinfo.blue_mask_size;
-#elif bios == 1
+#elif defined (BIOS)
             size_t rows, cols;
             init_vga_textmode(&rows, &cols, false);
 
@@ -653,7 +653,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
     //////////////////////////////////////////////
     // Create EFI system table info tag
     //////////////////////////////////////////////
-#if uefi == 1
+#if defined (UEFI)
     {
     #if defined (__i386__)
         uint32_t size = sizeof(struct multiboot_tag_efi32);
@@ -679,7 +679,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
     void *reloc_stub = ext_mem_alloc(reloc_stub_size);
     memcpy(reloc_stub, multiboot_reloc_stub, reloc_stub_size);
 
-#if uefi == 1
+#if defined (UEFI)
     efi_exit_boot_services();
 #endif
 
@@ -735,7 +735,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
     //////////////////////////////////////////////
     // Create EFI memory map tag
     //////////////////////////////////////////////
-#if uefi == 1
+#if defined (UEFI)
     {
         if ((efi_mmap_size / efi_desc_size) > 256) {
             panic(false, "multiboot2: too many EFI memory map entries");
diff --git a/common/pxe/pxe.s2.c b/common/pxe/pxe.s2.c
index 72f6a9f0..363ade0c 100644
--- a/common/pxe/pxe.s2.c
+++ b/common/pxe/pxe.s2.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <lib/print.h>
 #include <lib/real.h>
diff --git a/common/pxe/tftp.s2.c b/common/pxe/tftp.s2.c
index 33e72550..991aa9d5 100644
--- a/common/pxe/tftp.s2.c
+++ b/common/pxe/tftp.s2.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <pxe/tftp.h>
 #include <pxe/pxe.h>
diff --git a/common/sbat.c b/common/sbat.c
index dbe4e616..e0e10c08 100644
--- a/common/sbat.c
+++ b/common/sbat.c
@@ -1,4 +1,4 @@
-#if uefi == 1
+#if defined (UEFI)
 
 #include <config.h>
 
diff --git a/common/sys/a20.s2.c b/common/sys/a20.s2.c
index 57234b01..4adfc947 100644
--- a/common/sys/a20.s2.c
+++ b/common/sys/a20.s2.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <stdint.h>
 #include <stddef.h>
diff --git a/common/sys/e820.s2.c b/common/sys/e820.s2.c
index aae955c5..82a2222c 100644
--- a/common/sys/e820.s2.c
+++ b/common/sys/e820.s2.c
@@ -1,4 +1,4 @@
-#if bios == 1
+#if defined (BIOS)
 
 #include <stdint.h>
 #include <stddef.h>
diff --git a/common/sys/exceptions.s2.c b/common/sys/exceptions.s2.c
index 96444ce0..2a10a968 100644
--- a/common/sys/exceptions.s2.c
+++ b/common/sys/exceptions.s2.c
@@ -3,7 +3,7 @@
 #include <lib/trace.h>
 #include <lib/print.h>
 
-#if bios == 1
+#if defined (BIOS)
 
 static const char *exception_names[] = {
     "Division by 0",
diff --git a/common/sys/gdt.s2.c b/common/sys/gdt.s2.c
index 8f48db4d..b807c840 100644
--- a/common/sys/gdt.s2.c
+++ b/common/sys/gdt.s2.c
@@ -63,7 +63,7 @@ static struct gdt_desc gdt_descs[] = {
     }
 };
 
-#if bios == 1
+#if defined (BIOS)
 __attribute__((section(".realmode")))
 #endif
 struct gdtr gdt = {
@@ -74,7 +74,7 @@ struct gdtr gdt = {
 #endif
 };
 
-#if uefi == 1
+#if defined (UEFI)
 void init_gdt(void) {
     struct gdt_desc *gdt_copy = ext_mem_alloc(sizeof(gdt_descs));
     memcpy(gdt_copy, gdt_descs, sizeof(gdt_descs));
diff --git a/common/sys/idt.h b/common/sys/idt.h
index 46b58c8f..fc755cbb 100644
--- a/common/sys/idt.h
+++ b/common/sys/idt.h
@@ -37,7 +37,7 @@ struct idt_entry {
 
 #endif
 
-#if bios == 1
+#if defined (BIOS)
 
 extern struct idtr idt;
 
diff --git a/common/sys/idt.s2.c b/common/sys/idt.s2.c
index 88894147..33c2d736 100644
--- a/common/sys/idt.s2.c
+++ b/common/sys/idt.s2.c
@@ -3,7 +3,7 @@
 #include <sys/idt.h>
 #include <lib/misc.h>
 
-#if bios == 1
+#if defined (BIOS)
 
 static struct idt_entry idt_entries[32];
 
tab: 248 wrap: offon