diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-03 11:20:22 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-17 16:42:35 +0100 |
| commit | 43875979efea5dd73f63ac66c4fcc697c752f6ef (patch) | |
| tree | 834f7703117a792a453f023fc47b0d6afccdf6d0 /kernel/devices/src | |
| parent | 09e16896dfcd87c289be18b13867e64441efcaf5 (diff) | |
| download | teachos-43875979efea5dd73f63ac66c4fcc697c752f6ef.tar.xz teachos-43875979efea5dd73f63ac66c4fcc697c752f6ef.zip | |
implement write_block in RAMDiskDevice
Diffstat (limited to 'kernel/devices/src')
| -rw-r--r-- | kernel/devices/src/storage/RAMDisk/RAMDiskDevice.cpp | 16 |
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 |
