blob: fc3da43e454a98f988cb9413517d5974077bd9ea [file] [log] [blame]
Miklos Balint386b8b52017-11-29 13:12:32 +00001/*
Edison Aibb614aa2018-11-21 15:15:00 +08002 * 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 +080011#ifdef TFM_PSA_API
12#include "tfm_thread.h"
13#endif
14
15struct spm_partition_desc_t;
16struct spm_partition_db_t;
17
18uint32_t get_partition_idx(uint32_t partition_id);
19
Mate Toth-Pal349714a2018-02-23 15:30:24 +010020typedef int32_t(*sp_init_function)(void);
Miklos Balint386b8b52017-11-29 13:12:32 +000021
Edison Aibb614aa2018-11-21 15:15:00 +080022#define TFM_PARTITION_TYPE_APP "APPLICATION-ROT"
23#define TFM_PARTITION_TYPE_PSA "PSA-ROT"
24
Edison Ai764d41f2018-09-21 15:56:36 +080025#define TFM_STACK_SIZE 1024
26
Edison Aibb614aa2018-11-21 15:15:00 +080027#ifdef TFM_PSA_API
28enum tfm_partition_priority {
29 TFM_PRIORITY_LOW = THRD_PRIOR_LOWEST,
30 TFM_PRIORITY_NORMAL = THRD_PRIOR_MEDIUM,
31 TFM_PRIORITY_HIGH = THRD_PRIOR_HIGHEST,
32};
33#else
34enum tfm_partition_priority {
35 TFM_PRIORITY_LOW = 0xFF,
36 TFM_PRIORITY_NORMAL = 0x7F,
37 TFM_PRIORITY_HIGH = 0,
38};
39#endif
40
41#define TFM_PRIORITY(LEVEL) TFM_PRIORITY_##LEVEL
42
Mate Toth-Pale1475332018-04-09 17:28:49 +020043/**
44 * Holds the fields of the partition DB used by the SPM code. The values of
45 * these fields are calculated at compile time, and set during initialisation
46 * phase.
47 */
Mate Toth-Pal18b83922018-02-26 17:58:18 +010048struct spm_partition_static_data_t {
Mate Toth-Pal349714a2018-02-23 15:30:24 +010049 uint32_t partition_id;
Mate Toth-Pal59398712018-02-28 17:06:40 +010050 uint32_t partition_flags;
Edison Aibb614aa2018-11-21 15:15:00 +080051 uint32_t partition_priority;
Mate Toth-Pal349714a2018-02-23 15:30:24 +010052 sp_init_function partition_init;
Miklos Balint386b8b52017-11-29 13:12:32 +000053};
Mate Toth-Pal18b83922018-02-26 17:58:18 +010054
Mate Toth-Pale1475332018-04-09 17:28:49 +020055/**
56 * Holds the fields that define a partition for SPM. The fields are further
57 * divided to structures, to keep the related fields close to each other.
58 */
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020059struct spm_partition_desc_t {
Mate Toth-Pal18b83922018-02-26 17:58:18 +010060 struct spm_partition_static_data_t static_data;
61 struct spm_partition_runtime_data_t runtime_data;
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020062 struct tfm_spm_partition_platform_data_t *platform_data;
63#if TFM_LVL != 1
64 struct tfm_spm_partition_memory_data_t memory_data;
65#endif
Edison Ai764d41f2018-09-21 15:56:36 +080066#ifdef TFM_PSA_API
67 struct tfm_thrd_ctx sp_thrd;
68 /*
69 * FixMe: Hard code stack is not aligned with the definition in the
70 * manifest. It will use the partition stacks in the linker scripts/sct
71 * files include Level 1 to 3.
72 */
73 uint8_t stack[TFM_STACK_SIZE] __attribute__((aligned(8)));
74#endif
Mate Toth-Pal18b83922018-02-26 17:58:18 +010075};
Miklos Balint386b8b52017-11-29 13:12:32 +000076
Mate Toth-Pal936c33b2018-04-10 14:02:07 +020077/* Macros to pick linker symbols and allow to form the partition data base */
78#define REGION(a, b, c) a##b##c
79#define REGION_NAME(a, b, c) REGION(a, b, c)
80#if TFM_LVL == 1
81#define REGION_DECLARE(a, b, c)
82#else
83#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
84#define PART_REGION_ADDR(partition, region) \
85 (uint32_t)&REGION_NAME(Image$$, partition, region)
86#endif
87
Mate Toth-Pal52674ab2018-02-26 09:47:56 +010088#endif /* __SPM_DB_H__ */