aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/kernel/main.cpp')
-rw-r--r--arch/x86_64/src/kernel/main.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index 1289eb6..1c6aa55 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -9,8 +9,13 @@ 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);
- while (!condition)
+ for (;;)
{
// Trick the compiler into thinking the variable is changes at run time,
// to prevent the while loop being optimized away
@@ -39,7 +44,6 @@ namespace teachos::arch::kernel
auto process_elf_sections(arch::memory::elf_symbols_section * symbol, uint64_t & kernel_start,
uint64_t & kernel_end) -> void
{
- // Validate ELF sections
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);
@@ -61,17 +65,18 @@ namespace teachos::arch::kernel
{
switch (section->type)
{
- case arch::memory::elf_section_type::PROGRAMM:
+ case arch::memory::elf_section_type::PROGRAMM: {
if (section->virtual_address < kernel_start)
{
kernel_start = section->virtual_address;
}
-
- if (section->virtual_address + section->section_size > kernel_end)
+ auto virtual_address_end = section->virtual_address + section->section_size;
+ if (virtual_address_end > kernel_end)
{
- kernel_end = section->virtual_address + section->section_size;
+ kernel_end = virtual_address_end;
}
break;
+ }
case arch::memory::elf_section_type::DYNAMIC_SYMBOL_TABLE:
case arch::memory::elf_section_type::SYMBOL_TABLE:
symbol_table_section_count++;
@@ -121,13 +126,16 @@ namespace teachos::arch::kernel
{
switch (tag->type)
{
- case arch::memory::multi_boot_tag_type::ELF_SECTIONS:
- process_elf_sections(reinterpret_cast<teachos::arch::memory::elf_symbols_section *>(tag), kernel_start,
- kernel_end);
+ case arch::memory::multi_boot_tag_type::ELF_SECTIONS: {
+ auto symbol = reinterpret_cast<teachos::arch::memory::elf_symbols_section *>(tag);
+ process_elf_sections(symbol, kernel_start, kernel_end);
break;
- case arch::memory::multi_boot_tag_type::MEMORY_MAP:
- process_memory_map(reinterpret_cast<teachos::arch::memory::memory_map *>(tag), memory_areas, area_count);
+ }
+ case arch::memory::multi_boot_tag_type::MEMORY_MAP: {
+ auto mminfo = reinterpret_cast<teachos::arch::memory::memory_map *>(tag);
+ process_memory_map(mminfo, memory_areas, area_count);
break;
+ }
default:
// All other cases are not important and can be ignored
break;