#include "devices/storage/RAMDisk/RAMDiskDevice.hpp" #include "kapi/boot_module/boot_module.hpp" #include "kapi/system.hpp" #include "devices/BlockDevice.hpp" #include #include namespace devices::storage::ram_disk { ram_disk_device::ram_disk_device() // TODO BA-FS26 remove when kstd::vector is available : block_device(0, 0) {} ram_disk_device::ram_disk_device(kapi::boot_modules::boot_module const & module, size_t major, size_t minor) : block_device(major, minor) , m_boot_module(module) {} auto ram_disk_device::read_block(size_t block_index, void * buffer) const -> void { if (buffer == nullptr) { kapi::system::panic("[RAM DISK DEVICE] read_block called with null buffer."); } // TODO BA-FS26 add bounds checking based on module size? // TODO BA-FS26 fill with 0 after the end of the module, if the block extends beyond it? auto const offset = block_index * block_size; auto const source = static_cast(m_boot_module.start_address) + offset; kstd::libc::memcpy(buffer, source, block_size); } } // namespace devices::storage::ram_disk