blob: 6cd0e4ee0a0d5927e6871e99a08d7a5b1609a1ed [file] [log] [blame]
Miklos Balint386b8b52017-11-29 13:12:32 +00001/*
Mate Toth-Pal2a6f8c22018-12-13 16:37:17 +01002 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Miklos Balint386b8b52017-11-29 13:12:32 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Mate Toth-Pal52674ab2018-02-26 09:47:56 +01008#ifndef __SPM_DB_H__
9#define __SPM_DB_H__
Miklos Balint386b8b52017-11-29 13:12:32 +000010
Edison Aibb614aa2018-11-21 15:15:00 +080011struct spm_partition_desc_t;
12struct spm_partition_db_t;
13
Edison Ai9c48d202019-10-12 16:57:21 +080014typedef void(*sp_entry_point)(void);
Miklos Balint386b8b52017-11-29 13:12:32 +000015
Edison Aibb614aa2018-11-21 15:15:00 +080016#define TFM_PARTITION_TYPE_APP "APPLICATION-ROT"
17#define TFM_PARTITION_TYPE_PSA "PSA-ROT"
18
19#ifdef TFM_PSA_API
Hugues de Valon99578562019-06-18 16:08:51 +010020#define TFM_PRIORITY_LOW THRD_PRIOR_LOWEST
21#define TFM_PRIORITY_NORMAL THRD_PRIOR_MEDIUM
22#define TFM_PRIORITY_HIGH THRD_PRIOR_HIGHEST
Edison Aibb614aa2018-11-21 15:15:00 +080023#else
Hugues de Valon99578562019-06-18 16:08:51 +010024#define TFM_PRIORITY_LOW 0xFF
25#define TFM_PRIORITY_NORMAL 0x7F
26#define TFM_PRIORITY_HIGH 0
Edison Aibb614aa2018-11-21 15:15:00 +080027#endif
28
29#define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL
30
Mate Toth-Pale1475332018-04-09 17:28:49 +020031/**
32 * Holds the fields of the partition DB used by the SPM code. The values of
33 * these fields are calculated at compile time, and set during initialisation
34 * phase.
35 */
Mate Toth-Pal18b83922018-02-26 17:58:18 +010036struct spm_partition_static_data_t {
Edison Aif0501702019-10-11 14:36:42 +080037#ifdef TFM_PSA_API
38 uint32_t psa_framework_version;
39#endif /* defined(TFM_PSA_API) */
Mate Toth-Pal349714a2018-02-23 15:30:24 +010040 uint32_t partition_id;
Mate Toth-Pal59398712018-02-28 17:06:40 +010041 uint32_t partition_flags;
Edison Aibb614aa2018-11-21 15:15:00 +080042 uint32_t partition_priority;
Edison Ai9c48d202019-10-12 16:57:21 +080043 sp_entry_point partition_init;
Edison Aie728fbf2019-11-13 09:37:12 +080044 uint32_t dependencies_num;
45 int32_t *p_dependencies;
Miklos Balint386b8b52017-11-29 13:12:32 +000046};
Mate Toth-Pal18b83922018-02-26 17:58:18 +010047
Mate Toth-Pale1475332018-04-09 17:28:49 +020048/**
49 * Holds the fields that define a partition for SPM. The fields are further
50 * divided to structures, to keep the related fields close to each other.
51 */
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020052struct spm_partition_desc_t {
Mate Toth-Pal18b83922018-02-26 17:58:18 +010053 struct spm_partition_runtime_data_t runtime_data;
Summer Qin423dbef2019-08-22 15:59:35 +080054 const struct spm_partition_static_data_t *static_data;
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +010055 /** A list of platform_data pointers */
56 const struct tfm_spm_partition_platform_data_t **platform_data_list;
Robert Rostohar6a0424e2019-09-05 13:29:24 +020057#ifdef TFM_PSA_API
Summer Qin423dbef2019-08-22 15:59:35 +080058 const struct tfm_spm_partition_memory_data_t *memory_data;
Edison Ai788bae22019-02-18 17:38:59 +080059#endif
Mate Toth-Pal18b83922018-02-26 17:58:18 +010060};
Miklos Balint386b8b52017-11-29 13:12:32 +000061
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020062struct spm_partition_db_t {
63 uint32_t is_init;
64 uint32_t partition_count;
Edison Ai66fbdf12019-07-08 16:05:07 +080065#ifndef TFM_PSA_API
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020066 uint32_t running_partition_idx;
Edison Ai66fbdf12019-07-08 16:05:07 +080067#endif /* !defined(TFM_PSA_API) */
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020068 struct spm_partition_desc_t *partitions;
69};
70
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020071/* Macros to pick linker symbols and allow to form the partition data base */
72#define REGION(a, b, c) a##b##c
73#define REGION_NAME(a, b, c) REGION(a, b, c)
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020074#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
Mate Toth-Pal179a1562019-11-08 11:40:27 +010075#ifdef TFM_PSA_API
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020076#define PART_REGION_ADDR(partition, region) \
77 (uint32_t)&REGION_NAME(Image$$, partition, region)
Miklos Balintdd02bb32019-05-26 21:13:12 +020078#endif
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020079
Mate Toth-Pal52674ab2018-02-26 09:47:56 +010080#endif /* __SPM_DB_H__ */