summaryrefslogtreecommitdiffhomepage
path: root/dev/Boot/BootKit/HW/ATA.h
blob: 3b7b15577fec46b16d95b133af4910f518ec5b54 (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, t& Corporation, all rights reserved.

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

#pragma once

#include <Mod/ATA/ATA.h>
#include <BootKit/Device.h>

using namespace Kernel;

class BootDeviceATA final : public Device
{
public:
	enum
	{
		kPrimary   = ATA_PRIMARY_IO,
		kSecondary = ATA_SECONDARY_IO,
	};

	explicit BootDeviceATA() noexcept;
	~BootDeviceATA() = default;

	ZKA_COPY_DELETE(BootDeviceATA);

	enum
	{
		kSectorSize = kATASectorSize
	};

	struct ATATrait final : public Device::Trait
	{
		UInt16	mBus{kPrimary};
		UInt8	mMaster{0};
		Boolean mErr{false};

		operator bool()
		{
			return !mErr;
		}
	};

public:
	operator bool();

	SizeT GetSectorsCount() noexcept;
	SizeT GetDiskSize() noexcept;

	BootDeviceATA& Read(Char* Buf, const SizeT& SecCount) override;
	BootDeviceATA& Write(Char* Buf, const SizeT& SecCount) override;

	ATATrait& Leak() override;

private:
	ATATrait mTrait;
};