aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/kapi
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/kapi')
-rw-r--r--kernel/src/kapi/cio.cpp36
-rw-r--r--kernel/src/kapi/memory.cpp94
-rw-r--r--kernel/src/kapi/system.cpp21
3 files changed, 0 insertions, 151 deletions
diff --git a/kernel/src/kapi/cio.cpp b/kernel/src/kapi/cio.cpp
deleted file mode 100644
index 01c6420..0000000
--- a/kernel/src/kapi/cio.cpp
+++ /dev/null
@@ -1,36 +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(output_stream, std::string_view) -> void override {}
- };
-
- constinit null_device null_device::instance;
- } // namespace
-
- constinit auto static 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 write(output_stream stream, std::string_view text) -> void
- {
- active_device->write(stream, text);
- }
-
-} // namespace teachos::cio
diff --git a/kernel/src/kapi/memory.cpp b/kernel/src/kapi/memory.cpp
deleted file mode 100644
index ebd4c15..0000000
--- a/kernel/src/kapi/memory.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "kapi/memory.hpp"
-
-#include "kapi/system.hpp"
-
-#include <cstddef>
-#include <optional>
-#include <utility>
-
-namespace teachos::memory
-{
-
- namespace
- {
- struct bad_frame_allocator final : public frame_allocator
- {
- bad_frame_allocator static instance;
-
- auto allocate_many(std::size_t) noexcept -> std::optional<std::pair<frame, std::size_t>> override
- {
- system::panic("Tried to allocate frames without an active allocator.");
- }
-
- auto release_many(std::pair<frame, std::size_t>) -> void override
- {
- system::panic("Tried to release frames without an active allocator.");
- }
- };
-
- struct bad_page_mapper final : public page_mapper
- {
- bad_page_mapper static instance;
-
- auto map(page, frame, flags) -> std::byte * override
- {
- system::panic("Tried to map a page without an active mapper.");
- }
-
- auto unmap(page) -> void override
- {
- system::panic("Tried to unmap a page without an active mapper.");
- }
-
- auto try_unmap(page) noexcept -> bool override
- {
- return false;
- }
- };
-
- constinit bad_frame_allocator bad_frame_allocator::instance{};
- constinit bad_page_mapper bad_page_mapper::instance{};
- } // namespace
-
- constinit auto static active_frame_allocator = static_cast<frame_allocator *>(&bad_frame_allocator::instance);
- constinit auto static active_page_mapper = static_cast<page_mapper *>(&bad_page_mapper::instance);
-
- auto set_frame_allocator(frame_allocator & allocator) -> std::optional<frame_allocator *>
- {
- if (&allocator == active_frame_allocator)
- {
- return {};
- }
- return std::exchange(active_frame_allocator, &allocator);
- }
-
- auto set_page_mapper(page_mapper & mapper) -> std::optional<page_mapper *>
- {
- if (&mapper == active_page_mapper)
- {
- return {};
- }
- return std::exchange(active_page_mapper, &mapper);
- }
-
- auto allocate_frame() -> std::optional<frame>
- {
- return active_frame_allocator->allocate();
- }
-
- auto allocate_many_frames(std::size_t count) -> std::optional<std::pair<frame, std::size_t>>
- {
- return active_frame_allocator->allocate_many(count);
- }
-
- auto map(page page, frame frame) -> std::byte *
- {
- return active_page_mapper->map(page, frame, page_mapper::flags::empty);
- }
-
- auto unmap(page page) -> void
- {
- return active_page_mapper->unmap(page);
- }
-
-} // namespace teachos::memory \ No newline at end of file
diff --git a/kernel/src/kapi/system.cpp b/kernel/src/kapi/system.cpp
deleted file mode 100644
index cdde049..0000000
--- a/kernel/src/kapi/system.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "kapi/system.hpp"
-
-#include "kapi/cpu.hpp"
-
-#include <kstd/print>
-
-#include <source_location>
-#include <string_view>
-
-namespace teachos::system
-{
-
- [[gnu::weak]]
- auto panic(std::string_view message, std::source_location location) -> void
- {
- kstd::println(kstd::print_sink::stderr, "[PANIC] in {} : {} @ {}:{}", location.function_name(), message,
- location.file_name(), location.line());
- cpu::halt();
- }
-
-} // namespace teachos::system