blob: 3ec6fa3357cef983a31478fa1da5ff7732f8f3d7 [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>
Sughosh Ganue9269152021-12-07 16:49:21 +053013#include <drivers/partition/efi.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014
Haojian Zhuang91f56462016-07-28 14:19:36 +080015#if !PLAT_PARTITION_MAX_ENTRIES
16# define PLAT_PARTITION_MAX_ENTRIES 128
17#endif /* PLAT_PARTITION_MAX_ENTRIES */
18
19CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries);
20
Haojian Zhuang42a746d2019-09-14 18:01:16 +080021#if !PLAT_PARTITION_BLOCK_SIZE
22# define PLAT_PARTITION_BLOCK_SIZE 512
23#endif /* PLAT_PARTITION_BLOCK_SIZE */
24
25CASSERT((PLAT_PARTITION_BLOCK_SIZE == 512) ||
26 (PLAT_PARTITION_BLOCK_SIZE == 4096),
27 assert_plat_partition_block_size);
28
29#define LEGACY_PARTITION_BLOCK_SIZE 512
Haojian Zhuang91f56462016-07-28 14:19:36 +080030
Haojian Zhuang91f56462016-07-28 14:19:36 +080031typedef struct partition_entry {
32 uint64_t start;
33 uint64_t length;
34 char name[EFI_NAMELEN];
35} partition_entry_t;
36
37typedef struct partition_entry_list {
38 partition_entry_t list[PLAT_PARTITION_MAX_ENTRIES];
39 int entry_count;
40} partition_entry_list_t;
41
42int load_partition_table(unsigned int image_id);
43const partition_entry_t *get_partition_entry(const char *name);
44const partition_entry_list_t *get_partition_entry_list(void);
45void partition_init(unsigned int image_id);
46
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000047#endif /* PARTITION_H */