aboutsummaryrefslogtreecommitdiff
path: root/kern
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 /kern
parent2b8fafa2bddc48ddec047de517115c8e65ee61e8 (diff)
downloadteachos-4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd.tar.xz
teachos-4edbe94ce1266c9acc6a695fedf1d2edd4ce11cd.zip
build: factor out kernel API
Diffstat (limited to 'kern')
-rw-r--r--kern/CMakeLists.txt18
-rw-r--r--kern/include/kern/error.hpp13
-rw-r--r--kern/include/kern/print.hpp26
-rw-r--r--kern/src/abort.cpp3
-rw-r--r--kern/src/error.cpp19
-rw-r--r--kern/src/kstd.cpp10
-rw-r--r--kern/src/main.cpp14
-rw-r--r--kern/src/print.cpp51
8 files changed, 0 insertions, 154 deletions
diff --git a/kern/CMakeLists.txt b/kern/CMakeLists.txt
deleted file mode 100644
index 677fdc2..0000000
--- a/kern/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-add_library("kern" OBJECT)
-add_library("os::kern" ALIAS "kern")
-
-target_sources("kern" PRIVATE
- "src/abort.cpp"
- "src/error.cpp"
- "src/kstd.cpp"
- "src/main.cpp"
- "src/print.cpp"
-)
-
-target_include_directories("kern" PUBLIC
- "include"
-)
-
-target_link_libraries("kern" PUBLIC
- "arch::any"
-)
diff --git a/kern/include/kern/error.hpp b/kern/include/kern/error.hpp
deleted file mode 100644
index e58b9f1..0000000
--- a/kern/include/kern/error.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef TEACHOS_KERN_ERROR_HPP
-#define TEACHOS_KERN_ERROR_HPP
-
-#include <source_location>
-#include <string_view>
-
-namespace teachos
-{
- [[noreturn]]
- auto panic(std::string_view message, std::source_location = std::source_location::current()) -> void;
-}
-
-#endif
diff --git a/kern/include/kern/print.hpp b/kern/include/kern/print.hpp
deleted file mode 100644
index fc9b5d6..0000000
--- a/kern/include/kern/print.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#ifndef TEACHOS_KERN_PRINT_HPP
-#define TEACHOS_KERN_PRINT_HPP
-
-#include <string_view>
-
-namespace teachos
-{
-
- using print_handler = auto(std::string_view) -> void;
- using println_handler = auto(std::string_view) -> void;
-
- auto print(std::string_view text) -> void;
- auto println(std::string_view text) -> void;
-
- auto print_error(std::string_view text) -> void;
- auto println_error(std::string_view text) -> void;
-
- auto set_print_handler(print_handler handler) -> print_handler *;
- auto set_println_handler(println_handler handler) -> print_handler *;
- auto set_print_error_handler(print_handler handler) -> print_handler *;
- auto set_println_error_handler(println_handler handler) -> print_handler *;
-
-} // namespace teachos
-
-#endif
diff --git a/kern/src/abort.cpp b/kern/src/abort.cpp
deleted file mode 100644
index 6db0b74..0000000
--- a/kern/src/abort.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "kern/error.hpp"
-
-extern "C" [[noreturn]] auto abort() -> void { teachos::panic("Abort called"); }
diff --git a/kern/src/error.cpp b/kern/src/error.cpp
deleted file mode 100644
index a5229fd..0000000
--- a/kern/src/error.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "kern/error.hpp"
-
-#include "arch/system.hpp"
-#include "kern/print.hpp"
-
-namespace teachos
-{
-
- auto panic(std::string_view message, std::source_location location) -> void
- {
- println_error("!!!Kernel Panic!!! ");
- println_error(message);
- println_error(location.file_name());
- println_error(location.function_name());
-
- arch::system::halt();
- }
-
-} // namespace teachos
diff --git a/kern/src/kstd.cpp b/kern/src/kstd.cpp
deleted file mode 100644
index 1b7050b..0000000
--- a/kern/src/kstd.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "kern/error.hpp"
-
-#include <kstd/bits/os.hpp>
-
-namespace kstd::os
-{
-
- auto panic(std::string_view message, std::source_location location) -> void { teachos::panic(message, location); }
-
-} // namespace kstd::os \ No newline at end of file
diff --git a/kern/src/main.cpp b/kern/src/main.cpp
deleted file mode 100644
index b99fb37..0000000
--- a/kern/src/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "arch/io.hpp"
-#include "arch/memory.hpp"
-#include "kern/error.hpp"
-#include "kern/print.hpp"
-
-auto main() -> int
-{
- teachos::arch::io::init();
- teachos::println("[OS] IO subsystem initialized.");
-
- teachos::arch::memory::init();
-
- teachos::panic("Architecture specific main returned!");
-}
diff --git a/kern/src/print.cpp b/kern/src/print.cpp
deleted file mode 100644
index 2c8539b..0000000
--- a/kern/src/print.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-
-#include "kern/print.hpp"
-
-#include <string_view>
-
-namespace teachos
-{
- namespace
- {
- constinit auto noop = [](std::string_view) {};
-
- constinit auto current_print_handler = static_cast<print_handler *>(noop);
- constinit auto current_println_handler = static_cast<println_handler *>(noop);
- constinit auto current_print_error_handler = static_cast<print_handler *>(noop);
- constinit auto current_println_error_handler = static_cast<println_handler *>(noop);
- } // namespace
-
- auto print(std::string_view text) -> void { current_print_handler(text); }
- auto println(std::string_view text) -> void { current_println_handler(text); }
- auto print_error(std::string_view text) -> void { current_print_error_handler(text); }
- auto println_error(std::string_view text) -> void { current_println_error_handler(text); }
-
- auto set_print_handler(print_handler handler) -> print_handler *
- {
- auto old = current_print_handler;
- current_print_handler = handler;
- return old;
- }
-
- auto set_println_handler(println_handler handler) -> print_handler *
- {
- auto old = current_println_handler;
- current_println_handler = handler;
- return old;
- }
-
- auto set_print_error_handler(print_handler handler) -> print_handler *
- {
- auto old = current_print_error_handler;
- current_print_error_handler = handler;
- return old;
- }
-
- auto set_println_error_handler(println_handler handler) -> print_handler *
- {
- auto old = current_println_error_handler;
- current_println_error_handler = handler;
- return old;
- }
-
-} // namespace teachos