partition.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PARTITION_H
  7. #define PARTITION_H
  8. #include <stdint.h>
  9. #include <lib/cassert.h>
  10. #include <drivers/partition/efi.h>
  11. #include <tools_share/uuid.h>
  12. #if !PLAT_PARTITION_MAX_ENTRIES
  13. # define PLAT_PARTITION_MAX_ENTRIES 128
  14. #endif /* PLAT_PARTITION_MAX_ENTRIES */
  15. CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries);
  16. #if !PLAT_PARTITION_BLOCK_SIZE
  17. # define PLAT_PARTITION_BLOCK_SIZE 512
  18. #endif /* PLAT_PARTITION_BLOCK_SIZE */
  19. CASSERT((PLAT_PARTITION_BLOCK_SIZE == 512) ||
  20. (PLAT_PARTITION_BLOCK_SIZE == 4096),
  21. assert_plat_partition_block_size);
  22. #define LEGACY_PARTITION_BLOCK_SIZE 512
  23. #define LBA(n) ((unsigned long long)(n) * PLAT_PARTITION_BLOCK_SIZE)
  24. typedef struct partition_entry {
  25. uint64_t start;
  26. uint64_t length;
  27. char name[EFI_NAMELEN];
  28. struct efi_guid part_guid;
  29. struct efi_guid type_guid;
  30. } partition_entry_t;
  31. typedef struct partition_entry_list {
  32. partition_entry_t list[PLAT_PARTITION_MAX_ENTRIES];
  33. unsigned int entry_count;
  34. } partition_entry_list_t;
  35. int load_partition_table(unsigned int image_id);
  36. const partition_entry_t *get_partition_entry(const char *name);
  37. const partition_entry_t *get_partition_entry_by_type(
  38. const struct efi_guid *type_guid);
  39. const partition_entry_t *get_partition_entry_by_guid(
  40. const struct efi_guid *part_guid);
  41. const partition_entry_list_t *get_partition_entry_list(void);
  42. void partition_init(unsigned int image_id);
  43. int gpt_partition_init(void);
  44. #endif /* PARTITION_H */