summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/StorageKit/ATA.h
blob: 04cf88d7df71bc35dfe2b0cbafa82e116af65d6a (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
/* -------------------------------------------

	Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.

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

#pragma once

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

namespace Kernel
{
	/// @brief ATA device interface class.
	class ATADeviceInterface : public IDeviceObject<MountpointInterface*>
	{
	public:
		explicit ATADeviceInterface(void (*Out)(IDeviceObject*, MountpointInterface* outpacket),
									void (*In)(IDeviceObject*, MountpointInterface* inpacket));

		virtual ~ATADeviceInterface();

	public:
		ATADeviceInterface& operator<<(MountpointInterface* Data) override;
		ATADeviceInterface& operator>>(MountpointInterface* Data) override;

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

		const Char* Name() const override;

		const UInt16& GetIO();
		Void		  SetIO(const UInt16& io);

		const UInt16& GetMaster();
		Void		  SetMaster(const UInt16& master);

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

	private:
		UInt32 fDriveIndex{0U};
		UInt16 fIO, fMaster{0U};
	};

	/// @brief Initialize an PIO device (StorageKit function)
	/// @param is_master is the current PIO master?
	/// @return [io:master] for PIO device.
	BOOL sk_init_pio_device(BOOL is_master, UInt16& io, UInt8& master);

	/// @brief Acquires a new PIO device with drv_index in mind.
	/// @param drv_index The drive index to assign.
	/// @return A wrapped device interface if successful, or error code.
	ErrorOr<ATADeviceInterface> sk_acquire_pio_device(Int32 drv_index);
} // namespace Kernel