diff options
Diffstat (limited to 'kapi/src')
| -rw-r--r-- | kapi/src/cio.cpp | 29 | ||||
| -rw-r--r-- | kapi/src/system.cpp | 10 |
2 files changed, 34 insertions, 5 deletions
diff --git a/kapi/src/cio.cpp b/kapi/src/cio.cpp new file mode 100644 index 0000000..aa26d49 --- /dev/null +++ b/kapi/src/cio.cpp @@ -0,0 +1,29 @@ +#include "kapi/cio.hpp" + +#include <optional> +#include <utility> + +namespace teachos::cio +{ + auto constinit null_device = output_device{}; + + auto constinit active_device = &null_device; + + 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 index c3b1c5e..041404e 100644 --- a/kapi/src/system.cpp +++ b/kapi/src/system.cpp @@ -1,16 +1,16 @@ #include "kapi/system.hpp" -#include "kapi/io.hpp" +#include "kapi/cio.hpp" namespace teachos::system { auto panic(std::string_view message, std::source_location location) -> void { - io::println_error("!!!Kernel Panic!!! "); - io::println_error(message); - io::println_error(location.file_name()); - io::println_error(location.function_name()); + cio::println_error("!!!Kernel Panic!!! "); + cio::println_error(message); + cio::println_error(location.file_name()); + cio::println_error(location.function_name()); halt(); } |
