feat: update step
This commit is contained in:
parent
024407225c
commit
5b0cc28bc8
2 changed files with 34 additions and 26 deletions
|
|
@ -18,6 +18,11 @@ struct remove_reference<T&&> {
|
|||
template<typename T>
|
||||
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>
|
||||
constexpr remove_reference_t<T>&& move(T&& value) {
|
||||
return static_cast<remove_reference_t<T>&&>(value);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "memory/allocator.h"
|
||||
#include "memory/pointer.h"
|
||||
#include "memory/sections.h"
|
||||
#include "util/utility.h"
|
||||
|
||||
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void halt() {
|
||||
while (true)
|
||||
|
|
@ -18,23 +19,30 @@
|
|||
}
|
||||
|
||||
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) {
|
||||
print(" ");
|
||||
}
|
||||
print("Starting ");
|
||||
print(prefix);
|
||||
print(name);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
static auto step(const char* name, Fn&& fn) {
|
||||
print_step_boundary("Starting ", name);
|
||||
++step_depth;
|
||||
if constexpr (is_void_v<decltype(fn())>) {
|
||||
fn();
|
||||
--step_depth;
|
||||
for (int i = 0; i < step_depth; ++i) {
|
||||
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>
|
||||
|
|
@ -145,14 +153,9 @@ void PhysicalAllocator::init(const multiboot::tag_mmap* multiboot_info) {
|
|||
}
|
||||
|
||||
static void setupMemory() {
|
||||
multiboot::visit_all(
|
||||
overloaded{
|
||||
[](const multiboot::tag_mmap* mem) {
|
||||
multiboot::visit_all(overloaded{[](const multiboot::tag_mmap* mem) {
|
||||
PhysicalAllocator::init(mem);
|
||||
},
|
||||
[](const auto* tag) {}
|
||||
}
|
||||
);
|
||||
}});
|
||||
}
|
||||
|
||||
static paddr_t rsdp_physical_of(const uint8_t* rsdp_payload) {
|
||||
|
|
@ -173,8 +176,7 @@ static acpi::Rsdp findRsdp() {
|
|||
if (!rsdp.has_value()) {
|
||||
rsdp = rsdp_physical_of(tag->rsdp);
|
||||
}
|
||||
},
|
||||
[&](const auto* tag) {}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -189,18 +191,19 @@ struct AcpiDiscoveryResult {
|
|||
optional<acpi::Madt> madt;
|
||||
};
|
||||
|
||||
static void setupAcpi() {
|
||||
auto rsdp = findRsdp();
|
||||
rsdp.for_each_table(overloaded{[&](const acpi::sdt_header_t* header) {
|
||||
print(acpi::unfold_signature(header->signature).text);
|
||||
print("\n");
|
||||
static AcpiDiscoveryResult setupAcpi() {
|
||||
AcpiDiscoveryResult res{};
|
||||
res.rsdp = findRsdp();
|
||||
res.rsdp->for_each_table(overloaded{[&](const acpi::madt_t* header) {
|
||||
res.madt = acpi::Madt{header};
|
||||
}});
|
||||
return res;
|
||||
}
|
||||
|
||||
[[maybe_unused]] [[noreturn]] __attribute__((used)) void init() {
|
||||
initFromLow();
|
||||
print("Reached init\n");
|
||||
step("memory", setupMemory);
|
||||
step("acpi", setupAcpi);
|
||||
auto acpi = step("acpi", setupAcpi);
|
||||
halt();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue