diff options
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/include/x86_64/memory/region_allocator.hpp | 8 | ||||
| -rw-r--r-- | arch/x86_64/include/x86_64/vga/crtc.hpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/include/x86_64/vga/text.hpp | 26 | ||||
| -rw-r--r-- | arch/x86_64/src/cpu/registers.cpp | 4 | ||||
| -rw-r--r-- | arch/x86_64/src/kapi/cio.cpp | 1 | ||||
| -rw-r--r-- | arch/x86_64/src/kapi/memory.cpp | 14 | ||||
| -rw-r--r-- | arch/x86_64/src/vga/text.cpp | 7 |
7 files changed, 40 insertions, 24 deletions
diff --git a/arch/x86_64/include/x86_64/memory/region_allocator.hpp b/arch/x86_64/include/x86_64/memory/region_allocator.hpp index 913b0bb..4a18a0f 100644 --- a/arch/x86_64/include/x86_64/memory/region_allocator.hpp +++ b/arch/x86_64/include/x86_64/memory/region_allocator.hpp @@ -66,10 +66,10 @@ namespace teachos::memory::x86_64 frame m_next_frame; ///< The physical_frame after the last allocated one. std::optional<multiboot2::memory_map::region> m_current_region; ///< The memory region currently allocated from multiboot2::memory_map m_memory_map; ///< The boot loader supplied memory map. - frame const m_kernel_start; ///< The start address of the kernel code in memory. - frame const m_kernel_end; ///< The end address of the kernel code in memory. - frame const m_multiboot_start; ///< The start address of the multiboot code in memory. - frame const m_multiboot_end; ///< The end address of the multiboot code in memory. + frame m_kernel_start; ///< The start address of the kernel code in memory. + frame m_kernel_end; ///< The end address of the kernel code in memory. + frame m_multiboot_start; ///< The start address of the multiboot code in memory. + frame m_multiboot_end; ///< The end address of the multiboot code in memory. }; } // namespace teachos::memory::x86_64 diff --git a/arch/x86_64/include/x86_64/vga/crtc.hpp b/arch/x86_64/include/x86_64/vga/crtc.hpp index be72ac4..8bdc12d 100644 --- a/arch/x86_64/include/x86_64/vga/crtc.hpp +++ b/arch/x86_64/include/x86_64/vga/crtc.hpp @@ -10,12 +10,12 @@ namespace teachos::vga::x86_64::crtc /** * @brief The address port of the CRT Controller. */ - using address = io::x86_64::port<0x3d4, 1>; + using address = io::x86_64::port<0x3d4, 1>; // NOLINT(cppcoreguidelines-avoid-magic-numbers) /** * @brief The data port of the CRT Controller. */ - using data = io::x86_64::port<0x3d5, 1>; + using data = io::x86_64::port<0x3d5, 1>; // NOLINT(cppcoreguidelines-avoid-magic-numbers) namespace registers { diff --git a/arch/x86_64/include/x86_64/vga/text.hpp b/arch/x86_64/include/x86_64/vga/text.hpp index 858350f..d8919bf 100644 --- a/arch/x86_64/include/x86_64/vga/text.hpp +++ b/arch/x86_64/include/x86_64/vga/text.hpp @@ -54,7 +54,7 @@ namespace teachos::vga::x86_64::text { 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. + color background_color : 3; ///< The background color of the cell. enum background_flag background_flag : 1; ///< The background color modification flag of the cell. }; @@ -68,26 +68,34 @@ namespace teachos::vga::x86_64::text /** * @brief Make the affected cell display with a gray foreground and black background. */ - [[maybe_unused]] constexpr auto gray_on_black = - attribute{color::gray, foreground_flag::none, color::black, background_flag::none}; + [[maybe_unused]] constexpr auto gray_on_black = attribute{.foreground_color = color::gray, + .foreground_flag = foreground_flag::none, + .background_color = color::black, + .background_flag = background_flag::none}; /** * @brief Make the affected cell display with a green foreground and black background. */ - [[maybe_unused]] constexpr auto green_on_black = - attribute{color::green, foreground_flag::none, color::black, background_flag::none}; + [[maybe_unused]] constexpr auto green_on_black = attribute{.foreground_color = color::green, + .foreground_flag = foreground_flag::none, + .background_color = color::black, + .background_flag = background_flag::none}; /** * @brief Make the affected cell display with a green foreground and black background. */ - [[maybe_unused]] constexpr auto red_on_black = - attribute{color::red, foreground_flag::none, color::black, background_flag::none}; + [[maybe_unused]] constexpr auto red_on_black = attribute{.foreground_color = color::red, + .foreground_flag = foreground_flag::none, + .background_color = color::black, + .background_flag = background_flag::none}; /** * @brief Make the affected cell display with a white (gray + intense) foreground and red background. */ - [[maybe_unused]] constexpr auto white_on_red = - attribute{color::gray, foreground_flag::intense, color::red, background_flag::none}; + [[maybe_unused]] constexpr auto white_on_red = attribute{.foreground_color = color::gray, + .foreground_flag = foreground_flag::intense, + .background_color = color::red, + .background_flag = background_flag::none}; } // namespace common_attributes struct device final : teachos::cio::output_device diff --git a/arch/x86_64/src/cpu/registers.cpp b/arch/x86_64/src/cpu/registers.cpp index 8646829..d59776b 100644 --- a/arch/x86_64/src/cpu/registers.cpp +++ b/arch/x86_64/src/cpu/registers.cpp @@ -6,7 +6,7 @@ namespace teachos::cpu::x86_64 { auto read_control_register(control_register cr) -> uint64_t { - uint64_t current_value; + uint64_t current_value{}; switch (cr) { case control_register::cr0: @@ -59,6 +59,6 @@ namespace teachos::cpu::x86_64 auto set_cr0_bit(cr0_flags flag) -> void { auto const cr0 = read_control_register(control_register::cr0); - write_control_register(control_register::cr0, static_cast<std::underlying_type<cr0_flags>::type>(flag) | cr0); + write_control_register(control_register::cr0, static_cast<std::underlying_type_t<cr0_flags>>(flag) | cr0); } } // namespace teachos::cpu::x86_64 diff --git a/arch/x86_64/src/kapi/cio.cpp b/arch/x86_64/src/kapi/cio.cpp index eb0142a..456477a 100644 --- a/arch/x86_64/src/kapi/cio.cpp +++ b/arch/x86_64/src/kapi/cio.cpp @@ -5,6 +5,7 @@ namespace teachos::cio { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) auto static constinit vga_device = std::optional<vga::x86_64::text::device>{}; auto init() -> void diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp index 61d462f..e05fde9 100644 --- a/arch/x86_64/src/kapi/memory.cpp +++ b/arch/x86_64/src/kapi/memory.cpp @@ -19,19 +19,23 @@ namespace teachos::memory namespace { + // NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) auto constinit is_initialized = std::atomic_flag{}; auto constinit allocator = static_cast<frame_allocator *>(nullptr); + // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables) auto create_memory_information() -> x86_64::region_allocator::memory_information { auto const & mbi = boot::x86_64::multiboot_information_pointer.get(); auto map = mbi->memory_map(); - return {std::make_pair(physical_address{&boot::x86_64::_start_physical}, - physical_address{&boot::x86_64::_end_physical}), - std::make_pair(physical_address{std::bit_cast<std::byte *>(mbi)}, - physical_address{std::bit_cast<std::byte *>(mbi) + mbi->size_bytes()}), - map}; + // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) + return {.image_range = std::make_pair(physical_address{&boot::x86_64::_start_physical}, + physical_address{&boot::x86_64::_end_physical}), + .mbi_range = std::make_pair(physical_address{std::bit_cast<std::byte *>(mbi)}, + physical_address{std::bit_cast<std::byte *>(mbi) + mbi->size_bytes()}), + .memory_map = map}; + // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) }; auto create_early_frame_allocator() diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp index 8aa809f..0e0d353 100644 --- a/arch/x86_64/src/vga/text.cpp +++ b/arch/x86_64/src/vga/text.cpp @@ -15,10 +15,12 @@ namespace teachos::vga::x86_64::text namespace { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) auto constinit buffer_offset = std::ptrdiff_t{}; constexpr auto DEFAULT_TEXT_BUFFER_WIDTH = 80U; constexpr auto DEFAULT_TEXT_BUFFER_HEIGHT = 25U; + constexpr auto CURSOR_ENABLED_BIT = 5U; auto write_char(char code_point, attribute attribute) -> void { @@ -29,12 +31,13 @@ namespace teachos::vga::x86_64::text auto device::clear(attribute attribute) -> void { buffer_offset = 0; - std::ranges::fill_n(vga_buffer_pointer.get(), 2000, std::pair{' ', std::bit_cast<std::byte>(attribute)}); + std::ranges::fill_n(vga_buffer_pointer.get(), DEFAULT_TEXT_BUFFER_WIDTH * DEFAULT_TEXT_BUFFER_HEIGHT, + std::pair{' ', std::bit_cast<std::byte>(attribute)}); } auto device::cursor(bool enabled) -> void { - auto cursor_disable_byte = std::byte{!enabled} << 5; + auto cursor_disable_byte = std::byte{!enabled} << CURSOR_ENABLED_BIT; crtc::address::write(crtc::registers::cursor_start); crtc::data::write(crtc::data::read() | cursor_disable_byte); |
