case multiboot2::info::type_t::memory_map:
for (std::size_t i = 0; i < multiboot2::memory_map_number_of_entries(it); i++) {
if (multiboot2::memory_map_type(it, i) == 1) {
- const os::phys_ptr<os::paging::page> s{
- multiboot2::memory_map_base_addr(it, i) < 0x1000
- ? 0x1000
- : (multiboot2::memory_map_base_addr(it, i) + 0x1000 - 1) / 0x1000 * 0x1000
- };
+ const os::phys_ptr<os::paging::page> s{(multiboot2::memory_map_base_addr(it, i) + 0x1000 - 1) / 0x1000 * 0x1000};
const os::phys_ptr<os::paging::page> e{multiboot2::memory_map_base_addr(it, i) + multiboot2::memory_map_length(it, i) / 0x1000 * 0x1000};
if (s < e) {
remove_some_mem(
return { .ptr = nullptr, .size = count };
}
void os::paging::page_allocator::deallocate(block b) {
+ if (b.ptr == nullptr) { return; }
if (b.size == 0) { return; }
const phys_ptr<page> b_it{b.ptr.get_phys_addr()};
auto it = begin();
class phys_ptr {
public:
constexpr explicit phys_ptr(std::uintptr_t phys_addr): phys_addr(phys_addr) {}
- constexpr phys_ptr(std::nullptr_t): phys_addr(0) {}
+ constexpr phys_ptr(std::nullptr_t): phys_addr(~0ull) {}
T& operator[](std::size_t i) const {
return get_virt_addr()[i];
friend constexpr auto operator<=>(phys_ptr<T> a, phys_ptr<T> b) = default;
private:
- T* get_virt_addr() const {
+ constexpr T* get_virt_addr() const {
return reinterpret_cast<T*>(phys_addr + 0xFFFF800000000000);
}