1 /* 2 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef TRP_PRIVATE_H 8 #define TRP_PRIVATE_H 9 10 #include <services/rmmd_svc.h> 11 12 /* Definitions to help the assembler access the SMC/ERET args structure */ 13 #define TRP_ARGS_SIZE TRP_ARGS_END 14 #define TRP_ARG0 0x0 15 #define TRP_ARG1 0x8 16 #define TRP_ARG2 0x10 17 #define TRP_ARG3 0x18 18 #define TRP_ARG4 0x20 19 #define TRP_ARG5 0x28 20 #define TRP_ARG6 0x30 21 #define TRP_ARG7 0x38 22 #define TRP_ARGS_END 0x40 23 24 /* Definitions for RMM-EL3 Interface ABI VERSION */ 25 #define TRP_RMM_EL3_ABI_VERS_MAJOR RMM_EL3_IFC_VERSION_MAJOR 26 #define TRP_RMM_EL3_ABI_VERS_MINOR RMM_EL3_IFC_VERSION_MINOR 27 #define TRP_RMM_EL3_ABI_VERS (((TRP_RMM_EL3_ABI_VERS_MAJOR & 0x7FFF) << 16) | \ 28 (TRP_RMM_EL3_ABI_VERS_MINOR & 0xFFFF)) 29 30 #define TRP_PLATFORM_CORE_COUNT PLATFORM_CORE_COUNT 31 32 #ifndef __ASSEMBLER__ 33 34 #include <stdint.h> 35 36 /* Data structure to hold SMC arguments */ 37 typedef struct trp_args { 38 uint64_t regs[TRP_ARGS_END >> 3]; 39 } __aligned(CACHE_WRITEBACK_GRANULE) trp_args_t; 40 41 #define write_trp_arg(args, offset, val) (((args)->regs[offset >> 3]) \ 42 = val) 43 /* RMI SMC64 FIDs handled by the TRP */ 44 #define RMI_RMM_REQ_VERSION SMC64_RMI_FID(U(0)) 45 #define RMI_RMM_GRANULE_DELEGATE SMC64_RMI_FID(U(1)) 46 #define RMI_RMM_GRANULE_UNDELEGATE SMC64_RMI_FID(U(2)) 47 48 /* Definitions for RMI VERSION */ 49 #define RMI_ABI_VERSION_MAJOR U(0x0) 50 #define RMI_ABI_VERSION_MINOR U(0x0) 51 #define RMI_ABI_VERSION (((RMI_ABI_VERSION_MAJOR & 0x7FFF) \ 52 << 16) | \ 53 (RMI_ABI_VERSION_MINOR & 0xFFFF)) 54 55 #define TRP_RMM_EL3_VERSION_GET_MAJOR(x) \ 56 RMM_EL3_IFC_VERSION_GET_MAJOR((x)) 57 #define TRP_RMM_EL3_VERSION_GET_MINOR(x) \ 58 RMM_EL3_IFC_VERSION_GET_MAJOR_MINOR((x)) 59 60 /* Helper to issue SMC calls to BL31 */ 61 uint64_t trp_smc(trp_args_t *); 62 63 /* The main function to executed only by Primary CPU */ 64 void trp_main(void); 65 66 /* Setup TRP. Executed only by Primary CPU */ 67 void trp_setup(uint64_t x0, 68 uint64_t x1, 69 uint64_t x2, 70 uint64_t x3); 71 72 #endif /* __ASSEMBLER__ */ 73 #endif /* TRP_PRIVATE_H */ 74