From f7df7167f0c54bd8da79dbf2d48bda5d7491fd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sun, 6 Oct 2024 08:45:04 +0000 Subject: Remove high memory kernel and needless prints --- arch/x86_64/src/kernel/main.cpp | 120 ++++++++++++---------------------------- 1 file changed, 35 insertions(+), 85 deletions(-) (limited to 'arch/x86_64/src/kernel/main.cpp') diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 4d6296a..e867bad 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -9,47 +9,28 @@ namespace teachos::arch::kernel auto print_mem_info(arch::memory::memory_info * mem_info) -> void { using namespace video::vga; - auto mem_lower = mem_info->mem_lower; - text::write("Lower memory (kB): ", text::common_attributes::green_on_black); - text::write_number(mem_lower, text::common_attributes::green_on_black); - auto mem_upper = mem_info->mem_upper; - text::write("Upper memory (kB): ", text::common_attributes::green_on_black); - text::write_number(mem_upper, text::common_attributes::green_on_black); } auto print_memory_map(arch::memory::memory_map * mminfo) -> void { using namespace video::vga; - uint32_t const entry_size = mminfo->entry_size; - text::write("Entry Size: ", text::common_attributes::green_on_black); - text::write_number(entry_size, text::common_attributes::green_on_black); - - uint32_t const entry_version = mminfo->entry_version; - text::write("Version: ", text::common_attributes::green_on_black); - text::write_number(entry_version, text::common_attributes::green_on_black); - - uint32_t const remaining_size = mminfo->tag.size - (4 * sizeof(uint32_t)); - uint32_t const entry_amount = remaining_size / entry_size; + auto entry_size = mminfo->entry_size; + auto entry_version = mminfo->entry_version; + auto remaining_size = mminfo->tag.size - (4 * sizeof(uint32_t)); + auto entry_amount = remaining_size / entry_size; auto begin = &mminfo->entries; auto end = begin + entry_amount; - for (auto entry = begin; entry != end; ++entry) + for (auto entry = begin; entry != end; + entry = (teachos::arch::memory::memory_area *)(((uint8_t *)entry) + ((entry_size + 7) & ~7))) { - text::write("Base Address: ", text::common_attributes::green_on_black); - text::write_number(entry->base_addr, text::common_attributes::green_on_black); - - text::write("Length: ", text::common_attributes::green_on_black); - text::write_number(entry->length, text::common_attributes::green_on_black); - - text::write("Type: ", text::common_attributes::green_on_black); - text::write_number(static_cast::type>(entry->type), - text::common_attributes::green_on_black); - - text::write("Reserved: ", text::common_attributes::green_on_black); - text::write_number(entry->reserved, text::common_attributes::green_on_black); + auto base_addr = entry->base_addr; + auto length = entry->length; + auto type = entry->type; + auto reserved = entry->reserved; } } @@ -57,61 +38,33 @@ namespace teachos::arch::kernel { using namespace video::vga; - uint16_t const num = symbol->num; - text::write("Number of entries: ", text::common_attributes::green_on_black); - text::write_number(num, text::common_attributes::green_on_black); - - uint16_t const entsize = symbol->entsize; - text::write("Entry Size: ", text::common_attributes::green_on_black); - text::write_number(entsize, text::common_attributes::green_on_black); - - uint16_t const shndx = symbol->shndx; - text::write("Section index: ", text::common_attributes::green_on_black); - text::write_number(shndx, text::common_attributes::green_on_black); + auto num = symbol->num; + auto entsize = symbol->entsize; + auto shndx = symbol->shndx; auto begin = &symbol->sections; auto end = begin + num; - for (auto section = begin; section != end; ++section) - { - uint32_t const sh_name = section->sh_name; - text::write("Section name: ", text::common_attributes::green_on_black); - text::write_number(sh_name, text::common_attributes::green_on_black); - - uint32_t const sh_type = section->sh_type; - text::write("Section type: ", text::common_attributes::green_on_black); - text::write_number(sh_type, text::common_attributes::green_on_black); - - uint64_t const sh_flags = section->sh_flags; - text::write("Section flags: ", text::common_attributes::green_on_black); - text::write_number(sh_flags, text::common_attributes::green_on_black); - uint64_t const sh_addr = section->sh_addr; - text::write("Section address: ", text::common_attributes::green_on_black); - text::write_number(sh_addr, text::common_attributes::green_on_black); - - uint64_t const sh_offset = section->sh_offset; - text::write("Section offset: ", text::common_attributes::green_on_black); - text::write_number(sh_offset, text::common_attributes::green_on_black); - - uint64_t const sh_size = section->sh_size; - text::write("Section size: ", text::common_attributes::green_on_black); - text::write_number(sh_size, text::common_attributes::green_on_black); - - uint32_t const sh_link = section->sh_link; - text::write("Section link: ", text::common_attributes::green_on_black); - text::write_number(sh_link, text::common_attributes::green_on_black); - - uint32_t const sh_info = section->sh_info; - text::write("Section info: ", text::common_attributes::green_on_black); - text::write_number(sh_info, text::common_attributes::green_on_black); - - uint64_t const sh_addralign = section->sh_addralign; - text::write("Section address align: ", text::common_attributes::green_on_black); - text::write_number(sh_addralign, text::common_attributes::green_on_black); - - uint64_t const sh_entsize = section->sh_entsize; - text::write("Section entry size: ", text::common_attributes::green_on_black); - text::write_number(sh_entsize, text::common_attributes::green_on_black); + /* + * Loop over the elf section to access the information needed. + * Sections are defined in the header file and are padded so that each + * Section starts at an 8-bytes aligned adress. + * + * The increment part aligns the size to an 8-byte address. + */ + for (auto section = begin; section != end; + section = (teachos::arch::memory::elf_section_header *)(((uint8_t *)section) + ((entsize + 7) & ~7))) + { + auto sh_name = section->sh_name; + auto sh_type = section->sh_type; + auto sh_flags = section->sh_flags; + auto sh_addr = section->sh_addr; + auto sh_offset = section->sh_offset; + auto sh_size = section->sh_size; + auto sh_link = section->sh_link; + auto sh_info = section->sh_info; + auto sh_addralign = section->sh_addralign; + auto sh_entsize = section->sh_entsize; } } @@ -127,11 +80,8 @@ namespace teachos::arch::kernel (arch::memory::multi_boot_info *)arch::boot::multiboot_information_pointer; auto multiboot_tag = &(multiboot_information_pointer->tags); - text::write("Multiboot Start: ", text::common_attributes::green_on_black); - text::write_number(arch::boot::multiboot_information_pointer, text::common_attributes::green_on_black); - text::write("Multiboot End: ", text::common_attributes::green_on_black); - text::write_number(arch::boot::multiboot_information_pointer + multiboot_information_pointer->total_size, - text::common_attributes::green_on_black); + auto multiboot_start = arch::boot::multiboot_information_pointer; + auto multiboot_end = arch::boot::multiboot_information_pointer + multiboot_information_pointer->total_size; /* * Loop over the multiboot2 tags to access the information needed. -- cgit v1.2.3