tweak logging, get rid of old test in init

This commit is contained in:
Benji Dial 2026-01-02 23:02:48 -05:00
parent 085ae6ba53
commit c6dac5c489
5 changed files with 30 additions and 40 deletions

View file

@ -1,5 +1,5 @@
/* Calcite, src/kernel/debug.c /* 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 * 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 * 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); write_serial_string_n(" -", 2);
for (int i = file_length + function_length + 3; i < 49; ++i) for (int i = file_length + function_length + 3; i < 49; ++i)
write_serial_string_n("-", 1); write_serial_string_n("-", 1);
while (format[0] == ' ') {
write_serial_string_n("-", 1);
++format;
}
write_serial_string_n(" ", 1); write_serial_string_n(" ", 1);
va_list args; va_list args;

View file

@ -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) 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 //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) if (start_elf("root://calcite/apps/init/init.elf") == 0)
panic("could not start init.elf") 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(); resume_next_continuation();
} }

View file

@ -1,5 +1,5 @@
/* Calcite, src/kernel/pata.c /* 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 * 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 * 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; 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(" drive name %s", di->name)
debug_log(" command block base 0x%h", command_block_base, 4) debug_log(" command block base 0x%h", command_block_base, 4)
debug_log(" device byte 0x%h", device_byte, 2) debug_log(" device byte 0x%h", device_byte, 2)

View file

@ -373,6 +373,9 @@ struct process *start_elf(const char *uri) {
struct process *process = heap_alloc(sizeof(struct process)); struct process *process = heap_alloc(sizeof(struct process));
create_process(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; const struct fs_info *fs_info;
void *fs_node; void *fs_node;
@ -421,12 +424,6 @@ void syscall_create_thread(void (*f)(uint64_t), uint64_t x) {
add_to_queue(&ready_continuations, &ci); 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) { 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) for (int i = 0; i < info->set_envvar_count; ++i)
set_envvar(process, info->set_envvars[2 * i], info->set_envvars[2 * i + 1]); 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; return 1;
} }
@ -547,6 +538,11 @@ void destroy_process(struct process *process) {
unmap_and_free_kernel_page(process->p4_virtual_base); unmap_and_free_kernel_page(process->p4_virtual_base);
heap_dealloc(process, sizeof(struct process)); 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) { void destroy_thread(struct thread *thread) {
@ -567,6 +563,11 @@ void destroy_thread(struct thread *thread) {
heap_dealloc(thread, sizeof(struct 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) #define MAX_STACK_SIZE ((16 << 20) - 4096)
@ -615,6 +616,12 @@ void create_thread(struct process *process, struct thread *thread_out) {
++process->n_threads; ++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() { [[noreturn]] void syscall_illegal_args() {

View file

@ -1,5 +1,5 @@
/* Calcite, src/user-apps/init/init.c /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -21,24 +21,10 @@
#include <kernel-public/ipc.h> #include <kernel-public/ipc.h>
#include <calcite/syscalls.h> #include <calcite/syscalls.h>
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 #define MAX_LINE_LENGTH 1023
void main() { void main() {
create_thread((void *)&test, (uint64_t)hello);
struct file_stream *rc; struct file_stream *rc;
if (open_file_stream("root://calcite/init.rc", &rc) != FAR_SUCCESS) if (open_file_stream("root://calcite/init.rc", &rc) != FAR_SUCCESS)
return; return;
@ -78,12 +64,9 @@ void main() {
line[line_length] = 0; line[line_length] = 0;
const char *set_envvars[2] = { "hello", "world" };
struct process_start_info psi; struct process_start_info psi;
psi.forwared_envvar_count = 0; psi.forwared_envvar_count = 0;
psi.set_envvar_count = 1; psi.set_envvar_count = 0;
psi.set_envvars = set_envvars;
start_elf(line, &psi); start_elf(line, &psi);