PATADiskDevice.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/StringView.h>
  7. #include <Kernel/FileSystem/FileDescription.h>
  8. #include <Kernel/Sections.h>
  9. #include <Kernel/Storage/IDEChannel.h>
  10. #include <Kernel/Storage/IDEController.h>
  11. #include <Kernel/Storage/PATADiskDevice.h>
  12. namespace Kernel {
  13. UNMAP_AFTER_INIT NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block)
  14. {
  15. return adopt_ref(*new PATADiskDevice(controller, channel, type, interface_type, capabilities, max_addressable_block));
  16. }
  17. UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 capabilities, u64 max_addressable_block)
  18. : StorageDevice(controller, 512, max_addressable_block)
  19. , m_capabilities(capabilities)
  20. , m_channel(channel)
  21. , m_drive_type(type)
  22. , m_interface_type(interface_type)
  23. {
  24. }
  25. UNMAP_AFTER_INIT PATADiskDevice::~PATADiskDevice()
  26. {
  27. }
  28. StringView PATADiskDevice::class_name() const
  29. {
  30. return "PATADiskDevice";
  31. }
  32. void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
  33. {
  34. m_channel->start_request(request, is_slave(), m_capabilities);
  35. }
  36. String PATADiskDevice::device_name() const
  37. {
  38. return String::formatted("hd{:c}", 'a' + minor());
  39. }
  40. bool PATADiskDevice::is_slave() const
  41. {
  42. return m_drive_type == DriveType::Slave;
  43. }
  44. }