aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/cpu/registers.cpp4
-rw-r--r--arch/x86_64/src/kapi/cio.cpp1
-rw-r--r--arch/x86_64/src/kapi/memory.cpp14
-rw-r--r--arch/x86_64/src/vga/text.cpp7
4 files changed, 17 insertions, 9 deletions
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);