From 25a24b8b167a7cb28c622039ea30e4afd166cd83 Mon Sep 17 00:00:00 2001 From: Clément Sibille Date: Mon, 4 Oct 2021 13:30:31 +0200 Subject: Make kernel print hello world using the VGA text buffer --- boot/boot.S | 36 ++++++++++++++++++++++++++++++++++++ boot/linker.ld | 28 ++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 boot/boot.S create mode 100644 boot/linker.ld (limited to 'boot') diff --git a/boot/boot.S b/boot/boot.S new file mode 100644 index 0000000..6164029 --- /dev/null +++ b/boot/boot.S @@ -0,0 +1,36 @@ +MULTIBOOT_ALIGN EQU 1<<0 ; Align loaded modules on page boundaries +MULTIBOOT_MEMINFO EQU 1<<1 ; Provide memory map +MULTIBOOT_FLAGS EQU MULTIBOOT_ALIGN | MULTIBOOT_MEMINFO ; Multiboot flags +MULTIBOOT_MAGIC EQU 0x1BADB002 ; Multiboot 1 magic number +MULTIBOOT_CHECKSUM EQU -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS) ; Checksum + +SECTION .multiboot +ALIGN 4 +DD MULTIBOOT_MAGIC +DD MULTIBOOT_FLAGS +DD MULTIBOOT_CHECKSUM + +SECTION .bss +ALIGN 16 +stack_bottom: +RESB 16384 ; 16 KiB stack +stack_top: + + +SECTION .text +GLOBAL _start:function (_start.end - _start) +_start: + MOV esp, stack_top + EXTERN kmain + CALL kmain + CLI +.hang: HLT + JMP .hang +.end: + + + + + + + diff --git a/boot/linker.ld b/boot/linker.ld new file mode 100644 index 0000000..a725f4e --- /dev/null +++ b/boot/linker.ld @@ -0,0 +1,28 @@ +ENTRY(_start) + +SECTIONS +{ + . = 1M; + + .text BLOCK(4K) : ALIGN(4K) + { + *(.multiboot) + *(.text) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } + + .data BLOCK(4K) : ALIGN(4K) + { + *(.data) + } + + .bss BLOCK(4K) : ALIGN(4K) + { + *(COMMON) + *(.bss) + } +} \ No newline at end of file -- cgit v1.2.3