diff options
Diffstat (limited to 'boot/arch/amd64/mbr')
| -rw-r--r-- | boot/arch/amd64/mbr/Makefile | 16 | ||||
| -rw-r--r-- | boot/arch/amd64/mbr/link.ld | 21 | ||||
| -rw-r--r-- | boot/arch/amd64/mbr/mbr.S | 17 |
3 files changed, 54 insertions, 0 deletions
diff --git a/boot/arch/amd64/mbr/Makefile b/boot/arch/amd64/mbr/Makefile new file mode 100644 index 0000000..f41e5cc --- /dev/null +++ b/boot/arch/amd64/mbr/Makefile @@ -0,0 +1,16 @@ +CC = clang +CFLAGS = \ + -ffreestanding \ + -nostdlib \ + -nostdinc \ + -mno-red-zone \ + -mno-sse \ + -mno-sse2 \ + -target i386-unknown-elf + +.PHONY: all +all: mbr + +.PHONY: mbr +mbr: + clang -Tlink.ld $(CFLAGS) mbr.S -o $(GLOBAL_PROJECT_ROOT)/artifacts/mbr.bin diff --git a/boot/arch/amd64/mbr/link.ld b/boot/arch/amd64/mbr/link.ld new file mode 100644 index 0000000..6d25985 --- /dev/null +++ b/boot/arch/amd64/mbr/link.ld @@ -0,0 +1,21 @@ +OUTPUT_FORMAT(binary) + +SECTIONS { + . = 0x7C00; + + .text : { + *(.text) + } + + .data : { + *(.data) + } + + .rodata : { + *(.rodata) + } + + .bss : { + *(.bss) + } +} diff --git a/boot/arch/amd64/mbr/mbr.S b/boot/arch/amd64/mbr/mbr.S new file mode 100644 index 0000000..e071a41 --- /dev/null +++ b/boot/arch/amd64/mbr/mbr.S @@ -0,0 +1,17 @@ + .code16 +_start: + /* Normalize CS + other selectors */ + ljmp $0x00,$1f +1: xor %ax, %ax + mov %ax, %ds + mov %ax, %ss + mov %ax, %es + mov %ax, %gs + mov %ax, %fs +2: cli + hlt + jmp 2b + + .org 510 + .byte 0x55 + .byte 0xAA |
