aboutsummaryrefslogtreecommitdiff
path: root/kapi/include
diff options
context:
space:
mode:
authorLukas Oesch <lukas.oesch@ost.ch>2026-06-10 10:40:46 +0200
committerLukas Oesch <lukas.oesch@ost.ch>2026-06-10 10:40:46 +0200
commit33abd5cf264cb9e34121082105b0bc17b3cf7a36 (patch)
tree36b15d53fea04f4f9d9af817100f7ad013bd9b5c /kapi/include
parentd01caf1c4aef3c89c68b9d1cc9fe56445f0860b5 (diff)
parent7e27130c342b7299a1d2188a7192a7f17b5ac2ad (diff)
downloadkernel-develop.tar.xz
kernel-develop.zip
Merge branch 'develop-BA-FS26' into 'develop'HEADdevelop
Merge of BA-FS26 branch into develop See merge request teachos/kernel!49
Diffstat (limited to 'kapi/include')
-rw-r--r--kapi/include/kapi/boot.hpp17
-rw-r--r--kapi/include/kapi/cio.hpp32
-rw-r--r--kapi/include/kapi/cio/output_device.hpp39
-rw-r--r--kapi/include/kapi/cpu.hpp13
-rw-r--r--kapi/include/kapi/memory.hpp98
-rw-r--r--kapi/include/kapi/memory/address.hpp241
-rw-r--r--kapi/include/kapi/memory/chunk.hpp107
-rw-r--r--kapi/include/kapi/memory/frame.hpp48
-rw-r--r--kapi/include/kapi/memory/frame_allocator.hpp66
-rw-r--r--kapi/include/kapi/memory/layout.hpp26
-rw-r--r--kapi/include/kapi/memory/page.hpp38
-rw-r--r--kapi/include/kapi/memory/page_mapper.hpp90
-rw-r--r--kapi/include/kapi/system.hpp24
13 files changed, 0 insertions, 839 deletions
diff --git a/kapi/include/kapi/boot.hpp b/kapi/include/kapi/boot.hpp
deleted file mode 100644
index 55ca941..0000000
--- a/kapi/include/kapi/boot.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef TEACHOS_KAPI_BOOT_HPP
-#define TEACHOS_KAPI_BOOT_HPP
-
-namespace kapi::boot
-{
- //! @qualifier platform-defined
- //! Information passed from the early pre-main stage to the kernel executable.
- //!
- //! The specific structure of this type is defined on a platform level.
- struct information;
-
- //! @qualifier platform-defined
- //! An object passed from the early pre-main stage to the kernel executable.
- extern "C" information const bootstrap_information;
-} // namespace kapi::boot
-
-#endif
diff --git a/kapi/include/kapi/cio.hpp b/kapi/include/kapi/cio.hpp
deleted file mode 100644
index 48f3000..0000000
--- a/kapi/include/kapi/cio.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef TEACHOS_KAPI_CIO_HPP
-#define TEACHOS_KAPI_CIO_HPP
-
-#include "kapi/cio/output_device.hpp" // IWYU pragma: export
-
-#include <kstd/format>
-
-#include <optional>
-#include <string_view>
-
-namespace kapi::cio
-{
-
- //! @qualifier platform-defined
- //! Initialize the character I/O subsystem.
- //!
- //! @note If a platform support character output, it shall ensure that when this function returns, basic character
- //! output can be performed on the system.
- auto init() -> void;
-
- //! @qualifier kernel-defined
- //! Set the currently active output device.
- //!
- //! @param device A new output device.
- //! @return The previously active output device.
- auto set_output_device(output_device & device) -> std::optional<output_device *>;
-
- auto write(output_stream stream, std::string_view text) -> void;
-
-} // namespace kapi::cio
-
-#endif
diff --git a/kapi/include/kapi/cio/output_device.hpp b/kapi/include/kapi/cio/output_device.hpp
deleted file mode 100644
index f08d7ba..0000000
--- a/kapi/include/kapi/cio/output_device.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef TEACHOS_KAPI_CIO_OUTPUT_DEVICE_HPP
-#define TEACHOS_KAPI_CIO_OUTPUT_DEVICE_HPP
-
-// IWYU pragma: private, include "kapi/cio.hpp"
-
-#include <string_view>
-
-namespace kapi::cio
-{
-
- enum struct output_stream
- {
- stdout,
- stderr,
- };
-
- //! The interface of a device able to perform character output on a platform.
- struct output_device
- {
- output_device(output_device const &) = delete;
- output_device(output_device &&) = delete;
- auto operator=(output_device const &) -> output_device & = delete;
- auto operator=(output_device &&) -> output_device & = delete;
-
- virtual ~output_device() = default;
-
- //! Write the given text to the output device.
- //!
- //! @param stream The stream to write to.
- //! @param text The text to write.
- auto virtual write(output_stream stream, std::string_view text) -> void = 0;
-
- protected:
- output_device() = default;
- };
-
-} // namespace kapi::cio
-
-#endif
diff --git a/kapi/include/kapi/cpu.hpp b/kapi/include/kapi/cpu.hpp
deleted file mode 100644
index 05b84b7..0000000
--- a/kapi/include/kapi/cpu.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef TEACHOS_KAPI_CPU_HPP
-#define TEACHOS_KAPI_CPU_HPP
-
-namespace kapi::cpu
-{
- //! @qualifier platform-defined
- //! Halt the CPU.
- //!
- //! This function terminates execution of the kernel.
- [[noreturn]] auto halt() -> void;
-} // namespace kapi::cpu
-
-#endif
diff --git a/kapi/include/kapi/memory.hpp b/kapi/include/kapi/memory.hpp
deleted file mode 100644
index e31fa34..0000000
--- a/kapi/include/kapi/memory.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_HPP
-#define TEACHOS_KAPI_MEMORY_HPP
-
-#include "kapi/memory/address.hpp" // IWYU pragma: export
-#include "kapi/memory/chunk.hpp" // IWYU pragma: export
-#include "kapi/memory/frame.hpp" // IWYU pragma: export
-#include "kapi/memory/frame_allocator.hpp" // IWYU pragma: export
-#include "kapi/memory/layout.hpp" // IWYU pragma: export
-#include "kapi/memory/page.hpp" // IWYU pragma: export
-#include "kapi/memory/page_mapper.hpp" // IWYU pragma: export
-
-#include <cstddef>
-#include <optional>
-#include <utility>
-
-namespace kapi::memory
-{
-
- //! @qualifier platform-defined
- //! Initialize the memory subsystem.
- //!
- //! @note This function must be implemented by the target platform.
- //!
- //! This function initializes the memory subsystem and activates the platform-specific frame allocator and page
- //! mapper. When this function returns, a valid frame allocator and page mapper are expected to have been registered.
- auto init() -> void;
-
- //! @qualifier kernel-defined
- //! Initialize the physical memory manager.
- //!
- //! This function initializes the kernel-wide physical memory manager. The function will invoke the handoff handler to
- //! transfer the platform-specific frame allocation state to the physical memory manager.
- //!
- //! @note Once this function returns, the global allocator has been replaced by the platform-agnostic, kernel-defined
- //! allocator. Any state of the platform specific allocator may be released.
- //!
- //! @param frame_count The number of frames present in the system.
- //! @param handoff_handler A function to be invoked to transfer the platform-specific frame allocation state. The
- //! allocator to hand off to is passed to the handler.
- auto init_pmm(std::size_t frame_count, void (&handoff_handler)(frame_allocator &)) -> void;
-
- //! @qualifier kernel-defined
- //! Get the currently active frame allocator.
- auto get_frame_allocator() -> frame_allocator &;
-
- //! @qualifier kernel-defined
- //! Set the currently active frame allocator.
- //!
- //! @param allocator A new frame allocator.
- //! @return The previously active frame allocator.
- auto set_frame_allocator(frame_allocator & allocator) -> std::optional<frame_allocator *>;
-
- //! @qualifier kernel-defined
- //! Set the currently active page mapper.
- //!
- //! @param mapper A new page mapper.
- //! @return The previously active page mapper.
- auto set_page_mapper(page_mapper & mapper) -> std::optional<page_mapper *>;
-
- //! @qualifier kernel-defined
- //! Allocate a new frame of physical memory
- //!
- //! @warning This function will panic if no frame allocator has been registered.
- //!
- //! @return An engaged std::optional iff. a frame could be allocated, std::nullopt otherwise.
- auto allocate_frame() -> std::optional<frame>;
-
- //! @qualifier kernel-defined
- //! Allocate multiple new frames of physical memory
- //!
- //! @warning This function will panic if no frame allocator has been registered.
- //!
- //! @return An engaged std::optional iff. @p count frames could be allocated, std::nullopt otherwise.
- auto allocate_many_frames(std::size_t count) -> std::optional<std::pair<frame, std::size_t>>;
-
- //! @qualifier kernel-defined
- //! Map a page onto a frame.
- //!
- //! @warning This function will panic if no page mapper has been registered, or the page has already been mapped.
- //! This function will not ensure that the frame is not already in use.
- //!
- //! @param page The page to map.
- //! @param frame The frame to map the page into.
- //! @param flags The flags to apply to this mapping.
- //! @return A pointer to the first byte of the mapped page.
- auto map(page page, frame frame, page_mapper::flags flags = page_mapper::flags::empty) -> std::byte *;
-
- //! @qualifier kernel-defined
- //! Unmap a page.
- //!
- //! @warning This function will panic if no page mapper has been registered, or the page is not mapped.
- //!
- //! @param page The page to unmap
- auto unmap(page page) -> void;
-
-} // namespace kapi::memory
-
-#endif
diff --git a/kapi/include/kapi/memory/address.hpp b/kapi/include/kapi/memory/address.hpp
deleted file mode 100644
index 3bef358..0000000
--- a/kapi/include/kapi/memory/address.hpp
+++ /dev/null
@@ -1,241 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_ADDRESS_HPP
-#define TEACHOS_KAPI_MEMORY_ADDRESS_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include <kstd/format>
-
-#include <bit>
-#include <compare>
-#include <cstddef>
-#include <cstdint>
-#include <string_view>
-
-namespace kapi::memory
-{
-
- //! @qualifier kernel-defined
- //! A tag for different address types.
- enum struct address_type : bool
- {
- linear,
- physical,
- };
-
- //! @qualifier kernel-defined
- //! A physical or virtual address.
- //!
- //! This convenience wrapper type is used to ensure that no linear address is passed where a physical one is expected
- //! and vice versa.
- //!
- //! @tparam Type The type of address.
- template<address_type Type>
- struct address
- {
- //! Construct a null-address.
- constexpr explicit address() noexcept = default;
-
- //! Construct an address representing the given value.
- //!
- //! @param value The raw value to initialize this address with.
- constexpr explicit address(std::uintptr_t value) noexcept
- : m_value{value}
- {}
-
- //! Construct an address representing the given pointer value.
- //!
- //! @param pointer The pointer value to initialize this address with.
- explicit address(std::byte * pointer) noexcept
- : m_value{std::bit_cast<std::uintptr_t>(pointer)}
- {}
-
- //! Convert this address into a C++ pointer.
- //!
- //! @tparam T The type of the object this address should refer to.
- //! @return This address as a typed pointer to the given type.
- template<typename ObjectType>
- explicit operator ObjectType *() const noexcept
- {
- return std::bit_cast<ObjectType *>(m_value);
- }
-
- //! Create a new address n beyond this one.
- //!
- //! @param n The amount to add to this address.
- //! @return A new address, n further than this one.
- [[nodiscard]] constexpr auto operator+(std::ptrdiff_t n) const noexcept -> address
- {
- return address{m_value + n};
- }
-
- //! Increment this address by a given amount.
- //!
- //! @param n The amount to Increment the address by.
- //! @return A reference to this address.
- constexpr auto operator+=(std::ptrdiff_t n) noexcept -> address &
- {
- m_value += n;
- return *this;
- }
-
- //! Increment this address by one.
- //!
- //! @return A reference to this address.
- constexpr auto operator++() noexcept -> address &
- {
- return (*this += 1);
- }
-
- //! Increment this address by one.
- //!
- //! @return A copy of this address before the increment.
- constexpr auto operator++(int) noexcept -> address
- {
- auto copy = *this;
- ++*this;
- return copy;
- }
-
- //! Create a new address n bytes before this one
- //!
- //! @param n The amount to subtract from this address
- //! @return A nre address, @p n ahead of this one
- [[nodiscard]] constexpr auto operator-(std::ptrdiff_t n) noexcept -> address
- {
- return address{m_value - n};
- }
-
- //! Decrement this address by a given amount.
- //!
- //! @param n The amount to Decrement the address by.
- //! @return A reference to this address.
- constexpr auto operator-=(std::ptrdiff_t n) noexcept -> address &
- {
- m_value -= n;
- return *this;
- }
-
- //! Decrement this address by one.
- //!
- //! @return A reference to this address.
- constexpr auto operator--() noexcept -> address &
- {
- return (*this -= 1);
- }
-
- //! Decrement this address by one.
- //!
- //! @return A copy of this address before the decrement.
- constexpr auto operator--(int) noexcept -> address
- {
- auto copy = *this;
- --*this;
- return copy;
- }
-
- //! Calculate the distance between this address and another one
- //!
- //! @param other The address to calculate the distance to.
- //! @return The distance between this address and the given one.
- [[nodiscard]] constexpr auto operator-(address const & other) noexcept -> std::ptrdiff_t
- {
- return m_value - other.m_value;
- }
-
- //! Extract the lower bits of the address
- //!
- //! @note The only meaningful values for @p n are powers of two.
- //!
- //! @param n The divisor to use for extraction.
- //! @return The lower bits of the address as defined by the divisor.
- constexpr auto operator%(std::size_t n) const noexcept -> std::uintptr_t
- {
- return m_value % n;
- }
-
- //! Extract the upper bits of the address
- //!
- //! @note The only meaningful values for @p n are powers of two.
- //!
- //! @param n The divisor to use for extraction.
- //! @return The upper bits of the address as defined by the divisor.
- constexpr auto operator/(std::size_t n) const noexcept -> std::uintptr_t
- {
- return m_value / n;
- }
-
- //! Shift this address n bits to the right.
- //!
- //! @param n The width of the shift.
- //! @return A new address representing the result of the shift operation.
- constexpr auto operator>>(std::size_t n) const noexcept -> address
- {
- return address{m_value >> n};
- }
-
- //! Apply the given mask to this address.
- //!
- //! @param mask The mask to apply
- //! @return A new address representing the result of the masking operation.
- template<typename MaskType>
- constexpr auto operator&(MaskType mask) const noexcept -> MaskType
- {
- return static_cast<MaskType>(m_value & mask);
- }
-
- //! Check if this address is equal to another one.
- constexpr auto operator==(address const &) const noexcept -> bool = default;
-
- //! Lexicographically compare this address with another one.
- constexpr auto operator<=>(address const &) const noexcept -> std::strong_ordering = default;
-
- //! Extract the raw value from this address.
- //!
- //! @return The raw value of this address.
- [[nodiscard]] constexpr auto raw() const noexcept -> std::uintptr_t
- {
- return m_value;
- }
-
- private:
- //! The raw address value.
- std::uintptr_t m_value{};
- };
-
- //! A linear/virtual address.
- using linear_address = address<address_type::linear>;
-
- //! A physical address.
- using physical_address = address<address_type::physical>;
-
-} // namespace kapi::memory
-
-namespace kstd
-{
-
- template<kapi::memory::address_type Type>
- struct formatter<kapi::memory::address<Type>> : kstd::formatter<std::uintptr_t>
- {
- constexpr auto static suffix = Type == kapi::memory::address_type::linear ? "%lin" : "%phy";
-
- constexpr auto parse(std::string_view context) -> std::string_view
- {
- auto result = formatter<std::uintptr_t>::parse(context);
- if (!this->specs.type)
- {
- this->specs.type = 'p';
- this->specs.alternative_form = true;
- }
- return result;
- }
-
- auto format(kapi::memory::address<Type> const & address, format_context & context) const -> void
- {
- formatter<std::uintptr_t>::format(address.raw(), context);
- context.push(suffix);
- }
- };
-
-} // namespace kstd
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/chunk.hpp b/kapi/include/kapi/memory/chunk.hpp
deleted file mode 100644
index 4529535..0000000
--- a/kapi/include/kapi/memory/chunk.hpp
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_CHUNK_HPP
-#define TEACHOS_KAPI_MEMORY_CHUNK_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include <compare>
-#include <cstddef>
-
-namespace kapi::memory
-{
-
- //! @qualifier kernel-defined
- //! A fixed-size unit of memory, indexed by a number.
- //!
- //! @tparam ChunkType The CRTP type of the deriving class
- //! @tparam AddressType The type of addresses used to index this chunk
- //! @tparam Size The size of this chunk.
- template<typename ChunkType, typename AddressType, std::size_t Size>
- struct chunk
- {
- //! The type of addresses used to index this chunk
- using address_type = AddressType;
-
- //! The size of this chunk
- constexpr auto static size = Size;
-
- //! Construct a new chunk handle for the chunk containing the given address.
- //!
- //! @param address An address contained by the desired chunk.
- //! @return A handle to a chunk containing the given address.
- constexpr auto static containing(address_type address) noexcept -> ChunkType
- {
- return ChunkType{address / size};
- }
-
- //! Get the start address of the chunk referenced by this handle.
- //!
- //! @return The address of the first byte contained by the chunk referenced by this handle.
- [[nodiscard]] constexpr auto start_address() const noexcept -> address_type
- {
- return address_type{m_number * size};
- }
-
- //! Get the number of the chunk referenced by this handle.
- //!
- //! @return The zero-based number of the chunk referenced by this handle.
- [[nodiscard]] constexpr auto number() const noexcept -> std::size_t
- {
- return m_number;
- }
-
- //! Get a handle n chunks after the one referenced by this handle.
- //!
- //! @param n The positive offset to this chunk.
- //! @return A handle referencing the chunk n chunks after the one referenced by this handle.
- constexpr auto operator+(std::size_t n) const noexcept -> ChunkType
- {
- return ChunkType{m_number + n};
- }
-
- //! Let this handle reference the next chunk after the currently reference one.
- //!
- //! @return A handle referencing the same chunk as this handle did before the operation.
- constexpr auto operator++(int) noexcept -> ChunkType
- {
- auto copy = static_cast<ChunkType>(*this);
- ++*this;
- return copy;
- }
-
- //! Let this handle reference the next chunk after the currently reference one.
- //!
- //! @return A reference to this handle.
- constexpr auto operator++() noexcept -> ChunkType &
- {
- ++m_number;
- return static_cast<ChunkType &>(*this);
- }
-
- //! Check if this chunk handle reference the same chunk as another one.
- //!
- //! @param other Another chunk handle.
- constexpr auto operator==(chunk const & other) const noexcept -> bool = default;
-
- //! Compare the number of the chunk referenced by this handle to the one reference by another one.
- //!
- //! @param other Another chunk handle.
- constexpr auto operator<=>(chunk const & other) const noexcept -> std::strong_ordering = default;
-
- private:
- friend ChunkType;
-
- //! Construct a handle referencing the first chunk of the respective address space.
- constexpr chunk() noexcept = default;
-
- //! Construct a handle referencing the chunk of memory with the given number.
- explicit constexpr chunk(std::size_t number) noexcept
- : m_number{number}
- {}
-
- //! The number of the currently referenced chunk.
- std::size_t m_number{};
- };
-
-} // namespace kapi::memory
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/frame.hpp b/kapi/include/kapi/memory/frame.hpp
deleted file mode 100644
index a55b6ff..0000000
--- a/kapi/include/kapi/memory/frame.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_FRAME_HPP
-#define TEACHOS_KAPI_MEMORY_FRAME_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/address.hpp"
-#include "kapi/memory/chunk.hpp"
-#include "kapi/memory/layout.hpp"
-
-#include <cstddef>
-
-namespace kapi::memory
-{
-
- //! @qualifier kernel-defined
- //! A handle to a frame of physical memory.
- //!
- //! @note Contrary to the address types, this type is modeled using inheritance to support future extensions.
- struct frame : chunk<frame, physical_address, frame_size>
- {
- frame() = default;
-
- frame(std::size_t number)
- : chunk{number}
- {}
-
- using difference_type = std::ptrdiff_t;
-
- //! @copydoc chunk::containing
- //!
- //! @note This factory shadows the base factory to aid in type deduction.
- constexpr auto static containing(physical_address address) noexcept -> frame
- {
- return frame{chunk::containing(address)};
- }
-
- //! Convert a base chunk into a page.
- //!
- //! This constructor allows for conversion from chunk<physical_address, PLATFORM_FRAME_SIZE> to a frame for
- //! convenience. It is deliberately not explicit.
- constexpr frame(chunk other)
- : chunk{other}
- {}
- };
-
-} // namespace kapi::memory
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/frame_allocator.hpp b/kapi/include/kapi/memory/frame_allocator.hpp
deleted file mode 100644
index cfa8a1c..0000000
--- a/kapi/include/kapi/memory/frame_allocator.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_FRAME_ALLOCATOR_HPP
-#define TEACHOS_KAPI_MEMORY_FRAME_ALLOCATOR_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/frame.hpp"
-
-#include <cstddef>
-#include <optional>
-#include <utility>
-
-namespace kapi::memory
-{
-
- //! The interface of all frame allocators.
- //!
- //! A frame allocator is responsible for the allocation, and deallocation, of frames of physical memory. Frames
- //! obtained from an allocator shall only be deallocated, or released, via the same allocator. When a frame allocated
- //! from one allocator is release via a different one (instance or type), the behavior is undefined.
- struct frame_allocator
- {
- frame_allocator(frame_allocator const &) = delete;
- frame_allocator(frame_allocator &&) = delete;
- auto operator=(frame_allocator const &) -> frame_allocator & = delete;
- auto operator=(frame_allocator &&) -> frame_allocator & = delete;
-
- virtual ~frame_allocator() = default;
-
- //! Allocate a frame of physical memory.
- //!
- //! @return An engaged std::optional iff. a new frame could be allocated, std::nullopt otherwise.
- virtual auto allocate() noexcept -> std::optional<frame>
- {
- return allocate_many(1).transform([](auto result) { return result.first; });
- }
-
- //! Mark the given frame as used
- virtual auto mark_used(frame frame) -> void = 0;
-
- //! Allocate multiple consecutive frames of physical memory.
- //!
- //! @param count The number of frames to allocate
- //! @return an engaged optional iff. a block of consecutive frames could be allocated, std::nullopt otherwise.
- virtual auto allocate_many(std::size_t count) noexcept -> std::optional<std::pair<frame, std::size_t>> = 0;
-
- //! Release a frame of physical memory.
- //!
- //! @param frame A frame of physical memory, previously acquired by a call to the #allocate function.
- virtual auto release(frame frame) -> void
- {
- return release_many({frame, 1});
- }
-
- //! Release a frame of physical memory.
- //!
- //! @param frame_set A set of frames of physical memory, previously acquired by a call to the #allocate_many
- //! function.
- virtual auto release_many(std::pair<frame, std::size_t> frame_set) -> void = 0;
-
- protected:
- frame_allocator() = default;
- };
-
-} // namespace kapi::memory
-
-#endif // TEACHOS_KAPI_MEMORY_FRAME_ALLOCATOR_HPP \ No newline at end of file
diff --git a/kapi/include/kapi/memory/layout.hpp b/kapi/include/kapi/memory/layout.hpp
deleted file mode 100644
index f5ba0f9..0000000
--- a/kapi/include/kapi/memory/layout.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_LAYOUT_HPP
-#define TEACHOS_KAPI_MEMORY_LAYOUT_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/address.hpp"
-
-namespace kapi::memory
-{
-
- constexpr auto page_size = PLATFORM_PAGE_SIZE;
- constexpr auto frame_size = PLATFORM_FRAME_SIZE;
-
- constexpr auto higher_half_direct_map_base = linear_address{0xffff'8000'0000'0000uz};
-
- constexpr auto heap_base = linear_address{0xffff'c000'0000'0000uz};
-
- constexpr auto pmm_metadata_base = linear_address{0xffff'd000'0000'0000uz};
-
- constexpr auto mmio_base = linear_address{0xffff'e000'0000'0000uz};
-
- constexpr auto kernel_base = linear_address{0xffff'ffff'8000'0000uz};
-
-} // namespace kapi::memory
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/page.hpp b/kapi/include/kapi/memory/page.hpp
deleted file mode 100644
index aa161ee..0000000
--- a/kapi/include/kapi/memory/page.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_PAGE_HPP
-#define TEACHOS_KAPI_MEMORY_PAGE_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/address.hpp"
-#include "kapi/memory/chunk.hpp"
-#include "kapi/memory/layout.hpp"
-
-#include <cstddef>
-
-namespace kapi::memory
-{
-
- //! @qualifier kernel-defined
- //! A handle to a page of virtual memory.
- //!
- //! @note Contrary to the address types, this type is modeled using inheritance to support future extensions.
- struct page : chunk<page, linear_address, page_size>
- {
- page() = default;
-
- page(std::size_t number)
- : chunk{number}
- {}
-
- //! Convert a base chunk into a page.
- //!
- //! This constructor allows for conversion from chunk<linear_address, PLATFORM_PAGE_SIZE> to a page for convenience.
- //! It is deliberately not explicit.
- constexpr page(chunk other)
- : chunk{other}
- {}
- };
-
-} // namespace kapi::memory
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/memory/page_mapper.hpp b/kapi/include/kapi/memory/page_mapper.hpp
deleted file mode 100644
index c6052e9..0000000
--- a/kapi/include/kapi/memory/page_mapper.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef TEACHOS_KAPI_MEMORY_PAGE_MAPPER_HPP
-#define TEACHOS_KAPI_MEMORY_PAGE_MAPPER_HPP
-
-// IWYU pragma: private, include "kapi/memory.hpp"
-
-#include "kapi/memory/frame.hpp"
-#include "kapi/memory/page.hpp"
-
-#include <kstd/ext/bitfield_enum>
-
-#include <cstddef>
-#include <cstdint>
-#include <type_traits>
-
-namespace kapi::memory
-{
-
- //! @qualifier platform-implemented
- //! The interface of a type allowing the mapping, and unmapping, of pages onto frames.
- struct page_mapper
- {
- page_mapper(page_mapper const &) = delete;
- page_mapper(page_mapper &&) = delete;
- auto operator=(page_mapper const &) -> page_mapper & = delete;
- auto operator=(page_mapper &&) -> page_mapper & = delete;
-
- //! Platform independent page mapping flags
- enum struct flags : std::uint64_t
- {
- empty,
- writable = 1 << 0, //! The page is writable.
- executable = 1 << 1, //! The page contains executable instructions.
- uncached = 1 << 2, //! The page contents must not be cached.
- supervisor_only = 1 << 3, //! The page is only accessible in supervisor mode.
- global = 1 << 4, //! The page translation persists across context switches.
- };
-
- virtual ~page_mapper() = default;
-
- //! Map a page into a given frame, applying the given flags.
- //!
- //! @param page The page to map.
- //! @param frame The frame to map the page into.
- //! @param flags The flags to map the page with.
- //! @return A pointer to the first byte of mapped page.
- virtual auto map(page page, frame frame, flags flags) -> std::byte * = 0;
-
- //! Unmap the given page.
- //!
- //! @warning If the provided page is not mapped, the behavior is undefined. Implementation are encourage to
- //! terminate execution via a kernel panic.
- //!
- //! @param page The page to unmap.
- virtual auto unmap(page page) -> void = 0;
-
- //! Try to unmap the given page.
- //!
- //! @param page The page to unmap
- //! @return true iff. the page was successfully unmapped, false otherwise.
- virtual auto try_unmap(page page) noexcept -> bool = 0;
-
- //! @qualifier kernel-defined
- //! Map a page into a given frame, applyint the given flags.
- //!
- //! @tparam T The type of data contained in the page.
- //! @param page The page to map.
- //! @param frame The frame to map the page into.
- //! @param flags The flags to map the page with.
- //! @return A pointer to the first T in the page.
- template<typename T>
- [[nodiscard]] auto map_as(page page, frame frame, flags flags) -> T *
- {
- return std::bit_cast<T *>(map(page, frame, flags));
- }
-
- protected:
- page_mapper() = default;
- };
-
-} // namespace kapi::memory
-
-namespace kstd::ext
-{
- template<>
- struct is_bitfield_enum<kapi::memory::page_mapper::flags> : std::true_type
- {
- };
-} // namespace kstd::ext
-
-#endif \ No newline at end of file
diff --git a/kapi/include/kapi/system.hpp b/kapi/include/kapi/system.hpp
deleted file mode 100644
index e5c43c5..0000000
--- a/kapi/include/kapi/system.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef TEACHOS_KAPI_SYSTEM_HPP
-#define TEACHOS_KAPI_SYSTEM_HPP
-
-#include <source_location>
-#include <string_view>
-
-namespace kapi::system
-{
-
- //! @qualifier kernel-defined
- //! Terminate kernel execution with the given error message.
- //!
- //! This function terminates the execution of the kernel and attempts to issue the given error message to the user.
- //!
- //! @param message The message associated with the panic
- [[noreturn]] auto panic(std::string_view message, std::source_location = std::source_location::current()) -> void;
-
- //! @qualifier platform-defined
- //! A hook that runs once the memory subsystem has been initialized.
- auto memory_initialized() -> void;
-
-} // namespace kapi::system
-
-#endif