diff options
Diffstat (limited to 'arch/x86_64/src/kernel/main.cpp')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 7e4a336..c8981a8 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -1,6 +1,7 @@ #include "arch/kernel/main.hpp" #include "arch/boot/pointers.hpp" +#include "arch/exception_handling/assert.hpp" #include "arch/memory/frame_allocator.hpp" #include "arch/memory/multiboot.hpp" #include "arch/video/vga/text.hpp" @@ -9,31 +10,12 @@ namespace teachos::arch::kernel { - auto assert(bool condition) -> void - { - if (condition) - { - return; - } - - video::vga::text::write("Assert failed", video::vga::text::common_attributes::green_on_black); - for (;;) - { - // Trick the compiler into thinking the variable is changes at run time, - // to prevent the while loop being optimized away - // See - // https://stackoverflow.com/questions/9495856/how-to-prevent-g-from-optimizing-out-a-loop-controlled-by-a-variable-that-can - // for more information. - asm volatile("" : "+g"(condition)); - } - } - auto process_memory_map(arch::memory::memory_map * mminfo, arch::memory::memory_area *& memory_areas, uint8_t & area_count) -> void { auto expected_entry_size = mminfo->entry_size; constexpr auto actual_entry_size = sizeof(arch::memory::memory_area); - assert(expected_entry_size == actual_entry_size); + arch::exception_handling::assert(expected_entry_size == actual_entry_size, "Unexpected memoryarea entry size"); auto total_size = mminfo->tag.size; auto total_entries_size = total_size - sizeof(arch::memory::memory_map) + actual_entry_size; @@ -48,17 +30,18 @@ namespace teachos::arch::kernel { auto expected_entry_size = symbol->entry_size; constexpr auto actual_entry_size = sizeof(arch::memory::elf_section_header); - assert(expected_entry_size == actual_entry_size); + arch::exception_handling::assert(expected_entry_size == actual_entry_size, + "Unexpected elf_section_header entry size"); auto expected_total_size = symbol->tag.size; auto actual_total_entry_size = actual_entry_size * symbol->number_of_sections; constexpr auto actual_total_section_size = sizeof(arch::memory::elf_symbols_section) - sizeof(uint32_t); auto actual_total_size = actual_total_entry_size + actual_total_section_size; - assert(expected_total_size == actual_total_size); + arch::exception_handling::assert(expected_total_size == actual_total_size, "Unexpected elf_symbols total size"); auto begin = reinterpret_cast<arch::memory::elf_section_header *>(&symbol->end); auto end = begin + symbol->number_of_sections; - assert(begin->is_null()); + arch::exception_handling::assert(begin->is_null(), "Missing elf_section_header begin"); std::size_t symbol_table_section_count = 0U; std::size_t dynamic_section_count = 0U; @@ -115,8 +98,8 @@ namespace teachos::arch::kernel } } - assert(symbol_table_section_count == 1U); - assert(dynamic_section_count <= 1U); + arch::exception_handling::assert(symbol_table_section_count == 1U, "Unexpected symbol_table_count value"); + arch::exception_handling::assert(dynamic_section_count <= 1U, "Unexpected dynamic_section_count value"); } template<typename T> @@ -173,15 +156,6 @@ namespace teachos::arch::kernel } } - // Kernel start 0x100000 - // Kernel end 0x23E943 - // Kernel Size 0x13E943 -> 1'304'899 - // Multiboot start 0x241AA0 - // Multiboot end 0x242280 - // Multiboot Size 0x7E0 -> 2'016 - // Memory area start 0x241b10 - // - // Address of Frame: 0x203F00 auto allocator = arch::memory::area_frame_allocator(kernel_start, kernel_end, multiboot_start, multiboot_end, memory_areas, area_count); |
