Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 1 | /* |
Govindraj Raja | 998b1e2 | 2023-09-21 18:04:00 -0500 | [diff] [blame] | 2 | * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved. |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef GPT_H |
| 8 | #define GPT_H |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 9 | |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 10 | #include <drivers/partition/efi.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <drivers/partition/partition.h> |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 12 | #include <tools_share/uuid.h> |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 13 | |
| 14 | #define PARTITION_TYPE_GPT 0xee |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 15 | #define GPT_SIGNATURE "EFI PART" |
| 16 | |
| 17 | typedef struct gpt_entry { |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 18 | struct efi_guid type_uuid; |
| 19 | struct efi_guid unique_uuid; |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 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; |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 36 | struct efi_guid disk_uuid; |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 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; |
Govindraj Raja | 998b1e2 | 2023-09-21 18:04:00 -0500 | [diff] [blame] | 44 | } __packed gpt_header_t; |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 45 | |
| 46 | int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry); |
| 47 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 48 | #endif /* GPT_H */ |