]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
refactor: rename arch_start to arch_early_setup
authorTulio A M Mendes <[email protected]>
Sat, 7 Feb 2026 15:50:34 +0000 (12:50 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 7 Feb 2026 15:50:34 +0000 (12:50 -0300)
15 files changed:
README.md
include/arch/arch_early_setup.h [new file with mode: 0644]
include/arch/arch_start.h [deleted file]
src/arch/arm/arch_early_setup.c [new file with mode: 0644]
src/arch/arm/arch_start.c [deleted file]
src/arch/arm/boot.S
src/arch/mips/arch_early_setup.c [new file with mode: 0644]
src/arch/mips/arch_start.c [deleted file]
src/arch/mips/boot.S
src/arch/riscv/arch_early_setup.c [new file with mode: 0644]
src/arch/riscv/arch_start.c [deleted file]
src/arch/riscv/boot.S
src/arch/x86/arch_early_setup.c [new file with mode: 0644]
src/arch/x86/arch_start.c [deleted file]
src/arch/x86/boot.S

index 018a03e1b8b16ab19bd0d7091ec47f42b4e5c58b..f7ab93e8e4c6923e8f5c95d504853ed3fdfe4dc0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@ QEMU debug helpers:
 ## TODO
 - **Multi-architecture kernel bring-up**
   - Implement VMM/interrupts/scheduler for ARM/RISC-V/MIPS
-  - Standardize arch entrypoint behavior (`arch_start`) across architectures
+  - Standardize arch entrypoint behavior (`arch_early_setup`) across architectures
 - **Userspace**
   - Process model (fork/exec/wait), per-process address spaces, and cleanup on `exit`
   - Syscall ABI expansion (read/open/close, file descriptors, etc.)
diff --git a/include/arch/arch_early_setup.h b/include/arch/arch_early_setup.h
new file mode 100644 (file)
index 0000000..5893e89
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+ #ifndef ARCH_EARLY_SETUP_H
+ #define ARCH_EARLY_SETUP_H
+
+ #include "arch/arch_boot_args.h"
+
+ void arch_early_setup(const struct arch_boot_args* args);
+
+ #endif
diff --git a/include/arch/arch_start.h b/include/arch/arch_start.h
deleted file mode 100644 (file)
index faa317f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-/*
- * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
- * All rights reserved.
- * See LICENSE for details.
- *
- * Source: https://github.com/tadryanom/AdrOS
- */
-
-#ifndef ARCH_START_H
-#define ARCH_START_H
-
-#include "arch/arch_boot_args.h"
-
-void arch_start(const struct arch_boot_args* args);
-
-#endif
diff --git a/src/arch/arm/arch_early_setup.c b/src/arch/arm/arch_early_setup.c
new file mode 100644 (file)
index 0000000..2e64e9e
--- /dev/null
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+ #include "arch/arch_early_setup.h"
+#include "kernel/boot_info.h"
+
+#include "uart_console.h"
+
+extern void kernel_main(const struct boot_info* bi);
+
+ void arch_early_setup(const struct arch_boot_args* args) {
+    (void)args;
+
+    uart_init();
+    uart_print("\n[AdrOS] Booting...\n");
+
+    struct boot_info bi;
+    bi.arch_magic = 0;
+    bi.arch_boot_info = 0;
+    bi.initrd_start = 0;
+    bi.initrd_end = 0;
+    bi.cmdline = NULL;
+
+    kernel_main(&bi);
+
+    for(;;) {
+        __asm__ volatile("wfi");
+    }
+}
diff --git a/src/arch/arm/arch_start.c b/src/arch/arm/arch_start.c
deleted file mode 100644 (file)
index aa62edd..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-/*
- * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
- * All rights reserved.
- * See LICENSE for details.
- *
- * Source: https://github.com/tadryanom/AdrOS
- */
-
-#include "arch/arch_start.h"
-#include "kernel/boot_info.h"
-
-#include "uart_console.h"
-
-extern void kernel_main(const struct boot_info* bi);
-
-void arch_start(const struct arch_boot_args* args) {
-    (void)args;
-
-    uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
-
-    struct boot_info bi;
-    bi.arch_magic = 0;
-    bi.arch_boot_info = 0;
-    bi.initrd_start = 0;
-    bi.initrd_end = 0;
-    bi.cmdline = NULL;
-
-    kernel_main(&bi);
-
-    for(;;) {
-        __asm__ volatile("wfi");
-    }
-}
index 8051689408cd408cd78b5ccbc3ade58db899b05b..4f1f5440f5707f436f7b193f19048962c86356e3 100644 (file)
@@ -26,9 +26,9 @@ _start:
     ldr x0, =stack_top
     mov sp, x0
 
-    /* Build arch_boot_args (in .bss) and call arch_start(args) */
+    /* Build arch_boot_args (in .bss) and call arch_early_setup(args) */
     ldr x0, =arch_boot_args
-    bl arch_start
+    bl arch_early_setup
 
     /* Hang */
 1:  wfi
diff --git a/src/arch/mips/arch_early_setup.c b/src/arch/mips/arch_early_setup.c
new file mode 100644 (file)
index 0000000..6518b31
--- /dev/null
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+ #include "arch/arch_early_setup.h"
+#include "kernel/boot_info.h"
+
+#include "uart_console.h"
+
+extern void kernel_main(const struct boot_info* bi);
+
+ void arch_early_setup(const struct arch_boot_args* args) {
+    (void)args;
+
+    uart_init();
+    uart_print("\n[AdrOS] Booting...\n");
+
+    struct boot_info bi;
+    bi.arch_magic = 0;
+    bi.arch_boot_info = 0;
+    bi.initrd_start = 0;
+    bi.initrd_end = 0;
+    bi.cmdline = NULL;
+
+    kernel_main(&bi);
+
+    for(;;) {
+        __asm__ volatile("nop");
+    }
+}
diff --git a/src/arch/mips/arch_start.c b/src/arch/mips/arch_start.c
deleted file mode 100644 (file)
index 12e940d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-/*
- * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
- * All rights reserved.
- * See LICENSE for details.
- *
- * Source: https://github.com/tadryanom/AdrOS
- */
-
-#include "arch/arch_start.h"
-#include "kernel/boot_info.h"
-
-#include "uart_console.h"
-
-extern void kernel_main(const struct boot_info* bi);
-
-void arch_start(const struct arch_boot_args* args) {
-    (void)args;
-
-    uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
-
-    struct boot_info bi;
-    bi.arch_magic = 0;
-    bi.arch_boot_info = 0;
-    bi.initrd_start = 0;
-    bi.initrd_end = 0;
-    bi.cmdline = NULL;
-
-    kernel_main(&bi);
-
-    for(;;) {
-        __asm__ volatile("nop");
-    }
-}
index f4086b8f3d48b53bccaf3826fea8a3b62995bff1..d7bc85b30af3ca3912d976670e964cd69ea02c0a 100644 (file)
 _start:
     la   $sp, stack_top
 
-    /* Build arch_boot_args (in .bss) and call arch_start(args) */
+    /* Build arch_boot_args (in .bss) and call arch_early_setup(args) */
     la   $a0, arch_boot_args
     sw   $zero, 0($a0)
     sw   $zero, 4($a0)
     sw   $zero, 8($a0)
     sw   $zero, 12($a0)
 
-    jal  arch_start
+    jal  arch_early_setup
     nop
 
 1:
diff --git a/src/arch/riscv/arch_early_setup.c b/src/arch/riscv/arch_early_setup.c
new file mode 100644 (file)
index 0000000..2e64e9e
--- /dev/null
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+ #include "arch/arch_early_setup.h"
+#include "kernel/boot_info.h"
+
+#include "uart_console.h"
+
+extern void kernel_main(const struct boot_info* bi);
+
+ void arch_early_setup(const struct arch_boot_args* args) {
+    (void)args;
+
+    uart_init();
+    uart_print("\n[AdrOS] Booting...\n");
+
+    struct boot_info bi;
+    bi.arch_magic = 0;
+    bi.arch_boot_info = 0;
+    bi.initrd_start = 0;
+    bi.initrd_end = 0;
+    bi.cmdline = NULL;
+
+    kernel_main(&bi);
+
+    for(;;) {
+        __asm__ volatile("wfi");
+    }
+}
diff --git a/src/arch/riscv/arch_start.c b/src/arch/riscv/arch_start.c
deleted file mode 100644 (file)
index aa62edd..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-/*
- * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
- * All rights reserved.
- * See LICENSE for details.
- *
- * Source: https://github.com/tadryanom/AdrOS
- */
-
-#include "arch/arch_start.h"
-#include "kernel/boot_info.h"
-
-#include "uart_console.h"
-
-extern void kernel_main(const struct boot_info* bi);
-
-void arch_start(const struct arch_boot_args* args) {
-    (void)args;
-
-    uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
-
-    struct boot_info bi;
-    bi.arch_magic = 0;
-    bi.arch_boot_info = 0;
-    bi.initrd_start = 0;
-    bi.initrd_end = 0;
-    bi.cmdline = NULL;
-
-    kernel_main(&bi);
-
-    for(;;) {
-        __asm__ volatile("wfi");
-    }
-}
index 2097b98575c5b1f50d4f37a626a1dd20584ee461..1c4c5a4f76fab0b9585fdfcda3d7ed865b22189f 100644 (file)
@@ -24,9 +24,9 @@ _start:
      */
     la sp, stack_top
 
-    /* Build arch_boot_args (in .bss) and call arch_start(args) */
+    /* Build arch_boot_args (in .bss) and call arch_early_setup(args) */
     la a0, arch_boot_args
-    call arch_start
+    call arch_early_setup
 
     /* Hang if return */
 1:  wfi
diff --git a/src/arch/x86/arch_early_setup.c b/src/arch/x86/arch_early_setup.c
new file mode 100644 (file)
index 0000000..5d16980
--- /dev/null
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+ #include "arch/arch_early_setup.h"
+
+#include "kernel/boot_info.h"
+
+#include "gdt.h"
+#include "idt.h"
+#include "uart_console.h"
+
+#include "multiboot2.h"
+
+extern void kernel_main(const struct boot_info* bi);
+
+static uint8_t multiboot_copy[65536];
+static uint32_t multiboot_copy_size;
+
+ void arch_early_setup(const struct arch_boot_args* args) {
+    uart_init();
+    uart_print("\n[AdrOS] Booting...\n");
+
+    uint32_t magic = (uint32_t)(args ? args->a0 : 0);
+    uintptr_t mbi_phys = (uintptr_t)(args ? args->a1 : 0);
+
+    if (magic != 0x36d76289) {
+        uart_print("[ERR] Invalid Multiboot2 Magic!\n");
+    } else {
+        uart_print("[OK] Multiboot2 Magic Confirmed.\n");
+    }
+
+    uart_print("[AdrOS] Initializing GDT/TSS...\n");
+    gdt_init();
+
+    uart_print("[AdrOS] Initializing IDT...\n");
+    idt_init();
+
+    struct boot_info bi;
+    bi.arch_magic = magic;
+    bi.arch_boot_info = 0;
+    bi.initrd_start = 0;
+    bi.initrd_end = 0;
+    bi.cmdline = NULL;
+
+    if (mbi_phys) {
+        uint32_t total_size = *(volatile uint32_t*)mbi_phys;
+        if (total_size >= 8) {
+            multiboot_copy_size = total_size;
+            if (multiboot_copy_size > sizeof(multiboot_copy)) {
+                uart_print("[WARN] Multiboot2 info too large, truncating copy.\n");
+                multiboot_copy_size = sizeof(multiboot_copy);
+            }
+
+            for (uint32_t i = 0; i < multiboot_copy_size; i++) {
+                multiboot_copy[i] = *(volatile uint8_t*)(mbi_phys + i);
+            }
+            bi.arch_boot_info = (uintptr_t)multiboot_copy;
+        }
+    }
+
+    if (bi.arch_boot_info) {
+        struct multiboot_tag* tag;
+        for (tag = (struct multiboot_tag*)((uint8_t*)bi.arch_boot_info + 8);
+             tag->type != MULTIBOOT_TAG_TYPE_END;
+             tag = (struct multiboot_tag*)((uint8_t*)tag + ((tag->size + 7) & ~7))) {
+            if (tag->type == MULTIBOOT_TAG_TYPE_MODULE) {
+                struct multiboot_tag_module* mod = (struct multiboot_tag_module*)tag;
+                bi.initrd_start = mod->mod_start;
+                bi.initrd_end = mod->mod_end;
+                break;
+            }
+            if (tag->type == MULTIBOOT_TAG_TYPE_CMDLINE) {
+                struct multiboot_tag_string* s = (struct multiboot_tag_string*)tag;
+                bi.cmdline = s->string;
+            }
+        }
+    }
+
+    kernel_main(&bi);
+
+    for(;;) {
+        __asm__ volatile("hlt");
+    }
+}
diff --git a/src/arch/x86/arch_start.c b/src/arch/x86/arch_start.c
deleted file mode 100644 (file)
index eade7ce..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-// SPDX-License-Identifier: BSD-3-Clause
-/*
- * Copyright (c) 2018, Tulio A M Mendes <[email protected]>
- * All rights reserved.
- * See LICENSE for details.
- *
- * Source: https://github.com/tadryanom/AdrOS
- */
-
-#include "arch/arch_start.h"
-
-#include "kernel/boot_info.h"
-
-#include "gdt.h"
-#include "idt.h"
-#include "uart_console.h"
-
-#include "multiboot2.h"
-
-extern void kernel_main(const struct boot_info* bi);
-
-static uint8_t multiboot_copy[65536];
-static uint32_t multiboot_copy_size;
-
-void arch_start(const struct arch_boot_args* args) {
-    uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
-
-    uint32_t magic = (uint32_t)(args ? args->a0 : 0);
-    uintptr_t mbi_phys = (uintptr_t)(args ? args->a1 : 0);
-
-    if (magic != 0x36d76289) {
-        uart_print("[ERR] Invalid Multiboot2 Magic!\n");
-    } else {
-        uart_print("[OK] Multiboot2 Magic Confirmed.\n");
-    }
-
-    uart_print("[AdrOS] Initializing GDT/TSS...\n");
-    gdt_init();
-
-    uart_print("[AdrOS] Initializing IDT...\n");
-    idt_init();
-
-    struct boot_info bi;
-    bi.arch_magic = magic;
-    bi.arch_boot_info = 0;
-    bi.initrd_start = 0;
-    bi.initrd_end = 0;
-    bi.cmdline = NULL;
-
-    if (mbi_phys) {
-        uint32_t total_size = *(volatile uint32_t*)mbi_phys;
-        if (total_size >= 8) {
-            multiboot_copy_size = total_size;
-            if (multiboot_copy_size > sizeof(multiboot_copy)) {
-                uart_print("[WARN] Multiboot2 info too large, truncating copy.\n");
-                multiboot_copy_size = sizeof(multiboot_copy);
-            }
-
-            for (uint32_t i = 0; i < multiboot_copy_size; i++) {
-                multiboot_copy[i] = *(volatile uint8_t*)(mbi_phys + i);
-            }
-            bi.arch_boot_info = (uintptr_t)multiboot_copy;
-        }
-    }
-
-    if (bi.arch_boot_info) {
-        struct multiboot_tag* tag;
-        for (tag = (struct multiboot_tag*)((uint8_t*)bi.arch_boot_info + 8);
-             tag->type != MULTIBOOT_TAG_TYPE_END;
-             tag = (struct multiboot_tag*)((uint8_t*)tag + ((tag->size + 7) & ~7))) {
-            if (tag->type == MULTIBOOT_TAG_TYPE_MODULE) {
-                struct multiboot_tag_module* mod = (struct multiboot_tag_module*)tag;
-                bi.initrd_start = mod->mod_start;
-                bi.initrd_end = mod->mod_end;
-                break;
-            }
-            if (tag->type == MULTIBOOT_TAG_TYPE_CMDLINE) {
-                struct multiboot_tag_string* s = (struct multiboot_tag_string*)tag;
-                bi.cmdline = s->string;
-            }
-        }
-    }
-
-    kernel_main(&bi);
-
-    for(;;) {
-        __asm__ volatile("hlt");
-    }
-}
index e9e7b548bccba146ee51557b7e46c59f561a64a7..f57b5222d62eff65f06fd7f2e1edcc6e63c5c74a 100644 (file)
@@ -71,7 +71,7 @@ _start:
 
     /*
      * Map 0-16MB using 4 page tables.
-     * With Multiboot2 info copied in arch_start and initrd mapped via VMM,
+     * With Multiboot2 info copied in arch_early_setup and initrd mapped via VMM,
      * we only need a small identity window for early bring-up.
      */
 
@@ -162,7 +162,7 @@ higher_half_start:
     pop %ebx /* EBX now has the Multiboot Info address */
     pop %eax /* EAX now has the Magic Number */
 
-    /* Build arch_boot_args (in .bss) and call arch_start(args) */
+    /* Build arch_boot_args (in .bss) and call arch_early_setup(args) */
     mov $arch_boot_args, %ecx
     mov %eax, 0(%ecx)          /* args->a0 = multiboot magic */
     mov %ebx, 4(%ecx)          /* args->a1 = multiboot info phys */
@@ -170,7 +170,7 @@ higher_half_start:
     movl $0, 12(%ecx)          /* args->a3 = 0 */
 
     push %ecx
-    call arch_start
+    call arch_early_setup
     add $4, %esp
 
     /* Hang */