summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/StorageKit/AHCI.h
blob: 7e2eaf68eae129ced2dc611287a11e5f47dc58cb (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, all rights reserved.

------------------------------------------- */

#pragma once

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

namespace Kernel
{
	class AHCIDeviceInterface NE_DEVICE<MountpointInterface*>
	{
	public:
		explicit AHCIDeviceInterface(void (*out)(IDeviceObject* self, MountpointInterface* out),
									 void (*in)(IDeviceObject* self, MountpointInterface* in),
									 void (*cleanup)(void));

		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<<(MountpointInterface* Data) override;
		AHCIDeviceInterface& operator>>(MountpointInterface* Data) override;

	private:
		Void (*fCleanup)(Void) = {nullptr};
		UInt16 fPortsImplemented{0U};
		UInt32 fDriveIndex{0U};
	};

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