summaryrefslogtreecommitdiffhomepage
path: root/dev/Boot/BootKit/HW/SATA.h
blob: a7ece12427f2d78d41e66a0c86be95230717d54b (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, Amlal EL Mahrouss, all rights reserved.

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

#pragma once

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

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

	ZKA_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