diff options
Diffstat (limited to 'boot/amd64/generic/biosboot')
| -rw-r--r-- | boot/amd64/generic/biosboot/Makefile | 15 | ||||
| -rw-r--r-- | boot/amd64/generic/biosboot/biosboot.S | 54 | ||||
| -rw-r--r-- | boot/amd64/generic/biosboot/link.ld | 26 |
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) + } +} |
