From 9c5e1ad6f4c88b4db69e3906cc25b58e212d8dd6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 24 Jul 2026 23:28:22 +0200 Subject: kapi: move block and character device --- kapi/kapi/devices.hpp | 2 -- kapi/kapi/devices/block_device.hpp | 51 ------------------------------- kapi/kapi/devices/character_device.hpp | 39 ----------------------- kapi/kapi/filesystem.hpp | 8 +++-- kapi/kapi/filesystem/block_device.hpp | 51 +++++++++++++++++++++++++++++++ kapi/kapi/filesystem/character_device.hpp | 39 +++++++++++++++++++++++ 6 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 kapi/kapi/devices/block_device.hpp delete mode 100644 kapi/kapi/devices/character_device.hpp create mode 100644 kapi/kapi/filesystem/block_device.hpp create mode 100644 kapi/kapi/filesystem/character_device.hpp (limited to 'kapi') diff --git a/kapi/kapi/devices.hpp b/kapi/kapi/devices.hpp index c1e7e9f4..51f5129e 100644 --- a/kapi/kapi/devices.hpp +++ b/kapi/kapi/devices.hpp @@ -1,10 +1,8 @@ #ifndef TEACHOS_KAPI_DEVICES_HPP #define TEACHOS_KAPI_DEVICES_HPP -#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export -#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/kapi/kapi/devices/block_device.hpp b/kapi/kapi/devices/block_device.hpp deleted file mode 100644 index e606188e..00000000 --- a/kapi/kapi/devices/block_device.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef TEACHOS_KAPI_DEVICES_BLOCK_DEVICE_HPP -#define TEACHOS_KAPI_DEVICES_BLOCK_DEVICE_HPP - -// IWYU pragma: private, include - -#include - -#include -#include - -#include - -namespace kapi::devices -{ - - struct block_device - { - constexpr auto static id = interface_id{"block"}; - - //! Virtual destructor to enable clean deletes through base pointers. - virtual ~block_device() = default; - - //! Read data from a block into a given buffer. - //! - //! If the selected block is smaller than the buffer, a partial read will occur. - //! - //! @param block_index The number of the block to read from. - //! @param buffer The buffer to read into. - //! @return The number of bytes read on success, an error otherwise. - [[nodiscard]] auto virtual read_block(size_t block_index, void * buffer) const - -> kstd::result = 0; - - //! Write data from a buffer into a block. - //! - //! If the buffer is larger than the selected block, a partial write will occur. - //! - //! @param block_index The number of the block to write to. - //! @param buffer The buffer to write from. - //! @return The number of bytes written on success, an error otherwise. - auto virtual write_block(std::size_t block_index, void const * buffer) -> kstd::result = 0; - - //! Get the block size in bytes. - [[nodiscard]] auto virtual block_size() const -> kstd::units::bytes = 0; - - //! Get the capacity of the associated device. - [[nodiscard]] auto virtual capacity() const -> kstd::units::bytes = 0; - }; - -} // namespace kapi::devices - -#endif \ No newline at end of file diff --git a/kapi/kapi/devices/character_device.hpp b/kapi/kapi/devices/character_device.hpp deleted file mode 100644 index 40921940..00000000 --- a/kapi/kapi/devices/character_device.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef TEACHOS_KAPI_DEVICES_CHARACTER_DEVICE_HPP -#define TEACHOS_KAPI_DEVICES_CHARACTER_DEVICE_HPP - -// IWYU pragma: private, include - -#include - -#include -#include - -#include -#include - -namespace kapi::devices -{ - - struct character_device - { - constexpr auto static id = interface_id{"char"}; - - //! Virtual destructor to enable clean deletes through base pointers. - virtual ~character_device() = default; - - //! Read data from the stream into a given buffer. - //! - //! @param buffer The buffer to read into. - //! @return The number of bytes read on success, an error otherwise. - [[nodiscard]] auto virtual read(std::span buffer) const -> kstd::result = 0; - - //! Write data from a buffer into the stream. - //! - //! @param buffer The buffer to write from. - //! @return The number of bytes written on success, an error otherwise. - auto virtual write_block(std::span buffer) -> kstd::result = 0; - }; - -} // namespace kapi::devices - -#endif \ No newline at end of file diff --git a/kapi/kapi/filesystem.hpp b/kapi/kapi/filesystem.hpp index 4b0971f6..6796532f 100644 --- a/kapi/kapi/filesystem.hpp +++ b/kapi/kapi/filesystem.hpp @@ -1,9 +1,11 @@ #ifndef TEACHOS_KAPI_FILESYSTEM_HPP #define TEACHOS_KAPI_FILESYSTEM_HPP -#include // IWYU pragma: export -#include // IWYU pragma: export -#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export #include #include diff --git a/kapi/kapi/filesystem/block_device.hpp b/kapi/kapi/filesystem/block_device.hpp new file mode 100644 index 00000000..6d062b07 --- /dev/null +++ b/kapi/kapi/filesystem/block_device.hpp @@ -0,0 +1,51 @@ +#ifndef TEACHOS_KAPI_FILESYSTEM_BLOCK_DEVICE_HPP +#define TEACHOS_KAPI_FILESYSTEM_BLOCK_DEVICE_HPP + +// IWYU pragma: private, include + +#include + +#include +#include + +#include + +namespace kapi::filesystem +{ + + struct block_device + { + constexpr auto static id = kapi::devices::interface_id{"block"}; + + //! Virtual destructor to enable clean deletes through base pointers. + virtual ~block_device() = default; + + //! Read data from a block into a given buffer. + //! + //! If the selected block is smaller than the buffer, a partial read will occur. + //! + //! @param block_index The number of the block to read from. + //! @param buffer The buffer to read into. + //! @return The number of bytes read on success, an error otherwise. + [[nodiscard]] auto virtual read_block(size_t block_index, void * buffer) const + -> kstd::result = 0; + + //! Write data from a buffer into a block. + //! + //! If the buffer is larger than the selected block, a partial write will occur. + //! + //! @param block_index The number of the block to write to. + //! @param buffer The buffer to write from. + //! @return The number of bytes written on success, an error otherwise. + auto virtual write_block(std::size_t block_index, void const * buffer) -> kstd::result = 0; + + //! Get the block size in bytes. + [[nodiscard]] auto virtual block_size() const -> kstd::units::bytes = 0; + + //! Get the capacity of the associated device. + [[nodiscard]] auto virtual capacity() const -> kstd::units::bytes = 0; + }; + +} // namespace kapi::filesystem + +#endif \ No newline at end of file diff --git a/kapi/kapi/filesystem/character_device.hpp b/kapi/kapi/filesystem/character_device.hpp new file mode 100644 index 00000000..b839410d --- /dev/null +++ b/kapi/kapi/filesystem/character_device.hpp @@ -0,0 +1,39 @@ +#ifndef TEACHOS_KAPI_FILESYSTEM_CHARACTER_DEVICE_HPP +#define TEACHOS_KAPI_FILESYSTEM_CHARACTER_DEVICE_HPP + +// IWYU pragma: private, include + +#include + +#include +#include + +#include +#include + +namespace kapi::filesystem +{ + + struct character_device + { + constexpr auto static id = kapi::devices::interface_id{"char"}; + + //! Virtual destructor to enable clean deletes through base pointers. + virtual ~character_device() = default; + + //! Read data from the stream into a given buffer. + //! + //! @param buffer The buffer to read into. + //! @return The number of bytes read on success, an error otherwise. + [[nodiscard]] auto virtual read(std::span buffer) const -> kstd::result = 0; + + //! Write data from a buffer into the stream. + //! + //! @param buffer The buffer to write from. + //! @return The number of bytes written on success, an error otherwise. + auto virtual write_block(std::span buffer) -> kstd::result = 0; + }; + +} // namespace kapi::filesystem + +#endif \ No newline at end of file -- cgit v1.2.3