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 | |
| 10 | #include <partition.h> |
| 11 | |
| 12 | #define PARTITION_TYPE_GPT 0xee |
| 13 | #define GPT_HEADER_OFFSET PARTITION_BLOCK_SIZE |
| 14 | #define GPT_ENTRY_OFFSET (GPT_HEADER_OFFSET + \ |
| 15 | PARTITION_BLOCK_SIZE) |
| 16 | #define GUID_LEN 16 |
| 17 | |
| 18 | #define GPT_SIGNATURE "EFI PART" |
| 19 | |
| 20 | typedef struct gpt_entry { |
| 21 | unsigned char type_uuid[GUID_LEN]; |
| 22 | unsigned char unique_uuid[GUID_LEN]; |
| 23 | unsigned long long first_lba; |
| 24 | unsigned long long last_lba; |
| 25 | unsigned long long attr; |
| 26 | unsigned short name[EFI_NAMELEN]; |
| 27 | } gpt_entry_t; |
| 28 | |
| 29 | typedef struct gpt_header { |
| 30 | unsigned char signature[8]; |
| 31 | unsigned int revision; |
| 32 | unsigned int size; |
| 33 | unsigned int header_crc; |
| 34 | unsigned int reserved; |
| 35 | unsigned long long current_lba; |
| 36 | unsigned long long backup_lba; |
| 37 | unsigned long long first_lba; |
| 38 | unsigned long long last_lba; |
| 39 | unsigned char disk_uuid[16]; |
| 40 | /* starting LBA of array of partition entries */ |
| 41 | unsigned long long part_lba; |
| 42 | /* number of partition entries in array */ |
| 43 | unsigned int list_num; |
| 44 | /* size of a single partition entry (usually 128) */ |
| 45 | unsigned int part_size; |
| 46 | unsigned int part_crc; |
| 47 | } gpt_header_t; |
| 48 | |
| 49 | int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry); |
| 50 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 51 | #endif /* GPT_H */ |