1 /* 2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3 * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon 4 * company) or an affiliate of Cypress Semiconductor Corporation. All rights 5 * reserved. 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 17 /* TF-M internal partition ID */ 18 #define TFM_SP_IDLE_ID (1) 19 #define INVALID_PARTITION_ID (~0U) 20 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 26 /* 27 * Partition load data - flags 28 * bit 7-0: priority 29 * bit 8: 1 - PSA_ROT, 0 - APP_ROT 30 * bit 9: 1 - IPC model, 0 - SFN model 31 */ 32 #define PARTITION_PRI_HIGHEST (0x0) 33 #define PARTITION_PRI_HIGH (0xF) 34 #define PARTITION_PRI_NORMAL (0x1F) 35 #define PARTITION_PRI_LOW (0x7F) 36 #define PARTITION_PRI_LOWEST (0xFF) 37 #define PARTITION_PRI_MASK (0xFF) 38 39 #define PARTITION_MODEL_PSA_ROT (1U << 8) 40 #define PARTITION_MODEL_IPC (1U << 9) 41 42 #define PARTITION_NS_AGENT (1U << 10) 43 44 #define PARTITION_PRIORITY(flag) ((flag) & PARTITION_PRI_MASK) 45 #define TO_THREAD_PRIORITY(x) (x) 46 47 #define ENTRY_TO_POSITION(x) (uintptr_t)(x) 48 #define POSITION_TO_ENTRY(x, t) (t)(x) 49 50 #define PTR_TO_REFERENCE(x) (uintptr_t)(x) 51 #define REFERENCE_TO_PTR(x, t) (t)(x) 52 53 #define IS_PARTITION_PSA_ROT(pldi) (!!((pldi)->flags \ 54 & PARTITION_MODEL_PSA_ROT)) 55 #define IS_PARTITION_IPC_MODEL(pldi) (!!((pldi)->flags \ 56 & PARTITION_MODEL_IPC)) 57 #define IS_PARTITION_NS_AGENT(pldi) (!!((pldi)->flags \ 58 & PARTITION_NS_AGENT)) 59 60 /* 61 * Common partition structure type, the extendable data is right after it. 62 * Extendable data has different size for each partition, and must be 4-byte 63 * aligned. It includes: stack and heap position, dependencies, services and 64 * assets data. 65 */ 66 struct partition_load_info_t { 67 uint32_t psa_ff_ver; /* Encode the version with magic */ 68 int32_t pid; /* Partition ID */ 69 uint32_t flags; /* ARoT/PRoT, SFN/IPC, priority */ 70 uintptr_t entry; /* Entry point */ 71 size_t stack_size; /* Stack size */ 72 size_t heap_size; /* Heap size */ 73 uint32_t ndeps; /* Dependency number */ 74 uint32_t nservices; /* Service number */ 75 uint32_t nassets; /* Asset numbers */ 76 uint32_t nirqs; /* Number of IRQ owned by Partition */ 77 } __attribute__((aligned(4))); 78 79 #endif /* __PARTITION_DEFS_H__ */ 80