aboutsummaryrefslogtreecommitdiff
path: root/kernel/devices/src/storage/RAMDisk
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/devices/src/storage/RAMDisk')
-rw-r--r--kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp b/kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp
index f33cf94..1bc475d 100644
--- a/kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp
+++ b/kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp
@@ -35,4 +35,20 @@ namespace devices::storage::ram_disk
kstd::libc::memcpy(buffer, source, block_size);
}
+
+ auto ram_disk_device::write_block(size_t block_index, void const * buffer) -> void
+ {
+ if (buffer == nullptr)
+ {
+ kapi::system::panic("[RAM DISK DEVICE] write_block called with null buffer.");
+ }
+
+ // TODO BA-FS26 add bounds checking based on module size?
+ // TODO BA-FS26 ignore writes beyond the end of the module?
+
+ auto const offset = block_index * block_size;
+ auto const destination = static_cast<std::byte *>(m_boot_module.start_address) + offset;
+
+ kstd::libc::memcpy(destination, buffer, block_size);
+ }
} // namespace devices::storage::ram_disk \ No newline at end of file