diff options
author | trimill <trimill@trimillxyz.org> | 2024-01-26 22:29:49 -0500 |
---|---|---|
committer | trimill <trimill@trimillxyz.org> | 2024-01-26 22:29:49 -0500 |
commit | 4aad3cce1d22c39dfa9c0d360737fe6d92f38595 (patch) | |
tree | 9bbd6741e99f7fd1499c221748d7b74f567eb3eb /src/arch | |
parent | Created basic directory structure (diff) | |
download | corn-4aad3cce1d22c39dfa9c0d360737fe6d92f38595.tar.gz corn-4aad3cce1d22c39dfa9c0d360737fe6d92f38595.tar.bz2 corn-4aad3cce1d22c39dfa9c0d360737fe6d92f38595.zip |
added boilerplate (todo make it amd64)
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/amd64/boot.S | 72 | ||||
-rw-r--r-- | src/arch/amd64/linker.ld | 25 |
2 files changed, 97 insertions, 0 deletions
diff --git a/src/arch/amd64/boot.S b/src/arch/amd64/boot.S index e69de29..f7c24c4 100644 --- a/src/arch/amd64/boot.S +++ b/src/arch/amd64/boot.S @@ -0,0 +1,72 @@ +global start +extern kmain +bits 32 + +; base, limit, access, flags +%macro gdt_entry 4 + db %2 & 0xff + db (%2 >> 8) & 0xff + db %1 & 0xff + db (%1 >> 8) & 0xff + db (%1 >> 16) & 0xff + db %3 + db ((%2 >> 16) & 0x0f) | (%4 << 4) + db (%1 >> 24) & 0xff +%endmacro + +section .multiboot +align 8 +mb_start: +; header +dd 0xe85250d6 +dd 0 +dd mb_end - mb_start +dd 0x100000000 - (0xe85250d6 + (mb_end - mb_start)) +; null tag +dw 0 +dw 0 +dd 8 +; +mb_end: + +section .bss +align 16 +stack_start: + resb 16384 +stack_end: + +section .rodata +align 16 +gdt_start: +gdt_entry 0, 0, 0, 0 +gdt_entry 0, 0xFFFFF, 0x9A, 0xC +gdt_entry 0, 0xFFFFF, 0x92, 0xC +gdt_end: +gdt_descriptor: + dw gdt_end - gdt_start - 1 + dd gdt_start + + +section .text +align 8 +start: + cli + lgdt [gdt_descriptor] + jmp 0x08:after_lgdt +after_lgdt: + mov ax, 0x10 + mov ds, ax + mov ss, ax + mov es, ax + mov fs, ax + mov gs, ax + mov esp, stack_end + mov ebp, stack_end + sti + push ebx + call kmain + cli +halt: + hlt + jmp halt + diff --git a/src/arch/amd64/linker.ld b/src/arch/amd64/linker.ld new file mode 100644 index 0000000..4e796e2 --- /dev/null +++ b/src/arch/amd64/linker.ld @@ -0,0 +1,25 @@ +ENTRY(start) + +SECTIONS { + . = 1M; + + .boot BLOCK(4K) : ALIGN(4K) + { + *(.multiboot) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } + + .text BLOCK(4K) : ALIGN(4K) + { + *(.text) + } + + .bss BLOCK(4K) : ALIGN(4K) + { + *(.bss) + } +} |