summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/FirmwareKit/GPT.h
blob: dc2b5ce34270d914afddefb1fa7922f7cc38f6ae (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
61
/* -------------------------------------------

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

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

#pragma once

#include <NewKit/Defines.h>
#include <FirmwareKit/EFI/EFI.h>

#define kSectorAlignGPT_PartTbl	  (420U)
#define kSectorAlignGPT_PartEntry (72U)
#define kMagicLenGPT			  (8U)
#define kMagicGPT			  ("EFI PART") // "EFI PART"
#define kGPTPartitionTableLBA (512U + sizeof(GPT_PARTITION_TABLE))

namespace Kernel
{
	struct GPT_GUID;
	struct GPT_PARTITION_TABLE;
	struct GPT_PARTITION_ENTRY;

	/// @brief GPT GUID structure.
	typedef struct GPT_GUID
	{
		Kernel::UInt32 Data1;
		Kernel::UInt16 Data2;
		Kernel::UInt16 Data3;
		Kernel::UInt8  Data4[8];
	} GPT_GUID;

	struct PACKED GPT_PARTITION_TABLE final
	{
		Char	 Signature[kMagicLenGPT];
		UInt32	 Revision;
		UInt32	 HeaderSize;
		UInt32	 CRC32;
		UInt32	 Reserved1;
		UInt64	 LBAHeader;
		UInt64	 LBAAltHeader;
		UInt64	 FirstGPTEntry;
		UInt64	 LastGPTEntry;
		GPT_GUID Guid;
		UInt64	 StartingLBA;
		UInt32	 NumPartitionEntries;
		UInt32	 SizeOfEntries;
		UInt32	 CRC32PartEntry;
		UInt8	 Reserved2[kSectorAlignGPT_PartTbl];
	};

	struct PACKED GPT_PARTITION_ENTRY
	{
		GPT_GUID PartitionTypeGUID;
		GPT_GUID UniquePartitionGUID;
		UInt64	 StartLBA;
		UInt64	 EndLBA;
		UInt64	 Attributes;
		UInt8	 Name[kSectorAlignGPT_PartEntry];
	};
} // namespace Kernel