Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 1 | /* |
Kevin Peng | 56c571e | 2022-01-10 14:06:05 +0800 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Chris Brand | b4c2b00 | 2022-07-21 12:54:00 -0700 | [diff] [blame] | 3 | * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon |
| 4 | * company) or an affiliate of Cypress Semiconductor Corporation. All rights |
| 5 | * reserved. |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 6 | * |
| 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 Sun | ae77416 | 2021-07-08 15:18:14 +0800 | [diff] [blame] | 17 | /* TF-M internal partition ID */ |
Mingyang Sun | ae77416 | 2021-07-08 15:18:14 +0800 | [diff] [blame] | 18 | #define TFM_SP_IDLE_ID (1) |
| 19 | #define INVALID_PARTITION_ID (~0U) |
| 20 | |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 21 | /* 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 Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 26 | /* |
Summer Qin | 2ead4fc | 2023-02-24 14:09:34 +0800 | [diff] [blame^] | 27 | * 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 Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 40 | */ |
| 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 Liu | 897e8f1 | 2022-02-10 03:21:17 +0100 | [diff] [blame] | 48 | #define PARTITION_MODEL_PSA_ROT (1U << 8) |
Ken Liu | 59728d0 | 2021-10-06 12:47:39 +0800 | [diff] [blame] | 49 | #define PARTITION_MODEL_IPC (1U << 9) |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 50 | |
Chris Brand | c422cdd | 2022-07-21 13:32:47 -0700 | [diff] [blame] | 51 | #define PARTITION_NS_AGENT (1U << 10) |
| 52 | |
Ken Liu | acd2a57 | 2021-05-12 16:19:04 +0800 | [diff] [blame] | 53 | #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 Liu | 5d73c87 | 2021-08-19 19:23:17 +0800 | [diff] [blame] | 58 | |
| 59 | #define PTR_TO_REFERENCE(x) (uintptr_t)(x) |
| 60 | #define REFERENCE_TO_PTR(x, t) (t)(x) |
| 61 | |
Summer Qin | 2ead4fc | 2023-02-24 14:09:34 +0800 | [diff] [blame^] | 62 | #define IS_PSA_ROT(pldi) (!!((pldi)->flags \ |
Ken Liu | 897e8f1 | 2022-02-10 03:21:17 +0100 | [diff] [blame] | 63 | & PARTITION_MODEL_PSA_ROT)) |
Summer Qin | 2ead4fc | 2023-02-24 14:09:34 +0800 | [diff] [blame^] | 64 | #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 Peng | 56c571e | 2022-01-10 14:06:05 +0800 | [diff] [blame] | 69 | |
Mingyang Sun | f085184 | 2021-05-11 11:44:19 +0800 | [diff] [blame] | 70 | /* |
| 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 Liu | 4520ce3 | 2021-05-11 22:49:10 +0800 | [diff] [blame] | 76 | struct partition_load_info_t { |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 77 | uint32_t psa_ff_ver; /* Encode the version with magic */ |
Kevin Peng | eec41a8 | 2021-08-18 13:56:23 +0800 | [diff] [blame] | 78 | int32_t pid; /* Partition ID */ |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 79 | 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 Liu | 8668628 | 2021-04-27 11:11:15 +0800 | [diff] [blame] | 85 | uint32_t nassets; /* Asset numbers */ |
Kevin Peng | 27e4227 | 2021-05-24 17:58:53 +0800 | [diff] [blame] | 86 | uint32_t nirqs; /* Number of IRQ owned by Partition */ |
Mingyang Sun | 00df235 | 2021-04-15 15:46:08 +0800 | [diff] [blame] | 87 | } __attribute__((aligned(4))); |
| 88 | |
| 89 | #endif /* __PARTITION_DEFS_H__ */ |