Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 1 | /* |
Mate Toth-Pal | 2a6f8c2 | 2018-12-13 16:37:17 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 8 | #ifndef __SPM_DB_H__ |
| 9 | #define __SPM_DB_H__ |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 10 | |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 11 | struct spm_partition_desc_t; |
| 12 | struct spm_partition_db_t; |
| 13 | |
Edison Ai | 9c48d20 | 2019-10-12 16:57:21 +0800 | [diff] [blame] | 14 | typedef void(*sp_entry_point)(void); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 15 | |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 16 | #define TFM_PARTITION_TYPE_APP "APPLICATION-ROT" |
| 17 | #define TFM_PARTITION_TYPE_PSA "PSA-ROT" |
| 18 | |
| 19 | #ifdef TFM_PSA_API |
Hugues de Valon | 9957856 | 2019-06-18 16:08:51 +0100 | [diff] [blame] | 20 | #define TFM_PRIORITY_LOW THRD_PRIOR_LOWEST |
| 21 | #define TFM_PRIORITY_NORMAL THRD_PRIOR_MEDIUM |
| 22 | #define TFM_PRIORITY_HIGH THRD_PRIOR_HIGHEST |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 23 | #else |
Hugues de Valon | 9957856 | 2019-06-18 16:08:51 +0100 | [diff] [blame] | 24 | #define TFM_PRIORITY_LOW 0xFF |
| 25 | #define TFM_PRIORITY_NORMAL 0x7F |
| 26 | #define TFM_PRIORITY_HIGH 0 |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | #define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL |
| 30 | |
Mate Toth-Pal | e147533 | 2018-04-09 17:28:49 +0200 | [diff] [blame] | 31 | /** |
| 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-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 36 | struct spm_partition_static_data_t { |
Edison Ai | f050170 | 2019-10-11 14:36:42 +0800 | [diff] [blame] | 37 | #ifdef TFM_PSA_API |
| 38 | uint32_t psa_framework_version; |
| 39 | #endif /* defined(TFM_PSA_API) */ |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 40 | uint32_t partition_id; |
Mate Toth-Pal | 5939871 | 2018-02-28 17:06:40 +0100 | [diff] [blame] | 41 | uint32_t partition_flags; |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 42 | uint32_t partition_priority; |
Edison Ai | 9c48d20 | 2019-10-12 16:57:21 +0800 | [diff] [blame] | 43 | sp_entry_point partition_init; |
Edison Ai | e728fbf | 2019-11-13 09:37:12 +0800 | [diff] [blame] | 44 | uint32_t dependencies_num; |
| 45 | int32_t *p_dependencies; |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 46 | }; |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 47 | |
Mate Toth-Pal | e147533 | 2018-04-09 17:28:49 +0200 | [diff] [blame] | 48 | /** |
| 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-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 52 | struct spm_partition_desc_t { |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 53 | struct spm_partition_runtime_data_t runtime_data; |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 54 | const struct spm_partition_static_data_t *static_data; |
Mate Toth-Pal | 8ac98a7 | 2019-11-21 17:30:10 +0100 | [diff] [blame] | 55 | /** A list of platform_data pointers */ |
| 56 | const struct tfm_spm_partition_platform_data_t **platform_data_list; |
Robert Rostohar | 6a0424e | 2019-09-05 13:29:24 +0200 | [diff] [blame] | 57 | #ifdef TFM_PSA_API |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 58 | const struct tfm_spm_partition_memory_data_t *memory_data; |
Edison Ai | 788bae2 | 2019-02-18 17:38:59 +0800 | [diff] [blame] | 59 | #endif |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 60 | }; |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 61 | |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 62 | struct spm_partition_db_t { |
| 63 | uint32_t is_init; |
| 64 | uint32_t partition_count; |
Edison Ai | 66fbdf1 | 2019-07-08 16:05:07 +0800 | [diff] [blame] | 65 | #ifndef TFM_PSA_API |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 66 | uint32_t running_partition_idx; |
Edison Ai | 66fbdf1 | 2019-07-08 16:05:07 +0800 | [diff] [blame] | 67 | #endif /* !defined(TFM_PSA_API) */ |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 68 | struct spm_partition_desc_t *partitions; |
| 69 | }; |
| 70 | |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 71 | /* 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-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 74 | #define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c) |
Mate Toth-Pal | 179a156 | 2019-11-08 11:40:27 +0100 | [diff] [blame] | 75 | #ifdef TFM_PSA_API |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 76 | #define PART_REGION_ADDR(partition, region) \ |
| 77 | (uint32_t)®ION_NAME(Image$$, partition, region) |
Miklos Balint | dd02bb3 | 2019-05-26 21:13:12 +0200 | [diff] [blame] | 78 | #endif |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 79 | |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 80 | #endif /* __SPM_DB_H__ */ |