blob: 245d7bd08977060076270832e253c453ab896670 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include "arch/memory.hpp"
// #include "noarch/error.hpp"
// #include "noarch/print.hpp"
// #include "x86_64/bootstrap/mutiboot.hpp"
// #include "x86_64/memory/frame_allocator.hpp"
// #include "x86_64/memory/mbi_frame_allocator.hpp"
// #include <elf/constants.hpp>
// #include <elf/section_header.hpp>
// #include <elf/section_header_table.hpp>
// #include <multiboot2/information.hpp>
namespace teachos::arch::memory
{
// namespace
// {
// /**
// * @brief Remap the kernel according to the ELF information.
// *
// * After initial bootup, a basic identity mapping of the lower 1GiB is set up. This mapping allows execution
// from,
// * as well as read and write access to, the mapped memory. In order to protect the kernel, remap it according to
// the
// * information supplied by the ELF file. This means remapping code sections as read-only and data sections as
// * no-execute (and read only for .rodata).
// *
// * @param sections Information about the sections in the loaded kernel binary.
// * @param allocator The frame allocator used to create new page mappings.
// */
// auto remap_kernel(elf::section_header_table const & sections, x86_64::memory::frame_allocator & allocator) ->
// void
// {
// static_cast<void>(sections);
// static_cast<void>(allocator);
// }
// } // namespace
auto init() -> void
{
// kernel::println("Initializing memory");
// if (!x86_64::bootstrap::multiboot_information_pointer->has<multiboot2::memory_map>())
// {
// kernel::panic("Received no memory map from the boot loader!");
// }
// if (!x86_64::bootstrap::multiboot_information_pointer->has<multiboot2::elf_symbols>())
// {
// kernel::panic("Received no ELF symbol information from the boot loader!");
// }
// auto memory_map = x86_64::bootstrap::multiboot_information_pointer->memory_map();
// auto elf_symbols = x86_64::bootstrap::multiboot_information_pointer->elf_symbols();
// auto section_header_table = elf::section_header_table{elf_symbols.data(), elf::file_class::bits_64};
// auto allocator = x86_64::memory::mbi_frame_allocator{memory_map, section_header_table};
// remap_kernel(section_header_table, allocator);
}
} // namespace teachos::arch::memory
|