]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Moved the past_the_end page of the page allocator to the c++ code, and made it and...
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 8 May 2022 19:45:23 +0000 (21:45 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 8 May 2022 19:45:23 +0000 (21:45 +0200)
src/boot.S
src/kernel.cpp
src/paging.hpp

index 1bdfdba0c54c916129cb40ec695ae7b3def9b8dd..f113d375153acc52f5eac5fa1a29e4ef7182b6e1 100644 (file)
@@ -94,8 +94,6 @@ PDPT_high: .skip 0x1000 - 16
 
 .section .bss
 .align 0x1000
-.globl page_list_one_past_end
-page_list_one_past_end: .skip 0x1000
 PML4T: .skip 0x1000
 phys_mem_map: .skip 0x1000 * 128 - 8
 .align 16
index b1293dd169cc546ee81a78b0923df65cc7214f20..5799f4664ffc4615c0925c98fd26380d7fc4e3a2 100644 (file)
@@ -28,6 +28,10 @@ void remove_some_mem(os::phys_ptr<os::paging::page> mem_start,
        }
 }
 
+os::paging::page one_past_end_page_for_page_allocator;
+os::paging::page_allocator page_allocator(os::phys_ptr<os::paging::page>(reinterpret_cast<uintptr_t>(&one_past_end_page_for_page_allocator) - 0xFFFFFFFF80000000));
+
+
 extern "C" void kmain(unsigned long magic, os::phys_ptr<const multiboot2::info_start> info) {
        os::assert(magic == 0x36D76289, "Incorrect magic number: wasn't booted with multiboot2.");
 
@@ -35,11 +39,6 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr<const multiboot2::info_s
                os::halt();
        }
 
-       os::paging::page_allocator page_allocator{([]() {
-               os::phys_ptr<os::paging::page> ram_ptr = nullptr;
-               asm("mov $page_list_one_past_end - 0xFFFFFFFF80000000,%0" : "=ri"(ram_ptr));
-               return ram_ptr;
-       })()};
        const os::phys_ptr<os::paging::page> kernel_start = ([]() {
                os::phys_ptr<os::paging::page> ptr = nullptr;
                asm("mov $_kernel_phys_start,%0" : "=ri"(ptr));
@@ -87,10 +86,10 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr<const multiboot2::info_s
                                        if (s < e) {
                                                remove_some_mem(
                                                s, e, kernel_start, kernel_end,
-                                               [&page_allocator, info_start, info_end] (auto s, auto e) {
+                                               [info_start, info_end] (auto s, auto e) {
                                                        remove_some_mem(
                                                        s, e, info_start, info_end,
-                                                       [&page_allocator] (auto s, auto e) {
+                                                       [] (auto s, auto e) {
                                                                page_allocator.deallocate({.ptr = s, .size = (e.get_phys_addr() - s.get_phys_addr()) / 0x1000});
                                                        }
                                                        );
index 76024d7ec45843e6827cf9de2191b20468bcfa46..9013fb53bbbafb7620cb3c33f0f5ec4fbfdf5074 100644 (file)
@@ -133,7 +133,7 @@ struct __attribute__((aligned(0x1000))) paging_table {
 
 template<>
 struct paging_table<-1> {
-       std::uint8_t contents[0x1000];
+       std::uint8_t contents[0x1000] = {0};
 };
 
 using PML4T = paging_table<3>;