gpt.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef GPT_H
  7. #define GPT_H
  8. #include <drivers/partition/efi.h>
  9. #include <drivers/partition/partition.h>
  10. #include <tools_share/uuid.h>
  11. #define PARTITION_TYPE_GPT 0xee
  12. #define GPT_HEADER_OFFSET PLAT_PARTITION_BLOCK_SIZE
  13. #define GPT_ENTRY_OFFSET (GPT_HEADER_OFFSET + \
  14. PLAT_PARTITION_BLOCK_SIZE)
  15. #define GPT_SIGNATURE "EFI PART"
  16. typedef struct gpt_entry {
  17. struct efi_guid type_uuid;
  18. struct efi_guid unique_uuid;
  19. unsigned long long first_lba;
  20. unsigned long long last_lba;
  21. unsigned long long attr;
  22. unsigned short name[EFI_NAMELEN];
  23. } gpt_entry_t;
  24. typedef struct gpt_header {
  25. unsigned char signature[8];
  26. unsigned int revision;
  27. unsigned int size;
  28. unsigned int header_crc;
  29. unsigned int reserved;
  30. unsigned long long current_lba;
  31. unsigned long long backup_lba;
  32. unsigned long long first_lba;
  33. unsigned long long last_lba;
  34. struct efi_guid disk_uuid;
  35. /* starting LBA of array of partition entries */
  36. unsigned long long part_lba;
  37. /* number of partition entries in array */
  38. unsigned int list_num;
  39. /* size of a single partition entry (usually 128) */
  40. unsigned int part_size;
  41. unsigned int part_crc;
  42. } gpt_header_t;
  43. int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry);
  44. #endif /* GPT_H */