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 | 807fedb | 2019-03-07 11:22:03 +0800 | [diff] [blame] | 11 | |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 12 | #ifdef TFM_PSA_API |
| 13 | #include "tfm_thread.h" |
| 14 | #endif |
| 15 | |
| 16 | struct spm_partition_desc_t; |
| 17 | struct spm_partition_db_t; |
| 18 | |
Mate Toth-Pal | 2a6f8c2 | 2018-12-13 16:37:17 +0100 | [diff] [blame] | 19 | typedef psa_status_t(*sp_init_function)(void); |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 20 | |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 21 | #define TFM_PARTITION_TYPE_APP "APPLICATION-ROT" |
| 22 | #define TFM_PARTITION_TYPE_PSA "PSA-ROT" |
| 23 | |
Summer Qin | db1448b | 2019-02-26 11:20:52 +0800 | [diff] [blame] | 24 | #define TFM_STACK_SIZE (1024 * 5) |
Edison Ai | 764d41f | 2018-09-21 15:56:36 +0800 | [diff] [blame] | 25 | |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 26 | #ifdef TFM_PSA_API |
| 27 | enum tfm_partition_priority { |
| 28 | TFM_PRIORITY_LOW = THRD_PRIOR_LOWEST, |
| 29 | TFM_PRIORITY_NORMAL = THRD_PRIOR_MEDIUM, |
| 30 | TFM_PRIORITY_HIGH = THRD_PRIOR_HIGHEST, |
| 31 | }; |
| 32 | #else |
| 33 | enum tfm_partition_priority { |
| 34 | TFM_PRIORITY_LOW = 0xFF, |
| 35 | TFM_PRIORITY_NORMAL = 0x7F, |
| 36 | TFM_PRIORITY_HIGH = 0, |
| 37 | }; |
| 38 | #endif |
| 39 | |
| 40 | #define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL |
| 41 | |
Mate Toth-Pal | e147533 | 2018-04-09 17:28:49 +0200 | [diff] [blame] | 42 | /** |
| 43 | * Holds the fields of the partition DB used by the SPM code. The values of |
| 44 | * these fields are calculated at compile time, and set during initialisation |
| 45 | * phase. |
| 46 | */ |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 47 | struct spm_partition_static_data_t { |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 48 | uint32_t partition_id; |
Mate Toth-Pal | 5939871 | 2018-02-28 17:06:40 +0100 | [diff] [blame] | 49 | uint32_t partition_flags; |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 50 | uint32_t partition_priority; |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 51 | sp_init_function partition_init; |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 52 | }; |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 53 | |
Mate Toth-Pal | e147533 | 2018-04-09 17:28:49 +0200 | [diff] [blame] | 54 | /** |
| 55 | * Holds the fields that define a partition for SPM. The fields are further |
| 56 | * divided to structures, to keep the related fields close to each other. |
| 57 | */ |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 58 | struct spm_partition_desc_t { |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 59 | struct spm_partition_static_data_t static_data; |
| 60 | struct spm_partition_runtime_data_t runtime_data; |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 61 | struct tfm_spm_partition_platform_data_t *platform_data; |
| 62 | #if TFM_LVL != 1 |
| 63 | struct tfm_spm_partition_memory_data_t memory_data; |
| 64 | #endif |
Edison Ai | 764d41f | 2018-09-21 15:56:36 +0800 | [diff] [blame] | 65 | #ifdef TFM_PSA_API |
| 66 | struct tfm_thrd_ctx sp_thrd; |
| 67 | /* |
| 68 | * FixMe: Hard code stack is not aligned with the definition in the |
| 69 | * manifest. It will use the partition stacks in the linker scripts/sct |
| 70 | * files include Level 1 to 3. |
| 71 | */ |
| 72 | uint8_t stack[TFM_STACK_SIZE] __attribute__((aligned(8))); |
| 73 | #endif |
Mate Toth-Pal | 18b8392 | 2018-02-26 17:58:18 +0100 | [diff] [blame] | 74 | }; |
Miklos Balint | 386b8b5 | 2017-11-29 13:12:32 +0000 | [diff] [blame] | 75 | |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 76 | /* Macros to pick linker symbols and allow to form the partition data base */ |
| 77 | #define REGION(a, b, c) a##b##c |
| 78 | #define REGION_NAME(a, b, c) REGION(a, b, c) |
| 79 | #if TFM_LVL == 1 |
| 80 | #define REGION_DECLARE(a, b, c) |
| 81 | #else |
| 82 | #define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c) |
| 83 | #define PART_REGION_ADDR(partition, region) \ |
| 84 | (uint32_t)®ION_NAME(Image$$, partition, region) |
| 85 | #endif |
| 86 | |
Mate Toth-Pal | 52674ab | 2018-02-26 09:47:56 +0100 | [diff] [blame] | 87 | #endif /* __SPM_DB_H__ */ |