summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/StorageKit/AHCI.h
blob: fa74a0f45f2d7353cc1c8689ee093980d3c12114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ========================================

  Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.

======================================== */

#ifndef STORAGEKIT_AHCI_H
#define STORAGEKIT_AHCI_H

#include <KernelKit/DeviceMgr.h>
#include <KernelKit/DriveMgr.h>
#include <NeKit/OwnPtr.h>

namespace Kernel {
/// @brief AHCIDeviceInterface class
/// @details This class is used to send and receive data from the AHCI device.
/// @note The class is derived from the IDevice class.
class AHCIDeviceInterface NE_DEVICE<IMountpoint*> {
 public:
  explicit AHCIDeviceInterface(void (*out)(IDevice* self, IMountpoint* out),
                               void (*in)(IDevice* self, IMountpoint* in));

  virtual ~AHCIDeviceInterface() override;

 public:
  AHCIDeviceInterface& operator=(const AHCIDeviceInterface&) = default;
  AHCIDeviceInterface(const AHCIDeviceInterface&)            = default;

  const Char* Name() const override;

  const UInt16& GetPortsImplemented();
  Void          SetPortsImplemented(const UInt16& pi);

  const UInt32& GetIndex();
  Void          SetIndex(const UInt32& drv);

 public:
  AHCIDeviceInterface& operator<<(IMountpoint* Data) override;
  AHCIDeviceInterface& operator>>(IMountpoint* Data) override;

 private:
  UInt16 fPortsImplemented{0U};
  UInt32 fDriveIndex{0U};
};

UInt16                       sk_init_ahci_device(BOOL atapi);
ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(UInt32 drv_index);
}  // namespace Kernel

#endif