blob: d007c56bc35a896e54bc5379d2c406383c95c129 [file] [log] [blame]
Mingyang Sun00df2352021-04-15 15:46:08 +08001/*
Kevin Peng56c571e2022-01-10 14:06:05 +08002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
Chris Brandb4c2b002022-07-21 12:54:00 -07003 * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon
4 * company) or an affiliate of Cypress Semiconductor Corporation. All rights
5 * reserved.
Mingyang Sun00df2352021-04-15 15:46:08 +08006 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
11#ifndef __PARTITION_DEFS_H__
12#define __PARTITION_DEFS_H__
13
14#include <stddef.h>
15#include <stdint.h>
16
Mingyang Sunae774162021-07-08 15:18:14 +080017/* TF-M internal partition ID */
Mingyang Sunae774162021-07-08 15:18:14 +080018#define TFM_SP_IDLE_ID (1)
19#define INVALID_PARTITION_ID (~0U)
20
Mingyang Sun00df2352021-04-15 15:46:08 +080021/* Encode a magic number into version for validating partition info */
22#define PARTITION_INFO_VERSION_MASK (0x0000FFFF)
23#define PARTITION_INFO_MAGIC_MASK (0xFFFF0000)
24#define PARTITION_INFO_MAGIC (0x5F5F0000)
25
Mingyang Sun00df2352021-04-15 15:46:08 +080026/*
Summer Qin2ead4fc2023-02-24 14:09:34 +080027 * Partition flag start
28 *
29 * 31 10 9 8 7 0
30 * +---------+--+---+---+----------+
31 * | RES[21] |NS|I/S|A/P| Priority |
32 * +---------+--+---+---+----------+
33 *
34 * Field Desc Value
35 * Priority: Partition Priority Lowest, low, normal, high, hightest
36 * A/P: ARoT or PRoT domain 1: PRoT 0: ARoT
37 * I/S: IPC or SFN typed partition 1: IPC 0: SFN
38 * NS: NS Agent or not 1: NS Agent 0: Not
39 * RES: 21 bits reserved 0
Mingyang Sun00df2352021-04-15 15:46:08 +080040 */
41#define PARTITION_PRI_HIGHEST (0x0)
42#define PARTITION_PRI_HIGH (0xF)
43#define PARTITION_PRI_NORMAL (0x1F)
44#define PARTITION_PRI_LOW (0x7F)
45#define PARTITION_PRI_LOWEST (0xFF)
46#define PARTITION_PRI_MASK (0xFF)
47
Ken Liu897e8f12022-02-10 03:21:17 +010048#define PARTITION_MODEL_PSA_ROT (1U << 8)
Ken Liu59728d02021-10-06 12:47:39 +080049#define PARTITION_MODEL_IPC (1U << 9)
Mingyang Sun00df2352021-04-15 15:46:08 +080050
Chris Brandc422cdd2022-07-21 13:32:47 -070051#define PARTITION_NS_AGENT (1U << 10)
52
Ken Liuacd2a572021-05-12 16:19:04 +080053#define PARTITION_PRIORITY(flag) ((flag) & PARTITION_PRI_MASK)
54#define TO_THREAD_PRIORITY(x) (x)
55
56#define ENTRY_TO_POSITION(x) (uintptr_t)(x)
57#define POSITION_TO_ENTRY(x, t) (t)(x)
Ken Liu5d73c872021-08-19 19:23:17 +080058
59#define PTR_TO_REFERENCE(x) (uintptr_t)(x)
60#define REFERENCE_TO_PTR(x, t) (t)(x)
61
Summer Qin2ead4fc2023-02-24 14:09:34 +080062#define IS_PSA_ROT(pldi) (!!((pldi)->flags \
Ken Liu897e8f12022-02-10 03:21:17 +010063 & PARTITION_MODEL_PSA_ROT))
Summer Qin2ead4fc2023-02-24 14:09:34 +080064#define IS_IPC_MODEL(pldi) (!!((pldi)->flags \
65 & PARTITION_MODEL_IPC))
66#define IS_NS_AGENT(pldi) (!!((pldi)->flags \
67 & PARTITION_NS_AGENT))
68/* Partition flag end */
Kevin Peng56c571e2022-01-10 14:06:05 +080069
Mingyang Sunf0851842021-05-11 11:44:19 +080070/*
71 * Common partition structure type, the extendable data is right after it.
72 * Extendable data has different size for each partition, and must be 4-byte
73 * aligned. It includes: stack and heap position, dependencies, services and
74 * assets data.
75 */
Ken Liu4520ce32021-05-11 22:49:10 +080076struct partition_load_info_t {
Mingyang Sun00df2352021-04-15 15:46:08 +080077 uint32_t psa_ff_ver; /* Encode the version with magic */
Kevin Pengeec41a82021-08-18 13:56:23 +080078 int32_t pid; /* Partition ID */
Mingyang Sun00df2352021-04-15 15:46:08 +080079 uint32_t flags; /* ARoT/PRoT, SFN/IPC, priority */
80 uintptr_t entry; /* Entry point */
81 size_t stack_size; /* Stack size */
82 size_t heap_size; /* Heap size */
83 uint32_t ndeps; /* Dependency number */
84 uint32_t nservices; /* Service number */
Ken Liu86686282021-04-27 11:11:15 +080085 uint32_t nassets; /* Asset numbers */
Kevin Peng27e42272021-05-24 17:58:53 +080086 uint32_t nirqs; /* Number of IRQ owned by Partition */
Mingyang Sun00df2352021-04-15 15:46:08 +080087} __attribute__((aligned(4)));
88
89#endif /* __PARTITION_DEFS_H__ */