summaryrefslogtreecommitdiff
path: root/boot/amd64/generic/biosboot
diff options
context:
space:
mode:
authorChloe M. <chloe@aptel.org>2026-09-03 01:22:45 +0000
committerChloe M. <chloe@aptel.org>2026-09-03 02:49:49 +0000
commite758e02f0781e45f91674aeb5c2259ce4add3b88 (patch)
treee6ea80f93bbad0f93b6c859d126f144af12ad32f /boot/amd64/generic/biosboot
initial commitmain
Signed-off-by: Chloe M. <chloe@aptel.org>
Diffstat (limited to 'boot/amd64/generic/biosboot')
-rw-r--r--boot/amd64/generic/biosboot/Makefile15
-rw-r--r--boot/amd64/generic/biosboot/biosboot.S54
-rw-r--r--boot/amd64/generic/biosboot/link.ld26
3 files changed, 95 insertions, 0 deletions
diff --git a/boot/amd64/generic/biosboot/Makefile b/boot/amd64/generic/biosboot/Makefile
new file mode 100644
index 0000000..e9854be
--- /dev/null
+++ b/boot/amd64/generic/biosboot/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2026, Apollo Telephone Laboratories.
+# Provided under the BSD-3 clause.
+#
+
+include ../mk/build.mk
+
+CFLAGS = $(INTERNAL_CFLAGS)
+
+.PHONY: all
+all: biosboot
+
+.PHONY: biosboot
+biosboot:
+ $(CC) $(CFLAGS) -Tlink.ld biosboot.S -o biosboot.bin
diff --git a/boot/amd64/generic/biosboot/biosboot.S b/boot/amd64/generic/biosboot/biosboot.S
new file mode 100644
index 0000000..bf2b004
--- /dev/null
+++ b/boot/amd64/generic/biosboot/biosboot.S
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2026, Apollo Telephone Laboratories.
+ * Provided under the BSD-3 clause.
+ */
+
+ .text
+ .code16
+ .globl _start
+_start:
+ cli
+ xor %ax, %ax
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %ss
+
+ lgdt gdtr
+ mov %cr0, %eax
+ or $1, %eax
+ mov %eax, %cr0
+ ljmp $0x08,$1f
+
+ .code32
+1: mov $0x10, %ax
+ mov %ax, %es
+ mov %ax, %ss
+ mov %ax, %fs
+ mov %ax, %gs
+ mov %ax, %ds
+ jmp c_thunk
+
+gdt:
+.null:
+ .quad 0
+.code:
+ .word 0xFFFF
+ .word 0x0000
+ .byte 0x00
+ .byte 0b10011010
+ .byte 0b11001111
+ .byte 0x00
+.data:
+ .word 0xFFFF
+ .word 0x0000
+ .byte 0x00
+ .byte 0b10010010
+ .byte 0b11001111
+ .byte 0x00
+gdtr:
+ .word . - gdt - 1
+ .long gdt
+
+/* Fall-through : everything above this */
+c_thunk:
+ nop
diff --git a/boot/amd64/generic/biosboot/link.ld b/boot/amd64/generic/biosboot/link.ld
new file mode 100644
index 0000000..f039b2b
--- /dev/null
+++ b/boot/amd64/generic/biosboot/link.ld
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2026, Apollo Telephone Laboratories.
+ * Provided under the BSD-3 clause.
+ */
+
+OUTPUT_FORMAT(binary)
+
+SECTIONS {
+ . = 0x7C00;
+
+ .text : {
+ *(.text)
+ }
+
+ .data : {
+ *(.data)
+ }
+
+ .rodata : {
+ *(.rodata)
+ }
+
+ .bss : {
+ *(.bss)
+ }
+}