ref: update formatting

This commit is contained in:
Katharina 2026-07-02 19:38:45 +02:00
parent 7d0155d8ce
commit 024407225c
16 changed files with 433 additions and 377 deletions

View file

@ -1,8 +1,8 @@
#pragma once
#include "init/multiboot2.h"
#include "memory/pointer.h"
#include "util/optional.h"
#include "init/multiboot2.h"
constexpr const size_t page_size = 4096;

View file

@ -4,14 +4,19 @@
constexpr uint64_t high_base = 0xFFFF800000000000;
#define read_symbol(symbol) [](){uint64_t res; asm volatile("movabsq $" symbol ", %0": "=r"(res)); return res;}()
#define read_symbol(symbol) \
[]() { \
uint64_t res; \
asm volatile("movabsq $" symbol ", %0" : "=r"(res)); \
return res; \
}()
struct paddr_t {
uint64_t address;
template<typename T>
T* access() {
return reinterpret_cast<T*>(address+high_base);
return reinterpret_cast<T*>(address + high_base);
}
};
@ -25,14 +30,14 @@ inline void* operator new[](size_t, void* p) {
inline void* memcpy(void* dest, const void* src, size_t n) {
for (size_t i = 0; i < n; i++) {
((uint8_t*) dest)[i] = ((uint8_t*) src)[i];
((uint8_t*)dest)[i] = ((uint8_t*)src)[i];
}
return dest;
}
inline void* memset(void* dest, int c, size_t n) {
for (size_t i = 0; i < n; i++) {
((uint8_t*) dest)[i] = (uint8_t) c;
((uint8_t*)dest)[i] = (uint8_t)c;
}
return dest;
}

View file

@ -6,8 +6,12 @@ struct KernelSection {
uint64_t vma_end;
const char* name;
paddr_t phys_start() const { return paddr_t{vma_start >= high_base ? vma_start - high_base : vma_start}; }
paddr_t phys_end() const { return paddr_t{vma_end >= high_base ? vma_end - high_base : vma_end}; }
paddr_t phys_start() const {
return paddr_t{vma_start >= high_base ? vma_start - high_base : vma_start};
}
paddr_t phys_end() const {
return paddr_t{vma_end >= high_base ? vma_end - high_base : vma_end};
}
};
extern KernelSection __reserved_ranges_start__[], __reserved_ranges_end__[];
@ -21,8 +25,7 @@ void for_each_reserved_section(Fn&& fn) {
inline bool is_in_reserved_section(paddr_t ptr, size_t size = 1) {
bool res = false;
for_each_reserved_section([&](const KernelSection& section) {
if (ptr.address < section.phys_end().address &&
section.phys_start().address < ptr.address + size) {
if (ptr.address < section.phys_end().address && section.phys_start().address < ptr.address + size) {
res = true;
}
});