OffsetDiskDevice.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <Kernel/Devices/OffsetDiskDevice.h>
  2. // #define OFFD_DEBUG
  3. Retained<OffsetDiskDevice> OffsetDiskDevice::create(Retained<DiskDevice>&& device, unsigned offset)
  4. {
  5. return adopt(*new OffsetDiskDevice(move(device), offset));
  6. }
  7. OffsetDiskDevice::OffsetDiskDevice(Retained<DiskDevice>&& device, unsigned offset)
  8. : m_device(move(device)), m_offset(offset)
  9. {
  10. }
  11. OffsetDiskDevice::~OffsetDiskDevice()
  12. {
  13. }
  14. unsigned OffsetDiskDevice::block_size() const
  15. {
  16. return m_device->block_size();
  17. }
  18. bool OffsetDiskDevice::read_block(unsigned index, byte* out) const
  19. {
  20. #ifdef OFFD_DEBUG
  21. kprintf("OffsetDiskDevice::read_block %u (really: %u)\n", index, m_offset + index);
  22. #endif
  23. return m_device->read_block(m_offset + index, out);
  24. }
  25. bool OffsetDiskDevice::write_block(unsigned index, const byte* data)
  26. {
  27. #ifdef OFFD_DEBUG
  28. kprintf("OffsetDiskDevice::write_block %u (really: %u)\n", index, m_offset + index);
  29. #endif
  30. return m_device->write_block(m_offset + index, data);
  31. }
  32. bool OffsetDiskDevice::read_blocks(unsigned index, word count, byte* out)
  33. {
  34. #ifdef OFFD_DEBUG
  35. kprintf("OffsetDiskDevice::read_blocks %u (really: %u) count=%u\n", index, m_offset + index, count);
  36. #endif
  37. return m_device->read_blocks(m_offset + index, count, out);
  38. }
  39. bool OffsetDiskDevice::write_blocks(unsigned index, word count, const byte* data)
  40. {
  41. #ifdef OFFD_DEBUG
  42. kprintf("OffsetDiskDevice::write_blocks %u (really: %u) count=%u\n", index, m_offset + index, count);
  43. #endif
  44. return m_device->write_blocks(m_offset + index, count, data);
  45. }
  46. const char* OffsetDiskDevice::class_name() const
  47. {
  48. return "OffsetDiskDevice";
  49. }