kernel: Add a bunch more config definitions and hide debug messages behind them

This commit is contained in:
apio 2023-06-18 20:18:00 +02:00
parent ec34937f14
commit b7bdec9ece
Signed by: apio
GPG Key ID: B8A7D06E42258954
9 changed files with 36 additions and 11 deletions

View File

@ -3,4 +3,9 @@ target_compile_definitions(moon PRIVATE DEBUG_MODE)
target_compile_definitions(moon PRIVATE ELF_DEBUG)
target_compile_definitions(moon PRIVATE MMU_DEBUG)
target_compile_definitions(moon PRIVATE MMAP_DEBUG)
target_compile_definitions(moon PRIVATE EXEC_DEBUG)
target_compile_definitions(moon PRIVATE OPEN_DEBUG)
target_compile_definitions(moon PRIVATE REAP_DEBUG)
target_compile_definitions(moon PRIVATE PCI_DEBUG)
target_compile_definitions(moon PRIVATE DEVICE_REGISTRY_DEBUG)
target_compile_options(moon PRIVATE -fsanitize=undefined)

View File

@ -96,12 +96,16 @@ namespace PCI
// Single-function PCI bus
if ((header_type & 0x80) == 0)
{
#ifdef PCI_DEBUG
kdbgln("PCI bus is single-function");
#endif
scan_bus(0, { callback, match });
}
else
{
#ifdef PCI_DEBUG
kdbgln("PCI bus is multiple-function");
#endif
for (u32 function = 0; function < 8; function++)
{
if (read16({ 0, 0, function }, Field::VendorID) != PCI::INVALID_ID)

View File

@ -16,8 +16,8 @@ namespace GPT
if (memcmp(header.signature, GPT_SIGNATURE, GPT_SIGNATURE_LENGTH)) return false;
kdbgln("gpt: Found GUID partition table on device %s, revision %#.8x, with space for %d partition entries!",
device->device_path().chars(), header.revision, header.num_partitions);
kinfoln("gpt: Found GUID partition table on device %s, revision %#.8x, with space for %d partition entries!",
device->device_path().chars(), header.revision, header.num_partitions);
if (header.revision != GPT_REVISION)
{
@ -55,7 +55,7 @@ namespace GPT
if (!memcmp(entry.type_guid, null_guid, 16)) continue;
kdbgln("gpt: Partition entry #%u is active: start=%lu, end=%lu", i, entry.start_lba, entry.end_lba);
kinfoln("gpt: Partition entry #%u is active: start=%lu, end=%lu", i, entry.start_lba, entry.end_lba);
TRY(MBR::PartitionDevice::create(device, entry.start_lba, entry.end_lba - entry.start_lba,
partition_index++));

View File

@ -232,7 +232,7 @@ namespace VFS
auto parent_path = TRY(parser.dirname());
auto child = TRY(parser.basename());
kdbgln("vfs: Mounting filesystem on target %s", path);
kinfoln("vfs: Mounting filesystem on target %s", path);
auto parent_inode = TRY(resolve_path(parent_path.chars(), auth, working_directory));
@ -255,7 +255,7 @@ namespace VFS
if (child.view() == "/") return err(EBUSY);
kdbgln("vfs: Unmounting filesystem on target %s", path);
kinfoln("vfs: Unmounting filesystem on target %s", path);
auto parent_inode = TRY(resolve_path(parent_path.chars(), auth, working_directory));

View File

@ -51,7 +51,9 @@ namespace DeviceRegistry
const char* name = device->device_path().chars();
#ifdef DEVICE_REGISTRY_DEBUG
kdbgln("DeviceRegistry: registered new device type %u:%u at path /%s in devfs", major, minor, name);
#endif
auto desc = DeviceDescriptor { .device = device, .major = major, .minor = minor, .name = name, .mode = mode };

View File

@ -66,7 +66,9 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
if (!VFS::can_execute(inode, current->auth)) return err(EACCES);
kinfoln("exec: attempting to replace current image with %s", path.chars());
#ifdef EXEC_DEBUG
kdbgln("exec: attempting to replace current image with %s", path.chars());
#endif
auto guard = make_scope_guard([current] { MMU::switch_page_directory(current->directory); });
@ -80,7 +82,9 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
// From now on, nothing should fail.
kinfoln("exec: image load ok, will now replace existing process image");
#ifdef EXEC_DEBUG
kdbgln("exec: image load ok, will now replace existing process image");
#endif
guard.deactivate();
@ -110,6 +114,8 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
memcpy(regs, &current->regs, sizeof(*regs));
kinfoln("exec: thread %lu was replaced with %s", current->id, path.chars());
return 0;
}
@ -151,7 +157,9 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
Scheduler::add_thread(thread);
kinfoln("fork: thread %lu forked into child %lu", current->id, thread->id);
#ifdef FORK_DEBUG
kdbgln("fork: thread %lu forked into child %lu", current->id, thread->id);
#endif
return thread->id;
}

View File

@ -74,7 +74,9 @@ Result<u64> sys_openat(Registers*, SyscallArgs args)
int fd = TRY(current->allocate_fd(0));
kinfoln("openat: opening file %s from dirfd %d, flags %d, mode %#o = fd %d", path.chars(), dirfd, flags, mode, fd);
#ifdef OPEN_DEBUG
kdbgln("openat: opening file %s from dirfd %d, flags %d, mode %#o = fd %d", path.chars(), dirfd, flags, mode, fd);
#endif
inode->add_handle();

View File

@ -73,7 +73,9 @@ namespace ELFLoader
return err(ENOEXEC);
}
kinfoln("ELF: Loading ELF with entry=%#.16lx", elf_header.e_entry);
#ifdef ELF_DEBUG
kdbgln("ELF: Loading ELF with entry=%#.16lx", elf_header.e_entry);
#endif
usize i;
Elf64_Phdr program_header;

View File

@ -171,7 +171,9 @@ namespace Scheduler
{
CPU::disable_interrupts();
kinfoln("reap: reaping thread with id %zu", thread->id);
#ifdef REAP_DEBUG
kdbgln("reap: reaping thread with id %zu", thread->id);
#endif
if (thread->is_kernel)
{