Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 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 | 42a746d | 2019-09-14 18:01:16 +0800 | [diff] [blame] | 15 | #define GPT_HEADER_OFFSET PLAT_PARTITION_BLOCK_SIZE |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 16 | #define GPT_ENTRY_OFFSET (GPT_HEADER_OFFSET + \ |
Haojian Zhuang | 42a746d | 2019-09-14 18:01:16 +0800 | [diff] [blame] | 17 | PLAT_PARTITION_BLOCK_SIZE) |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 18 | |
| 19 | #define GPT_SIGNATURE "EFI PART" |
| 20 | |
| 21 | typedef struct gpt_entry { |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 22 | struct efi_guid type_uuid; |
| 23 | struct efi_guid unique_uuid; |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 24 | unsigned long long first_lba; |
| 25 | unsigned long long last_lba; |
| 26 | unsigned long long attr; |
| 27 | unsigned short name[EFI_NAMELEN]; |
| 28 | } gpt_entry_t; |
| 29 | |
| 30 | typedef struct gpt_header { |
| 31 | unsigned char signature[8]; |
| 32 | unsigned int revision; |
| 33 | unsigned int size; |
| 34 | unsigned int header_crc; |
| 35 | unsigned int reserved; |
| 36 | unsigned long long current_lba; |
| 37 | unsigned long long backup_lba; |
| 38 | unsigned long long first_lba; |
| 39 | unsigned long long last_lba; |
Sughosh Ganu | e926915 | 2021-12-07 16:49:21 +0530 | [diff] [blame] | 40 | struct efi_guid disk_uuid; |
Haojian Zhuang | 91f5646 | 2016-07-28 14:19:36 +0800 | [diff] [blame] | 41 | /* starting LBA of array of partition entries */ |
| 42 | unsigned long long part_lba; |
| 43 | /* number of partition entries in array */ |
| 44 | unsigned int list_num; |
| 45 | /* size of a single partition entry (usually 128) */ |
| 46 | unsigned int part_size; |
| 47 | unsigned int part_crc; |
| 48 | } gpt_header_t; |
| 49 | |
| 50 | int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry); |
| 51 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 52 | #endif /* GPT_H */ |