ref: update formatting
This commit is contained in:
parent
7d0155d8ce
commit
024407225c
16 changed files with 433 additions and 377 deletions
10
.clang-format
Normal file
10
.clang-format
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
ColumnLimit: 120
|
||||||
|
PointerAlignment: Left
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortLambdasOnASingleLine: Empty
|
||||||
|
AlignAfterOpenBracket: BlockIndent
|
||||||
|
BreakTemplateDeclarations: Yes
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/number.h"
|
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
|
#include "util/number.h"
|
||||||
|
|
||||||
namespace acpi {
|
namespace acpi {
|
||||||
|
|
||||||
constexpr uint32_t fold_signature(const char (&text)[5]) {
|
constexpr uint32_t fold_signature(const char (&text)[5]) {
|
||||||
return static_cast<uint32_t>(static_cast<uint8_t>(text[0]))
|
return static_cast<uint32_t>(static_cast<uint8_t>(text[0])) |
|
||||||
| static_cast<uint32_t>(static_cast<uint8_t>(text[1])) << 8
|
static_cast<uint32_t>(static_cast<uint8_t>(text[1])) << 8 |
|
||||||
| static_cast<uint32_t>(static_cast<uint8_t>(text[2])) << 16
|
static_cast<uint32_t>(static_cast<uint8_t>(text[2])) << 16 |
|
||||||
| static_cast<uint32_t>(static_cast<uint8_t>(text[3])) << 24;
|
static_cast<uint32_t>(static_cast<uint8_t>(text[3])) << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class signature : uint32_t {
|
enum class signature : uint32_t {
|
||||||
|
|
@ -90,7 +90,8 @@ private:
|
||||||
|
|
||||||
switch (static_cast<signature>(header->signature)) {
|
switch (static_cast<signature>(header->signature)) {
|
||||||
ACPI_DISPATCH(madt, madt_t)
|
ACPI_DISPATCH(madt, madt_t)
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef ACPI_DISPATCH
|
#undef ACPI_DISPATCH
|
||||||
|
|
|
||||||
|
|
@ -134,25 +134,25 @@ struct madt_local_apic_address_override_t {
|
||||||
static_assert(sizeof(madt_local_apic_address_override_t) == 12);
|
static_assert(sizeof(madt_local_apic_address_override_t) == 12);
|
||||||
|
|
||||||
struct Madt {
|
struct Madt {
|
||||||
explicit Madt(paddr_t madt_physical)
|
explicit Madt(paddr_t madt_physical) : table(madt_physical.access<madt_t>()) {}
|
||||||
: table(madt_physical.access<madt_t>()) {}
|
|
||||||
explicit Madt(const madt_t* madt_table) : table(madt_table) {}
|
explicit Madt(const madt_t* madt_table) : table(madt_table) {}
|
||||||
|
|
||||||
paddr_t local_apic_address() {
|
paddr_t local_apic_address() {
|
||||||
uint64_t address = table->local_apic_address;
|
uint64_t address = table->local_apic_address;
|
||||||
for_each_entry(
|
for_each_entry([&](const madt_local_apic_address_override_t* override_entry) {
|
||||||
[&](const madt_local_apic_address_override_t *override_entry) {
|
|
||||||
address = override_entry->local_apic_address;
|
address = override_entry->local_apic_address;
|
||||||
});
|
});
|
||||||
return paddr_t{address};
|
return paddr_t{address};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_legacy_pic() { return table->flags.dual_8259_present != 0; }
|
bool has_legacy_pic() {
|
||||||
|
return table->flags.dual_8259_present != 0;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Fn> void for_each_entry(Fn &&callback) {
|
template<typename Fn>
|
||||||
|
void for_each_entry(Fn&& callback) {
|
||||||
auto ptr = table->entries;
|
auto ptr = table->entries;
|
||||||
const auto end =
|
const auto end = reinterpret_cast<const uint8_t*>(table) + table->header.length;
|
||||||
reinterpret_cast<const uint8_t *>(table) + table->header.length;
|
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
auto entry = reinterpret_cast<const madt_entry_t*>(ptr);
|
auto entry = reinterpret_cast<const madt_entry_t*>(ptr);
|
||||||
if (entry->length < sizeof(madt_entry_t)) {
|
if (entry->length < sizeof(madt_entry_t)) {
|
||||||
|
|
@ -178,8 +178,7 @@ private:
|
||||||
MADT_DISPATCH(interrupt_source_override, madt_interrupt_source_override_t)
|
MADT_DISPATCH(interrupt_source_override, madt_interrupt_source_override_t)
|
||||||
MADT_DISPATCH(nmi_source, madt_nmi_source_t)
|
MADT_DISPATCH(nmi_source, madt_nmi_source_t)
|
||||||
MADT_DISPATCH(local_apic_nmi, madt_local_apic_nmi_t)
|
MADT_DISPATCH(local_apic_nmi, madt_local_apic_nmi_t)
|
||||||
MADT_DISPATCH(local_apic_address_override,
|
MADT_DISPATCH(local_apic_address_override, madt_local_apic_address_override_t)
|
||||||
madt_local_apic_address_override_t)
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/number.h"
|
|
||||||
#include "util/function.h"
|
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
|
#include "util/function.h"
|
||||||
|
#include "util/number.h"
|
||||||
|
|
||||||
namespace multiboot {
|
namespace multiboot {
|
||||||
|
|
||||||
|
|
@ -36,28 +36,50 @@ enum class tag_type : uint32_t {
|
||||||
|
|
||||||
inline constexpr const char* get_tag_name(tag_type type) {
|
inline constexpr const char* get_tag_name(tag_type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case tag_type::end: return "end";
|
case tag_type::end:
|
||||||
case tag_type::cmdline: return "cmdline";
|
return "end";
|
||||||
case tag_type::boot_loader_name: return "boot_loader_name";
|
case tag_type::cmdline:
|
||||||
case tag_type::module: return "module";
|
return "cmdline";
|
||||||
case tag_type::basic_meminfo: return "basic_meminfo";
|
case tag_type::boot_loader_name:
|
||||||
case tag_type::bootdev: return "bootdev";
|
return "boot_loader_name";
|
||||||
case tag_type::mmap: return "mmap";
|
case tag_type::module:
|
||||||
case tag_type::vbe: return "vbe";
|
return "module";
|
||||||
case tag_type::framebuffer: return "framebuffer";
|
case tag_type::basic_meminfo:
|
||||||
case tag_type::elf_sections: return "elf_sections";
|
return "basic_meminfo";
|
||||||
case tag_type::apm: return "apm";
|
case tag_type::bootdev:
|
||||||
case tag_type::efi32: return "efi32";
|
return "bootdev";
|
||||||
case tag_type::efi64: return "efi64";
|
case tag_type::mmap:
|
||||||
case tag_type::smbios: return "smbios";
|
return "mmap";
|
||||||
case tag_type::acpi_old: return "acpi_old";
|
case tag_type::vbe:
|
||||||
case tag_type::acpi_new: return "acpi_new";
|
return "vbe";
|
||||||
case tag_type::network: return "network";
|
case tag_type::framebuffer:
|
||||||
case tag_type::efi_mmap: return "efi_mmap";
|
return "framebuffer";
|
||||||
case tag_type::efi_bs: return "efi_bs";
|
case tag_type::elf_sections:
|
||||||
case tag_type::efi32_ih: return "efi32_ih";
|
return "elf_sections";
|
||||||
case tag_type::efi64_ih: return "efi64_ih";
|
case tag_type::apm:
|
||||||
case tag_type::load_base_addr: return "load_base_addr";
|
return "apm";
|
||||||
|
case tag_type::efi32:
|
||||||
|
return "efi32";
|
||||||
|
case tag_type::efi64:
|
||||||
|
return "efi64";
|
||||||
|
case tag_type::smbios:
|
||||||
|
return "smbios";
|
||||||
|
case tag_type::acpi_old:
|
||||||
|
return "acpi_old";
|
||||||
|
case tag_type::acpi_new:
|
||||||
|
return "acpi_new";
|
||||||
|
case tag_type::network:
|
||||||
|
return "network";
|
||||||
|
case tag_type::efi_mmap:
|
||||||
|
return "efi_mmap";
|
||||||
|
case tag_type::efi_bs:
|
||||||
|
return "efi_bs";
|
||||||
|
case tag_type::efi32_ih:
|
||||||
|
return "efi32_ih";
|
||||||
|
case tag_type::efi64_ih:
|
||||||
|
return "efi64_ih";
|
||||||
|
case tag_type::load_base_addr:
|
||||||
|
return "load_base_addr";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -78,12 +100,18 @@ enum class mem_type : uint32_t {
|
||||||
|
|
||||||
inline constexpr const char* get_mem_type_name(mem_type type) {
|
inline constexpr const char* get_mem_type_name(mem_type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case mem_type::available: return "available";
|
case mem_type::available:
|
||||||
case mem_type::reserved: return "reserved";
|
return "available";
|
||||||
case mem_type::acpi_reclaimable: return "acpi_reclaimable";
|
case mem_type::reserved:
|
||||||
case mem_type::nvs: return "nvs";
|
return "reserved";
|
||||||
case mem_type::badram: return "badram";
|
case mem_type::acpi_reclaimable:
|
||||||
default: return "unknown";
|
return "acpi_reclaimable";
|
||||||
|
case mem_type::nvs:
|
||||||
|
return "nvs";
|
||||||
|
case mem_type::badram:
|
||||||
|
return "badram";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +189,6 @@ struct tag_vbe {
|
||||||
vbe_mode_info_block vbe_mode_info;
|
vbe_mode_info_block vbe_mode_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct tag_framebuffer {
|
struct tag_framebuffer {
|
||||||
tag_type type;
|
tag_type type;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
@ -317,7 +344,8 @@ void visit(const tag* t, Fn&& fn) {
|
||||||
MB_DISPATCH(efi32_ih, tag_efi32_ih)
|
MB_DISPATCH(efi32_ih, tag_efi32_ih)
|
||||||
MB_DISPATCH(efi64_ih, tag_efi64_ih)
|
MB_DISPATCH(efi64_ih, tag_efi64_ih)
|
||||||
MB_DISPATCH(load_base_addr, tag_load_base_addr)
|
MB_DISPATCH(load_base_addr, tag_load_base_addr)
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MB_DISPATCH
|
#undef MB_DISPATCH
|
||||||
|
|
@ -329,7 +357,8 @@ void visit_all(const info* mb, Fn&& fn) {
|
||||||
const auto end = reinterpret_cast<const uint8_t*>(mb) + mb->total_size;
|
const auto end = reinterpret_cast<const uint8_t*>(mb) + mb->total_size;
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
auto t = reinterpret_cast<const tag*>(ptr);
|
auto t = reinterpret_cast<const tag*>(ptr);
|
||||||
if (t->type == tag_type::end) break;
|
if (t->type == tag_type::end)
|
||||||
|
break;
|
||||||
visit(t, fn);
|
visit(t, fn);
|
||||||
ptr += (t->size + alignment - 1) & ~(alignment - 1);
|
ptr += (t->size + alignment - 1) & ~(alignment - 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ struct TextAttr {
|
||||||
|
|
||||||
constexpr TextAttr(Color fg = Color::White, Color bg = Color::Black) : fg(fg), bg(bg) {}
|
constexpr TextAttr(Color fg = Color::White, Color bg = Color::Black) : fg(fg), bg(bg) {}
|
||||||
|
|
||||||
// Returns the attribute in the high byte, ready to OR with a character value.
|
|
||||||
constexpr uint16_t word() const {
|
constexpr uint16_t word() const {
|
||||||
return (uint16_t)(((uint8_t)bg << 4) | (uint8_t)fg) << 8;
|
return (uint16_t)(((uint8_t)bg << 4) | (uint8_t)fg) << 8;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "init/multiboot2.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
#include "util/optional.h"
|
#include "util/optional.h"
|
||||||
#include "init/multiboot2.h"
|
|
||||||
|
|
||||||
constexpr const size_t page_size = 4096;
|
constexpr const size_t page_size = 4096;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,12 @@
|
||||||
|
|
||||||
constexpr uint64_t high_base = 0xFFFF800000000000;
|
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 {
|
struct paddr_t {
|
||||||
uint64_t address;
|
uint64_t address;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,12 @@ struct KernelSection {
|
||||||
uint64_t vma_end;
|
uint64_t vma_end;
|
||||||
const char* name;
|
const char* name;
|
||||||
|
|
||||||
paddr_t phys_start() const { return paddr_t{vma_start >= high_base ? vma_start - high_base : vma_start}; }
|
paddr_t phys_start() const {
|
||||||
paddr_t phys_end() const { return paddr_t{vma_end >= high_base ? vma_end - high_base : vma_end}; }
|
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__[];
|
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) {
|
inline bool is_in_reserved_section(paddr_t ptr, size_t size = 1) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
for_each_reserved_section([&](const KernelSection& section) {
|
for_each_reserved_section([&](const KernelSection& section) {
|
||||||
if (ptr.address < section.phys_end().address &&
|
if (ptr.address < section.phys_end().address && section.phys_start().address < ptr.address + size) {
|
||||||
section.phys_start().address < ptr.address + size) {
|
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
optional& operator=(const optional& other) {
|
optional& operator=(const optional& other) {
|
||||||
if (this == &other) return *this;
|
if (this == &other)
|
||||||
|
return *this;
|
||||||
destroy();
|
destroy();
|
||||||
if (other.initialized) {
|
if (other.initialized) {
|
||||||
new (buffer) T(*other);
|
new (buffer) T(*other);
|
||||||
|
|
@ -77,7 +78,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
optional& operator=(optional&& other) noexcept {
|
optional& operator=(optional&& other) noexcept {
|
||||||
if (this == &other) return *this;
|
if (this == &other)
|
||||||
|
return *this;
|
||||||
destroy();
|
destroy();
|
||||||
if (other.initialized) {
|
if (other.initialized) {
|
||||||
new (buffer) T(move(*other));
|
new (buffer) T(move(*other));
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,17 @@
|
||||||
// Minimal freestanding replacements for <utility> (no stdlib available).
|
// Minimal freestanding replacements for <utility> (no stdlib available).
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct remove_reference { using type = T; };
|
struct remove_reference {
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct remove_reference<T&> { using type = T; };
|
struct remove_reference<T&> {
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct remove_reference<T&&> { using type = T; };
|
struct remove_reference<T&&> {
|
||||||
|
using type = 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;
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,4 @@ void __cxa_pure_virtual() {
|
||||||
__asm__ volatile("cli; hlt");
|
__asm__ volatile("cli; hlt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
#include "memory/pointer.h"
|
|
||||||
#include "memory/sections.h"
|
|
||||||
#include "init/init.h"
|
#include "init/init.h"
|
||||||
#include "init/multiboot2.h"
|
|
||||||
#include "init/print.h"
|
|
||||||
#include "init/acpi.h"
|
#include "init/acpi.h"
|
||||||
#include "init/apic.h"
|
#include "init/apic.h"
|
||||||
|
#include "init/multiboot2.h"
|
||||||
|
#include "init/print.h"
|
||||||
#include "memory/allocator.h"
|
#include "memory/allocator.h"
|
||||||
|
#include "memory/pointer.h"
|
||||||
|
#include "memory/sections.h"
|
||||||
|
|
||||||
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void halt() {
|
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void halt() {
|
||||||
while (true) __asm__ volatile ("hlt");
|
while (true)
|
||||||
|
__asm__ volatile("hlt");
|
||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void panic(const char* msg) {
|
[[maybe_unused]] [[noreturn]] __attribute__((used)) static void panic(const char* msg) {
|
||||||
|
|
@ -55,8 +56,7 @@ static bool is_in_boot_reserved_range(paddr_t ptr, size_t size) {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(ptr.address < start.address + length &&
|
if (ptr.address < start.address + length && start.address < ptr.address + size) {
|
||||||
start.address < ptr.address + size) {
|
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -145,12 +145,14 @@ void PhysicalAllocator::init(const multiboot::tag_mmap* multiboot_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupMemory() {
|
static void setupMemory() {
|
||||||
multiboot::visit_all(overloaded{
|
multiboot::visit_all(
|
||||||
|
overloaded{
|
||||||
[](const multiboot::tag_mmap* mem) {
|
[](const multiboot::tag_mmap* mem) {
|
||||||
PhysicalAllocator::init(mem);
|
PhysicalAllocator::init(mem);
|
||||||
},
|
},
|
||||||
[](const auto* tag) {}
|
[](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) {
|
||||||
|
|
@ -162,7 +164,8 @@ static paddr_t rsdp_physical_of(const uint8_t* rsdp_payload) {
|
||||||
|
|
||||||
static acpi::Rsdp findRsdp() {
|
static acpi::Rsdp findRsdp() {
|
||||||
optional<paddr_t> rsdp{};
|
optional<paddr_t> rsdp{};
|
||||||
multiboot::visit_all(overloaded{
|
multiboot::visit_all(
|
||||||
|
overloaded{
|
||||||
[&](const multiboot::tag_new_acpi* tag) {
|
[&](const multiboot::tag_new_acpi* tag) {
|
||||||
rsdp = rsdp_physical_of(tag->rsdp);
|
rsdp = rsdp_physical_of(tag->rsdp);
|
||||||
},
|
},
|
||||||
|
|
@ -172,7 +175,8 @@ static acpi::Rsdp findRsdp() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&](const auto* tag) {}
|
[&](const auto* tag) {}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (!rsdp.has_value()) {
|
if (!rsdp.has_value()) {
|
||||||
panic("System could not find ACPI RSDP!");
|
panic("System could not find ACPI RSDP!");
|
||||||
|
|
@ -187,12 +191,10 @@ struct AcpiDiscoveryResult {
|
||||||
|
|
||||||
static void setupAcpi() {
|
static void setupAcpi() {
|
||||||
auto rsdp = findRsdp();
|
auto rsdp = findRsdp();
|
||||||
rsdp.for_each_table(overloaded{
|
rsdp.for_each_table(overloaded{[&](const acpi::sdt_header_t* header) {
|
||||||
[&](const acpi::sdt_header_t* header) {
|
|
||||||
print(acpi::unfold_signature(header->signature).text);
|
print(acpi::unfold_signature(header->signature).text);
|
||||||
print("\n");
|
print("\n");
|
||||||
}
|
}});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[maybe_unused]] [[noreturn]] __attribute__((used)) void init() {
|
[[maybe_unused]] [[noreturn]] __attribute__((used)) void init() {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,7 @@
|
||||||
#define RESERVE_SECTION(n) \
|
#define RESERVE_SECTION(n) \
|
||||||
extern char __##n##_start__[], __##n##_end__[]; \
|
extern char __##n##_start__[], __##n##_end__[]; \
|
||||||
[[maybe_unused]] static const KernelSection _rsv_##n \
|
[[maybe_unused]] static const KernelSection _rsv_##n \
|
||||||
__attribute__((section(".reserved_ranges"), used)) = { \
|
__attribute__((section(".reserved_ranges"), used)) = {(uint64_t)__##n##_start__, (uint64_t)__##n##_end__, #n}
|
||||||
(uint64_t)__##n##_start__, \
|
|
||||||
(uint64_t)__##n##_end__, \
|
|
||||||
#n \
|
|
||||||
}
|
|
||||||
|
|
||||||
RESERVE_SECTION(boot);
|
RESERVE_SECTION(boot);
|
||||||
RESERVE_SECTION(startup_text);
|
RESERVE_SECTION(startup_text);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ struct PhysicalAllocatorImpl {
|
||||||
struct Cursor {
|
struct Cursor {
|
||||||
page_t* node;
|
page_t* node;
|
||||||
size_t slot;
|
size_t slot;
|
||||||
uint64_t& value() { return node->count[slot]; }
|
uint64_t& value() {
|
||||||
|
return node->count[slot];
|
||||||
|
}
|
||||||
void advance() {
|
void advance() {
|
||||||
++slot;
|
++slot;
|
||||||
if (slot == entries_per_node) {
|
if (slot == entries_per_node) {
|
||||||
|
|
@ -168,8 +170,10 @@ struct PhysicalAllocatorImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run_list_t collect_runs(uint64_t start_page, uint64_t count, bool is_free,
|
run_list_t collect_runs(
|
||||||
const run_location_t& start, const run_location_t& end, size_t total_runs) {
|
uint64_t start_page, uint64_t count, bool is_free, const run_location_t& start, const run_location_t& end,
|
||||||
|
size_t total_runs
|
||||||
|
) {
|
||||||
bool has_left_neighbor = start.index > 0;
|
bool has_left_neighbor = start.index > 0;
|
||||||
bool has_right_neighbor = end.index + 1 < total_runs;
|
bool has_right_neighbor = end.index + 1 < total_runs;
|
||||||
uint64_t left_remainder = start_page - start.address;
|
uint64_t left_remainder = start_page - start.address;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ extern "C" [[maybe_unused]] [[noreturn]] __attribute__((used)) void __entry64()
|
||||||
(*ctor)();
|
(*ctor)();
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
while (true) __asm__ volatile ("hlt");
|
while (true)
|
||||||
|
__asm__ volatile("hlt");
|
||||||
}
|
}
|
||||||
|
|
||||||
asm(R"(
|
asm(R"(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue