xref: /rk3399_ARM-atf/include/drivers/partition/gpt.h (revision 689dcfe0e31d5c2a0aab7e0d19a50001072de6b3)
1 /*
2  * Copyright (c) 2016-2025, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef GPT_H
8 #define GPT_H
9 
10 #include <drivers/partition/efi.h>
11 #include <drivers/partition/partition.h>
12 #include <tools_share/uuid.h>
13 
14 #define PARTITION_TYPE_GPT		0xee
15 #define GPT_SIGNATURE			"EFI PART"
16 
17 #define PRIMARY_GPT_CORRUPTED (1U << 0)
18 
19 typedef struct gpt_entry {
20 	struct efi_guid		type_uuid;
21 	struct efi_guid		unique_uuid;
22 	unsigned long long	first_lba;
23 	unsigned long long	last_lba;
24 	unsigned long long	attr;
25 	unsigned short		name[EFI_NAMELEN];
26 } gpt_entry_t;
27 
28 typedef struct gpt_header {
29 	unsigned char		signature[8];
30 	unsigned int		revision;
31 	unsigned int		size;
32 	unsigned int		header_crc;
33 	unsigned int		reserved;
34 	unsigned long long	current_lba;
35 	unsigned long long	backup_lba;
36 	unsigned long long	first_lba;
37 	unsigned long long	last_lba;
38 	struct efi_guid		disk_uuid;
39 	/* starting LBA of array of partition entries */
40 	unsigned long long	part_lba;
41 	/* number of partition entries in array */
42 	unsigned int		list_num;
43 	/* size of a single partition entry (usually 128) */
44 	unsigned int		part_size;
45 	unsigned int		part_crc;
46 } __packed gpt_header_t;
47 
48 int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry);
49 
50 #endif /* GPT_H */
51