:: commit fc23258aa7d7810b2a76b0f70d3ae22fee1b2940

mintsuki <mintsuki@protonmail.com> — 2020-08-26 22:44

parents: b2d24ecca3

Handle intel style inline assembly via macros for compatibility with clang, remove TempleOS protocol support

diff --git a/README.md b/README.md
index 4e0bd1e6..ec2c8537 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,7 @@ x86/x86_64 BIOS Bootloader
 
 ### Supported boot protocols
 * Linux
-* stivale (qloader2's native boot protocol, see STIVALE.md for details)
-* TempleOS
+* stivale and stivale2 (qloader2's native boot protocols, see STIVALE{,2}.md for details)
 
 ### Supported filesystems
 * ext2
diff --git a/qloader2.bin b/qloader2.bin
index e4114f32..032989d1 100644
Binary files a/qloader2.bin and b/qloader2.bin differ
diff --git a/src/Makefile b/src/Makefile
index cb599948..7c44049b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -5,7 +5,6 @@ CFLAGS = -Os -pipe -Wall -Wextra
 INTERNAL_CFLAGS = \
 	-std=gnu99 \
 	-ffreestanding \
-	-masm=intel \
 	-fno-pic \
 	-mno-80387 \
 	-mno-mmx \
diff --git a/src/lib/asm.h b/src/lib/asm.h
new file mode 100644
index 00000000..560057c0
--- /dev/null
+++ b/src/lib/asm.h
@@ -0,0 +1,17 @@
+#ifndef __LIB__ASM_H__
+#define __LIB__ASM_H__
+
+#define ASM(body, ...) asm volatile (".intel_syntax noprefix\n\t" body ".att_syntax prefix" : __VA_ARGS__)
+#define ASM_BASIC(body) asm (".intel_syntax noprefix\n\t" body ".att_syntax prefix")
+
+#define FARJMP16(seg, off) \
+    ".byte 0xea\n\t" \
+    ".2byte " off "\n\t" \
+    ".2byte " seg "\n\t" \
+
+#define FARJMP32(seg, off) \
+    ".byte 0xea\n\t" \
+    ".4byte " off "\n\t" \
+    ".2byte " seg "\n\t" \
+
+#endif
diff --git a/src/lib/blib.c b/src/lib/blib.c
index 38136ff5..86748f1f 100644
--- a/src/lib/blib.c
+++ b/src/lib/blib.c
@@ -9,6 +9,7 @@
 #include <lib/cio.h>
 #include <lib/e820.h>
 #include <lib/print.h>
+#include <lib/asm.h>
 
 uint8_t bcd_to_int(uint8_t val) {
     return (val & 0x0f) + ((val & 0xf0) >> 4) * 10;
@@ -17,32 +18,30 @@ uint8_t bcd_to_int(uint8_t val) {
 int cpuid(uint32_t leaf, uint32_t subleaf,
           uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
     uint32_t cpuid_max;
-    asm volatile ("cpuid"
-                  : "=a" (cpuid_max)
-                  : "a" (leaf & 0x80000000)
-                  : "rbx", "rcx", "rdx");
+    ASM("cpuid\n\t", "=a" (cpuid_max)
+                   : "a" (leaf & 0x80000000)
+                   : "rbx", "rcx", "rdx");
     if (leaf > cpuid_max)
         return 1;
-    asm volatile ("cpuid"
-                  : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
-                  : "a" (leaf), "c" (subleaf));
+    ASM("cpuid\n\t", "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+                   : "a" (leaf), "c" (subleaf));
     return 0;
 }
 
 __attribute__((noreturn)) void panic(const char *fmt, ...) {
-    asm volatile ("cli" ::: "memory");
+    ASM("cli\n\t", :: "memory");
 
     va_list args;
 
     va_start(args, fmt);
 
-    print("\033[31mPANIC:\033[37;1m\033[40m ");
+    print("\033[31mPANIC\033[37;1m\033[40m: ");
     vprint(fmt, args);
 
     va_end(args);
 
     for (;;) {
-        asm volatile ("hlt" ::: "memory");
+        ASM("hlt\n\t", :: "memory");
     }
 }
 
@@ -76,7 +75,7 @@ void *balloc_aligned(size_t count, size_t alignment) {
 __attribute__((used)) static uint32_t int_08_ticks_counter;
 
 __attribute__((naked)) static void int_08_isr(void) {
-    asm (
+    ASM_BASIC(
         ".code16\n\t"
         "inc dword ptr cs:[int_08_ticks_counter]\n\t"
         "int 0x40\n\t"   // call callback
@@ -100,7 +99,7 @@ __attribute__((used)) static void dehook_int_08(void) {
 // This is a dirty hack but we need to execute this full function in real mode
 __attribute__((naked))
 int pit_sleep_and_quit_on_keypress(uint32_t ticks) {
-    asm (
+    ASM_BASIC(
         "call hook_int_08\n\t"
 
         // pit_ticks in edx
@@ -117,7 +116,7 @@ int pit_sleep_and_quit_on_keypress(uint32_t ticks) {
         "push ebp\n\t"
 
         // Jump to real mode
-        "jmp 0x08:1f\n\t"
+        FARJMP32("0x08", "1f")
         "1: .code16\n\t"
         "mov ax, 0x10\n\t"
         "mov ds, ax\n\t"
@@ -128,8 +127,8 @@ int pit_sleep_and_quit_on_keypress(uint32_t ticks) {
         "mov eax, cr0\n\t"
         "and al, 0xfe\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0:2f\n\t"
-        "2:\n\t"
+        FARJMP16("0", "1f")
+        "1:\n\t"
         "mov ax, 0\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -171,8 +170,8 @@ int pit_sleep_and_quit_on_keypress(uint32_t ticks) {
         "mov ebx, cr0\n\t"
         "or bl, 1\n\t"
         "mov cr0, ebx\n\t"
-        "jmp 0x18:4f\n\t"
-        "4: .code32\n\t"
+        FARJMP16("0x18", "1f")
+        "1: .code32\n\t"
         "mov bx, 0x20\n\t"
         "mov ds, bx\n\t"
         "mov es, bx\n\t"
@@ -192,7 +191,6 @@ int pit_sleep_and_quit_on_keypress(uint32_t ticks) {
         "pop eax\n\t"
         "ret\n\t"
     );
-    (void)ticks;
 }
 
 uint64_t strtoui(const char *s) {
diff --git a/src/lib/cio.h b/src/lib/cio.h
index f33a7afc..76053099 100644
--- a/src/lib/cio.h
+++ b/src/lib/cio.h
@@ -2,53 +2,36 @@
 #define __CIO_H__
 
 #include <stdint.h>
-
-#define port_out_b(port, value) ({				\
-	asm volatile (	"out dx, al"				\
-					:							\
-					: "a" (value), "d" (port)	\
-					: "memory" );						\
-})
-
-#define port_out_w(port, value) ({				\
-	asm volatile (	"out dx, ax"				\
-					:							\
-					: "a" (value), "d" (port)	\
-					: "memory" );						\
-})
-
-#define port_out_d(port, value) ({				\
-	asm volatile (	"out dx, eax"				\
-					:							\
-					: "a" (value), "d" (port)	\
-					: "memory" );						\
-})
-
-#define port_in_b(port) ({						\
-	uint8_t value;								\
-	asm volatile (	"in al, dx"					\
-					: "=a" (value)				\
-					: "d" (port)				\
-					: "memory" );						\
-	value;										\
-})
-
-#define port_in_w(port) ({						\
-	uint16_t value;								\
-	asm volatile (	"in ax, dx"					\
-					: "=a" (value)				\
-					: "d" (port)				\
-					: "memory" );						\
-	value;										\
-})
-
-#define port_in_d(port) ({						\
-	uint32_t value;								\
-	asm volatile (	"in eax, dx"				\
-					: "=a" (value)				\
-					: "d" (port)				\
-					: "memory" );						\
-	value;										\
-})
+#include <lib/asm.h>
+
+static inline void port_out_b(uint16_t port, uint8_t value) {
+    ASM("out dx, al\n\t",  : "a" (value), "d" (port) : "memory");
+}
+
+static inline void port_out_w(uint16_t port, uint16_t value) {
+    ASM("out dx, ax\n\t",  : "a" (value), "d" (port) : "memory");
+}
+
+static inline void port_out_d(uint16_t port, uint32_t value) {
+    ASM("out dx, eax\n\t", : "a" (value), "d" (port) : "memory");
+}
+
+static inline uint8_t port_in_b(uint16_t port) {
+    uint8_t value;
+    ASM("in al, dx\n\t",  "=a" (value) : "d" (port) : "memory");
+    return value;
+}
+
+static inline uint16_t port_in_w(uint16_t port) {
+    uint16_t value;
+    ASM("in ax, dx\n\t",  "=a" (value) : "d" (port) : "memory");
+    return value;
+}
+
+static inline uint32_t port_in_d(uint16_t port) {
+    uint32_t value;
+    ASM("in eax, dx\n\t", "=a" (value) : "d" (port) : "memory");
+    return value;
+}
 
 #endif
diff --git a/src/lib/real.c b/src/lib/real.c
index 9000d05a..18270366 100644
--- a/src/lib/real.c
+++ b/src/lib/real.c
@@ -1,9 +1,10 @@
 #include <stdint.h>
 #include <lib/real.h>
+#include <lib/asm.h>
 
 __attribute__((naked))
 void rm_flush_irqs(void) {
-    asm (
+    ASM_BASIC(
         // Mask PICs
         "mov al, 0xff\n\t"
         "out 0x21, al\n\t"
@@ -19,7 +20,7 @@ void rm_flush_irqs(void) {
         "push ebp\n\t"
 
         // Jump to real mode
-        "jmp 0x08:1f\n\t"
+        FARJMP32("0x08", "1f")
         "1: .code16\n\t"
         "mov ax, 0x10\n\t"
         "mov ds, ax\n\t"
@@ -30,8 +31,8 @@ void rm_flush_irqs(void) {
         "mov eax, cr0\n\t"
         "and al, 0xfe\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0:2f\n\t"
-        "2:\n\t"
+        FARJMP16("0", "1f")
+        "1:\n\t"
         "mov ax, 0\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -50,8 +51,8 @@ void rm_flush_irqs(void) {
         "mov eax, cr0\n\t"
         "or al, 1\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0x18:4f\n\t"
-        "4: .code32\n\t"
+        FARJMP16("0x18", "1f")
+        "1: .code32\n\t"
         "mov ax, 0x20\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -85,7 +86,7 @@ void rm_flush_irqs(void) {
 
 __attribute__((naked))
 void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
-    asm (
+    ASM_BASIC(
         // Self-modifying code: int $int_no
         "mov al, byte ptr ss:[esp+4]\n\t"
         "mov byte ptr ds:[3f], al\n\t"
@@ -108,7 +109,7 @@ void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
         "push ebp\n\t"
 
         // Jump to real mode
-        "jmp 0x08:1f\n\t"
+        FARJMP32("0x08", "1f")
         "1: .code16\n\t"
         "mov ax, 0x10\n\t"
         "mov ds, ax\n\t"
@@ -119,8 +120,8 @@ void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
         "mov eax, cr0\n\t"
         "and al, 0xfe\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0:2f\n\t"
-        "2:\n\t"
+        FARJMP16("0", "1f")
+        "1:\n\t"
         "mov ax, 0\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -170,8 +171,8 @@ void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
         "mov eax, cr0\n\t"
         "or al, 1\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0x18:4f\n\t"
-        "4: .code32\n\t"
+        FARJMP16("0x18", "1f")
+        "1: .code32\n\t"
         "mov ax, 0x20\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -198,5 +199,4 @@ void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) {
         "8: .long 0\n\t"
         "   .long 0\n\t"
     );
-    (void)int_no; (void)out_regs; (void)in_regs;
 }
diff --git a/src/main.c b/src/main.c
index b83e3103..ea2e2d1f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,6 @@
-asm (
+#include <lib/asm.h>
+
+ASM_BASIC(
     ".section .entry\n\t"
 
     // Zero out .bss
@@ -26,7 +28,6 @@ asm (
 #include <protos/stivale.h>
 #include <protos/stivale2.h>
 #include <protos/linux.h>
-#include <protos/templeos.h>
 #include <protos/chainload.h>
 #include <menu.h>
 
@@ -76,8 +77,6 @@ void main(int boot_drive) {
         stivale2_load(cmdline, boot_drive);
     } else if (!strcmp(proto, "linux")) {
         linux_load(cmdline, boot_drive);
-    } else if (!strcmp(proto, "templeos")) {
-        templeos_load(boot_drive);
     } else if (!strcmp(proto, "chainload")) {
         chainload();
     } else {
diff --git a/src/protos/chainload.c b/src/protos/chainload.c
index 2e6249a6..d72f5c48 100644
--- a/src/protos/chainload.c
+++ b/src/protos/chainload.c
@@ -6,6 +6,7 @@
 #include <lib/blib.h>
 #include <drivers/disk.h>
 #include <drivers/vga_textmode.h>
+#include <lib/asm.h>
 
 void chainload(void) {
     int part; {
@@ -35,9 +36,9 @@ void chainload(void) {
         read(drive, (void *)0x7c00, 0, 512);
     }
 
-    asm volatile (
+    ASM(
         // Jump to real mode
-        "jmp 0x08:1f\n\t"
+        FARJMP32("0x08", "1f")
         "1: .code16\n\t"
         "mov ax, 0x10\n\t"
         "mov ds, ax\n\t"
@@ -48,8 +49,8 @@ void chainload(void) {
         "mov eax, cr0\n\t"
         "and al, 0xfe\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0:2f\n\t"
-        "2:\n\t"
+        FARJMP16("0", "1f")
+        "1:\n\t"
         "mov ax, 0\n\t"
         "mov ds, ax\n\t"
         "mov es, ax\n\t"
@@ -59,8 +60,7 @@ void chainload(void) {
         "push 0\n\t"
         "push 0x7c00\n\t"
         "retf\n\t"
-        ".code32\n\t"
-        :
+        ".code32\n\t",
         : "d" (drive)
         : "memory"
     );
diff --git a/src/protos/linux.c b/src/protos/linux.c
index a8a60f68..e296b599 100644
--- a/src/protos/linux.c
+++ b/src/protos/linux.c
@@ -8,6 +8,7 @@
 #include <lib/config.h>
 #include <lib/print.h>
 #include <lib/memmap.h>
+#include <lib/asm.h>
 
 #define KERNEL_LOAD_ADDR ((size_t)0x100000)
 #define INITRD_LOAD_ADDR ((size_t)0x1000000)
@@ -136,11 +137,11 @@ void linux_load(char *cmdline, int boot_drive) {
 
     deinit_vga_textmode();
 
-    asm volatile (
+    ASM(
         "cli\n\t"
         "cld\n\t"
 
-        "jmp 0x08:1f\n\t"
+        FARJMP32("0x08", "1f")
         "1: .code16\n\t"
         "mov ax, 0x10\n\t"
         "mov ds, ax\n\t"
@@ -151,8 +152,8 @@ void linux_load(char *cmdline, int boot_drive) {
         "mov eax, cr0\n\t"
         "and al, 0xfe\n\t"
         "mov cr0, eax\n\t"
-        "jmp 0:2f\n\t"
-        "2:\n\t"
+        FARJMP16("0", "1f")
+        "1:\n\t"
         "mov ds, bx\n\t"
         "mov es, bx\n\t"
         "mov fs, bx\n\t"
@@ -163,8 +164,7 @@ void linux_load(char *cmdline, int boot_drive) {
 
         "push cx\n\t"
         "push 0\n\t"
-        "retf\n\t"
-        :
+        "retf\n\t",
         : "b" (real_mode_code_seg), "c" (kernel_entry_seg)
         : "memory"
     );
diff --git a/src/protos/stivale.c b/src/protos/stivale.c
index b086b371..d3efab14 100644
--- a/src/protos/stivale.c
+++ b/src/protos/stivale.c
@@ -14,6 +14,7 @@
 #include <drivers/vbe.h>
 #include <drivers/vga_textmode.h>
 #include <fs/file.h>
+#include <lib/asm.h>
 
 struct stivale_header {
     uint64_t stack;
@@ -253,10 +254,10 @@ void stivale_load(char *cmdline, int boot_drive) {
         void *pagemap_ptr;
         if (level5pg && (stivale_hdr.flags & (1 << 1))) {
             // Enable CR4.LA57
-            asm volatile (
+            ASM(
                 "mov eax, cr4\n\t"
                 "bts eax, 12\n\t"
-                "mov cr4, eax\n\t"
+                "mov cr4, eax\n\t", :: "eax", "memory"
             );
 
             struct pagemap {
@@ -324,7 +325,7 @@ void stivale_load(char *cmdline, int boot_drive) {
                 (&pagemap->pml2_0gb[0])[i] = (i * 0x200000) | 0x03 | (1 << 7);
         }
 
-        asm volatile (
+        ASM(
             "cli\n\t"
             "cld\n\t"
             "mov cr3, eax\n\t"
@@ -338,7 +339,7 @@ void stivale_load(char *cmdline, int boot_drive) {
             "mov eax, cr0\n\t"
             "or eax, 1 << 31\n\t"
             "mov cr0, eax\n\t"
-            "jmp 0x28:1f\n\t"
+            FARJMP32("0x28", "1f")
             "1: .code64\n\t"
             "mov ax, 0x30\n\t"
             "mov ds, ax\n\t"
@@ -369,14 +370,13 @@ void stivale_load(char *cmdline, int boot_drive) {
             "xor r15, r15\n\t"
 
             "iretq\n\t"
-            ".code32\n\t"
-            :
+            ".code32\n\t",
             : "a" (pagemap_ptr), "b" (&entry_point),
               "D" (&stivale_struct), "S" (&stivale_hdr.stack)
             : "memory"
         );
     } else if (bits == 32) {
-        asm volatile (
+        ASM(
             "cli\n\t"
             "cld\n\t"
 
@@ -397,8 +397,7 @@ void stivale_load(char *cmdline, int boot_drive) {
             "xor edi, edi\n\t"
             "xor ebp, ebp\n\t"
 
-            "iret\n\t"
-            :
+            "iret\n\t",
             : "b" (&entry_point), "D" (&stivale_struct), "S" (&stivale_hdr.stack)
             : "memory"
         );
diff --git a/src/protos/stivale2.c b/src/protos/stivale2.c
index 18ea0206..bfa59fd8 100644
--- a/src/protos/stivale2.c
+++ b/src/protos/stivale2.c
@@ -16,6 +16,7 @@
 #include <drivers/vbe.h>
 #include <drivers/vga_textmode.h>
 #include <fs/file.h>
+#include <lib/asm.h>
 
 struct stivale2_tag {
     uint64_t identifier;
@@ -419,13 +420,10 @@ void stivale2_load(char *cmdline, int boot_drive) {
         void *pagemap_ptr;
         if (level5pg && level5pg_requested) {
             // Enable CR4.LA57
-            asm volatile (
+            ASM(
                 "mov eax, cr4\n\t"
                 "bts eax, 12\n\t"
-                "mov cr4, eax\n\t"
-                :
-                :
-                : "eax", "memory"
+                "mov cr4, eax\n\t", :: "eax", "memory"
             );
 
             struct pagemap {
@@ -493,7 +491,7 @@ void stivale2_load(char *cmdline, int boot_drive) {
                 (&pagemap->pml2_0gb[0])[i] = (i * 0x200000) | 0x03 | (1 << 7);
         }
 
-        asm volatile (
+        ASM(
             "cli\n\t"
             "cld\n\t"
             "mov cr3, eax\n\t"
@@ -507,7 +505,7 @@ void stivale2_load(char *cmdline, int boot_drive) {
             "mov eax, cr0\n\t"
             "or eax, 1 << 31\n\t"
             "mov cr0, eax\n\t"
-            "jmp 0x28:1f\n\t"
+            FARJMP32("0x28", "1f")
             "1: .code64\n\t"
             "mov ax, 0x30\n\t"
             "mov ds, ax\n\t"
@@ -538,14 +536,13 @@ void stivale2_load(char *cmdline, int boot_drive) {
             "xor r15, r15\n\t"
 
             "iretq\n\t"
-            ".code32\n\t"
-            :
+            ".code32\n\t",
             : "a" (pagemap_ptr), "b" (&entry_point),
               "D" (&stivale2_struct), "S" (&stivale2_hdr.stack)
             : "memory"
         );
     } else if (bits == 32) {
-        asm volatile (
+        ASM(
             "cli\n\t"
             "cld\n\t"
 
@@ -566,8 +563,7 @@ void stivale2_load(char *cmdline, int boot_drive) {
             "xor edi, edi\n\t"
             "xor ebp, ebp\n\t"
 
-            "iret\n\t"
-            :
+            "iret\n\t",
             : "b" (&entry_point), "D" (&stivale2_struct), "S" (&stivale2_hdr.stack)
             : "memory"
         );
diff --git a/src/protos/templeos.c b/src/protos/templeos.c
deleted file mode 100644
index d75060d5..00000000
--- a/src/protos/templeos.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <stddef.h>
-#include <stdint.h>
-#include <lib/config.h>
-#include <lib/blib.h>
-#include <lib/libc.h>
-#include <lib/print.h>
-#include <fs/file.h>
-
-__attribute__((used))
-__attribute__((naked)) static void trampoline(void *p, size_t sz, int boot_drive) {
-    asm (
-        "tos_trampoline_begin:\n\t"
-
-        "mov edx, dword ptr ss:[esp+12]\n\t"
-
-        "mov ecx, dword ptr ss:[esp+8]\n\t"
-        "mov esi, dword ptr ss:[esp+4]\n\t"
-        "mov edi, 0x7c00\n\t"
-        "cld\n\t"
-        "rep movsb\n\t"
-
-        "lgdt [4f - tos_trampoline_begin + 0x500]\n\t"
-
-        "jmp 0x08:1f - tos_trampoline_begin + 0x500\n\t"
-        "1: .code16\n\t"
-        "mov ax, 0x10\n\t"
-        "mov ds, ax\n\t"
-        "mov es, ax\n\t"
-        "mov fs, ax\n\t"
-        "mov gs, ax\n\t"
-        "mov ss, ax\n\t"
-        "mov eax, cr0\n\t"
-        "and al, 0xfe\n\t"
-        "mov cr0, eax\n\t"
-        "jmp 0:2f - tos_trampoline_begin + 0x500\n\t"
-        "2:\n\t"
-        "xor ax, ax\n\t"
-        "mov fs, ax\n\t"
-        "mov gs, ax\n\t"
-
-        "mov ax, 0x96c0\n\t"
-        "mov ds, ax\n\t"
-        "mov ss, ax\n\t"
-
-        "mov ax, 0x35e0\n\t"
-        "mov es, ax\n\t"
-
-        "mov eax, 3\n\t"
-
-        "xor ebx, ebx\n\t"
-        "xor ecx, ecx\n\t"
-        "mov esi, 0x92\n\t"
-        "mov edi, 0x200\n\t"
-        "xor ebp, ebp\n\t"
-
-        "mov esp, 0x400\n\t"
-
-        "push 0x246\n\t"
-        "push 0x07c0\n\t"
-        "push 0x0\n\t"
-        "iret\n\t"
-
-        ".code32\n\t"
-
-        "3:\n\t"
-        ".quad 0\n\t"
-        ".quad 0x00009A000000FFFF\n\t"
-        ".quad 0x000092000000FFFF\n\t"
-        "4:\n\t"
-        ".short 4b - 3b - 1\n\t"
-        ".long 3b - tos_trampoline_begin + 0x500\n\t"
-
-        "tos_trampoline_end:\n\t"
-    );
-    (void)p; (void)sz; (void)boot_drive;
-}
-
-extern symbol tos_trampoline_begin;
-extern symbol tos_trampoline_end;
-
-void templeos_load(int boot_drive) {
-    int kernel_drive; {
-        char buf[32];
-        if (!config_get_value(buf, 0, 32, "DRIVE")) {
-            kernel_drive = boot_drive;
-        } else {
-            kernel_drive = (int)strtoui(buf);
-        }
-    }
-
-    int kernel_part; {
-        char buf[32];
-        if (!config_get_value(buf, 0, 32, "PARTITION")) {
-            panic("PARTITION not specified");
-        } else {
-            kernel_part = (int)strtoui(buf);
-        }
-    }
-
-    struct file_handle f;
-    if (fopen(&f, kernel_drive, kernel_part, "/Kernel.BIN.C")) {
-        panic("TempleOS kernel not found.");
-    }
-
-    print("TempleOS kernel size: %U bytes\n", f.size);
-
-    void *kernel = balloc(f.size);
-    fread(&f, kernel, 0, f.size);
-
-    void (*t)(void *p, size_t sz, int boot_drive);
-    t = (void *)0x500;
-
-    memcpy(t, tos_trampoline_begin, (size_t)tos_trampoline_end - (size_t)tos_trampoline_begin);
-
-    t(kernel, f.size, kernel_drive);
-
-    for (;;);
-}
diff --git a/src/protos/templeos.h b/src/protos/templeos.h
deleted file mode 100644
index 97610863..00000000
--- a/src/protos/templeos.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __PROTOS__TEMPLEOS_H__
-#define __PROTOS__TEMPLEOS_H__
-
-void templeos_load(int boot_drive);
-
-#endif
tab: 248 wrap: offon