summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/boot.s28
-rw-r--r--kernel/kernel.c4
-rw-r--r--kernel/linker.ld28
3 files changed, 60 insertions, 0 deletions
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)
+ }
+}