aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-10-29 11:09:42 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-10-29 11:09:42 +0100
commit6434de8ff75a9143847ef529bc209790ac4909b3 (patch)
treea66902303f99f10897cb04e294c55fabf814c49f /arch/x86_64/src
parentacabbacdee68ad80e829bda56ae5363d04646d2d (diff)
downloadteachos-6434de8ff75a9143847ef529bc209790ac4909b3.tar.xz
teachos-6434de8ff75a9143847ef529bc209790ac4909b3.zip
kapi: move frame and address to KAPI
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.cpp2
-rw-r--r--arch/x86_64/src/kapi/memory.cpp8
-rw-r--r--arch/x86_64/src/memory/mmu.cpp6
-rw-r--r--arch/x86_64/src/memory/region_allocator.cpp16
-rw-r--r--arch/x86_64/src/vga/text.cpp6
6 files changed, 20 insertions, 22 deletions
diff --git a/arch/x86_64/src/cpu/registers.cpp b/arch/x86_64/src/cpu/registers.cpp
index 7ade98d..8646829 100644
--- a/arch/x86_64/src/cpu/registers.cpp
+++ b/arch/x86_64/src/cpu/registers.cpp
@@ -2,7 +2,7 @@
#include <type_traits>
-namespace teachos::x86_64::cpu
+namespace teachos::cpu::x86_64
{
auto read_control_register(control_register cr) -> uint64_t
{
@@ -61,4 +61,4 @@ namespace teachos::x86_64::cpu
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);
}
-} // namespace teachos::x86_64::cpu
+} // namespace teachos::cpu::x86_64
diff --git a/arch/x86_64/src/kapi/cio.cpp b/arch/x86_64/src/kapi/cio.cpp
index ac3ae39..eb0142a 100644
--- a/arch/x86_64/src/kapi/cio.cpp
+++ b/arch/x86_64/src/kapi/cio.cpp
@@ -5,7 +5,7 @@
namespace teachos::cio
{
- auto static constinit vga_device = std::optional<x86_64::vga::text::device>{};
+ 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 d1c1f03..55e6ba9 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -1,10 +1,10 @@
#include "kapi/memory.hpp"
+#include "kapi/memory/frame.hpp"
#include "kapi/system.hpp"
#include "x86_64/boot/boot.hpp"
#include "x86_64/boot/ld.hpp"
-#include "x86_64/memory/address.hpp"
#include "x86_64/memory/region_allocator.hpp"
#include <multiboot2/information.hpp>
@@ -13,8 +13,10 @@
namespace teachos::memory
{
- using namespace x86_64::memory;
- using namespace x86_64::boot;
+ using namespace boot::x86_64;
+ using namespace memory::x86_64;
+
+ std::size_t const PLATFORM_FRAME_SIZE{4096};
namespace
{
diff --git a/arch/x86_64/src/memory/mmu.cpp b/arch/x86_64/src/memory/mmu.cpp
index 31783fe..e573b4e 100644
--- a/arch/x86_64/src/memory/mmu.cpp
+++ b/arch/x86_64/src/memory/mmu.cpp
@@ -2,8 +2,10 @@
#include "x86_64/cpu/registers.hpp"
-namespace teachos::x86_64::memory
+namespace teachos::memory::x86_64
{
+ namespace cpu = cpu::x86_64;
+
auto tlb_flush(linear_address address) -> void
{
asm volatile("invlpg (%[input])" : /* no output from call */ : [input] "r"(address) : "memory");
@@ -14,4 +16,4 @@ namespace teachos::x86_64::memory
auto current_value = cpu::read_control_register(cpu::control_register::cr3);
cpu::write_control_register(cpu::control_register::cr3, current_value);
}
-} // namespace teachos::x86_64::memory
+} // namespace teachos::memory::x86_64
diff --git a/arch/x86_64/src/memory/region_allocator.cpp b/arch/x86_64/src/memory/region_allocator.cpp
index c9a98b4..91a5d49 100644
--- a/arch/x86_64/src/memory/region_allocator.cpp
+++ b/arch/x86_64/src/memory/region_allocator.cpp
@@ -1,22 +1,14 @@
-// #include "arch/memory/allocator/region_allocator.hpp"
-
-// #include "arch/exception_handling/assert.hpp"
-
-// #include <algorithm>
-// #include <array>
-// #include <ranges>
-
#include "x86_64/memory/region_allocator.hpp"
-#include "x86_64/memory/address.hpp"
-#include "x86_64/memory/frame.hpp"
+#include "kapi/memory/address.hpp"
+#include "kapi/memory/frame.hpp"
#include <multiboot2/information.hpp>
#include <algorithm>
#include <ranges>
-namespace teachos::x86_64::memory
+namespace teachos::memory::x86_64
{
namespace
{
@@ -92,4 +84,4 @@ namespace teachos::x86_64::memory
}
auto region_allocator::deallocate_frame(frame const &) -> void {}
-} // namespace teachos::x86_64::memory
+} // namespace teachos::memory::x86_64
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index af089fd..8f78ea9 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -9,8 +9,10 @@
#include <string_view>
#include <utility>
-namespace teachos::x86_64::vga::text
+namespace teachos::vga::x86_64::text
{
+ using boot::x86_64::vga_buffer_pointer;
+
namespace
{
auto constinit buffer_offset = std::ptrdiff_t{};
@@ -67,4 +69,4 @@ namespace teachos::x86_64::vga::text
newline();
}
-} // namespace teachos::x86_64::vga::text
+} // namespace teachos::vga::x86_64::text