summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/StorageKit/AHCI.h
blob: 24191dbe0cf1e787421598cab91e8128bae5e030 (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
51
52
53
54
55
56
57
58
59
60
/* -------------------------------------------

	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()
		{
			return this->fPortsImplemented;
		}

		Void SetPortsImplemented(const UInt16& pi)
		{
			MUST_PASS(pi > 0);
			this->fPortsImplemented = pi;
		}

		const UInt32& GetIndex()
		{
			return this->fDriveIndex;
		}

		Void SetIndex(const UInt32& drv)
		{
			MUST_PASS(MountpointInterface::kDriveIndexInvalid != drv);
			this->fDriveIndex = drv;
		}

	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