Imre Kis | 9fcf841 | 2020-11-23 03:15:45 +0100 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | /* |
| 3 | * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #ifndef LIBSP_INCLUDE_FFA_API_H_ |
| 7 | #define LIBSP_INCLUDE_FFA_API_H_ |
| 8 | |
| 9 | /** |
| 10 | * @file ffa_api.h |
| 11 | * @brief The file contains wrapper functions around the FF-A interfaces |
| 12 | * described in sections 7-11 of the specification. |
| 13 | */ |
| 14 | |
| 15 | #include "ffa_api_types.h" |
| 16 | #include "ffa_api_defines.h" |
| 17 | #include <stdint.h> |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | /** |
| 24 | * Setup and discovery interfaces |
| 25 | */ |
| 26 | |
| 27 | /** |
| 28 | * @brief Queries the version of the Firmware Framework implementation at |
| 29 | * the FF-A instance. |
| 30 | * |
| 31 | * @param[out] version Version number of the FF-A implementation |
| 32 | * |
| 33 | * @return The FF-A error status code |
| 34 | */ |
| 35 | ffa_result ffa_version(uint32_t *version); |
| 36 | |
| 37 | /** |
| 38 | * @brief Queries whether the FF-A interface is implemented of the |
| 39 | * component at the higher EL and if it implements any optional |
| 40 | * features. The meaning of the interface_properties structure |
| 41 | * depends on the queried FF-A function and it is described in |
| 42 | * section 8.2 of the FF-A standard (v1.0). |
| 43 | * |
| 44 | * @param[in] ffa_function_id The function id of the queried FF-A |
| 45 | * function |
| 46 | * @param[out] interface_properties Used to encode any optional features |
| 47 | * implemented or any implementation details |
| 48 | * exported by the queried interface |
| 49 | * |
| 50 | * @return The FF-A error status code |
| 51 | */ |
| 52 | ffa_result ffa_features(uint32_t ffa_function_id, |
| 53 | struct ffa_interface_properties *interface_properties); |
| 54 | |
| 55 | /** |
| 56 | * @brief Relinquishes the ownership of the RX buffer after reading a |
| 57 | * message from it. |
| 58 | * |
| 59 | * @return The FF-A error status code |
| 60 | */ |
| 61 | ffa_result ffa_rx_release(void); |
| 62 | |
| 63 | /** |
| 64 | * @brief Maps the RX/TX buffer pair in the callee's translation regime. |
| 65 | * |
| 66 | * @param[in] tx_buffer Base address of the TX buffer |
| 67 | * @param[in] rx_buffer Base address of the RX buffer |
| 68 | * @param[in] page_count Number of contiguous 4K pages allocated for each |
| 69 | * buffer |
| 70 | * |
| 71 | * @return The FF-A error status code |
| 72 | */ |
| 73 | ffa_result ffa_rxtx_map(const void *tx_buffer, const void *rx_buffer, |
| 74 | uint32_t page_count); |
| 75 | |
| 76 | /** |
| 77 | * @brief Unmaps the RX/TX buffer pair in the callee's translation regime. |
| 78 | * |
| 79 | * @param[in] id ID of FF-A component that allocated the RX/TX buffer |
| 80 | * |
| 81 | * @return The FF-A error status code |
| 82 | */ |
| 83 | ffa_result ffa_rxtx_unmap(uint16_t id); |
| 84 | |
| 85 | /** |
| 86 | * @brief Requests the SPM to return information about the partition of |
| 87 | * the system. Nil UUID can be used to return information about all |
| 88 | * the SPs of the system. The information is returned in the RX |
| 89 | * buffer of the caller as an array of ffa_partition_information |
| 90 | * structures. |
| 91 | * |
| 92 | * @param[in] uuid The uuid |
| 93 | * @param[out] count Count of partition information descriptors populated in |
| 94 | * RX buffer of caller |
| 95 | * |
| 96 | * @return The FF-A error status code |
| 97 | */ |
| 98 | ffa_result ffa_partition_info_get(const struct ffa_uuid *uuid, uint32_t *count); |
| 99 | |
| 100 | /** |
| 101 | * @brief Returns the 16 bit ID of the calling FF-A component |
| 102 | * |
| 103 | * @param id ID of the caller |
| 104 | * |
| 105 | * @return The FF-A error status code |
| 106 | */ |
| 107 | ffa_result ffa_id_get(uint16_t *id); |
| 108 | |
| 109 | /** |
| 110 | * CPU cycle management interfaces |
| 111 | */ |
| 112 | |
| 113 | /** |
| 114 | * @brief Blocks the caller until a message is available or until an |
| 115 | * interrupt happens. It is also used to indicate the completion of |
| 116 | * the boot phase and the end of the interrupt handling. |
| 117 | * @note The ffa_interrupt_handler function can be called during the |
| 118 | * execution of this function. |
| 119 | * |
| 120 | * @param[out] msg The incoming message |
| 121 | * |
| 122 | * @return The FF-A error status code |
| 123 | */ |
| 124 | ffa_result ffa_msg_wait(struct ffa_direct_msg *msg); |
| 125 | |
| 126 | /** Messaging interfaces */ |
| 127 | |
| 128 | /** |
| 129 | * @brief Sends a partition message in parameter registers as a request and |
| 130 | * blocks until the response is available. |
| 131 | * @note The ffa_interrupt_handler function can be called during the |
| 132 | * execution of this function |
| 133 | * |
| 134 | * @param[in] source Source endpoint ID |
| 135 | * @param[in] dest Destination endpoint ID |
| 136 | * @param[in] a0,a1,a2,a3,a4 Implementation defined message values |
| 137 | * @param[out] msg The response message |
| 138 | * |
| 139 | * @return The FF-A error status code |
| 140 | */ |
| 141 | ffa_result ffa_msg_send_direct_req(uint16_t source, uint16_t dest, uint32_t a0, |
| 142 | uint32_t a1, uint32_t a2, uint32_t a3, |
| 143 | uint32_t a4, struct ffa_direct_msg *msg); |
| 144 | |
| 145 | /** |
| 146 | * @brief Sends a partition message in parameter registers as a response |
| 147 | * and blocks until the response is available. |
| 148 | * @note The ffa_interrupt_handler function can be called during the |
| 149 | * execution of this function |
| 150 | * |
| 151 | * @param[in] source Source endpoint ID |
| 152 | * @param[in] dest Destination endpoint ID |
| 153 | * @param[in] a0,a1,a2,a3,a4 Implementation defined message values |
| 154 | * @param[out] msg The response message |
| 155 | * |
| 156 | * @return The FF-A error status code |
| 157 | */ |
| 158 | ffa_result ffa_msg_send_direct_resp(uint16_t source, uint16_t dest, uint32_t a0, |
| 159 | uint32_t a1, uint32_t a2, uint32_t a3, |
| 160 | uint32_t a4, struct ffa_direct_msg *msg); |
| 161 | |
| 162 | /** |
| 163 | * @brief Interrupt handler prototype. Must be implemented by another |
| 164 | * component. |
| 165 | * |
| 166 | * @param[in] interrupt_id The interrupt identifier |
| 167 | */ |
| 168 | void ffa_interrupt_handler(uint32_t interrupt_id); |
| 169 | |
| 170 | #ifdef __cplusplus |
| 171 | } |
| 172 | #endif |
| 173 | |
| 174 | #endif /* LIBSP_INCLUDE_FFA_API_H_ */ |