diff --git a/src/kernel/debug.c b/src/kernel/debug.c index 72ad60f..2c794ab 100644 --- a/src/kernel/debug.c +++ b/src/kernel/debug.c @@ -1,5 +1,5 @@ /* Calcite, src/kernel/debug.c - * Copyright 2025 Benji Dial + * Copyright 2025-2026 Benji Dial * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +37,10 @@ void log_core(const char *file, const char *function, const char *format, ...) { write_serial_string_n(" -", 2); for (int i = file_length + function_length + 3; i < 49; ++i) write_serial_string_n("-", 1); + while (format[0] == ' ') { + write_serial_string_n("-", 1); + ++format; + } write_serial_string_n(" ", 1); va_list args; diff --git a/src/kernel/entry.c b/src/kernel/entry.c index 7303b55..b6af873 100644 --- a/src/kernel/entry.c +++ b/src/kernel/entry.c @@ -246,9 +246,9 @@ static const char *cmdline_look_up(const char *key) { } - debug_log("command line:") + debug_log("command line") for (int i = 0; i < cmdline_pair_count; ++i) - debug_log(" %s = %s", cmdline_pairs[i].key, cmdline_pairs[i].value) + debug_log(" %s %s", cmdline_pairs[i].key, cmdline_pairs[i].value) //set up interrupts @@ -321,10 +321,6 @@ static const char *cmdline_look_up(const char *key) { if (start_elf("root://calcite/apps/init/init.elf") == 0) panic("could not start init.elf") - debug_log("about to switch to init") - debug_log(" free physical memory %B", count_free_pram()) - debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) - resume_next_continuation(); } diff --git a/src/kernel/pata.c b/src/kernel/pata.c index b005b2d..0f34efa 100644 --- a/src/kernel/pata.c +++ b/src/kernel/pata.c @@ -1,5 +1,5 @@ /* Calcite, src/kernel/pata.c - * Copyright 2025 Benji Dial + * Copyright 2025-2026 Benji Dial * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -211,7 +211,7 @@ static void probe_pata_drive(uint16_t command_block_base, uint8_t device_byte) { di->read_blocks = &read_blocks_patapi; - debug_log("added pata drive:") + debug_log("added pata drive") debug_log(" drive name %s", di->name) debug_log(" command block base 0x%h", command_block_base, 4) debug_log(" device byte 0x%h", device_byte, 2) diff --git a/src/kernel/process.c b/src/kernel/process.c index eedaa73..3a3bea0 100644 --- a/src/kernel/process.c +++ b/src/kernel/process.c @@ -373,6 +373,9 @@ struct process *start_elf(const char *uri) { struct process *process = heap_alloc(sizeof(struct process)); create_process(process); + debug_log("new process") + debug_log(" path %s", uri) + debug_log(" process struct 0x%h", process, 16) const struct fs_info *fs_info; void *fs_node; @@ -421,12 +424,6 @@ void syscall_create_thread(void (*f)(uint64_t), uint64_t x) { add_to_queue(&ready_continuations, &ci); - debug_log("started thread") - debug_log(" process struct at 0xffffffff.%h", thread->process, 8) - debug_log(" thread struct at 0xffffffff.%h", thread, 8) - debug_log(" free physical memory %B", count_free_pram()) - debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) - } int syscall_start_elf(const char *path, const struct process_start_info *info) { @@ -467,12 +464,6 @@ int syscall_start_elf(const char *path, const struct process_start_info *info) { for (int i = 0; i < info->set_envvar_count; ++i) set_envvar(process, info->set_envvars[2 * i], info->set_envvars[2 * i + 1]); - debug_log("started process") - debug_log(" path %s", path) - debug_log(" process struct at 0xffffffff.%h", process, 8) - debug_log(" free physical memory %B", count_free_pram()) - debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) - return 1; } @@ -547,6 +538,11 @@ void destroy_process(struct process *process) { unmap_and_free_kernel_page(process->p4_virtual_base); heap_dealloc(process, sizeof(struct process)); + debug_log("process destroyed") + debug_log(" process struct 0x%h", process, 16) + debug_log(" free physical memory %B", count_free_pram()) + debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) + } void destroy_thread(struct thread *thread) { @@ -567,6 +563,11 @@ void destroy_thread(struct thread *thread) { heap_dealloc(thread, sizeof(struct thread)); + debug_log("thread destroyed") + debug_log(" thread struct 0x%h", thread, 16) + debug_log(" free physical memory %B", count_free_pram()) + debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) + } #define MAX_STACK_SIZE ((16 << 20) - 4096) @@ -615,6 +616,12 @@ void create_thread(struct process *process, struct thread *thread_out) { ++process->n_threads; + debug_log("new thread") + debug_log(" process struct 0x%h", process, 16) + debug_log(" thread struct 0x%h", thread_out, 16) + debug_log(" free physical memory %B", count_free_pram()) + debug_log(" free kernel virtual memory %B", count_free_kernel_vram()) + } [[noreturn]] void syscall_illegal_args() { diff --git a/src/user-apps/init/init.c b/src/user-apps/init/init.c index 33a8b1e..8f6f280 100644 --- a/src/user-apps/init/init.c +++ b/src/user-apps/init/init.c @@ -1,5 +1,5 @@ /* Calcite, src/user-apps/init/init.c - * Copyright 2025 Benji Dial + * Copyright 2025-2026 Benji Dial * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,24 +21,10 @@ #include #include -const char *hello = "hello"; - -[[noreturn]] void test(const char *message) { - - ipc_dgram_sender_handle_t handle; - if (ipc_create_dgram_sender("calcite-test", &handle) == IPR_SUCCESS) - ipc_send_dgram(handle, message, 5); - - end_thread(); - -} - #define MAX_LINE_LENGTH 1023 void main() { - create_thread((void *)&test, (uint64_t)hello); - struct file_stream *rc; if (open_file_stream("root://calcite/init.rc", &rc) != FAR_SUCCESS) return; @@ -78,12 +64,9 @@ void main() { line[line_length] = 0; - const char *set_envvars[2] = { "hello", "world" }; - struct process_start_info psi; psi.forwared_envvar_count = 0; - psi.set_envvar_count = 1; - psi.set_envvars = set_envvars; + psi.set_envvar_count = 0; start_elf(line, &psi);