drivers: partition: support different block size
[project/bcm63xx/atf.git] / include / drivers / partition / partition.h
1 /*
2 * Copyright (c) 2016-2018, 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
14 #if !PLAT_PARTITION_MAX_ENTRIES
15 # define PLAT_PARTITION_MAX_ENTRIES 128
16 #endif /* PLAT_PARTITION_MAX_ENTRIES */
17
18 CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries);
19
20 #if !PLAT_PARTITION_BLOCK_SIZE
21 # define PLAT_PARTITION_BLOCK_SIZE 512
22 #endif /* PLAT_PARTITION_BLOCK_SIZE */
23
24 CASSERT((PLAT_PARTITION_BLOCK_SIZE == 512) ||
25 (PLAT_PARTITION_BLOCK_SIZE == 4096),
26 assert_plat_partition_block_size);
27
28 #define LEGACY_PARTITION_BLOCK_SIZE 512
29
30 #define EFI_NAMELEN 36
31
32 typedef struct partition_entry {
33 uint64_t start;
34 uint64_t length;
35 char name[EFI_NAMELEN];
36 } partition_entry_t;
37
38 typedef struct partition_entry_list {
39 partition_entry_t list[PLAT_PARTITION_MAX_ENTRIES];
40 int entry_count;
41 } partition_entry_list_t;
42
43 int load_partition_table(unsigned int image_id);
44 const partition_entry_t *get_partition_entry(const char *name);
45 const partition_entry_list_t *get_partition_entry_list(void);
46 void partition_init(unsigned int image_id);
47
48 #endif /* PARTITION_H */