diff options
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/include/arch/memory/frame_allocator.hpp | 34 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/multiboot.hpp | 30 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/video/vga/text.hpp | 2 | ||||
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 24 | ||||
| -rw-r--r-- | arch/x86_64/src/memory/frame_allocator.cpp | 4 |
5 files changed, 47 insertions, 47 deletions
diff --git a/arch/x86_64/include/arch/memory/frame_allocator.hpp b/arch/x86_64/include/arch/memory/frame_allocator.hpp index bcb0882..8dee848 100644 --- a/arch/x86_64/include/arch/memory/frame_allocator.hpp +++ b/arch/x86_64/include/arch/memory/frame_allocator.hpp @@ -11,37 +11,37 @@ namespace teachos::arch::memory const size_t PAGE_FRAME_SIZE = 4096U; } - struct Frame + struct frame { size_t frame_number; - Frame(size_t frame_number) + frame(size_t frame_number) : frame_number(frame_number) { // Nothing to do } - auto containing_address(size_t address) -> Frame { return Frame{address / PAGE_FRAME_SIZE}; } + auto containing_address(size_t address) -> frame { return frame{address / PAGE_FRAME_SIZE}; } }; - struct IFrameAllocator + struct frame_allocator { - virtual auto allocate_frame() -> std::optional<Frame> = 0; - virtual auto deallocate_frame(Frame frame) -> void = 0; + virtual auto allocate_frame() -> std::optional<frame> = 0; + virtual auto deallocate_frame(frame frame) -> void = 0; }; - struct AreaFrameAllocator : public IFrameAllocator + struct area_frame_allocator : public frame_allocator { - Frame next_free_frame; - // std::optional<MemoryArea> current_area; - // MemoryArea * areas; - Frame kernel_start; - Frame kernel_end; - Frame multiboot_start; - Frame multiboot_end; - - auto allocate_frame() -> std::optional<Frame> override; - auto deallocate_frame(Frame frame) -> void override; + frame next_free_frame; + // std::optional<memory_area> current_area; + // memory_area * areas; + frame kernel_start; + frame kernel_end; + frame multiboot_start; + frame multiboot_end; + + auto allocate_frame() -> std::optional<frame> override; + auto deallocate_frame(frame frame) -> void override; }; } // namespace teachos::arch::memory diff --git a/arch/x86_64/include/arch/memory/multiboot.hpp b/arch/x86_64/include/arch/memory/multiboot.hpp index 95e6404..baad25b 100644 --- a/arch/x86_64/include/arch/memory/multiboot.hpp +++ b/arch/x86_64/include/arch/memory/multiboot.hpp @@ -10,7 +10,7 @@ namespace teachos::arch::memory * The gnu boot information format is defined here: * https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Boot-information-format */ - enum class MultibootTagType : uint32_t + enum class multi_boot_tag_type : uint32_t { END, CMDLINE, @@ -36,13 +36,13 @@ namespace teachos::arch::memory LOAD_BASE_ADDRESS }; - struct MultibootTag + struct multi_boot_tag { - MultibootTagType type; + multi_boot_tag_type type; uint32_t size; }; - struct MemoryInfo + struct memory_info { uint32_t type; uint32_t size; @@ -50,19 +50,19 @@ namespace teachos::arch::memory uint32_t mem_upper; }; - struct MultibootInfo + struct multi_boot_info { uint32_t total_size; uint32_t reserved; /* - * field "tags" is an array of MultibootTag, however the array is never + * field "tags" is an array of multi_boot_tag, however the array is never * being accessed by index we don't know the real size at compile-time, * and using an array definition with size 0 produces a compiler error. */ - struct MultibootTag tags; + struct multi_boot_tag tags; }; - enum class MemoryAreaType : uint32_t + enum class memory_area_type : uint32_t { AVAILABLE = 1, RESERVED, @@ -71,25 +71,25 @@ namespace teachos::arch::memory DEFECTIVE }; - struct MemoryArea + struct memory_area { uint64_t base_addr; uint64_t length; - MemoryAreaType type; + memory_area_type type; uint32_t reserved; }; - struct MemoryMap + struct memory_map { - MultibootTag tag; + multi_boot_tag tag; uint32_t entry_size; uint32_t entry_version; /* - * field "entries" is an array of MemoryArea, however the array is never + * field "entries" is an array of memory_area, however the array is never * being accessed by index, we don't know the real size at compile-time, * and using an array definition with size 0 produces a compiler error. */ - struct MemoryArea entries; + struct memory_area entries; }; #define EI_NIDENT 16 @@ -162,7 +162,7 @@ namespace teachos::arch::memory struct elf_symbols_section { - MultibootTag tag; + multi_boot_tag tag; uint16_t num; uint16_t entsize; uint16_t shndx; diff --git a/arch/x86_64/include/arch/video/vga/text.hpp b/arch/x86_64/include/arch/video/vga/text.hpp index 3b484e5..9c4c701 100644 --- a/arch/x86_64/include/arch/video/vga/text.hpp +++ b/arch/x86_64/include/arch/video/vga/text.hpp @@ -130,7 +130,7 @@ namespace teachos::arch::video::vga::text * * @note This function also updates the text mode buffer pointer. * - * @param code_points A integral value to write to the VGA text mode buffer. + * @param value A integral value to write to the VGA text mode buffer. * @param attribute The attribute to apply to the written sequence of code points. * @see vga::text::attribute */ diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index cffbfb8..4d6296a 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -6,7 +6,7 @@ namespace teachos::arch::kernel { - auto print_mem_info(arch::memory::MemoryInfo * mem_info) -> void + auto print_mem_info(arch::memory::memory_info * mem_info) -> void { using namespace video::vga; @@ -19,7 +19,7 @@ namespace teachos::arch::kernel text::write_number(mem_upper, text::common_attributes::green_on_black); } - auto print_memory_map(arch::memory::MemoryMap * mminfo) -> void + auto print_memory_map(arch::memory::memory_map * mminfo) -> void { using namespace video::vga; @@ -45,7 +45,7 @@ namespace teachos::arch::kernel 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<std::underlying_type<arch::memory::MemoryAreaType>::type>(entry->type), + text::write_number(static_cast<std::underlying_type<arch::memory::memory_area_type>::type>(entry->type), text::common_attributes::green_on_black); text::write("Reserved: ", text::common_attributes::green_on_black); @@ -123,8 +123,8 @@ namespace teachos::arch::kernel text::cursor(false); text::write("TeachOS is starting up...", text::common_attributes::green_on_black); - arch::memory::MultibootInfo * multiboot_information_pointer = - (arch::memory::MultibootInfo *)arch::boot::multiboot_information_pointer; + arch::memory::multi_boot_info * multiboot_information_pointer = + (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); @@ -140,19 +140,19 @@ namespace teachos::arch::kernel * * The increment part aligns the size to an 8-byte address. */ - for (auto tag = multiboot_tag; tag->type != arch::memory::MultibootTagType::END; - tag = (arch::memory::MultibootTag *)(((uint8_t *)tag) + ((tag->size + 7) & ~7))) + for (auto tag = multiboot_tag; tag->type != arch::memory::multi_boot_tag_type::END; + tag = (arch::memory::multi_boot_tag *)(((uint8_t *)tag) + ((tag->size + 7) & ~7))) { switch (tag->type) { - case arch::memory::MultibootTagType::BASIC_MEMORY_INFO: - print_mem_info((arch::memory::MemoryInfo *)tag); + case arch::memory::multi_boot_tag_type::BASIC_MEMORY_INFO: + print_mem_info((arch::memory::memory_info *)tag); break; - case arch::memory::MultibootTagType::ELF_SECTIONS: + case arch::memory::multi_boot_tag_type::ELF_SECTIONS: print_elf_sections((arch::memory::elf_symbols_section *)tag); break; - case arch::memory::MultibootTagType::MEMORY_MAP: - print_memory_map((arch::memory::MemoryMap *)tag); + case arch::memory::multi_boot_tag_type::MEMORY_MAP: + print_memory_map((arch::memory::memory_map *)tag); break; default: // All other cases are not important and can be ignored diff --git a/arch/x86_64/src/memory/frame_allocator.cpp b/arch/x86_64/src/memory/frame_allocator.cpp index 425528a..b9d26a5 100644 --- a/arch/x86_64/src/memory/frame_allocator.cpp +++ b/arch/x86_64/src/memory/frame_allocator.cpp @@ -2,8 +2,8 @@ namespace teachos::arch::memory { - auto AreaFrameAllocator::allocate_frame() -> std::optional<Frame> {} + auto area_frame_allocator::allocate_frame() -> std::optional<frame> {} - auto AreaFrameAllocator::deallocate_frame(Frame frame) -> void {} + auto area_frame_allocator::deallocate_frame(frame frame) -> void {} } // namespace teachos::arch::memory |
