blob: 383c17de65ae0380caafaa6a11bd5c2664e423c8 [file] [log] [blame]
Haojian Zhuang91f56462016-07-28 14:19:36 +08001/*
Govindraj Raja998b1e22023-09-21 18:04:00 -05002 * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
Haojian Zhuang91f56462016-07-28 14:19:36 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang91f56462016-07-28 14:19:36 +08005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef GPT_H
8#define GPT_H
Haojian Zhuang91f56462016-07-28 14:19:36 +08009
Sughosh Ganue9269152021-12-07 16:49:21 +053010#include <drivers/partition/efi.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <drivers/partition/partition.h>
Sughosh Ganue9269152021-12-07 16:49:21 +053012#include <tools_share/uuid.h>
Haojian Zhuang91f56462016-07-28 14:19:36 +080013
14#define PARTITION_TYPE_GPT 0xee
Haojian Zhuang91f56462016-07-28 14:19:36 +080015#define GPT_SIGNATURE "EFI PART"
16
17typedef struct gpt_entry {
Sughosh Ganue9269152021-12-07 16:49:21 +053018 struct efi_guid type_uuid;
19 struct efi_guid unique_uuid;
Haojian Zhuang91f56462016-07-28 14:19:36 +080020 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
26typedef 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 Ganue9269152021-12-07 16:49:21 +053036 struct efi_guid disk_uuid;
Haojian Zhuang91f56462016-07-28 14:19:36 +080037 /* 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 Raja998b1e22023-09-21 18:04:00 -050044} __packed gpt_header_t;
Haojian Zhuang91f56462016-07-28 14:19:36 +080045
46int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry);
47
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000048#endif /* GPT_H */