aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-07-24 15:31:31 +0000
committerFelix Morgner <felix.morgner@ost.ch>2025-07-24 15:31:31 +0000
commit4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd (patch)
tree6738e5ab071075c15beccc59b3f79f53477f477d /arch
parent2b8fafa2bddc48ddec047de517115c8e65ee61e8 (diff)
downloadteachos-4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd.tar.xz
teachos-4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd.zip
build: factor out kernel API
Diffstat (limited to 'arch')
-rw-r--r--arch/CMakeLists.txt26
-rw-r--r--arch/include/arch/io.hpp9
-rw-r--r--arch/include/arch/memory.hpp9
-rw-r--r--arch/include/arch/system.hpp9
-rw-r--r--arch/x86_64/CMakeLists.txt3
-rw-r--r--arch/x86_64/src/io.cpp44
-rw-r--r--arch/x86_64/src/memory.cpp12
-rw-r--r--arch/x86_64/src/system.cpp6
8 files changed, 37 insertions, 81 deletions
diff --git a/arch/CMakeLists.txt b/arch/CMakeLists.txt
index 83da439..516bfe9 100644
--- a/arch/CMakeLists.txt
+++ b/arch/CMakeLists.txt
@@ -1,27 +1,3 @@
-add_library("arch-any" INTERFACE)
-add_library("arch::any" ALIAS "arch-any")
-
-target_sources("arch-any" INTERFACE
- FILE_SET HEADERS
- BASE_DIRS "include"
- FILES
- "include/arch/io.hpp"
- "include/arch/memory.hpp"
- "include/arch/system.hpp"
-)
-
-target_include_directories("arch-any" INTERFACE
- "include"
-)
-
-target_link_libraries("arch-any" INTERFACE
- "libs::kstd"
-
- "c"
- "gcc"
- "stdc++"
-)
+set(KERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/scripts/kernel.ld" PARENT_SCOPE)
add_subdirectory("${CMAKE_SYSTEM_PROCESSOR}")
-
-set(KERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/scripts/kernel.ld" PARENT_SCOPE)
diff --git a/arch/include/arch/io.hpp b/arch/include/arch/io.hpp
deleted file mode 100644
index 8986b9c..0000000
--- a/arch/include/arch/io.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef TEACHOS_ARCH_IO_HPP
-#define TEACHOS_ARCH_IO_HPP
-
-namespace teachos::arch::io
-{
- auto init() -> void;
-}
-
-#endif
diff --git a/arch/include/arch/memory.hpp b/arch/include/arch/memory.hpp
deleted file mode 100644
index 33f7fdd..0000000
--- a/arch/include/arch/memory.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef TEACHOS_ARCH_MEMORY_HPP
-#define TEACHOS_ARCH_MEMORY_HPP
-
-namespace teachos::arch::memory
-{
- auto init() -> void;
-}
-
-#endif
diff --git a/arch/include/arch/system.hpp b/arch/include/arch/system.hpp
deleted file mode 100644
index 73e2463..0000000
--- a/arch/include/arch/system.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef TEACHOS_ARCH_SYSTEM_HPP
-#define TEACHOS_ARCH_SYSTEM_HPP
-
-namespace teachos::arch::system
-{
- [[noreturn]] auto halt() -> void;
-}
-
-#endif
diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt
index 431520e..4cb20b6 100644
--- a/arch/x86_64/CMakeLists.txt
+++ b/arch/x86_64/CMakeLists.txt
@@ -6,8 +6,7 @@ target_include_directories("arch-x86_64" PUBLIC
)
target_link_libraries("arch-x86_64" PUBLIC
- "arch::any"
- "os::kern"
+ "api::kapi"
"libs::multiboot2"
)
diff --git a/arch/x86_64/src/io.cpp b/arch/x86_64/src/io.cpp
index 8e9e411..eab6473 100644
--- a/arch/x86_64/src/io.cpp
+++ b/arch/x86_64/src/io.cpp
@@ -1,28 +1,36 @@
-#include "kern/print.hpp"
+#include "kapi/io.hpp"
+
#include "x86_64/vga/text.hpp"
-namespace teachos::arch::io
+namespace teachos::io
{
auto init() -> void
{
+ x86_64::vga::text::clear();
x86_64::vga::text::cursor(false);
+ }
+
+ auto print(std::string_view text) -> void
+ {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black);
+ }
+
+ auto println(std::string_view text) -> void
+ {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black);
+ x86_64::vga::text::newline();
+ }
+
+ auto print_error(std::string_view text) -> void
+ {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black);
+ }
- teachos::set_print_handler(
- [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black); });
- teachos::set_println_handler([](auto text) {
- x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::green_on_black);
- x86_64::vga::text::newline();
- });
-
- teachos::set_print_error_handler(
- [](auto text) { return x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black); });
- teachos::set_println_error_handler([](auto text) {
- x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black);
- x86_64::vga::text::newline();
- });
-
- teachos::println("[x86-64] Basic VGA text output initialized.");
+ auto println_error(std::string_view text) -> void
+ {
+ x86_64::vga::text::write(text, x86_64::vga::text::common_attributes::red_on_black);
+ x86_64::vga::text::newline();
}
-} // namespace teachos::arch::io
+} // namespace teachos::io
diff --git a/arch/x86_64/src/memory.cpp b/arch/x86_64/src/memory.cpp
index b6901a5..d1c1f03 100644
--- a/arch/x86_64/src/memory.cpp
+++ b/arch/x86_64/src/memory.cpp
@@ -1,6 +1,6 @@
-#include "arch/memory.hpp"
+#include "kapi/memory.hpp"
-#include "kern/error.hpp"
+#include "kapi/system.hpp"
#include "x86_64/boot/boot.hpp"
#include "x86_64/boot/ld.hpp"
@@ -11,7 +11,7 @@
#include <atomic>
-namespace teachos::arch::memory
+namespace teachos::memory
{
using namespace x86_64::memory;
using namespace x86_64::boot;
@@ -36,13 +36,13 @@ namespace teachos::arch::memory
{
if (is_initialized.test_and_set())
{
- teachos::panic("[x86_64] Memory management has already been initialized.");
+ system::panic("[x86_64] Memory management has already been initialized.");
}
auto memory_map = multiboot_information_pointer->maybe_memory_map();
if (!memory_map)
{
- teachos::panic("[x86_64] No memory map available.");
+ system::panic("[x86_64] No memory map available.");
}
auto mem_info = create_memory_information();
@@ -63,4 +63,4 @@ namespace teachos::arch::memory
// video::vga::text::newline();
}
-} // namespace teachos::arch::memory
+} // namespace teachos::memory
diff --git a/arch/x86_64/src/system.cpp b/arch/x86_64/src/system.cpp
index 60ebf0e..2d4c3fe 100644
--- a/arch/x86_64/src/system.cpp
+++ b/arch/x86_64/src/system.cpp
@@ -1,6 +1,6 @@
-#include "arch/system.hpp"
+#include "kapi/system.hpp"
-namespace teachos::arch::system
+namespace teachos::system
{
auto halt() -> void
@@ -9,4 +9,4 @@ namespace teachos::arch::system
__builtin_unreachable();
}
-} // namespace teachos::arch::system
+} // namespace teachos::system