aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/arch/boot/boot.hpp4
-rw-r--r--arch/x86_64/arch/boot/ld.hpp4
-rw-r--r--arch/x86_64/arch/bus/cpu.hpp2
-rw-r--r--arch/x86_64/arch/bus/isa.hpp6
-rw-r--r--arch/x86_64/arch/cpu/control_register.hpp4
-rw-r--r--arch/x86_64/arch/cpu/global_descriptor_table.hpp4
-rw-r--r--arch/x86_64/arch/cpu/interrupts.cpp7
-rw-r--r--arch/x86_64/arch/cpu/interrupts.hpp4
-rw-r--r--arch/x86_64/arch/cpu/legacy_pic.hpp4
-rw-r--r--arch/x86_64/arch/cpu/model_specific_register.hpp4
-rw-r--r--arch/x86_64/arch/cpu/registers.hpp4
-rw-r--r--arch/x86_64/arch/cpu/segment_descriptor.hpp4
-rw-r--r--arch/x86_64/arch/cpu/segment_selector.hpp4
-rw-r--r--arch/x86_64/arch/cpu/task_state_segment.hpp4
-rw-r--r--arch/x86_64/arch/debug/qemu_output.hpp4
-rw-r--r--arch/x86_64/arch/io/port_io.hpp4
-rw-r--r--arch/x86_64/arch/memory/higher_half_mapper.hpp4
-rw-r--r--arch/x86_64/arch/memory/kernel_mapper.hpp4
-rw-r--r--arch/x86_64/arch/memory/mmu.hpp4
-rw-r--r--arch/x86_64/arch/memory/page_table.hpp4
-rw-r--r--arch/x86_64/arch/memory/page_utilities.hpp4
-rw-r--r--arch/x86_64/arch/memory/region_allocator.cpp3
-rw-r--r--arch/x86_64/arch/memory/region_allocator.hpp4
-rw-r--r--arch/x86_64/arch/vga/crtc.hpp4
-rw-r--r--arch/x86_64/arch/vga/text.hpp6
-rw-r--r--arch/x86_64/arch/vga/text/attribute.hpp4
-rw-r--r--arch/x86_64/arch/vga/text/buffer.hpp4
-rw-r--r--arch/x86_64/arch/vga/text/color.hpp4
-rw-r--r--arch/x86_64/arch/vga/text/common_attributes.hpp4
-rw-r--r--arch/x86_64/arch/vga/text/device.hpp4
-rw-r--r--arch/x86_64/arch/vga/text/flags.hpp4
-rw-r--r--arch/x86_64/kapi/memory.cpp2
-rw-r--r--kapi/kapi/devices/bus.hpp2
-rw-r--r--kapi/kapi/devices/facet_registry.hpp9
-rw-r--r--kapi/kapi/devices/power.hpp2
-rw-r--r--kapi/kapi/filesystem.hpp2
-rw-r--r--kapi/kapi/memory/frame_allocator.hpp2
-rw-r--r--kernel/kapi/tracked_mutex.cpp4
-rw-r--r--kernel/kernel/devices/block_device_utils.hpp8
-rw-r--r--kernel/kernel/filesystems/devfs/inode.hpp3
-rw-r--r--kernel/kernel/filesystems/ext2/inode.hpp3
-rw-r--r--kernel/kernel/filesystems/rootfs/inode.hpp3
-rw-r--r--kernel/kernel/main.cpp84
-rw-r--r--kernel/kernel/vfs/inode.hpp3
-rw-r--r--kernel/kernel/vfs/mount.hpp5
-rw-r--r--kernel/kernel/vfs/open_file_descriptor.hpp10
-rw-r--r--kernel/kernel/vfs/open_file_table.hpp4
-rw-r--r--kernel/kernel/vfs/path.hpp2
-rw-r--r--libs/kstd/kstd/bits/basic_string.hpp16
-rw-r--r--libs/kstd/kstd/bits/format/error.hpp6
-rw-r--r--libs/kstd/kstd/bits/format/formatter.hpp6
-rw-r--r--libs/kstd/kstd/bits/mutex/lock_guard.hpp4
-rw-r--r--libs/kstd/kstd/bits/observer_ptr.hpp2
-rw-r--r--libs/kstd/kstd/bits/shared_ptr.hpp4
-rw-r--r--libs/kstd/kstd/cstring.hpp4
-rw-r--r--libs/kstd/kstd/posix.hpp4
-rw-r--r--libs/kstd/kstd/print.hpp4
-rw-r--r--libs/kstd/kstd/ranges.hpp4
-rw-r--r--libs/kstd/kstd/system_error.hpp4
-rw-r--r--libs/kstd/kstd/vector.hpp12
60 files changed, 184 insertions, 162 deletions
diff --git a/arch/x86_64/arch/boot/boot.hpp b/arch/x86_64/arch/boot/boot.hpp
index 7df61c4b..c790152c 100644
--- a/arch/x86_64/arch/boot/boot.hpp
+++ b/arch/x86_64/arch/boot/boot.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_BOOT_BOOT_HPP
-#define TEACHOS_X86_64_BOOT_BOOT_HPP
+#ifndef TEACHOS_ARCH_X86_64_BOOT_BOOT_HPP
+#define TEACHOS_ARCH_X86_64_BOOT_BOOT_HPP
#ifdef __ASSEMBLER__
// clang-format off
diff --git a/arch/x86_64/arch/boot/ld.hpp b/arch/x86_64/arch/boot/ld.hpp
index a8b83d66..f46caac6 100644
--- a/arch/x86_64/arch/boot/ld.hpp
+++ b/arch/x86_64/arch/boot/ld.hpp
@@ -12,8 +12,8 @@
//!
//! @see arch/x86_64/scripts/kernel.ld
-#ifndef TEACHOS_X86_64_BOOT_LD_HPP
-#define TEACHOS_X86_64_BOOT_LD_HPP
+#ifndef TEACHOS_ARCH_X86_64_BOOT_LD_HPP
+#define TEACHOS_ARCH_X86_64_BOOT_LD_HPP
#include <cstddef>
diff --git a/arch/x86_64/arch/bus/cpu.hpp b/arch/x86_64/arch/bus/cpu.hpp
index b027b5f5..b7b4b9b3 100644
--- a/arch/x86_64/arch/bus/cpu.hpp
+++ b/arch/x86_64/arch/bus/cpu.hpp
@@ -73,4 +73,4 @@ namespace arch::bus
} // namespace arch::bus
-#endif // TEACHOS_X86_64_BUS_CPU_HPP
+#endif
diff --git a/arch/x86_64/arch/bus/isa.hpp b/arch/x86_64/arch/bus/isa.hpp
index 44a68059..cefc48f0 100644
--- a/arch/x86_64/arch/bus/isa.hpp
+++ b/arch/x86_64/arch/bus/isa.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_BUS_ISA_HPP
-#define TEACHOS_X86_64_BUS_ISA_HPP
+#ifndef TEACHOS_ARCH_X86_64_BUS_ISA_HPP
+#define TEACHOS_ARCH_X86_64_BUS_ISA_HPP
#include <kapi/capabilities/facet_id.hpp>
#include <kapi/devices.hpp>
@@ -47,4 +47,4 @@ namespace arch::bus
} // namespace arch::bus
-#endif // TEACHOS_X86_64_BUS_ISA_HPP
+#endif
diff --git a/arch/x86_64/arch/cpu/control_register.hpp b/arch/x86_64/arch/cpu/control_register.hpp
index 127d1e24..c11ea367 100644
--- a/arch/x86_64/arch/cpu/control_register.hpp
+++ b/arch/x86_64/arch/cpu/control_register.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_CPU_CONTROL_REGISTERS_HPP
-#define TEACHOS_X86_64_CPU_CONTROL_REGISTERS_HPP
+#ifndef TEACHOS_ARCH_X86_64_CPU_CONTROL_REGISTERS_HPP
+#define TEACHOS_ARCH_X86_64_CPU_CONTROL_REGISTERS_HPP
// IWYU pragma: private, include <arch/cpu/registers.hpp>
diff --git a/arch/x86_64/arch/cpu/global_descriptor_table.hpp b/arch/x86_64/arch/cpu/global_descriptor_table.hpp
index b17c5093..e485d65c 100644
--- a/arch/x86_64/arch/cpu/global_descriptor_table.hpp
+++ b/arch/x86_64/arch/cpu/global_descriptor_table.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_GLOBAL_DESCRIPTOR_TABLE_HPP
-#define TEACHOS_X86_64_GLOBAL_DESCRIPTOR_TABLE_HPP
+#ifndef TEACHOS_ARCH_X86_64_GLOBAL_DESCRIPTOR_TABLE_HPP
+#define TEACHOS_ARCH_X86_64_GLOBAL_DESCRIPTOR_TABLE_HPP
#include <arch/cpu/segment_descriptor.hpp>
diff --git a/arch/x86_64/arch/cpu/interrupts.cpp b/arch/x86_64/arch/cpu/interrupts.cpp
index c825e8ab..2fdc4671 100644
--- a/arch/x86_64/arch/cpu/interrupts.cpp
+++ b/arch/x86_64/arch/cpu/interrupts.cpp
@@ -50,7 +50,7 @@ namespace arch::cpu
constexpr auto pic_master_irq_end = pic_master_irq_start + 8;
constexpr auto pic_slave_irq_start = pic_master_irq_end;
- constexpr auto to_exception_type(exception e)
+ constexpr auto to_exception_type(exception e) -> enum kapi::cpu::exception::type
{
switch (e)
{
@@ -75,7 +75,7 @@ namespace arch::cpu
}
}
- constexpr auto has_error_code(exception e)
+ constexpr auto has_error_code(exception e) -> bool
{
switch (e)
{
@@ -155,8 +155,7 @@ namespace arch::cpu
if (kapi::interrupts::dispatch(irq_number) == kapi::interrupts::status::unhandled)
{
- kstd::println(kstd::print_sink::stderr, "[ARCH:CPU] Unhandled interrupt {:#04x} (IRQ{})", number,
- irq_number);
+ kstd::println(kstd::print_sink::stderr, "[ARCH:CPU] Unhandled interrupt {:#04x} (IRQ{})", number, irq_number);
}
acknowledge_pic_interrupt(frame);
diff --git a/arch/x86_64/arch/cpu/interrupts.hpp b/arch/x86_64/arch/cpu/interrupts.hpp
index 6162f56a..be755cc3 100644
--- a/arch/x86_64/arch/cpu/interrupts.hpp
+++ b/arch/x86_64/arch/cpu/interrupts.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_CPU_INTERRUPTS_HPP
-#define TEACHOS_X86_64_CPU_INTERRUPTS_HPP
+#ifndef TEACHOS_ARCH_X86_64_CPU_INTERRUPTS_HPP
+#define TEACHOS_ARCH_X86_64_CPU_INTERRUPTS_HPP
#include <arch/cpu/segment_selector.hpp>
diff --git a/arch/x86_64/arch/cpu/legacy_pic.hpp b/arch/x86_64/arch/cpu/legacy_pic.hpp
index 5fcaecac..f85efd19 100644
--- a/arch/x86_64/arch/cpu/legacy_pic.hpp
+++ b/arch/x86_64/arch/cpu/legacy_pic.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_CPU_LEGACY_PIC_HPP
-#define TEACHOS_X86_64_CPU_LEGACY_PIC_HPP
+#ifndef TEACHOS_ARCH_X86_64_CPU_LEGACY_PIC_HPP
+#define TEACHOS_ARCH_X86_64_CPU_LEGACY_PIC_HPP
#include <arch/io/port_io.hpp>
diff --git a/arch/x86_64/arch/cpu/model_specific_register.hpp b/arch/x86_64/arch/cpu/model_specific_register.hpp
index 1410c343..7f854124 100644
--- a/arch/x86_64/arch/cpu/model_specific_register.hpp
+++ b/arch/x86_64/arch/cpu/model_specific_register.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_CPU_MODEL_SPECIFIC_REGISTER_HPP
-#define TEACHOS_X86_64_CPU_MODEL_SPECIFIC_REGISTER_HPP
+#ifndef TEACHOS_ARCH_X86_64_CPU_MODEL_SPECIFIC_REGISTER_HPP
+#define TEACHOS_ARCH_X86_64_CPU_MODEL_SPECIFIC_REGISTER_HPP
// IWYU pragma: private, include <x86_64/cpu/registers.hpp>
diff --git a/arch/x86_64/arch/cpu/registers.hpp b/arch/x86_64/arch/cpu/registers.hpp
index 58633f6e..afe7d1e1 100644
--- a/arch/x86_64/arch/cpu/registers.hpp
+++ b/arch/x86_64/arch/cpu/registers.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_CPU_REGISTERS_HPP
-#define TEACHOS_X86_64_CPU_REGISTERS_HPP
+#ifndef TEACHOS_ARCH_X86_64_CPU_REGISTERS_HPP
+#define TEACHOS_ARCH_X86_64_CPU_REGISTERS_HPP
#include <arch/cpu/control_register.hpp> // IWYU pragma: export
#include <arch/cpu/model_specific_register.hpp> // IWYU pragma: export
diff --git a/arch/x86_64/arch/cpu/segment_descriptor.hpp b/arch/x86_64/arch/cpu/segment_descriptor.hpp
index 9570670f..0c1ada01 100644
--- a/arch/x86_64/arch/cpu/segment_descriptor.hpp
+++ b/arch/x86_64/arch/cpu/segment_descriptor.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_SEGMENT_DESCRIPTOR_HPP
-#define TEACHOS_X86_64_SEGMENT_DESCRIPTOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_SEGMENT_DESCRIPTOR_HPP
+#define TEACHOS_ARCH_X86_64_SEGMENT_DESCRIPTOR_HPP
#include <cstdint>
diff --git a/arch/x86_64/arch/cpu/segment_selector.hpp b/arch/x86_64/arch/cpu/segment_selector.hpp
index 1a78c473..87806751 100644
--- a/arch/x86_64/arch/cpu/segment_selector.hpp
+++ b/arch/x86_64/arch/cpu/segment_selector.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_SEGMENT_SELECTOR_HPP
-#define TEACHOS_X86_64_SEGMENT_SELECTOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_SEGMENT_SELECTOR_HPP
+#define TEACHOS_ARCH_X86_64_SEGMENT_SELECTOR_HPP
#include <cstdint>
diff --git a/arch/x86_64/arch/cpu/task_state_segment.hpp b/arch/x86_64/arch/cpu/task_state_segment.hpp
index 373fb8af..ab141f4c 100644
--- a/arch/x86_64/arch/cpu/task_state_segment.hpp
+++ b/arch/x86_64/arch/cpu/task_state_segment.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_TASK_STATE_SEGMENT_HPP
-#define TEACHOS_X86_64_TASK_STATE_SEGMENT_HPP
+#ifndef TEACHOS_ARCH_X86_64_TASK_STATE_SEGMENT_HPP
+#define TEACHOS_ARCH_X86_64_TASK_STATE_SEGMENT_HPP
#include <cstdint>
diff --git a/arch/x86_64/arch/debug/qemu_output.hpp b/arch/x86_64/arch/debug/qemu_output.hpp
index 27898395..18ae84bb 100644
--- a/arch/x86_64/arch/debug/qemu_output.hpp
+++ b/arch/x86_64/arch/debug/qemu_output.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_DEBUG_QEMU_OUTPUT_HPP
-#define TEACHOS_X86_64_DEBUG_QEMU_OUTPUT_HPP
+#ifndef TEACHOS_ARCH_X86_64_DEBUG_QEMU_OUTPUT_HPP
+#define TEACHOS_ARCH_X86_64_DEBUG_QEMU_OUTPUT_HPP
#include <arch/io/port_io.hpp>
diff --git a/arch/x86_64/arch/io/port_io.hpp b/arch/x86_64/arch/io/port_io.hpp
index 475e223b..d21ef976 100644
--- a/arch/x86_64/arch/io/port_io.hpp
+++ b/arch/x86_64/arch/io/port_io.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_IO_PORT_IO_HPP
-#define TEACHOS_X86_64_IO_PORT_IO_HPP
+#ifndef TEACHOS_ARCH_X86_64_IO_PORT_IO_HPP
+#define TEACHOS_ARCH_X86_64_IO_PORT_IO_HPP
#include <array>
#include <concepts>
diff --git a/arch/x86_64/arch/memory/higher_half_mapper.hpp b/arch/x86_64/arch/memory/higher_half_mapper.hpp
index 9b02ee63..4f6574ff 100644
--- a/arch/x86_64/arch/memory/higher_half_mapper.hpp
+++ b/arch/x86_64/arch/memory/higher_half_mapper.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_HIGHER_HALF_MAPPER_HPP
-#define TEACHOS_X86_64_HIGHER_HALF_MAPPER_HPP
+#ifndef TEACHOS_ARCH_X86_64_HIGHER_HALF_MAPPER_HPP
+#define TEACHOS_ARCH_X86_64_HIGHER_HALF_MAPPER_HPP
#include <arch/memory/page_table.hpp>
diff --git a/arch/x86_64/arch/memory/kernel_mapper.hpp b/arch/x86_64/arch/memory/kernel_mapper.hpp
index adbf688f..aeb936dc 100644
--- a/arch/x86_64/arch/memory/kernel_mapper.hpp
+++ b/arch/x86_64/arch/memory/kernel_mapper.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_KERNEL_MAPPER_HPP
-#define TEACHOS_X86_64_KERNEL_MAPPER_HPP
+#ifndef TEACHOS_ARCH_X86_64_KERNEL_MAPPER_HPP
+#define TEACHOS_ARCH_X86_64_KERNEL_MAPPER_HPP
#include <kapi/memory.hpp>
diff --git a/arch/x86_64/arch/memory/mmu.hpp b/arch/x86_64/arch/memory/mmu.hpp
index 7046f7fc..9bd95b43 100644
--- a/arch/x86_64/arch/memory/mmu.hpp
+++ b/arch/x86_64/arch/memory/mmu.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_MEMORY_MMU_HPP
-#define TEACHOS_X86_64_MEMORY_MMU_HPP
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_MMU_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_MMU_HPP
#include <kapi/memory/address.hpp>
diff --git a/arch/x86_64/arch/memory/page_table.hpp b/arch/x86_64/arch/memory/page_table.hpp
index 12abacb5..0c0f1a77 100644
--- a/arch/x86_64/arch/memory/page_table.hpp
+++ b/arch/x86_64/arch/memory/page_table.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_PAGE_TABLE_HPP
-#define TEACHOS_X86_64_PAGE_TABLE_HPP
+#ifndef TEACHOS_ARCH_X86_64_PAGE_TABLE_HPP
+#define TEACHOS_ARCH_X86_64_PAGE_TABLE_HPP
#include <kapi/memory.hpp>
diff --git a/arch/x86_64/arch/memory/page_utilities.hpp b/arch/x86_64/arch/memory/page_utilities.hpp
index 068e8249..478f776d 100644
--- a/arch/x86_64/arch/memory/page_utilities.hpp
+++ b/arch/x86_64/arch/memory/page_utilities.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_PAGE_UTILITIES_HPP
-#define TEACHOS_X86_64_PAGE_UTILITIES_HPP
+#ifndef TEACHOS_ARCH_X86_64_PAGE_UTILITIES_HPP
+#define TEACHOS_ARCH_X86_64_PAGE_UTILITIES_HPP
#include <kapi/memory.hpp>
diff --git a/arch/x86_64/arch/memory/region_allocator.cpp b/arch/x86_64/arch/memory/region_allocator.cpp
index ece492f3..b78924d8 100644
--- a/arch/x86_64/arch/memory/region_allocator.cpp
+++ b/arch/x86_64/arch/memory/region_allocator.cpp
@@ -15,12 +15,13 @@ namespace arch::memory
{
namespace
{
- constexpr auto last_frame(multiboot2::memory_map::region const & region)
+ constexpr auto last_frame(multiboot2::memory_map::region const & region) -> kapi::memory::frame
{
return kapi::memory::frame::containing(kapi::memory::physical_address{region.base + region.size_in_B - 1});
}
constexpr auto falls_within(kapi::memory::frame candidate, kapi::memory::frame start, kapi::memory::frame end)
+ -> bool
{
return candidate >= start && candidate <= end;
}
diff --git a/arch/x86_64/arch/memory/region_allocator.hpp b/arch/x86_64/arch/memory/region_allocator.hpp
index 5d9da2e0..61cc1d4d 100644
--- a/arch/x86_64/arch/memory/region_allocator.hpp
+++ b/arch/x86_64/arch/memory/region_allocator.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_MEMORY_REGION_ALLOCATOR_HPP
-#define TEACHOS_X86_64_MEMORY_REGION_ALLOCATOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_MEMORY_REGION_ALLOCATOR_HPP
+#define TEACHOS_ARCH_X86_64_MEMORY_REGION_ALLOCATOR_HPP
#include <kapi/memory/address.hpp>
#include <kapi/memory/frame.hpp>
diff --git a/arch/x86_64/arch/vga/crtc.hpp b/arch/x86_64/arch/vga/crtc.hpp
index e57e675f..75469e4b 100644
--- a/arch/x86_64/arch/vga/crtc.hpp
+++ b/arch/x86_64/arch/vga/crtc.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_IO_HPP
-#define TEACHOS_X86_64_VGA_IO_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_CRTC_HPP
+#define TEACHOS_ARCH_X86_64_VGA_CRTC_HPP
#include <arch/io/port_io.hpp>
diff --git a/arch/x86_64/arch/vga/text.hpp b/arch/x86_64/arch/vga/text.hpp
index 2e73dd2d..35e57292 100644
--- a/arch/x86_64/arch/vga/text.hpp
+++ b/arch/x86_64/arch/vga/text.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_HPP
-#define TEACHOS_X86_64_VGA_TEXT_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_HPP
#include <arch/vga/text/attribute.hpp> // IWYU pragma: export
#include <arch/vga/text/color.hpp> // IWYU pragma: export
@@ -7,4 +7,4 @@
#include <arch/vga/text/device.hpp> // IWYU pragma: export
#include <arch/vga/text/flags.hpp> // IWYU pragma: export
-#endif // TEACHOS_ARCH_X86_64_VIDEO_VGA_TEXT_HPP \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/arch/x86_64/arch/vga/text/attribute.hpp b/arch/x86_64/arch/vga/text/attribute.hpp
index 29ff22b7..9e3d79af 100644
--- a/arch/x86_64/arch/vga/text/attribute.hpp
+++ b/arch/x86_64/arch/vga/text/attribute.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_ATTRIBUTE_HPP
-#define TEACHOS_X86_64_VGA_TEXT_ATTRIBUTE_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_ATTRIBUTE_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_ATTRIBUTE_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/arch/vga/text/buffer.hpp b/arch/x86_64/arch/vga/text/buffer.hpp
index 8eb66457..7827b1af 100644
--- a/arch/x86_64/arch/vga/text/buffer.hpp
+++ b/arch/x86_64/arch/vga/text/buffer.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_BUFFER_HPP
-#define TEACHOS_X86_64_VGA_TEXT_BUFFER_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_BUFFER_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_BUFFER_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/arch/vga/text/color.hpp b/arch/x86_64/arch/vga/text/color.hpp
index e0ad6dfa..75e0a5fd 100644
--- a/arch/x86_64/arch/vga/text/color.hpp
+++ b/arch/x86_64/arch/vga/text/color.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_COLOR_HPP
-#define TEACHOS_X86_64_VGA_TEXT_COLOR_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_COLOR_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_COLOR_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/arch/vga/text/common_attributes.hpp b/arch/x86_64/arch/vga/text/common_attributes.hpp
index 3d8929f4..20faa841 100644
--- a/arch/x86_64/arch/vga/text/common_attributes.hpp
+++ b/arch/x86_64/arch/vga/text/common_attributes.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_COMMON_ATTRIBUTES_HPP
-#define TEACHOS_X86_64_VGA_TEXT_COMMON_ATTRIBUTES_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_COMMON_ATTRIBUTES_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_COMMON_ATTRIBUTES_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/arch/vga/text/device.hpp b/arch/x86_64/arch/vga/text/device.hpp
index 0a0e0178..be07876b 100644
--- a/arch/x86_64/arch/vga/text/device.hpp
+++ b/arch/x86_64/arch/vga/text/device.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_DEVICE_HPP
-#define TEACHOS_X86_64_VGA_TEXT_DEVICE_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_DEVICE_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_DEVICE_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/arch/vga/text/flags.hpp b/arch/x86_64/arch/vga/text/flags.hpp
index 7a29e334..45f94e6b 100644
--- a/arch/x86_64/arch/vga/text/flags.hpp
+++ b/arch/x86_64/arch/vga/text/flags.hpp
@@ -1,5 +1,5 @@
-#ifndef TEACHOS_X86_64_VGA_TEXT_FLAGS_HPP
-#define TEACHOS_X86_64_VGA_TEXT_FLAGS_HPP
+#ifndef TEACHOS_ARCH_X86_64_VGA_TEXT_FLAGS_HPP
+#define TEACHOS_ARCH_X86_64_VGA_TEXT_FLAGS_HPP
// IWYU pragma: private, include <arch/vga/text.hpp>
diff --git a/arch/x86_64/kapi/memory.cpp b/arch/x86_64/kapi/memory.cpp
index 9cf955e5..03c5107c 100644
--- a/arch/x86_64/kapi/memory.cpp
+++ b/arch/x86_64/kapi/memory.cpp
@@ -40,7 +40,7 @@ namespace kapi::memory
auto constinit higher_half_mapper = std::optional<arch::memory::higher_half_mapper>{};
//! Instantiate a basic, memory region based, early frame allocator for remapping.
- auto collect_memory_information()
+ auto collect_memory_information() -> arch::memory::region_allocator::memory_information
{
auto memory_map = boot::bootstrap_information.mbi->maybe_memory_map();
if (!memory_map)
diff --git a/kapi/kapi/devices/bus.hpp b/kapi/kapi/devices/bus.hpp
index dc46dc3a..aaca462a 100644
--- a/kapi/kapi/devices/bus.hpp
+++ b/kapi/kapi/devices/bus.hpp
@@ -28,7 +28,7 @@ namespace kapi::devices
//! Construct a bus with the given name.
//!
//! @param name The name of the bus.
- bus(kstd::string const & name);
+ explicit bus(kstd::string const & name);
//! Construct a bus with the given name and protocol.
//!
diff --git a/kapi/kapi/devices/facet_registry.hpp b/kapi/kapi/devices/facet_registry.hpp
index 7006c026..3c405923 100644
--- a/kapi/kapi/devices/facet_registry.hpp
+++ b/kapi/kapi/devices/facet_registry.hpp
@@ -150,7 +150,7 @@ namespace kapi::devices
//! @param device The device to publish the facet for.
//! @param name A stable name for the device.
template<typename FacetType>
- auto publish(kstd::shared_ptr<device> device, kstd::string name) -> kstd::result<void>
+ [[nodiscard]] auto publish(kstd::shared_ptr<device> device, kstd::string name) -> kstd::result<void>
{
if (!device)
{
@@ -172,7 +172,8 @@ namespace kapi::devices
//! @param name A stable name for the device.
//! @param facet The implementation of the facet for the device.
template<typename FacetType>
- auto publish(kstd::shared_ptr<device> device, kstd::string name, FacetType * facet) -> kstd::result<void>
+ [[nodiscard]] auto publish(kstd::shared_ptr<device> device, kstd::string name, FacetType * facet)
+ -> kstd::result<void>
{
return do_publish(device, std::move(name), FacetType::id, facet);
}
@@ -254,8 +255,8 @@ namespace kapi::devices
//! @param name A stable name for the device.
//! @param id The id of the facet to be published for the device.
//! @param facet The facet of the device.
- auto do_publish(kstd::shared_ptr<device> device, kstd::string name, kapi::capabilities::facet_id id, void * facet)
- -> kstd::result<void>;
+ [[nodiscard]] auto do_publish(kstd::shared_ptr<device> device, kstd::string name, kapi::capabilities::facet_id id,
+ void * facet) -> kstd::result<void>;
//! Notify all subscribed observers about a new facet having been published for a device.
//!
diff --git a/kapi/kapi/devices/power.hpp b/kapi/kapi/devices/power.hpp
index 44837a65..a87ebc78 100644
--- a/kapi/kapi/devices/power.hpp
+++ b/kapi/kapi/devices/power.hpp
@@ -21,7 +21,7 @@ namespace kapi::devices
//!
//! @param root The root of the tree to suspend.
//! @return nothing on success, the first error to occur otherwise.
- auto suspend_tree(bus & root) -> kstd::result<void>;
+ [[nodiscard]] auto suspend_tree(bus & root) -> kstd::result<void>;
//! Resume a device (sub-)tree rooted in a given bus.
//!
diff --git a/kapi/kapi/filesystem.hpp b/kapi/kapi/filesystem.hpp
index 04630006..ab8a8f4a 100644
--- a/kapi/kapi/filesystem.hpp
+++ b/kapi/kapi/filesystem.hpp
@@ -119,4 +119,4 @@ namespace kapi::filesystem
//! @}
} // namespace kapi::filesystem
-#endif // TEACHOS_KAPI_FILESYSTEM_HPP \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/kapi/kapi/memory/frame_allocator.hpp b/kapi/kapi/memory/frame_allocator.hpp
index 783bd3cb..12f56c2d 100644
--- a/kapi/kapi/memory/frame_allocator.hpp
+++ b/kapi/kapi/memory/frame_allocator.hpp
@@ -68,4 +68,4 @@ namespace kapi::memory
} // namespace kapi::memory
-#endif // TEACHOS_KAPI_MEMORY_FRAME_ALLOCATOR_HPP \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/kernel/kapi/tracked_mutex.cpp b/kernel/kapi/tracked_mutex.cpp
index b1796adc..1694d814 100644
--- a/kernel/kapi/tracked_mutex.cpp
+++ b/kernel/kapi/tracked_mutex.cpp
@@ -17,7 +17,7 @@ namespace kapi
{
if (expected == self)
{
- system::panic("[OS] CPU {} tried to reacquire a mutex it already holds!", self);
+ system::panic("[OS:LCK] CPU {} tried to reacquire a mutex it already holds!", self);
}
expected = kapi::cpu::invalid_id;
}
@@ -43,7 +43,7 @@ namespace kapi
if (!m_owner.compare_exchange_strong(expected, kapi::cpu::invalid_id, std::memory_order::release))
{
- system::panic("[OS] CPU {} released a mutex it did not hold!", self);
+ system::panic("[OS:LCK] CPU {} released a mutex it did not hold!", self);
}
}
diff --git a/kernel/kernel/devices/block_device_utils.hpp b/kernel/kernel/devices/block_device_utils.hpp
index 1fb7cd9d..d6a6724c 100644
--- a/kernel/kernel/devices/block_device_utils.hpp
+++ b/kernel/kernel/devices/block_device_utils.hpp
@@ -30,8 +30,8 @@ namespace kernel::devices::block_device_utils
//! @param buffer The buffer to read data into.
//! @param offset The offset on the block device to start reading from.
//! @return The number of bytes actually read, which may be less than the requested size.
- auto read(kapi::filesystem::block_special_file & device, std::span<std::byte> buffer, kstd::bytes offset)
- -> kstd::result<kstd::bytes>;
+ [[nodiscard]] auto read(kapi::filesystem::block_special_file & device, std::span<std::byte> buffer,
+ kstd::bytes offset) -> kstd::result<kstd::bytes>;
//! @brief Write data from a buffer to a given block device.
//!
@@ -39,8 +39,8 @@ namespace kernel::devices::block_device_utils
//! @param buffer The buffer to write data from.
//! @param offset The offset on the block device to start writing to.
//! @return The number of bytes actually written, which may be less than the requested size.
- auto write(kapi::filesystem::block_special_file & device, std::span<std::byte const> buffer, kstd::bytes offset)
- -> kstd::result<kstd::bytes>;
+ [[nodiscard]] auto write(kapi::filesystem::block_special_file & device, std::span<std::byte const> buffer,
+ kstd::bytes offset) -> kstd::result<kstd::bytes>;
} // namespace kernel::devices::block_device_utils
#endif \ No newline at end of file
diff --git a/kernel/kernel/filesystems/devfs/inode.hpp b/kernel/kernel/filesystems/devfs/inode.hpp
index c19671df..9a01d777 100644
--- a/kernel/kernel/filesystems/devfs/inode.hpp
+++ b/kernel/kernel/filesystems/devfs/inode.hpp
@@ -22,7 +22,8 @@ namespace kernel::filesystems::devfs
[[nodiscard]] auto read(std::span<std::byte> buffer, kstd::bytes offset) const
-> kstd::result<kstd::bytes> override;
- auto write(std::span<std::byte const> buffer, kstd::bytes offset) -> kstd::result<kstd::bytes> override;
+ [[nodiscard]] auto write(std::span<std::byte const> buffer, kstd::bytes offset)
+ -> kstd::result<kstd::bytes> override;
[[nodiscard]] auto is_directory() const -> bool override;
diff --git a/kernel/kernel/filesystems/ext2/inode.hpp b/kernel/kernel/filesystems/ext2/inode.hpp
index 9a3561f7..206d2a48 100644
--- a/kernel/kernel/filesystems/ext2/inode.hpp
+++ b/kernel/kernel/filesystems/ext2/inode.hpp
@@ -64,7 +64,8 @@ namespace kernel::filesystems::ext2
[[nodiscard]] auto read(std::span<std::byte> buffer, kstd::bytes offset) const
-> kstd::result<kstd::bytes> override;
- auto write(std::span<std::byte const> buffer, kstd::bytes offset) -> kstd::result<kstd::bytes> override;
+ [[nodiscard]] auto write(std::span<std::byte const> buffer, kstd::bytes offset)
+ -> kstd::result<kstd::bytes> override;
//! @}
diff --git a/kernel/kernel/filesystems/rootfs/inode.hpp b/kernel/kernel/filesystems/rootfs/inode.hpp
index 10e6a4e1..2bd5863f 100644
--- a/kernel/kernel/filesystems/rootfs/inode.hpp
+++ b/kernel/kernel/filesystems/rootfs/inode.hpp
@@ -23,7 +23,8 @@ namespace kernel::filesystems::rootfs
[[nodiscard]] auto read(std::span<std::byte> buffer, kstd::bytes offset) const
-> kstd::result<kstd::bytes> override;
- auto write(std::span<std::byte const> buffer, kstd::bytes offset) -> kstd::result<kstd::bytes> override;
+ [[nodiscard]] auto write(std::span<std::byte const> buffer, kstd::bytes offset)
+ -> kstd::result<kstd::bytes> override;
[[nodiscard]] auto is_directory() const -> bool override;
diff --git a/kernel/kernel/main.cpp b/kernel/kernel/main.cpp
index ac2e18b8..bc192950 100644
--- a/kernel/kernel/main.cpp
+++ b/kernel/kernel/main.cpp
@@ -28,84 +28,82 @@ using namespace kstd::units_literals;
auto run_demo() -> void
{
// 1) open a file
- kstd::println("attempting to open /entrance/tickets.txt");
+ kstd::println("trying to open /entrance/tickets.txt");
auto fd_1 = kapi::filesystem::open("/entrance/tickets.txt");
if (!fd_1)
{
- kapi::system::panic("[demo failed]");
+ kapi::system::panic("[OS:DEM] failed to open '/entrance/tickets.txt'", fd_1.error());
}
else
{
- kstd::println("--> successfully opened /entrance/tickets.txt with file descriptor {}", fd_1.value());
+ kstd::println("[OS:DEM] opened /entrance/tickets.txt with file descriptor {}", fd_1.value());
}
// 2) read from the file
kstd::vector<std::byte> buffer_1{10};
auto bytes_read = *kapi::filesystem::read(fd_1.value(), buffer_1);
auto buffer_as_str = std::string_view{reinterpret_cast<char *>(buffer_1.data()), bytes_read};
- kstd::println("--> read {} from /entrance/tickets.txt: {}", bytes_read, buffer_as_str);
- kstd::println("");
+ kstd::println("[OS:DEM] read {} from /entrance/tickets.txt: {}", bytes_read, buffer_as_str);
// 3) show that /entrance/information/info_1.txt is not accessible before mounting
- kstd::println("attempting to open /entrance/information/info_1.txt before mounting");
+ kstd::println("[OS:DEM] trying to open /entrance/information/info_1.txt before mounting");
auto fd_before_mount = kapi::filesystem::open("/entrance/information/info_1.txt");
if (!fd_before_mount && fd_before_mount.error() == kstd::errc::no_such_file_or_directory)
{
- kstd::println("--> as expected the file could not be opened before mounting");
+ kstd::println("[OS:DEM] file could not be opened before mounting");
}
// 4) mount a new filesystem on top of /entrance
- kstd::println("mount /dev/ram1 to /entrance");
- if (kapi::filesystem::mount("/dev/ram1", "/entrance"))
+ kstd::println("[OS:DEM] mount /dev/ram1 to /entrance");
+ if (auto result = kapi::filesystem::mount("/dev/ram1", "/entrance"))
{
- kstd::println("--> successfully mounted /dev/ram1 to /entrance");
+ kstd::println("[OS:DEM] mounted /dev/ram1 to /entrance");
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to mount /dev/ram1 on /entrance", result.error());
}
- kstd::println("");
// 5) open a file from the new filesystem
- kstd::println("attempting to open /entrance/information/info_1.txt");
+ kstd::println("[OS:DEM] trying to open /entrance/information/info_1.txt");
auto fd_2 = kapi::filesystem::open("/entrance/information/info_1.txt");
if (fd_2)
{
- kstd::println("--> successfully opened /entrance/information/info_1.txt with file descriptor {}", fd_2.value());
+ kstd::println("[OS:DEM] opened /entrance/information/info_1.txt with file descriptor {}", fd_2.value());
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to open /entrance/information/info_1.txt", fd_2.error());
}
// 6) read from the new file
kstd::vector<std::byte> buffer_2{10};
bytes_read = *kapi::filesystem::read(fd_2.value(), buffer_2);
buffer_as_str = std::string_view{reinterpret_cast<char *>(buffer_2.data()), static_cast<std::size_t>(bytes_read)};
- kstd::println("--> read {} from /entrance/information/info_1.txt: {}", bytes_read, buffer_as_str);
+ kstd::println("[OS:DEM] read {} from /entrance/information/info_1.txt: {}", bytes_read, buffer_as_str);
// 7) open device as file
- kstd::println("attempting to open /dev/ram2 as a file");
+ kstd::println("[OS:DEM] trying to open /dev/ram2 as a file");
auto fd_3 = kapi::filesystem::open("/dev/ram2");
if (fd_3)
{
- kstd::println("--> successfully opened /dev/ram2 as a file with file descriptor {}", fd_3.value());
+ kstd::println("[OS:DEM] opened /dev/ram2 as a file with file descriptor {}", fd_3.value());
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to open /dev/ram2 as a file", fd_3.error());
}
// 8) read from the device file
kstd::vector<std::byte> buffer_3{2};
bytes_read = *kapi::filesystem::read(fd_3.value(), buffer_3);
- kstd::println("--> read {} from /dev/ram2: {::#04x}", bytes_read, buffer_3);
+ kstd::println("[OS:DEM] read {} from /dev/ram2: {::#04x}", bytes_read, buffer_3);
// 9) write to the device file
auto const default_buffer_value = std::byte{0xAA};
kstd::vector<std::byte> write_buffer{default_buffer_value, default_buffer_value};
auto bytes_written = *kapi::filesystem::write(fd_3.value(), write_buffer);
- kstd::println("--> wrote {} to /dev/ram2: {::#04x}", bytes_written, write_buffer);
+ kstd::println("[OS:DEM] wrote {} to /dev/ram2: {::#04x}", bytes_written, write_buffer);
// 10) do memory dump to show that the write to the device file had an effect
@@ -119,25 +117,25 @@ auto run_demo() -> void
if (!creation_result)
{
- kapi::system::panic("demo failed", creation_result.error());
+ kapi::system::panic("[OS:DEM] failed to create /test_files/test_file.txt", creation_result.error());
}
// 13) write to the new file
auto fd_4 = kapi::filesystem::open("/test_files/test_file.txt");
if (fd_4)
{
- kstd::println("--> successfully opened /test_files/test_file.txt as a file with file descriptor {}", fd_4.value());
+ kstd::println("[OS:DEM] opened /test_files/test_file.txt as a file with file descriptor {}", fd_4.value());
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to open /test_files/test_file.txt", fd_4.error());
}
kstd::vector<std::byte> test_write_buffer{
std::byte{'H'}, std::byte{'e'}, std::byte{'l'}, std::byte{'l'}, std::byte{'o'}, std::byte{' '}, std::byte{'T'},
std::byte{'e'}, std::byte{'a'}, std::byte{'c'}, std::byte{'h'}, std::byte{'O'}, std::byte{'S'}};
bytes_written = *kapi::filesystem::write(*fd_4, test_write_buffer);
- kstd::println("--> wrote {} to /test_files/test_file.txt: {::#04x}", bytes_written, test_write_buffer);
+ kstd::println("[OS:DEM] wrote {} to /test_files/test_file.txt: {::#04x}", bytes_written, test_write_buffer);
// 14) dmp the module after create new directory and file
// -exec monitor memsave 0xffffffff8025b000 0xA00000 dump_after.bin
@@ -146,75 +144,75 @@ auto run_demo() -> void
auto fd_5 = kapi::filesystem::open("/dev/null");
if (fd_5)
{
- kstd::println("--> successfully opened /dev/null as a file with file descriptor {}", fd_5.value());
+ kstd::println("[OS:DEM] opened /dev/null as a file with file descriptor {}", fd_5.value());
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to open /dev/null", fd_5.error());
}
auto buffer_4 = kstd::vector<std::byte>{10, std::byte{0xff}};
if (auto read = kapi::filesystem::read(fd_5.value(), buffer_4); !read)
{
- kapi::system::panic("demo failed: {}", read.error());
+ kapi::system::panic("[OS:DEM] failed to read from /dev/null", read.error());
}
else
{
bytes_read = *read;
}
- kstd::println("--> read {} from /dev/null", bytes_read);
+ kstd::println("[OS:DEM] read {} from /dev/null", bytes_read);
if (auto written = kapi::filesystem::write(fd_5.value(), buffer_4); !written)
{
- kapi::system::panic("demo failed: {}", written.error());
+ kapi::system::panic("[OS:DEM] failed to write to /dev/null", written.error());
}
else
{
bytes_written = *written;
}
- kstd::println("--> wrote {} to /dev/null", bytes_written);
+ kstd::println("[OS:DEM] wrote {} to /dev/null", bytes_written);
// 16) read from /dev/null
auto fd_6 = kapi::filesystem::open("/dev/zero");
if (fd_6)
{
- kstd::println("--> successfully opened /dev/zero as a file with file descriptor {}", fd_6.value());
+ kstd::println("[OS:DEM] opened /dev/zero as a file with file descriptor {}", fd_6.value());
}
else
{
- kapi::system::panic("demo failed");
+ kapi::system::panic("[OS:DEM] failed to open /dev/zero", fd_6.error());
}
auto buffer_5 = kstd::vector<std::byte>{10, std::byte{0xff}};
if (auto read = kapi::filesystem::read(fd_6.value(), buffer_5); !read)
{
- kapi::system::panic("demo failed: {}", read.error());
+ kapi::system::panic("[OS:DEM] failed to read from /dev/zero", read.error());
}
else
{
bytes_read = *read;
}
- kstd::println("--> read {} from /dev/zero: {::#04x}", bytes_read, buffer_5);
+ kstd::println("[OS:DEM] read {} from /dev/zero: {::#04x}", bytes_read, buffer_5);
if (auto written = kapi::filesystem::write(fd_6.value(), buffer_5); !written)
{
- kapi::system::panic("demo failed: {}", written.error());
+ kapi::system::panic("[OS:DEM] failed to write to /dev/zero", written.error());
}
else
{
bytes_written = *written;
}
- kstd::println("--> wrote {} to /dev/zero", bytes_written);
+ kstd::println("[OS:DEM] wrote {} to /dev/zero", bytes_written);
auto ls = [](std::string_view path) {
auto fd = kapi::filesystem::open(path);
if (fd)
{
- kstd::println("--> ls '{}'", path);
+ kstd::println("[OS:DEM] ls '{}'", path);
}
else
{
- kstd::println(kstd::print_sink::stderr, "!!> ls '{}': {}", path, fd.error());
+ kstd::println(kstd::print_sink::stderr, "[OS:DEM] ls '{}': {}", path, fd.error());
return;
}
@@ -232,7 +230,7 @@ auto run_demo() -> void
}
else
{
- kstd::println(kstd::print_sink::stderr, "!!> ls '{}': {}", path, stat.error());
+ kstd::println(kstd::print_sink::stderr, "[OS:DEM] ls '{}': {}", path, stat.error());
}
}
}
@@ -246,12 +244,12 @@ auto run_demo() -> void
}
else
{
- kstd::println(kstd::print_sink::stderr, "!!> ls '{}': {}", path, stat.error());
+ kstd::println(kstd::print_sink::stderr, "[OS:DEM] ls '{}': {}", path, stat.error());
}
}
else
{
- kstd::println(kstd::print_sink::stderr, "!!> ls '{}': {}", path, read.error());
+ kstd::println(kstd::print_sink::stderr, "[OS:DEM] ls '{}': {}", path, read.error());
return;
}
};
@@ -316,5 +314,5 @@ auto main() -> int
// TODO BA-FS26 remove demo code?
run_demo();
- kapi::system::panic("Returning from kernel main!");
+ kapi::system::panic("[OS] Returning from kernel main!");
}
diff --git a/kernel/kernel/vfs/inode.hpp b/kernel/kernel/vfs/inode.hpp
index 63e73315..37fed901 100644
--- a/kernel/kernel/vfs/inode.hpp
+++ b/kernel/kernel/vfs/inode.hpp
@@ -55,7 +55,8 @@ namespace kernel::vfs
//! @param buffer Source buffer.
//! @param offset Write offset in bytes.
//! @return The number of bytes written on success, an error otherwise.
- virtual auto write(std::span<std::byte const> buffer, kstd::bytes offset) -> kstd::result<kstd::bytes> = 0;
+ [[nodiscard]] virtual auto write(std::span<std::byte const> buffer, kstd::bytes offset)
+ -> kstd::result<kstd::bytes> = 0;
//! @}
diff --git a/kernel/kernel/vfs/mount.hpp b/kernel/kernel/vfs/mount.hpp
index dc49212c..4b303297 100644
--- a/kernel/kernel/vfs/mount.hpp
+++ b/kernel/kernel/vfs/mount.hpp
@@ -43,8 +43,9 @@ namespace kernel::vfs
//! @param parent_mount The parent mount which contains the mount_dentry.
//! @param source_mount The mount that the filesystem originates from.
//! @param backing_inode The backing inode for the filesystem, if any.
- auto static create(dentry_ptr const & mount_dentry, filesystem_ptr const & fs, mount_ptr const & parent_mount,
- mount_ptr const & source_mount, inode_ptr const & backing_inode) -> kstd::result<mount_ptr>;
+ [[nodiscard]] auto static create(dentry_ptr const & mount_dentry, filesystem_ptr const & fs,
+ mount_ptr const & parent_mount, mount_ptr const & source_mount,
+ inode_ptr const & backing_inode) -> kstd::result<mount_ptr>;
//! Get the directory entry where the filesystem is mounted.
[[nodiscard]] auto mount_dentry() const -> dentry_ptr const &;
diff --git a/kernel/kernel/vfs/open_file_descriptor.hpp b/kernel/kernel/vfs/open_file_descriptor.hpp
index 587105b8..5cac23e8 100644
--- a/kernel/kernel/vfs/open_file_descriptor.hpp
+++ b/kernel/kernel/vfs/open_file_descriptor.hpp
@@ -32,26 +32,28 @@ namespace kernel::vfs
//!
//! @param buffer The buffer to read data into.
//! @return The number of bytes read on success, an error otherwise.
- virtual auto read(std::span<std::byte> buffer) -> kstd::result<kstd::bytes>;
+ [[nodiscard]] virtual auto read(std::span<std::byte> buffer) -> kstd::result<kstd::bytes>;
//! Write data to the open file descriptor from a buffer.
//!
//! @param buffer The buffer to write data from.
//! @return The number of bytes written on success, an error otherwise.
- virtual auto write(std::span<std::byte const> buffer) -> kstd::result<kstd::bytes>;
+ [[nodiscard]] virtual auto write(std::span<std::byte const> buffer) -> kstd::result<kstd::bytes>;
//! Move the read/write offset of the file.
//!
//! @param offset The offset to apply relative to the given origin.
//! @param origin The origin of the offset.
//! @return the new offset on success, an error otherwise.
- virtual auto seek(kstd::offset offset, kapi::filesystem::seek_origin origin) -> kstd::result<kstd::bytes>;
+ [[nodiscard]] virtual auto seek(kstd::offset offset, kapi::filesystem::seek_origin origin)
+ -> kstd::result<kstd::bytes>;
//! Read directory entries from the file.
//!
//! @param entries A buffer to read the entries into.
//! @return The number of read entries on success, an error otherwise.
- virtual auto read_directory(std::span<kapi::filesystem::directory_entry> entries) -> kstd::result<std::size_t>;
+ [[nodiscard]] virtual auto read_directory(std::span<kapi::filesystem::directory_entry> entries)
+ -> kstd::result<std::size_t>;
//! Get a reference to the directory entry associated with this open file descriptor.
//!
diff --git a/kernel/kernel/vfs/open_file_table.hpp b/kernel/kernel/vfs/open_file_table.hpp
index 8d6a2341..e7e57f6b 100644
--- a/kernel/kernel/vfs/open_file_table.hpp
+++ b/kernel/kernel/vfs/open_file_table.hpp
@@ -33,7 +33,7 @@ namespace kernel::vfs
//!
//! @param fd The file descriptor to add.
//! @return The file descriptor index assigned to the file on success, an error otherwise.
- auto add_file(kstd::shared_ptr<open_file_descriptor> const & fd) -> kstd::result<std::size_t>;
+ [[nodiscard]] auto add_file(kstd::shared_ptr<open_file_descriptor> const & fd) -> kstd::result<std::size_t>;
//! Get a file from the open file table.
//!
@@ -45,7 +45,7 @@ namespace kernel::vfs
//!
//! @param fd The file descriptor index to remove.
//! @return Nothin on success, an error otherwise.
- auto remove_file(std::size_t fd) -> kstd::result<void>;
+ [[nodiscard]] auto remove_file(std::size_t fd) -> kstd::result<void>;
private:
open_file_table() = default;
diff --git a/kernel/kernel/vfs/path.hpp b/kernel/kernel/vfs/path.hpp
index e3dbe8d5..38cf2967 100644
--- a/kernel/kernel/vfs/path.hpp
+++ b/kernel/kernel/vfs/path.hpp
@@ -94,4 +94,4 @@ namespace kernel::vfs::path
} // namespace kernel::vfs::path
-#endif // TEACHOS_KERNEL_FILESYSTEM_PATH_HPP \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/libs/kstd/kstd/bits/basic_string.hpp b/libs/kstd/kstd/bits/basic_string.hpp
index 1f8b60af..a2dd7f15 100644
--- a/libs/kstd/kstd/bits/basic_string.hpp
+++ b/libs/kstd/kstd/bits/basic_string.hpp
@@ -8,7 +8,6 @@
#include <algorithm>
#include <array>
-#include <compare>
#include <cstddef>
#include <functional>
#include <initializer_list>
@@ -1329,23 +1328,27 @@ namespace kstd
}
[[nodiscard]] constexpr friend auto operator<=>(basic_string const & lhs, basic_string const & rhs) noexcept
+ -> traits_type::comparison_category
{
return std::lexicographical_compare_three_way(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs), std::cend(rhs));
}
[[nodiscard]] constexpr friend auto
operator<=>(basic_string const & lhs, std::basic_string_view<value_type, traits_type> const & rhs) noexcept
+ -> traits_type::comparison_category
{
return std::lexicographical_compare_three_way(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs), std::cend(rhs));
}
[[nodiscard]] constexpr friend auto operator<=>(std::basic_string_view<value_type, traits_type> const & lhs,
- basic_string const & rhs) noexcept -> std::strong_ordering
+ basic_string const & rhs) noexcept
+ -> traits_type::comparison_category
{
return std::lexicographical_compare_three_way(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs), std::cend(rhs));
}
[[nodiscard]] constexpr friend auto operator<=>(basic_string const & lhs, const_pointer rhs) noexcept
+ -> traits_type::comparison_category
{
if (rhs == nullptr)
{
@@ -1356,6 +1359,7 @@ namespace kstd
}
[[nodiscard]] constexpr friend auto operator<=>(const_pointer lhs, basic_string const & rhs) noexcept
+ -> traits_type::comparison_category
{
if (rhs == nullptr)
{
@@ -1443,7 +1447,7 @@ namespace kstd
}
[[nodiscard]] constexpr auto static do_compare(std::basic_string_view<value_type, traits_type> lhs,
- std::basic_string_view<value_type, traits_type> rhs) noexcept
+ std::basic_string_view<value_type, traits_type> rhs) noexcept -> int
{
// clang-tidy is not smart enough to see that whe are, in essence, passing the correct length.
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
@@ -1466,7 +1470,7 @@ namespace kstd
//! Copy elements from a range described by an input iterator pair.
//!
//! @param first An iterator pointing to the first element to copy.
- //! @param last An iterator pointing beyond the last elemento copy.
+ //! @param last An iterator pointing beyond the last element to copy.
template<typename InputIterator, typename Sentinel>
requires std::input_iterator<std::remove_cvref_t<InputIterator>>
constexpr auto forward_from(InputIterator && first, Sentinel last) -> void
@@ -1496,7 +1500,7 @@ namespace kstd
//! Copy elements from a range described by a forward iterator pair.
//!
//! @param first An iterator pointing to the first element to copy.
- //! @param last An iterator pointing beyond the last elemento copy.
+ //! @param last An iterator pointing beyond the last element to copy.
template<typename ForwardIterator, typename Sentinel>
requires std::forward_iterator<std::remove_cvref_t<ForwardIterator>>
constexpr auto forward_from(ForwardIterator && first, Sentinel last) -> void
@@ -1551,7 +1555,7 @@ namespace kstd
//! Release the current buffer of this string.
//!
//! This function can be called even if this string is currently in tis SSO state.
- [[nodiscard]] constexpr auto release_buffer()
+ constexpr auto release_buffer() -> void
{
if (!in_sso_state())
{
diff --git a/libs/kstd/kstd/bits/format/error.hpp b/libs/kstd/kstd/bits/format/error.hpp
index 30cb7523..1442d2be 100644
--- a/libs/kstd/kstd/bits/format/error.hpp
+++ b/libs/kstd/kstd/bits/format/error.hpp
@@ -3,14 +3,16 @@
#include <kstd/os/error.hpp>
+#include <string_view>
+
namespace kstd::bits::format
{
- constexpr auto error(char const * message) -> void
+ constexpr auto error(std::string_view message) -> void
{
if consteval
{
- extern void compile_time_format_error_triggered(char const *);
+ extern auto compile_time_format_error_triggered(std::string_view)->void;
compile_time_format_error_triggered(message);
}
else
diff --git a/libs/kstd/kstd/bits/format/formatter.hpp b/libs/kstd/kstd/bits/format/formatter.hpp
index c26907b2..5f1d89c6 100644
--- a/libs/kstd/kstd/bits/format/formatter.hpp
+++ b/libs/kstd/kstd/bits/format/formatter.hpp
@@ -30,13 +30,13 @@ namespace kstd
m_separator = sep;
}
- constexpr auto set_brackets(std::string_view opening, std::string_view closing)
+ constexpr auto set_brackets(std::string_view opening, std::string_view closing) -> void
{
m_prefix = opening;
m_suffix = closing;
}
- constexpr auto parse(format_parse_context & context)
+ constexpr auto parse(format_parse_context & context) -> format_parse_context::iterator
{
auto it = context.begin();
auto const end = context.end();
@@ -63,7 +63,7 @@ namespace kstd
}
template<typename Range>
- auto format(Range const & range, format_context & context)
+ auto format(Range const & range, format_context & context) -> void
{
context.push(m_prefix);
diff --git a/libs/kstd/kstd/bits/mutex/lock_guard.hpp b/libs/kstd/kstd/bits/mutex/lock_guard.hpp
index b4762c36..40221b0f 100644
--- a/libs/kstd/kstd/bits/mutex/lock_guard.hpp
+++ b/libs/kstd/kstd/bits/mutex/lock_guard.hpp
@@ -1,5 +1,5 @@
-#ifndef KSTD_BITS_MUTEX_LOCK_GUARD
-#define KSTD_BITS_MUTEX_LOCK_GUARD
+#ifndef KSTD_BITS_MUTEX_LOCK_GUARD_HPP
+#define KSTD_BITS_MUTEX_LOCK_GUARD_HPP
// IWYU pragma: private, include <kstd/mutex.hpp>
diff --git a/libs/kstd/kstd/bits/observer_ptr.hpp b/libs/kstd/kstd/bits/observer_ptr.hpp
index 260d9d33..d53ab5a0 100644
--- a/libs/kstd/kstd/bits/observer_ptr.hpp
+++ b/libs/kstd/kstd/bits/observer_ptr.hpp
@@ -24,6 +24,8 @@ namespace kstd
constexpr observer_ptr() noexcept = default;
//! Construct an empty observer pointer from a null pointer.
+ //!
+ //! @note this constructor is deliberately not explicit, as required by the standard.
constexpr observer_ptr(std::nullptr_t) noexcept {}
//! Construct an observer pointer from a raw pointer.
diff --git a/libs/kstd/kstd/bits/shared_ptr.hpp b/libs/kstd/kstd/bits/shared_ptr.hpp
index 1c1ae08c..378030dc 100644
--- a/libs/kstd/kstd/bits/shared_ptr.hpp
+++ b/libs/kstd/kstd/bits/shared_ptr.hpp
@@ -227,6 +227,8 @@ namespace kstd
}
//! Construct a weak pointer which shares ownership of the object managed by other.
+ //!
+ //! @note this constructor is deliberately not explicit, as required by the standard.
template<typename Y>
requires bits::is_shared_pointer_ctor_compatible<Y *, T *>::value
constexpr weak_ptr(weak_ptr<Y> const & other) noexcept
@@ -452,6 +454,8 @@ namespace kstd
{}
//! @brief Construct an empty shared pointer.
+ //!
+ //! @note this constructor is deliberately not explicit, as required by the standard.
constexpr shared_ptr(std::nullptr_t) noexcept
: m_pointer(nullptr)
, m_control_block(nullptr)
diff --git a/libs/kstd/kstd/cstring.hpp b/libs/kstd/kstd/cstring.hpp
index 9678f77f..bc83181b 100644
--- a/libs/kstd/kstd/cstring.hpp
+++ b/libs/kstd/kstd/cstring.hpp
@@ -1,5 +1,5 @@
-#ifndef KSTD_CSTRING
-#define KSTD_CSTRING
+#ifndef KSTD_CSTRING_HPP
+#define KSTD_CSTRING_HPP
#include <cstddef>
diff --git a/libs/kstd/kstd/posix.hpp b/libs/kstd/kstd/posix.hpp
index 12bd5ec0..fc66a4b0 100644
--- a/libs/kstd/kstd/posix.hpp
+++ b/libs/kstd/kstd/posix.hpp
@@ -1,5 +1,5 @@
-#ifndef KSTD_CERRNO_HPP
-#define KSTD_CERRNO_HPP
+#ifndef KSTD_POSIX_HPP
+#define KSTD_POSIX_HPP
namespace kstd::posix
{
diff --git a/libs/kstd/kstd/print.hpp b/libs/kstd/kstd/print.hpp
index 0d37efbe..10adcf43 100644
--- a/libs/kstd/kstd/print.hpp
+++ b/libs/kstd/kstd/print.hpp
@@ -1,5 +1,5 @@
-#ifndef KSTD_PRINT
-#define KSTD_PRINT
+#ifndef KSTD_PRINT_HPP
+#define KSTD_PRINT_HPP
#include <kstd/bits/print_sink.hpp> // IWYU pragma: export
#include <kstd/format.hpp>
diff --git a/libs/kstd/kstd/ranges.hpp b/libs/kstd/kstd/ranges.hpp
index 78c3adbf..64b73968 100644
--- a/libs/kstd/kstd/ranges.hpp
+++ b/libs/kstd/kstd/ranges.hpp
@@ -1,5 +1,5 @@
-#ifndef KSTD_RANGES
-#define KSTD_RANGES
+#ifndef KSTD_RANGES_HPP
+#define KSTD_RANGES_HPP
#include <ranges> // IWYU pragma: export
diff --git a/libs/kstd/kstd/system_error.hpp b/libs/kstd/kstd/system_error.hpp
index d6e78ffe..3b8e628a 100644
--- a/libs/kstd/kstd/system_error.hpp
+++ b/libs/kstd/kstd/system_error.hpp
@@ -152,6 +152,8 @@ namespace kstd
//! Construct an error condition from an error condition enumeration value.
//!
+ //! @note this constructor is deliberately not explicit, as required by the standard.
+ //!
//! @tparam Enum The error condition enumeration type.
//! @param value The error condition enumeration value.
template<error_condition_enum Enum>
@@ -237,6 +239,8 @@ namespace kstd
//! Construct an error code from an error code enumeration value.
//!
+ //! @note this constructor is deliberately not explicit, as required by the standard.
+ //!
//! @tparam Enum The error code enumeration type.
//! @param value The error code enumeration value.
template<error_code_enum Enum>
diff --git a/libs/kstd/kstd/vector.hpp b/libs/kstd/kstd/vector.hpp
index 5a56381b..fc3020c7 100644
--- a/libs/kstd/kstd/vector.hpp
+++ b/libs/kstd/kstd/vector.hpp
@@ -898,7 +898,7 @@ namespace kstd
}
//! Release the memory of this vector.
- constexpr auto deallocate()
+ constexpr auto deallocate() -> void
{
if (m_data)
{
@@ -914,7 +914,7 @@ namespace kstd
//! @param position The position to insert the element at.
//! @param value The value to insert.
template<typename U>
- constexpr auto do_insert(const_iterator position, U && value)
+ constexpr auto do_insert(const_iterator position, U && value) -> iterator
{
auto prefix_size = std::ranges::distance(cbegin(), position);
if (position == cend())
@@ -969,7 +969,7 @@ namespace kstd
//! @param to The start of the target range inside this vector.
//! @param count The number of elements to copy
template<typename SourceIterator>
- constexpr auto uninitialized_copy_with_allocator(SourceIterator from, iterator to, size_type count)
+ constexpr auto uninitialized_copy_with_allocator(SourceIterator from, iterator to, size_type count) -> void
{
for (auto i = 0uz; i < count; ++i)
{
@@ -983,7 +983,7 @@ namespace kstd
//! @param to The start of the target range inside this vector.
//! @param count The number of elements to copy
template<typename SourceIterator>
- constexpr auto uninitialized_move_with_allocator(SourceIterator from, iterator to, size_type count)
+ constexpr auto uninitialized_move_with_allocator(SourceIterator from, iterator to, size_type count) -> void
{
for (auto i = 0uz; i < count; ++i)
{
@@ -1004,7 +1004,7 @@ namespace kstd
}
//! Shift all elements, starting the given position, one position back inside the vector.
- constexpr auto shift_back(iterator starting_at)
+ constexpr auto shift_back(iterator starting_at) -> void
{
std::allocator_traits<allocator_type>::construct(m_allocator, end(), std::move(*(end() - 1)));
std::ranges::move_backward(starting_at, end() - 1, end());
@@ -1015,7 +1015,7 @@ namespace kstd
//! @param position The position to insert the element at.
//! @param args The constructor arguments for the inserted element.
template<typename... Args>
- constexpr auto reallocate_and_insert(iterator position, Args &&... args)
+ constexpr auto reallocate_and_insert(iterator position, Args &&... args) -> void
{
auto prefix_size = std::ranges::distance(begin(), position);
auto suffix_size = std::ranges::distance(position, end());