remove_some_mem(
s, e, info_start, info_end,
[] (auto s, auto e) {
- page_allocator.deallocate({.ptr = s, .size = (e.get_phys_addr() - s.get_phys_addr()) / 0x1000});
+ page_allocator.deallocate({.ptr = s, .size = std::uint64_t(e - s)});
}
);
}
// Deallocate multiboot info structure: not usable anymore.
if (info_pages_wholly_usable) {
- page_allocator.deallocate({.ptr = info_start, .size = (info_end.get_phys_addr() - info_start.get_phys_addr()) / 0x1000});
+ page_allocator.deallocate({.ptr = info_start, .size = std::uint64_t(info_end - info_start)});
} else if (info_start + 1 < info_end - 1) {
// Ignore the first and last blocks: ensures all the RAM is truly usable.
- page_allocator.deallocate({.ptr = info_start + 1, .size = (info_end.get_phys_addr() - info_start.get_phys_addr()) / 0x1000 - 2});
+ page_allocator.deallocate({.ptr = info_start + 1, .size = std::uint64_t(info_end - info_start - 2)});
}
os::print("RAM:\n");
friend constexpr phys_ptr<T> operator-(phys_ptr<T> ptr, std::ptrdiff_t offset) {
return phys_ptr<T>{ptr.phys_addr - offset * sizeof(T)};
}
+ friend constexpr std::ptrdiff_t operator-(phys_ptr<T> a, phys_ptr<T> b) {
+ return (a.phys_addr - b.phys_addr) / sizeof(T);
+ }
constexpr std::uintptr_t get_phys_addr() const {
return phys_addr;