diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-12-12 14:26:16 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-12-12 14:26:16 +0100 |
| commit | 4bf9eded3a5d6b007ba79a5716143fa8b3a5aaf6 (patch) | |
| tree | 5ffcfb9b12afd58627a52498f232c798b273a351 /kapi | |
| parent | 5f695cd3519d8a09a53485c08971f49ed92969ff (diff) | |
| download | teachos-4bf9eded3a5d6b007ba79a5716143fa8b3a5aaf6.tar.xz teachos-4bf9eded3a5d6b007ba79a5716143fa8b3a5aaf6.zip | |
kapi: move platform independent implementation
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | kapi/src/cio.cpp | 57 | ||||
| -rw-r--r-- | kapi/src/system.cpp | 20 |
3 files changed, 3 insertions, 85 deletions
diff --git a/kapi/CMakeLists.txt b/kapi/CMakeLists.txt index d0ecb70..e513dba 100644 --- a/kapi/CMakeLists.txt +++ b/kapi/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library("kapi" OBJECT) +add_library("kapi" INTERFACE) add_library("os::kapi" ALIAS "kapi") target_sources("kapi" PUBLIC @@ -16,16 +16,11 @@ target_sources("kapi" PUBLIC "include/kapi/system.hpp" ) -target_sources("kapi" PRIVATE - "src/cio.cpp" - "src/system.cpp" -) - -target_include_directories("kapi" PUBLIC +target_include_directories("kapi" INTERFACE "include" ) -target_link_libraries("kapi" PUBLIC +target_link_libraries("kapi" INTERFACE "libs::kstd" "gcc" diff --git a/kapi/src/cio.cpp b/kapi/src/cio.cpp deleted file mode 100644 index 66493b6..0000000 --- a/kapi/src/cio.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "kapi/cio.hpp" - -#include <optional> -#include <string_view> -#include <utility> - -namespace teachos::cio -{ - namespace - { - struct null_device final : public output_device - { - null_device static instance; - - auto write(std::string_view) -> void override {} - auto writeln(std::string_view) -> void override {} - - auto write_error(std::string_view) -> void override {} - auto writeln_error(std::string_view) -> void override {} - }; - - constinit null_device null_device::instance; - } // namespace - - // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) - constinit auto active_device = static_cast<output_device *>(&null_device::instance); - - auto set_output_device(output_device & device) -> std::optional<output_device *> - { - if (&device == active_device) - { - return {}; - } - return std::exchange(active_device, &device); - } - - auto print(std::string_view text) -> void - { - active_device->write(text); - } - - auto println(std::string_view text) -> void - { - active_device->writeln(text); - } - - auto print_error(std::string_view text) -> void - { - active_device->write_error(text); - } - - auto println_error(std::string_view text) -> void - { - active_device->writeln_error(text); - } - -} // namespace teachos::cio
\ No newline at end of file diff --git a/kapi/src/system.cpp b/kapi/src/system.cpp deleted file mode 100644 index 3ae3f29..0000000 --- a/kapi/src/system.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "kapi/system.hpp" - -#include "kapi/cio.hpp" -#include "kapi/cpu.hpp" - -namespace teachos::system -{ - - [[gnu::weak]] - auto panic(std::string_view message, std::source_location location) -> void - { - cio::println_error("!!!Kernel Panic!!! "); - cio::println_error(message); - cio::println_error(location.file_name()); - cio::println_error(location.function_name()); - - cpu::halt(); - } - -} // namespace teachos::system |
