blob: 8a9568b322b3ae97bcdfc298d543359ed5c04379 [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 Ai807fedb2019-03-07 11:22:03 +080011
Edison Aibb614aa2018-11-21 15:15:00 +080012#ifdef TFM_PSA_API
13#include "tfm_thread.h"
14#endif
15
16struct spm_partition_desc_t;
17struct spm_partition_db_t;
18
Mate Toth-Pal2a6f8c22018-12-13 16:37:17 +010019typedef psa_status_t(*sp_init_function)(void);
Miklos Balint386b8b52017-11-29 13:12:32 +000020
Edison Aibb614aa2018-11-21 15:15:00 +080021#define TFM_PARTITION_TYPE_APP "APPLICATION-ROT"
22#define TFM_PARTITION_TYPE_PSA "PSA-ROT"
23
Edison Ai788bae22019-02-18 17:38:59 +080024#if TFM_LVL == 1
Summer Qindb1448b2019-02-26 11:20:52 +080025#define TFM_STACK_SIZE (1024 * 5)
Edison Ai788bae22019-02-18 17:38:59 +080026#endif
Edison Ai764d41f2018-09-21 15:56:36 +080027
Edison Aibb614aa2018-11-21 15:15:00 +080028#ifdef TFM_PSA_API
29enum tfm_partition_priority {
30 TFM_PRIORITY_LOW = THRD_PRIOR_LOWEST,
31 TFM_PRIORITY_NORMAL = THRD_PRIOR_MEDIUM,
32 TFM_PRIORITY_HIGH = THRD_PRIOR_HIGHEST,
33};
34#else
35enum tfm_partition_priority {
36 TFM_PRIORITY_LOW = 0xFF,
37 TFM_PRIORITY_NORMAL = 0x7F,
38 TFM_PRIORITY_HIGH = 0,
39};
40#endif
41
42#define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL
43
Mate Toth-Pale1475332018-04-09 17:28:49 +020044/**
45 * Holds the fields of the partition DB used by the SPM code. The values of
46 * these fields are calculated at compile time, and set during initialisation
47 * phase.
48 */
Mate Toth-Pal18b83922018-02-26 17:58:18 +010049struct spm_partition_static_data_t {
Mate Toth-Pal349714a2018-02-23 15:30:24 +010050 uint32_t partition_id;
Mate Toth-Pal59398712018-02-28 17:06:40 +010051 uint32_t partition_flags;
Edison Aibb614aa2018-11-21 15:15:00 +080052 uint32_t partition_priority;
Mate Toth-Pal349714a2018-02-23 15:30:24 +010053 sp_init_function partition_init;
Miklos Balint386b8b52017-11-29 13:12:32 +000054};
Mate Toth-Pal18b83922018-02-26 17:58:18 +010055
Mate Toth-Pale1475332018-04-09 17:28:49 +020056/**
57 * Holds the fields that define a partition for SPM. The fields are further
58 * divided to structures, to keep the related fields close to each other.
59 */
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020060struct spm_partition_desc_t {
Mate Toth-Pal18b83922018-02-26 17:58:18 +010061 struct spm_partition_static_data_t static_data;
62 struct spm_partition_runtime_data_t runtime_data;
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020063 struct tfm_spm_partition_platform_data_t *platform_data;
64#if TFM_LVL != 1
65 struct tfm_spm_partition_memory_data_t memory_data;
66#endif
Edison Ai764d41f2018-09-21 15:56:36 +080067#ifdef TFM_PSA_API
68 struct tfm_thrd_ctx sp_thrd;
69 /*
70 * FixMe: Hard code stack is not aligned with the definition in the
71 * manifest. It will use the partition stacks in the linker scripts/sct
72 * files include Level 1 to 3.
73 */
Edison Ai788bae22019-02-18 17:38:59 +080074#if TFM_LVL == 1
Edison Ai764d41f2018-09-21 15:56:36 +080075 uint8_t stack[TFM_STACK_SIZE] __attribute__((aligned(8)));
76#endif
Edison Ai788bae22019-02-18 17:38:59 +080077#endif
Mate Toth-Pal18b83922018-02-26 17:58:18 +010078};
Miklos Balint386b8b52017-11-29 13:12:32 +000079
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020080/* Macros to pick linker symbols and allow to form the partition data base */
81#define REGION(a, b, c) a##b##c
82#define REGION_NAME(a, b, c) REGION(a, b, c)
83#if TFM_LVL == 1
84#define REGION_DECLARE(a, b, c)
85#else
86#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
87#define PART_REGION_ADDR(partition, region) \
88 (uint32_t)&REGION_NAME(Image$$, partition, region)
89#endif
90
Mate Toth-Pal52674ab2018-02-26 09:47:56 +010091#endif /* __SPM_DB_H__ */