CeDOS - Commit c16cf73e

kernel: Make init process configurable Signed-off-by: Celina Sophie Kalus <hello@celinakalus.de>
Celina Sophie Kalus
Wed, 23 Jul 2025 21:43:58 +0200
2 files changed, 32 insertions(+), 24 deletions(-)
M CMakeLists.txtCMakeLists.txt

@@ -42,6 +42,7 @@ add_compile_options(-DVERSION="${GIT_VERSION}")

add_compile_options(-Wall -Wextra -Werror) set(CEDOS_TTY_CON vga_con) +set(CEDOS_INIT_EXE "shelf") list(APPEND COMMON_SRC common/memory.c

@@ -155,6 +156,7 @@ )

target_compile_options(kernel.elf PRIVATE -DCEDOS_TTY_CON=${CEDOS_TTY_CON} + -DCEDOS_INIT_EXE=${CEDOS_INIT_EXE} ) cedos_linker_script(kernel.elf ${CMAKE_SOURCE_DIR}/kernel/link.txt)
M kernel/main.ckernel/main.c

@@ -25,6 +25,9 @@ #include "linker.h"

#include "assert.h" #include "string.h" +#define _STRINGIFY(string) #string +#define STRINGIFY(string) _STRINGIFY(string) + #ifdef DEBUG #define PRINT_DBG(...) printk("[" __FILE__ "] " __VA_ARGS__) #else

@@ -136,32 +139,35 @@ }

} int os_main(void) { - infodump(); - - printk("Starting scheduler.\n"); - sched_start(); + const char *init_exe = STRINGIFY(CEDOS_INIT_EXE); + + infodump(); + + printk("Starting scheduler.\n"); + sched_start(); + + printk("Creating tasks.\n"); - printk("Creating tasks.\n"); - - /** - * Here, the kernel "forks" into the idle process and - * the shell. - * - * The idle process is executed whenever, duh, all - * processes are out of work and idling. - * - * The shell is where the user can give commands and - * start her own processes. It is an executable that - * is read from disk. - */ - int pid = sched_spawn("shelf", "Hello World!", 0); - assert(pid != -1); + /** + * Here, the kernel "forks" into the idle process and + * the shell. + * + * The idle process is executed whenever, duh, all + * processes are out of work and idling. + * + * The shell is where the user can give commands and + * start her own processes. It is an executable that + * is read from disk. + */ + printk("Starting '%s'...\n", init_exe); + int pid = sched_spawn(init_exe, "Hello World!", 0); + assert(pid != -1); - // here is where the idle process (PID 0) starts. - sched_idle(NULL); + // here is where the idle process (PID 0) starts. + sched_idle(NULL); - // this should never happen. - kpanic("Returned from idle process!"); + // this should never happen. + kpanic("Returned from idle process!"); - return 0; + return 0; }