Compare commits

..

No commits in common. "04322d9ff7ed7652258daafee28c47196c43b5b8" and "08997007f2c9ecb73dd2cba73c748e93f8c49238" have entirely different histories.

14 changed files with 11 additions and 211 deletions

1
.gitignore vendored
View File

@ -7,4 +7,3 @@ initrd/bin/**
initrd/tests/** initrd/tests/**
base/ base/
.fakeroot .fakeroot
kernel/config.cmake

View File

@ -103,10 +103,6 @@ if(MOON_DEBUG)
include(debug.cmake) include(debug.cmake)
endif() endif()
if(EXISTS config.cmake)
include(config.cmake)
endif()
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel) target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
set_target_properties(moon PROPERTIES CXX_STANDARD 20) set_target_properties(moon PROPERTIES CXX_STANDARD 20)

View File

@ -1,12 +0,0 @@
# Copy this file and rename it to 'config.cmake' before making your own changes.
# config.cmake: Configuration file for the kernel.
# Edit/add values to customize kernel compilation flags/defines.
# This file is automatically ignored by git.
# To use an example configuration line, just remove the hashtag '#' at the beginning.
# Example: Adding a compiler definition. This will define PCI_DEBUG in the kernel source.
# target_compile_definitions(moon PRIVATE PCI_DEBUG)
# Example: Adding a compiler flag. This will optimize the kernel aggressively (warning: untested, use at your own discretion).
# target_compile_options(moon PRIVATE -O3)

View File

@ -3,9 +3,4 @@ target_compile_definitions(moon PRIVATE DEBUG_MODE)
target_compile_definitions(moon PRIVATE ELF_DEBUG) target_compile_definitions(moon PRIVATE ELF_DEBUG)
target_compile_definitions(moon PRIVATE MMU_DEBUG) target_compile_definitions(moon PRIVATE MMU_DEBUG)
target_compile_definitions(moon PRIVATE MMAP_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) target_compile_options(moon PRIVATE -fsanitize=undefined)

View File

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

View File

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

View File

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

View File

@ -51,9 +51,7 @@ namespace DeviceRegistry
const char* name = device->device_path().chars(); 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); 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 }; auto desc = DeviceDescriptor { .device = device, .major = major, .minor = minor, .name = name, .mode = mode };

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,6 @@ luna_test(libluna/TestBase64.cpp TestBase64)
luna_test(libluna/TestUtf8.cpp TestUtf8) luna_test(libluna/TestUtf8.cpp TestUtf8)
luna_test(libluna/TestFormat.cpp TestFormat) luna_test(libluna/TestFormat.cpp TestFormat)
luna_test(libluna/TestHashTable.cpp TestHashTable) luna_test(libluna/TestHashTable.cpp TestHashTable)
luna_test(libluna/TestCPath.cpp TestCPath)
luna_app(run-tests.cpp run-tests) luna_app(run-tests.cpp run-tests)
endif() endif()

View File

@ -1,157 +0,0 @@
#include <luna/CPath.h>
#include <string.h>
#include <test.h>
// Test cases taken from the basename(3) manpage on my Arch Linux system (which are taken from SUSv2).
TestResult test_dirname_usr_lib()
{
char path[] = "/usr/lib";
char* dir = dirname(path);
validate(!strcmp(dir, "/usr"));
test_success;
}
TestResult test_basename_usr_lib()
{
char path[] = "/usr/lib";
char* name = basename(path);
validate(!strcmp(name, "lib"));
test_success;
}
TestResult test_dirname_absolute_usr()
{
char path[] = "/usr/";
char* dir = dirname(path);
validate(!strcmp(dir, "/"));
test_success;
}
TestResult test_basename_absolute_usr()
{
char path[] = "/usr/";
char* name = basename(path);
validate(!strcmp(name, "usr"));
test_success;
}
TestResult test_dirname_relative_usr()
{
char path[] = "usr";
char* dir = dirname(path);
validate(!strcmp(dir, "."));
test_success;
}
TestResult test_basename_relative_usr()
{
char path[] = "usr";
char* name = basename(path);
validate(!strcmp(name, "usr"));
test_success;
}
TestResult test_dirname_root()
{
char path[] = "/";
char* dir = dirname(path);
validate(!strcmp(dir, "/"));
test_success;
}
TestResult test_basename_root()
{
char path[] = "/";
char* name = basename(path);
validate(!strcmp(name, "/"));
test_success;
}
TestResult test_dirname_self()
{
char path[] = ".";
char* dir = dirname(path);
validate(!strcmp(dir, "."));
test_success;
}
TestResult test_basename_self()
{
char path[] = ".";
char* name = basename(path);
validate(!strcmp(name, "."));
test_success;
}
TestResult test_dirname_parent()
{
char path[] = "..";
char* dir = dirname(path);
validate(!strcmp(dir, "."));
test_success;
}
TestResult test_basename_parent()
{
char path[] = "..";
char* name = basename(path);
validate(!strcmp(name, ".."));
test_success;
}
Result<void> test_main()
{
test_prelude;
run_test(test_basename_usr_lib);
run_test(test_basename_absolute_usr);
run_test(test_basename_relative_usr);
run_test(test_basename_root);
run_test(test_basename_self);
run_test(test_basename_parent);
run_test(test_dirname_usr_lib);
run_test(test_dirname_absolute_usr);
run_test(test_dirname_relative_usr);
run_test(test_dirname_root);
run_test(test_dirname_self);
run_test(test_dirname_parent);
return {};
}