blob: 5f6483373f3da2ab55b7ed5cc00e6e01952a4172 [file] [log] [blame]
Haojian Zhuang91f56462016-07-28 14:19:36 +08001/*
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01002 * Copyright (c) 2016-2018, 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 PARTITION_H
8#define PARTITION_H
Haojian Zhuang91f56462016-07-28 14:19:36 +08009
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +010010#include <stdint.h>
Haojian Zhuang91f56462016-07-28 14:19:36 +080011
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/cassert.h>
13
Haojian Zhuang91f56462016-07-28 14:19:36 +080014#if !PLAT_PARTITION_MAX_ENTRIES
15# define PLAT_PARTITION_MAX_ENTRIES 128
16#endif /* PLAT_PARTITION_MAX_ENTRIES */
17
18CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries);
19
Haojian Zhuang42a746d2019-09-14 18:01:16 +080020#if !PLAT_PARTITION_BLOCK_SIZE
21# define PLAT_PARTITION_BLOCK_SIZE 512
22#endif /* PLAT_PARTITION_BLOCK_SIZE */
23
24CASSERT((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
Haojian Zhuang91f56462016-07-28 14:19:36 +080029
30#define EFI_NAMELEN 36
31
32typedef struct partition_entry {
33 uint64_t start;
34 uint64_t length;
35 char name[EFI_NAMELEN];
36} partition_entry_t;
37
38typedef struct partition_entry_list {
39 partition_entry_t list[PLAT_PARTITION_MAX_ENTRIES];
40 int entry_count;
41} partition_entry_list_t;
42
43int load_partition_table(unsigned int image_id);
44const partition_entry_t *get_partition_entry(const char *name);
45const partition_entry_list_t *get_partition_entry_list(void);
46void partition_init(unsigned int image_id);
47
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000048#endif /* PARTITION_H */