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