From 06d05938cc828901703112b99740c2e90a392b88 Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Tue, 8 Aug 2023 18:38:07 +0700 Subject: First commit --- kernel/boot.s | 28 ++++++++++++++++++++++++++++ kernel/kernel.c | 4 ++++ kernel/linker.ld | 28 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 kernel/boot.s create mode 100644 kernel/kernel.c create mode 100644 kernel/linker.ld (limited to 'kernel') diff --git a/kernel/boot.s b/kernel/boot.s new file mode 100644 index 0000000..2fd1c55 --- /dev/null +++ b/kernel/boot.s @@ -0,0 +1,28 @@ +MBALIGN equ 1 << 0 +MEMINFO equ 1 << 1 +MBFLAGS equ MBALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC + MBFLAGS) + +section .multiboot +align 4 + dd MAGIC + dd MBFLAGS + dd CHECKSUM + +section .bss +align 16 +stack_bottom: +resb 16384 +stack_top: + +section .text +global _start:function (_start.end - _start) +_start: + mov esp, stack_top + extern main + call main + cli +.hang: hlt + jmp .hang +.end: diff --git a/kernel/kernel.c b/kernel/kernel.c new file mode 100644 index 0000000..1d734c9 --- /dev/null +++ b/kernel/kernel.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +}; diff --git a/kernel/linker.ld b/kernel/linker.ld new file mode 100644 index 0000000..e490e6a --- /dev/null +++ b/kernel/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) + } +} -- cgit v1.2.3