PATADiskDevice.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. //
  7. // A Disk Device Connected to a PATA Channel
  8. //
  9. #pragma once
  10. #include <Kernel/Interrupts/IRQHandler.h>
  11. #include <Kernel/Locking/Mutex.h>
  12. #include <Kernel/Storage/StorageDevice.h>
  13. namespace Kernel {
  14. class IDEController;
  15. class IDEChannel;
  16. class PATADiskDevice final : public StorageDevice {
  17. friend class IDEController;
  18. AK_MAKE_ETERNAL
  19. public:
  20. // Type of drive this IDEDiskDevice is on the ATA channel.
  21. //
  22. // Each PATA channel can contain only two devices, which (I think) are
  23. // jumper selectable on the drive itself by shorting two pins.
  24. enum class DriveType : u8 {
  25. Master,
  26. Slave
  27. };
  28. enum class InterfaceType : u8 {
  29. ATA,
  30. ATAPI,
  31. };
  32. public:
  33. static NonnullRefPtr<PATADiskDevice> create(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
  34. virtual ~PATADiskDevice() override;
  35. // ^BlockDevice
  36. virtual void start_request(AsyncBlockDeviceRequest&) override;
  37. virtual String device_name() const override;
  38. private:
  39. PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
  40. // ^DiskDevice
  41. virtual StringView class_name() const override;
  42. bool is_slave() const;
  43. u16 m_capabilities { 0 };
  44. NonnullRefPtr<IDEChannel> m_channel;
  45. DriveType m_drive_type { DriveType::Master };
  46. InterfaceType m_interface_type { InterfaceType::ATA };
  47. };
  48. }