1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 2020, Linaro Limited 4 * Copyright (c) 2018-2021, Arm Limited. All rights reserved. 5 */ 6 7 #ifndef __FFA_H 8 #define __FFA_H 9 10 /* This is based on the FF-A 1.0 EAC specification */ 11 12 #include <smccc.h> 13 #include <stdint.h> 14 15 /* Error codes */ 16 #define FFA_OK 0 17 #define FFA_NOT_SUPPORTED -1 18 #define FFA_INVALID_PARAMETERS -2 19 #define FFA_NO_MEMORY -3 20 #define FFA_BUSY -4 21 #define FFA_INTERRUPTED -5 22 #define FFA_DENIED -6 23 #define FFA_RETRY -7 24 #define FFA_ABORTED -8 25 26 /* FFA_VERSION helpers */ 27 #define FFA_VERSION_MAJOR U(1) 28 #define FFA_VERSION_MAJOR_SHIFT U(16) 29 #define FFA_VERSION_MAJOR_MASK U(0x7FFF) 30 #define FFA_VERSION_MINOR U(0) 31 #define FFA_VERSION_MINOR_SHIFT U(0) 32 #define FFA_VERSION_MINOR_MASK U(0xFFFF) 33 #define MAKE_FFA_VERSION(major, minor) \ 34 ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \ 35 ((minor) & FFA_VERSION_MINOR_MASK)) 36 37 /* Function IDs */ 38 #define FFA_ERROR U(0x84000060) 39 #define FFA_SUCCESS_32 U(0x84000061) 40 #define FFA_SUCCESS_64 U(0xC4000061) 41 #define FFA_INTERRUPT U(0x84000062) 42 #define FFA_VERSION U(0x84000063) 43 #define FFA_FEATURES U(0x84000064) 44 #define FFA_RX_RELEASE U(0x84000065) 45 #define FFA_RXTX_MAP_32 U(0x84000066) 46 #define FFA_RXTX_MAP_64 U(0xC4000066) 47 #define FFA_RXTX_UNMAP U(0x84000067) 48 #define FFA_PARTITION_INFO_GET U(0x84000068) 49 #define FFA_ID_GET U(0x84000069) 50 #define FFA_MSG_WAIT U(0x8400006B) 51 #define FFA_MSG_YIELD U(0x8400006C) 52 #define FFA_MSG_RUN U(0x8400006D) 53 #define FFA_MSG_SEND U(0x8400006E) 54 #define FFA_MSG_SEND_DIRECT_REQ_32 U(0x8400006F) 55 #define FFA_MSG_SEND_DIRECT_REQ_64 U(0xC400006F) 56 #define FFA_MSG_SEND_DIRECT_RESP_32 U(0x84000070) 57 #define FFA_MSG_SEND_DIRECT_RESP_64 U(0xC4000070) 58 #define FFA_MSG_POLL U(0x8400006A) 59 #define FFA_MEM_DONATE_32 U(0x84000071) 60 #define FFA_MEM_DONATE_64 U(0xC4000071) 61 #define FFA_MEM_LEND_32 U(0x84000072) 62 #define FFA_MEM_LEND_64 U(0xC4000072) 63 #define FFA_MEM_SHARE_32 U(0x84000073) 64 #define FFA_MEM_SHARE_64 U(0xC4000073) 65 #define FFA_MEM_RETRIEVE_REQ_32 U(0x84000074) 66 #define FFA_MEM_RETRIEVE_REQ_64 U(0xC4000074) 67 #define FFA_MEM_RETRIEVE_RESP U(0x84000075) 68 #define FFA_MEM_RELINQUISH U(0x84000076) 69 #define FFA_MEM_RECLAIM U(0x84000077) 70 #define FFA_MEM_FRAG_RX U(0x8400007A) 71 #define FFA_MEM_FRAG_TX U(0x8400007B) 72 #define FFA_SECONDARY_EP_REGISTER_64 U(0xC4000084) 73 74 /* Special value for traffic targeted to the Hypervisor or SPM */ 75 #define FFA_TARGET_INFO_MBZ U(0x0) 76 77 /* Memory attributes: Normal memory, Write-Back cacheable, Inner shareable */ 78 #define FFA_NORMAL_MEM_REG_ATTR U(0x2f) 79 80 /* Memory access permissions: Read-write */ 81 #define FFA_MEM_ACC_RW U(0x2) 82 83 /* Clear memory before mapping in receiver */ 84 #define FFA_MEMORY_REGION_FLAG_CLEAR BIT(0) 85 /* Relayer may time slice this operation */ 86 #define FFA_MEMORY_REGION_FLAG_TIME_SLICE BIT(1) 87 /* Clear memory after receiver relinquishes it */ 88 #define FFA_MEMORY_REGION_FLAG_CLEAR_RELINQUISH BIT(2) 89 90 /* Share memory transaction */ 91 #define FFA_MEMORY_REGION_TRANSACTION_TYPE_SHARE SHIFT_U32(1, 3) 92 /* Relayer must choose the alignment boundary */ 93 #define FFA_MEMORY_REGION_FLAG_ANY_ALIGNMENT 0 94 95 /* Special value for MBZ parameters */ 96 #define FFA_PARAM_MBZ U(0x0) 97 98 #ifndef __ASSEMBLER__ 99 /* Constituent memory region descriptor */ 100 struct ffa_address_range { 101 uint64_t address; 102 uint32_t page_count; 103 uint32_t reserved; 104 }; 105 106 /* Composite memory region descriptor */ 107 struct ffa_mem_region { 108 uint32_t total_page_count; 109 uint32_t address_range_count; 110 uint64_t reserved; 111 struct ffa_address_range address_range_array[]; 112 }; 113 114 /* Memory access permissions descriptor */ 115 struct ffa_mem_access_perm { 116 uint16_t endpoint_id; 117 uint8_t perm; 118 uint8_t flags; 119 }; 120 121 /* Endpoint memory access descriptor */ 122 struct ffa_mem_access { 123 struct ffa_mem_access_perm access_perm; 124 uint32_t region_offs; 125 uint64_t reserved; 126 }; 127 128 /* Lend, donate or share memory transaction descriptor */ 129 struct ffa_mem_transaction { 130 uint16_t sender_id; 131 uint8_t mem_reg_attr; 132 uint8_t reserved0; 133 uint32_t flags; 134 uint64_t global_handle; 135 uint64_t tag; 136 uint32_t reserved1; 137 uint32_t mem_access_count; 138 struct ffa_mem_access mem_access_array[]; 139 }; 140 141 /* Partition information descriptor */ 142 struct ffa_partition_info { 143 uint16_t id; 144 uint16_t execution_context; 145 uint32_t partition_properties; 146 }; 147 148 /* Descriptor to relinquish a memory region (FFA_MEM_RELINQUISH) */ 149 struct ffa_mem_relinquish { 150 uint64_t handle; 151 uint32_t flags; 152 uint32_t endpoint_count; 153 uint16_t endpoint_id_array[]; 154 }; 155 #endif /*__ASSEMBLER__*/ 156 #endif /* __FFA_H */ 157