blob: 3ad20b1d2b7080beba3fe096424576f743e81679 [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.
Mingyang Sun00df2352021-04-15 15:46:08 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __PARTITION_DEFS_H__
9#define __PARTITION_DEFS_H__
10
11#include <stddef.h>
12#include <stdint.h>
13
Mingyang Sunae774162021-07-08 15:18:14 +080014/* TF-M internal partition ID */
15#define TFM_SP_NON_SECURE_ID (0)
16#define TFM_SP_IDLE_ID (1)
17#define INVALID_PARTITION_ID (~0U)
18
Mingyang Sun00df2352021-04-15 15:46:08 +080019/* Encode a magic number into version for validating partition info */
20#define PARTITION_INFO_VERSION_MASK (0x0000FFFF)
21#define PARTITION_INFO_MAGIC_MASK (0xFFFF0000)
22#define PARTITION_INFO_MAGIC (0x5F5F0000)
23
Mingyang Sun00df2352021-04-15 15:46:08 +080024/*
Ken Liu4520ce32021-05-11 22:49:10 +080025 * Partition load data - flags
Ken Liu27f9a492022-01-29 15:30:01 +080026 * bit [7-0]: priority
27 * bit [8]: '1' for PSA RoT domain; '0' for APP RoT domain.
28 * bit [9]: '1' for IPC model partition; '0' for SFN model partition.
29 * bit [10]: '1' indicates partition accesses NSPE; '0' for common partition.
Mingyang Sun00df2352021-04-15 15:46:08 +080030 */
31#define PARTITION_PRI_HIGHEST (0x0)
32#define PARTITION_PRI_HIGH (0xF)
33#define PARTITION_PRI_NORMAL (0x1F)
34#define PARTITION_PRI_LOW (0x7F)
35#define PARTITION_PRI_LOWEST (0xFF)
36#define PARTITION_PRI_MASK (0xFF)
37
Ken Liu27f9a492022-01-29 15:30:01 +080038#define PARTITION_DOMAIN_PSA_ROT (1U << 8)
Ken Liu59728d02021-10-06 12:47:39 +080039#define PARTITION_MODEL_IPC (1U << 9)
Mingyang Sun00df2352021-04-15 15:46:08 +080040
Ken Liu27f9a492022-01-29 15:30:01 +080041#define PARTITION_NON_SECURE_AGENT (1U << 10)
42
Ken Liuacd2a572021-05-12 16:19:04 +080043#define PARTITION_PRIORITY(flag) ((flag) & PARTITION_PRI_MASK)
44#define TO_THREAD_PRIORITY(x) (x)
45
46#define ENTRY_TO_POSITION(x) (uintptr_t)(x)
47#define POSITION_TO_ENTRY(x, t) (t)(x)
Ken Liu5d73c872021-08-19 19:23:17 +080048
49#define PTR_TO_REFERENCE(x) (uintptr_t)(x)
50#define REFERENCE_TO_PTR(x, t) (t)(x)
51
Kevin Peng56c571e2022-01-10 14:06:05 +080052#define IS_PARTITION_PSA_ROT(pldi) (!!((pldi)->flags \
Ken Liu27f9a492022-01-29 15:30:01 +080053 & PARTITION_DOMAIN_PSA_ROT))
Kevin Peng56c571e2022-01-10 14:06:05 +080054#define IS_PARTITION_IPC_MODEL(pldi) (!!((pldi)->flags \
Ken Liu27f9a492022-01-29 15:30:01 +080055 & PARTITION_MODEL_IPC))
Kevin Peng56c571e2022-01-10 14:06:05 +080056
Mingyang Sunf0851842021-05-11 11:44:19 +080057/*
58 * Common partition structure type, the extendable data is right after it.
59 * Extendable data has different size for each partition, and must be 4-byte
60 * aligned. It includes: stack and heap position, dependencies, services and
61 * assets data.
62 */
Ken Liu4520ce32021-05-11 22:49:10 +080063struct partition_load_info_t {
Mingyang Sun00df2352021-04-15 15:46:08 +080064 uint32_t psa_ff_ver; /* Encode the version with magic */
Kevin Pengeec41a82021-08-18 13:56:23 +080065 int32_t pid; /* Partition ID */
Mingyang Sun00df2352021-04-15 15:46:08 +080066 uint32_t flags; /* ARoT/PRoT, SFN/IPC, priority */
67 uintptr_t entry; /* Entry point */
68 size_t stack_size; /* Stack size */
69 size_t heap_size; /* Heap size */
70 uint32_t ndeps; /* Dependency number */
71 uint32_t nservices; /* Service number */
Ken Liu86686282021-04-27 11:11:15 +080072 uint32_t nassets; /* Asset numbers */
Kevin Peng27e42272021-05-24 17:58:53 +080073 uint32_t nirqs; /* Number of IRQ owned by Partition */
Mingyang Sun00df2352021-04-15 15:46:08 +080074} __attribute__((aligned(4)));
75
76#endif /* __PARTITION_DEFS_H__ */