wires

summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorwires <wires@noreply.wires.systems>2025-03-19 17:09:41 -0400
committerwires <wires@noreply.wires.systems>2025-03-19 17:09:41 -0400
commit8466e9b4d2fbca85d53d8dadc87914b4766c43de (patch)
tree99a0d7a23e805f4ad3e30814ee9a09ebb00ae08b /src
downloadzosimos-8466e9b4d2fbca85d53d8dadc87914b4766c43de.tar.gz
initial commit
Diffstat (limited to 'src')
-rw-r--r--src/Link.ld35
-rw-r--r--src/main.zig3
-rw-r--r--src/startup.s28
3 files changed, 66 insertions, 0 deletions
diff --git a/src/Link.ld b/src/Link.ld
new file mode 100644
index 0000000..aec6d6a
--- /dev/null
+++ b/src/Link.ld
@@ -0,0 +1,35 @@
+ENTRY(_start)
+OUTPUT_FORMAT("elf64-littleaarch64")
+
+SECTIONS {
+  __kernel_load_address = 0x80000;
+  __stack_base = __kernel_load_address;
+
+  . = __kernel_load_address;
+
+  .init : {
+    KEEP(*(.init))
+  }
+
+  .text : {
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t*)
+  }
+
+  . = ALIGN(CONSTANT(MAXPAGESIZE));
+  __bss_start = .;
+  .bss (NOLOAD) : {
+    *(.bss*)
+    *(.gnu.linkonce.b*)
+    *(COMMON)
+  }
+  __bss_end = .;
+  __bss_size = (__bss_end - __bss_start) / 8;
+
+  . = ALIGN(CONSTANT(COMMONPAGESIZE));
+  .rodata : { *(.rodata*) *(.gnu.linkonce.d*) }
+
+  . = ALIGN(CONSTANT(COMMONPAGESIZE));
+  .data : { *(.data*) *(.gnu.linkonce.d*) }
+}
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..602f270
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,3 @@
+export fn main() callconv(.C) void {
+    while (true) {}
+}
diff --git a/src/startup.s b/src/startup.s
new file mode 100644
index 0000000..e0c6385
--- /dev/null
+++ b/src/startup.s
@@ -0,0 +1,28 @@
+.section ".init"
+.global _start
+
+_start:
+    mrs     x1, MPIDR_EL1
+    and     x1, x1, 0b11
+
+    cbz     x1, init
+halt:
+    wfe
+    b       halt
+
+init:
+    adr     x1, __stack_base
+    mov     sp, x1
+
+    adr     x1, __bss_start
+    adr     x2, __bss_size
+    cbz     x2, exec_kernel
+
+clear_bss:
+    str     xzr, [x1], 8
+    sub     x2, x2, 1
+    cbnz    w2, clear_bss
+
+exec_kernel:
+    bl      main
+    b       halt