feat: update step

This commit is contained in:
Katharina 2026-07-02 20:03:40 +02:00
parent 024407225c
commit 5b0cc28bc8
2 changed files with 34 additions and 26 deletions

View file

@ -18,6 +18,11 @@ struct remove_reference<T&&> {
template<typename T> template<typename T>
using remove_reference_t = typename remove_reference<T>::type; using remove_reference_t = typename remove_reference<T>::type;
template<typename T>
inline constexpr bool is_void_v = false;
template<>
inline constexpr bool is_void_v<void> = true;
template<typename T> template<typename T>
constexpr remove_reference_t<T>&& move(T&& value) { constexpr remove_reference_t<T>&& move(T&& value) {
return static_cast<remove_reference_t<T>&&>(value); return static_cast<remove_reference_t<T>&&>(value);

View file

@ -6,6 +6,7 @@
#include "memory/allocator.h" #include "memory/allocator.h"
#include "memory/pointer.h" #include "memory/pointer.h"
#include "memory/sections.h" #include "memory/sections.h"
#include "util/utility.h"
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void halt() { [[maybe_unused]] [[noreturn]] __attribute__((used)) static void halt() {
while (true) while (true)
@ -18,23 +19,30 @@
} }
static int step_depth = 0; static int step_depth = 0;
template<typename T>
static void step(const char* name, T&& fn) { static void print_step_boundary(const char* prefix, const char* name) {
for (int i = 0; i < step_depth; ++i) { for (int i = 0; i < step_depth; ++i) {
print(" "); print(" ");
} }
print("Starting "); print(prefix);
print(name); print(name);
print("\n"); print("\n");
}
template<typename Fn>
static auto step(const char* name, Fn&& fn) {
print_step_boundary("Starting ", name);
++step_depth; ++step_depth;
fn(); if constexpr (is_void_v<decltype(fn())>) {
--step_depth; fn();
for (int i = 0; i < step_depth; ++i) { --step_depth;
print(" "); print_step_boundary("Finished ", name);
} else {
auto result = fn();
--step_depth;
print_step_boundary("Finished ", name);
return result;
} }
print("Finished ");
print(name);
print("\n");
} }
template<typename Fn> template<typename Fn>
@ -145,14 +153,9 @@ void PhysicalAllocator::init(const multiboot::tag_mmap* multiboot_info) {
} }
static void setupMemory() { static void setupMemory() {
multiboot::visit_all( multiboot::visit_all(overloaded{[](const multiboot::tag_mmap* mem) {
overloaded{ PhysicalAllocator::init(mem);
[](const multiboot::tag_mmap* mem) { }});
PhysicalAllocator::init(mem);
},
[](const auto* tag) {}
}
);
} }
static paddr_t rsdp_physical_of(const uint8_t* rsdp_payload) { static paddr_t rsdp_physical_of(const uint8_t* rsdp_payload) {
@ -173,8 +176,7 @@ static acpi::Rsdp findRsdp() {
if (!rsdp.has_value()) { if (!rsdp.has_value()) {
rsdp = rsdp_physical_of(tag->rsdp); rsdp = rsdp_physical_of(tag->rsdp);
} }
}, }
[&](const auto* tag) {}
} }
); );
@ -189,18 +191,19 @@ struct AcpiDiscoveryResult {
optional<acpi::Madt> madt; optional<acpi::Madt> madt;
}; };
static void setupAcpi() { static AcpiDiscoveryResult setupAcpi() {
auto rsdp = findRsdp(); AcpiDiscoveryResult res{};
rsdp.for_each_table(overloaded{[&](const acpi::sdt_header_t* header) { res.rsdp = findRsdp();
print(acpi::unfold_signature(header->signature).text); res.rsdp->for_each_table(overloaded{[&](const acpi::madt_t* header) {
print("\n"); res.madt = acpi::Madt{header};
}}); }});
return res;
} }
[[maybe_unused]] [[noreturn]] __attribute__((used)) void init() { [[maybe_unused]] [[noreturn]] __attribute__((used)) void init() {
initFromLow(); initFromLow();
print("Reached init\n"); print("Reached init\n");
step("memory", setupMemory); step("memory", setupMemory);
step("acpi", setupAcpi); auto acpi = step("acpi", setupAcpi);
halt(); halt();
} }