1 /* 2 * Copyright (c) 2016-2023, 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 typedef struct gpt_entry { 18 struct efi_guid type_uuid; 19 struct efi_guid unique_uuid; 20 unsigned long long first_lba; 21 unsigned long long last_lba; 22 unsigned long long attr; 23 unsigned short name[EFI_NAMELEN]; 24 } gpt_entry_t; 25 26 typedef struct gpt_header { 27 unsigned char signature[8]; 28 unsigned int revision; 29 unsigned int size; 30 unsigned int header_crc; 31 unsigned int reserved; 32 unsigned long long current_lba; 33 unsigned long long backup_lba; 34 unsigned long long first_lba; 35 unsigned long long last_lba; 36 struct efi_guid disk_uuid; 37 /* starting LBA of array of partition entries */ 38 unsigned long long part_lba; 39 /* number of partition entries in array */ 40 unsigned int list_num; 41 /* size of a single partition entry (usually 128) */ 42 unsigned int part_size; 43 unsigned int part_crc; 44 } __packed gpt_header_t; 45 46 int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry); 47 48 #endif /* GPT_H */ 49