summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/BootKit/HW/SATA.h
blob: 4073d959eb47f16a459e8e198be467197ca4ec28 (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
/* -------------------------------------------

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

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

#pragma once

#include <CompilerKit/CompilerKit.h>
#include <modules/AHCI/AHCI.h>

class BootDeviceSATA final
{
public:
	explicit BootDeviceSATA() noexcept;
	~BootDeviceSATA() = default;

	NE_COPY_DEFAULT(BootDeviceSATA)

	struct SATATrait final
	{
		Kernel::SizeT	mBase{1024};
		Kernel::Boolean mErr{false};
		Kernel::Boolean mDetected{false};

		operator bool()
		{
			return !this->mErr;
		}
	};

	operator bool()
	{
		return this->Leak().mDetected;
	}

	BootDeviceSATA& Read(Kernel::WideChar* Buf, const Kernel::SizeT SecCount);
	BootDeviceSATA& Write(Kernel::WideChar* Buf, const Kernel::SizeT SecCount);

	SATATrait& Leak();

private:
	SATATrait mTrait;
};

#define kAHCISectorSz 4096