diff options
| -rw-r--r-- | arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp | 108 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/multiboot/info.hpp | 55 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/multiboot/memory_map.hpp | 34 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/multiboot/reader.hpp | 11 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/page_entry.hpp | 16 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/page_mapper.hpp | 17 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/paging/page_table.hpp | 33 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/video/vga/text.hpp | 26 | ||||
| -rw-r--r-- | arch/x86_64/src/exception_handling/abort.cpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 1 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_table.cpp | 14 | ||||
| -rw-r--r-- | include/memory/asm_pointer.hpp | 4 |
13 files changed, 175 insertions, 150 deletions
diff --git a/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp b/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp index 7b1bb16..a1b771e 100644 --- a/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp +++ b/arch/x86_64/include/arch/memory/allocator/area_frame_allocator.hpp @@ -29,7 +29,7 @@ namespace teachos::arch::memory::allocator /** * @brief Allocate memory by finding and returning a free physical_frame. * - * The physical_frame allocation executes multiple checks before returning + * @note The physical_frame allocation executes multiple checks before returning * the physical_frame that is available to allocate. It must at least * do the following: * - check if the next_free_frame is within the current_area diff --git a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp index 72767a8..fc8cb15 100644 --- a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp @@ -8,33 +8,35 @@ namespace teachos::arch::memory::multiboot { /** - * @brief Defines all elf section types an elf section header can have. See - * https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html for more information. + * @brief Defines all elf section types an elf section header can have. + * + * @note See https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html for more information. */ enum struct elf_section_type : uint32_t { - INACTIVE, ///< (SHT_NULL) Unused, meaning all values are zeroed out - PROGRAMM, ///< (SHT_PROGBITS) Program data (DATA, CODE) - SYMBOL_TABLE, ///< (SHT_SYMBTAB) Contains actual entries pointed to in symbol hash table - STRING_TABLE, ///< (SHT_STRTAB) Contains symbols, section and deubbging null-terminated strings - RELOCATION_ENTRY_WITH_ADDENDS, ///< (SHT_RELA) Only used on 64 bit systems - SYMBOL_HASH_TABLE, ///< (SHT_HASH) Hash table used by dynamic linker to locate symbols - DYNAMIC, ///< (SHT_DYNAMIC) Contains dynamic linking information - NOTE, ///< (SHT_NOTE) Stores information that marks files in some way - EMPTY, ///< (SHT_NOBITS) Program data section, that occupies no space in the file (.bss) - RELOCATION_ENTRY_WITHOUT_ADDENDS, ///< (SHT_REL) Only used on 32 bit systems - UNSPECIFIED, ///< (SHT_SHLIB) Reserved but has unspecified semantics - DYNAMIC_SYMBOL_TABLE, ///< (SHT_DYNSYM) Holds minimal set of symbols adequate for dynamic linking - INITALIZATION_FUNCTION_ARRAY = 14, ///< (SHT_INIT_ARRAY) Array of pointers to intialization functions () -> void - TERMINATION_FUNCTION_ARRAY, ///< (SHT_FINI_ARRAY) Array of pointers to termination functions () -> void + INACTIVE, ///< (SHT_NULL) Unused, meaning all values are zeroed out. + PROGRAMM, ///< (SHT_PROGBITS) Program data (DATA, CODE). + SYMBOL_TABLE, ///< (SHT_SYMBTAB) Contains actual entries pointed to in symbol hash table. + STRING_TABLE, ///< (SHT_STRTAB) Contains symbols, section and deubbging null-terminated strings. + RELOCATION_ENTRY_WITH_ADDENDS, ///< (SHT_RELA) Only used on 64 bit systems. + SYMBOL_HASH_TABLE, ///< (SHT_HASH) Hash table used by dynamic linker to locate symbols. + DYNAMIC, ///< (SHT_DYNAMIC) Contains dynamic linking information. + NOTE, ///< (SHT_NOTE) Stores information that marks files in some way. + EMPTY, ///< (SHT_NOBITS) Program data section, that occupies no space in the file (.bss). + RELOCATION_ENTRY_WITHOUT_ADDENDS, ///< (SHT_REL) Only used on 32 bit systems. + UNSPECIFIED, ///< (SHT_SHLIB) Reserved but has unspecified semantics. + DYNAMIC_SYMBOL_TABLE, ///< (SHT_DYNSYM) Holds minimal set of symbols adequate for dynamic linking. + INITALIZATION_FUNCTION_ARRAY = 14, ///< (SHT_INIT_ARRAY) Array of pointers to intialization functions () -> void. + TERMINATION_FUNCTION_ARRAY, ///< (SHT_FINI_ARRAY) Array of pointers to termination functions () -> void. PRE_INITALIZATION_FUNCTION_ARRAY ///< (SHT_PRE_INIT_ARRAY) Array of pointers to functions invoked before other - ///< initalization functions () -> void + ///< initalization functions () -> void. }; /** * @brief Defines helper function for all states that the elf section flags of an elf section header can - * have. See https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html - * See https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html for more information. + * have. + * + * @note See https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html for more information. */ struct elf_section_flags { @@ -63,9 +65,9 @@ namespace teachos::arch::memory::multiboot COMPRESSED = 1U << 11U, ///< (SHF_COMPRESSED) Section contains compressed data. SPECIAL_ORDERING_REQUIREMENTS = 1U << 30U, ///< (SHF_ORDERED) Section has special ordering requirements, meaning it - ///< should be ordered in relation to other sections of the same type + ///< should be ordered in relation to other sections of the same type. EXCLUDED_UNLESS_REFERENCED_OR_ALLOCATED = 1U << 31U, ///< (SHF_EXCLUDE)Section is excluded unless referenced or - ///< allocated, used for LTO (Link-Time Optimizations) + ///< allocated, used for LTO (Link-Time Optimizations). }; /** @@ -81,20 +83,21 @@ namespace teachos::arch::memory::multiboot } /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset, meaning that all - * bits that are set in the given std::bitset also have to be set in the underlyng std::bitset. Any additional bits - * that are set are not relevant. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * + * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng + * std::bitset. Any additional bits that are set are not relevant. * * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset + * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. */ auto contains_flags(std::bitset<64U> other) const -> bool; /** - * @brief Allows to compare the underlying std::bitset of two instances + * @brief Allows to compare the underlying std::bitset of two instances. * - * @param other Other instance that we want to compare with - * @return Whether the underlying std::bitset of both types is the same + * @param other Other instance that we want to compare with. + * @return Whether the underlying std::bitset of both types is the same. */ auto operator==(elf_section_flags const & other) const -> bool = default; @@ -106,33 +109,35 @@ namespace teachos::arch::memory::multiboot /** * @brief Defines the data included in a section header, where each section has exactly one section header. - * See https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html for more information + * + * @note See https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html for more information. */ struct elf_section_header { - uint32_t name_table_index; ///< Index into the section header string table, specifies the name of the section - elf_section_type type; ///< Categorizes the sections content and semantics - elf_section_flags flags; ///< 1-bit flgas that describe section attributes + uint32_t name_table_index; ///< Index into the section header string table, specifies the name of the section. + elf_section_type type; ///< Categorizes the sections content and semantics. + elf_section_flags flags; ///< 1-bit flgas that describe section attributes. uint64_t virtual_address; ///< If section appears in memory image of a process, gives address at which the sections - ///< first byte should reside, otherwise 0 + ///< first byte should reside, otherwise 0. uint64_t file_offset; ///< Offset from the beginning of the file to the first byte in the section. SHT_NOBITS - ///< contains the conceptual placement instead (because it occupies no space in the file) - uint64_t section_size; ///< Complete section size in bytes, SHT_NOBITS may have non-zero value but will always - ///< occupy no space in the file - uint32_t other_section; ///< Section header table index link, behaviour varies on type - ///< https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#sh_link + ///< contains the conceptual placement instead (because it occupies no space in the file). + uint64_t section_size; ///< Complete section size in bytes, SHT_NOBITS may have non-zero value but will always + ///< occupy no space in the file. + uint32_t other_section; ///< Section header table index link, behaviour varies on type + ///< https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#sh_link. uint32_t additional_information; ///< Extra information, behaviour varies on type - ///< https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#sh_link + ///< https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html#sh_link. uint64_t address_alignment; ///< Possible address alignment constraints. Value of virutal_address must be 0 % value - ///< of address_alignment. Value 0 or 1 mean no alignment constraints + ///< of address_alignment. Value 0 or 1 mean no alignment constraints. uint64_t fixed_table_entry_size; ///< If sections holds table with fixed-sized entries, this gives the size in - ///< bytes of each entry + ///< bytes of each entry. /** * @brief Detect whether a section header is inactive or not, should always be the case for the first entry in the - * sections table + * sections table. + * * @return Whether the current section header is actually null or not, requires all fields besides section_size and - * other_section to contain 0 + * other_section to contain 0. */ auto is_null() const -> bool; }; @@ -140,17 +145,18 @@ namespace teachos::arch::memory::multiboot /** * @brief Defines an entry in the multi_boot_tag array of the multi_boot_info struct, of type * multi_boot_tag_type::ELF_SECTIONS. - * The first section in the sections array will always be INACTIVE, there can only ever be one DYNAMIC section and - * only either one DYNAMIC_SYMBOL_TABLE or SYMBOL_TABLE. + * + * @note The first section in the sections array will always be INACTIVE, there can only ever be one DYNAMIC section + * and only either one DYNAMIC_SYMBOL_TABLE or SYMBOL_TABLE. */ struct elf_symbols_section_header { - tag info; ///< Basic multi_boot_tag information - uint32_t number_of_sections; ///< Number of sections in the sections array - uint32_t entry_size; ///< Size of each entry in the sections array - uint32_t section_index; ///< Index to the string table used for symbol names - std::byte end; ///< Marks the end of the tag, used to mark the beginning of any additional data - ///< contained in the section, to ensure byte alignment is actually 4 byte + tag info; ///< Basic multi_boot_tag information. + uint32_t number_of_sections; ///< Number of sections in the sections array. + uint32_t entry_size; ///< Size of each entry in the sections array. + uint32_t section_index; ///< Index to the string table used for symbol names. + std::byte end; ///< Marks the end of the tag, used to mark the beginning of any additional data. + ///< contained in the section, to ensure byte alignment is actually 4 byte. }; } // namespace teachos::arch::memory::multiboot diff --git a/arch/x86_64/include/arch/memory/multiboot/info.hpp b/arch/x86_64/include/arch/memory/multiboot/info.hpp index a0f095f..7924993 100644 --- a/arch/x86_64/include/arch/memory/multiboot/info.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/info.hpp @@ -7,35 +7,36 @@ namespace teachos::arch::memory::multiboot { /** * @brief Defines all possible types a multiboot2 tag structure can have. - * See + * + * @note See * https://github.com/rhboot/grub2/blob/fedora-39/include/multiboot2.h for more information on the structure of the * tag headers and see https://github.com/rhboot/grub2/blob/fedora-39/include/multiboot.h for more information on the * actual header contents and their following data. */ enum struct tag_type : uint32_t { - END, ///< Signals final tag for the multiboot2 information structure - CMDLINE, ///< Contains the command line string - BOOT_LOADER_NAME, ///< Contains the name of the boot loader booting the kernel - MODULE, ///< Indicates the boot module which was loaded along the kernel image - BASIC_MEMORY_INFO, ///< Contains the amount of lower (0MB start address) and upper memory (1MB start address) - BOOTDEV, ///< Indicates which BIOS disk device the hoot loader has loaded the OS image from - MEMORY_MAP, ///< Describes the memory layout of the system with individual areas and their flags - VBE_INFO, ///< Includes information to access and utilize the device GPU - FRAMEBUFFER, ///< VBE framebuffer information - ELF_SECTIONS, ///< Includes list of all section headers from the loaded ELF kernel - APM_INFO, ///< Advanced Power Management information - EFI32, ///< EFI 32 bit system table pointer - EFI64, ///< EFI 64 bit system table pointer - SMBIOS, ///< Contains copy of all Sytem Management BIOS tables - ACPI_OLD, ///< Contains copy of RSDP as defined per ACPI1.0 specification - ACPI_NEW, ///< Contains copy of RSDP as defined per ACPI2.0 or later specification - NETWORK, ///< Contains network information specified specified as DHCP - EFI_MEMORY_MAP, ///< Contains EFI memory map - EFI_BS_NOT_TERMINATED, ///< Indicated ExitBootServies wasn't called - EFI32_IMAGE_HANDLE, ///< EFI 32 bit image handle pointer - EFI64_IMAGE_HANDLE, ///< EFI 64 bit imae handle pointer - LOAD_BASE_ADDRESS ///< Contains image load base physical address + END, ///< Signals final tag for the multiboot2 information structure. + CMDLINE, ///< Contains the command line string. + BOOT_LOADER_NAME, ///< Contains the name of the boot loader booting the kernel. + MODULE, ///< Indicates the boot module which was loaded along the kernel image. + BASIC_MEMORY_INFO, ///< Contains the amount of lower (0MB start address) and upper memory (1MB start address). + BOOTDEV, ///< Indicates which BIOS disk device the hoot loader has loaded the OS image from. + MEMORY_MAP, ///< Describes the memory layout of the system with individual areas and their flags. + VBE_INFO, ///< Includes information to access and utilize the device GPU. + FRAMEBUFFER, ///< VBE framebuffer information. + ELF_SECTIONS, ///< Includes list of all section headers from the loaded ELF kernel. + APM_INFO, ///< Advanced Power Management information. + EFI32, ///< EFI 32 bit system table pointer. + EFI64, ///< EFI 64 bit system table pointer. + SMBIOS, ///< Contains copy of all Sytem Management BIOS tables. + ACPI_OLD, ///< Contains copy of RSDP as defined per ACPI1.0 specification. + ACPI_NEW, ///< Contains copy of RSDP as defined per ACPI2.0 or later specification. + NETWORK, ///< Contains network information specified specified as DHCP. + EFI_MEMORY_MAP, ///< Contains EFI memory map. + EFI_BS_NOT_TERMINATED, ///< Indicated ExitBootServies wasn't called. + EFI32_IMAGE_HANDLE, ///< EFI 32 bit image handle pointer. + EFI64_IMAGE_HANDLE, ///< EFI 64 bit imae handle pointer. + LOAD_BASE_ADDRESS ///< Contains image load base physical address. }; /** @@ -44,8 +45,8 @@ namespace teachos::arch::memory::multiboot */ struct tag { - tag_type type; ///< Specific type of this multi_boot_tag entry, used to differentiate handling - uint32_t size; ///< Total size of this multi_boot_tag entry with all fields of the actual type + tag_type type; ///< Specific type of this multi_boot_tag entry, used to differentiate handling. + uint32_t size; ///< Total size of this multi_boot_tag entry with all fields of the actual type. }; /** @@ -54,8 +55,8 @@ namespace teachos::arch::memory::multiboot */ struct info_header { - uint32_t total_size; ///< Total size of all multiboot::tags and their data - alignas(8) struct tag tags; ///< Specific tags + uint32_t total_size; ///< Total size of all multiboot::tags and their data. + alignas(8) struct tag tags; ///< Specific tags. }; } // namespace teachos::arch::memory::multiboot diff --git a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp index ecf3975..1a38a30 100644 --- a/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/memory_map.hpp @@ -11,25 +11,27 @@ namespace teachos::arch::memory::multiboot */ enum struct memory_area_type : uint32_t { - AVAILABLE = 1, ///< Region is available for use by the OS - RESERVED, ///< Region is reserved by firmware or bootloader and should not be used by OS - ACPI_AVAILABLE, ///< Region is reclaimable by OS after ACPI event - RESERVED_HIBERNATION, ///< Region is used for Non-volatile Storage (NVS) - DEFECTIVE ///< Region is defective or unusable + AVAILABLE = 1, ///< Region is available for use by the OS. + RESERVED, ///< Region is reserved by firmware or bootloader and should not be used by OS. + ACPI_AVAILABLE, ///< Region is reclaimable by OS after ACPI event. + RESERVED_HIBERNATION, ///< Region is used for Non-volatile Storage (NVS). + DEFECTIVE ///< Region is defective or unusable. }; /** - * @brief Defines an entry in the entries array of the memory_map struct. Has to have all padding stripped between the - * individual values, because the size of the entry needs to be exactly 24 bytes and not one byte more. See + * @brief Defines an entry in the entries array of the memory_map struct. + * + * @note Has to have all padding stripped between the individual values, because the size of the entry needs to be + * exactly 24 bytes and not one byte more. See * https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Packed-Structures.html for more information on the * used attribute. */ struct __attribute__((packed)) memory_area { - uint32_t size; ///< Size of this structure in bytes - uint64_t base_address; ///< Base address the memory region starts at - uint64_t area_length; ///< Size of the memory region, added to base_address results in the final address - memory_area_type type; ///< Specific type of memory the region can contain + uint32_t size; ///< Size of this structure in bytes. + uint64_t base_address; ///< Base address the memory region starts at. + uint64_t area_length; ///< Size of the memory region, added to base_address results in the final address. + memory_area_type type; ///< Specific type of memory the region can contain. }; /** @@ -38,10 +40,10 @@ namespace teachos::arch::memory::multiboot */ struct memory_map_header { - tag info; ///< Basic multi_boot_tag information - uint32_t entry_size; ///< Size of each entry in the memory_area array. Guaranteed multiple of 8 - uint32_t entry_version; ///< Version of the entries, currently 0 - struct memory_area entries; ///< Specific memory regions + tag info; ///< Basic multi_boot_tag information. + uint32_t entry_size; ///< Size of each entry in the memory_area array. Guaranteed multiple of 8. + uint32_t entry_version; ///< Version of the entries, currently 0. + struct memory_area entries; ///< Specific memory regions. }; /** @@ -64,7 +66,7 @@ namespace teachos::arch::memory::multiboot memory_area & operator*() const; /** - * @brief Post increment operator. Returns a copy of the value + * @brief Post increment operator. Returns a copy of the value. * * @return Copy of the incremented underlying address. */ diff --git a/arch/x86_64/include/arch/memory/multiboot/reader.hpp b/arch/x86_64/include/arch/memory/multiboot/reader.hpp index 2f72980..393db8b 100644 --- a/arch/x86_64/include/arch/memory/multiboot/reader.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/reader.hpp @@ -22,11 +22,12 @@ namespace teachos::arch::memory::multiboot }; /** - * @brief Reads the relevant multiboot2 information data from memory. This is done using the - * multiboot_information_pointer, which marks the start of the multiboot2 data. The indivdual headers we have to read - * are 8 byte aligned, whereas the data contained in those headers does not have to be. All sections that are read - * additionaly receive some sanity to ensure the read address is actually pointing to the expected structure, if they - * are not this method will assert. + * @brief Reads the relevant multiboot2 information data from memory. + * + * @note This is done using the multiboot_information_pointer, which marks the start of the multiboot2 data. The + * indivdual headers we have to read are 8 byte aligned, whereas the data contained in those headers does not have to + * be. All sections that are read additionaly receive some sanity to ensure the read address is actually pointing to + * the expected structure, if they are not this method will assert. * * The memory_information variables are calcualted like this: * - kernel_start: Calculated by getting the lowest address specified in the elf symbols headers. diff --git a/arch/x86_64/include/arch/memory/paging/page_entry.hpp b/arch/x86_64/include/arch/memory/paging/page_entry.hpp index 158af2e..2b3b3f3 100644 --- a/arch/x86_64/include/arch/memory/paging/page_entry.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_entry.hpp @@ -64,20 +64,22 @@ namespace teachos::arch::memory::paging auto set_entry(allocator::physical_frame frame, std::bitset<64U> flags) -> void; /** - * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset, meaning that all - * bits that are set in the given std::bitset also have to be set in the underlyng std::bitset. Any additional bits - * that are set are not relevant. + * @brief Checks if the given std::bitset is a subset or equivalent to the underlying std::bitset. + * + * @note Meaning that all bits that are set in the given std::bitset also have to be set in the underlyng + * std::bitset. Any additional bits that are set are not relevant. * * @param other Flags that we want to compare against and check if the underlying std::bitset has the same bits set. - * @return Whether the given flags are a subset or equivalent with the underlying std::bitset + * @return Whether the given flags are a subset or equivalent with the underlying std::bitset. */ auto contains_flags(std::bitset<64U> other) const -> bool; private: /** - * @brief Extracts the physical address from the underlying bitset read from bit index 12 - 51. Is a 52 bit page - * aligned physical address of the frame of the next page table or the pyhscial address of the frame for P1 page - * tables. + * @brief Extracts the physical address from the underlying bitset read from bit index 12 - 51. + * + * @note Is a 52 bit page aligned physical address of the frame of the next page table or the pyhscial address of + * the frame for P1 page tables. * * @return Extracted physical address of the next page or of the frame for P1 page tables. */ diff --git a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp index a8cca4c..df232ea 100644 --- a/arch/x86_64/include/arch/memory/paging/page_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_mapper.hpp @@ -44,9 +44,10 @@ namespace teachos::arch::memory::paging auto translate_address(std::size_t virtual_address) -> std::optional<std::size_t>; /** - * @brief Maps a virtual page to a physical frame in the page table with the specified flags. Allocates and maps an - * entry in every page level if it does not exists yet down to level 1. If the level 1 page table already exists it - * halts execution instead. + * @brief Maps a virtual page to a physical frame in the page table with the specified flags. + * + * @note Allocates and maps an entry in every page level if it does not exists yet down to level 1. If the level 1 + * page table already exists it halts execution instead. * * @tparam T Type constraint of the allocator, being that is follows the given concept and contains an allocate and * deallocate method. @@ -93,6 +94,8 @@ namespace teachos::arch::memory::paging /** * @brief Allocates the next free frame and then uses that frame to call map_page_to_frame. + * + * @see map_page_to_frame */ template<allocator::FrameAllocator T> auto map_next_free_page_to_frame(T & allocator, virtual_page page, std::bitset<64U> flags) -> void @@ -104,6 +107,8 @@ namespace teachos::arch::memory::paging /** * @brief Gets the corresponding page the given frame has to be contained in and uses that to call map_page_to_frame. + * + * @see map_page_to_frame */ template<allocator::FrameAllocator T> auto identity_map(T & allocator, allocator::physical_frame frame, std::bitset<64U> flags) -> void @@ -113,8 +118,10 @@ namespace teachos::arch::memory::paging } /** - * @brief Unmaps the virtual page from the previously mapped to physical frame and resets the flags. Deallocates and - * unmaps the entry in every page level if this page was the last one up to level 4. + * @brief Unmaps the virtual page from the previously mapped to physical frame and resets the flags. + * + * @note Deallocates and unmaps the entry in every page level if this page was the last one up to level 4 and ensures + * to clear the Translation Lookaside Buffer, so that the unmapped value is removed from cache as well. * * @tparam T Type constraint of the allocator, being that is follows the given concept and contains an allocate and * deallocate method. diff --git a/arch/x86_64/include/arch/memory/paging/page_table.hpp b/arch/x86_64/include/arch/memory/paging/page_table.hpp index 9aaaafb..feb327a 100644 --- a/arch/x86_64/include/arch/memory/paging/page_table.hpp +++ b/arch/x86_64/include/arch/memory/paging/page_table.hpp @@ -8,9 +8,11 @@ namespace teachos::arch::memory::paging constexpr std::size_t PAGE_TABLE_ENTRY_COUNT = 512U; ///< Default entry count of a page table in x86_84 is 512. /** - * @brief Forward delcaration of the page_table, because it should only be accessible over the handle, the actual - * methods or constructor are not defined meaning they are not callable from outside. Instead the struct is only fully - * defined in the implementation (.cpp) file of the page table, and therefore also only accesible in that file. + * @brief Forward delcaration of the page_table, because it should only be accessible over the handle. + * + * @note The actual methods or constructor are not defined meaning they are not callable from outside. Instead the + * struct is only fully defined in the implementation (.cpp) file of the page table, and therefore the memthods are + * only accesible in that file. */ struct page_table; @@ -48,11 +50,11 @@ namespace teachos::arch::memory::paging auto zero_entries() -> void; /** - * @brief Returns the next page table level from the given page table index. + * @brief Returns the next page table level from the given page table index. Meaning we + * use an index into a Level 4 page table to get the according Level 3 page table. * - * Meaning we use an index into a Level 4 page table to get the according Level 3 page table. If this method is - * called with a Level 1 page table it will instead assert and halt execution, because there is no furthere page - * table and mangeling up and returning the physical address would cause hard to debug issues. + * @note If this method is called with a Level 1 page table it will instead assert and halt execution, because there + * is no furthere page table and mangeling up and returning the physical address would cause hard to debug issues. * * @param table_index Index of this page table in the page table one level lower. */ @@ -67,15 +69,16 @@ namespace teachos::arch::memory::paging auto operator[](std::size_t index) const -> entry; /** - * @brief Decrements the page table handle level enum by one. + * @brief Decrements the page table handle level enum by one, is defined so we can use it as a replacement for an + * int index in a range based for loop. * - * Is defined so we can use it as a replacement for an int index in a range based for loop. Will halt execution if - * called with page_table_handle::LEVEL1, because there is no level below. Has to be defined as either a friend - * function or inline header method, because we define an operator of another type. In this instance friend function - * was choosen, because the struct itself also requires the operator, but declaring before the struct is not - * possible, because the enum is in the struct. This is inpossible because the struct requires the operator declared - * before itself to work, and the operator requires the struct declared before itself to work. Furthermore this - * allows the defintion of the method to be done in the cpp, avoiding includes in the header file. + * @note Will halt execution if called with page_table_handle::LEVEL1, because there is no level below. Has to be + * defined as either a friend function or inline header method, because we define an operator of another type. In + * this instance friend function was choosen, because the struct itself also requires the operator, but declaring + * before the struct is not possible, because the enum is in the struct. This is inpossible because the struct + * requires the operator declared before itself to work, and the operator requires the struct declared before itself + * to work. Furthermore this allows the defintion of the method to be done in the cpp, avoiding includes in the + * header file. * * @param value Value we want to decrement on * @return level New level value decrement by one, meaning the level is also decrement by one Level4 --> Level3, ... diff --git a/arch/x86_64/include/arch/video/vga/text.hpp b/arch/x86_64/include/arch/video/vga/text.hpp index 690f4aa..f200da4 100644 --- a/arch/x86_64/include/arch/video/vga/text.hpp +++ b/arch/x86_64/include/arch/video/vga/text.hpp @@ -12,14 +12,14 @@ namespace teachos::arch::video::vga::text */ enum struct color : std::uint8_t { - black, ///< Equivalent to HTML color \#000000 - blue, ///< Equivalent to HTML color \#0000AA - green, ///< Equivalent to HTML color \#00AA00 - cyan, ///< Equivalent to HTML color \#00AAAA - red, ///< Equivalent to HTML color \#AA0000 - purple, ///< Equivalent to HTML color \#AA00AA - brown, ///< Equivalent to HTML color \#AA5500 - gray, ///< Equivalent to HTML color \#AAAAAA + black, ///< Equivalent to HTML color \#000000. + blue, ///< Equivalent to HTML color \#0000AA. + green, ///< Equivalent to HTML color \#00AA00. + cyan, ///< Equivalent to HTML color \#00AAAA. + red, ///< Equivalent to HTML color \#AA0000. + purple, ///< Equivalent to HTML color \#AA00AA. + brown, ///< Equivalent to HTML color \#AA5500. + gray, ///< Equivalent to HTML color \#AAAAAA. }; /** @@ -37,21 +37,21 @@ namespace teachos::arch::video::vga::text enum struct background_flag : bool { none, ///< Apply no flag e.g., keep color as is. - blink_or_bright, ///< Make the cell blink or more intense, dependent on the VGA configuration + blink_or_bright, ///< Make the cell blink or more intense, dependent on the VGA configuration. }; /** * @brief The VGA text mode attribute. * - * In the text mode of VGA, every code point being presented is followed by an attribute description. This allows for - * the modification of how the relevant "cell" is presented. + * @note In the text mode of VGA, every code point being presented is followed by an attribute description. This + * allows for the modification of how the relevant "cell" is presented. * * @see vga::text::foreground_flag * @see vga::text::background_flag */ struct attribute { - color foreground_color : 3; ///< The foreground color of the cell, e.g. the color of the code point + color foreground_color : 3; ///< The foreground color of the cell, e.g. the color of the code point. enum foreground_flag foreground_flag : 1; ///< The foreground color modification flag of the cell. color bacground_color : 3; ///< The background color of the cell. enum background_flag background_flag : 1; ///< The background color modification flag of the cell. @@ -60,7 +60,7 @@ namespace teachos::arch::video::vga::text static_assert(sizeof(attribute) == 1, "The VGA text mode attribute must fit inside a single byte."); /** - * @brief Commonly used VGA text mode attributes + * @brief Commonly used VGA text mode attributes. */ namespace common_attributes { diff --git a/arch/x86_64/src/exception_handling/abort.cpp b/arch/x86_64/src/exception_handling/abort.cpp index e331d34..e12e4cb 100644 --- a/arch/x86_64/src/exception_handling/abort.cpp +++ b/arch/x86_64/src/exception_handling/abort.cpp @@ -7,8 +7,8 @@ namespace teachos::arch::exception_handling /** * @brief Override for the newlib abort function. * - * newlib defines @p ::abort as a weak symbol, thus allowing implementations to override it by simply providing a - * matching implementation. Since the default implemenatation calls a number of functions the kernel does not + * @note newlib defines @p ::abort as a weak symbol, thus allowing implementations to override it by simply providing + * a matching implementation. Since the default implemenatation calls a number of functions the kernel does not * currently implement, @p ::abort gets overridden to simply panic. */ extern "C" auto abort() -> void { panic("Terminate was called, possibly due to an unhandled exception"); } diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 3e25d2d..ad1eb39 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -10,7 +10,6 @@ namespace teachos::arch::kernel { - auto main() -> void { video::vga::text::clear(); diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp index 939f3b1..555d38a 100644 --- a/< |
