1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. 4 */ 5 6 #ifndef LIBSP_INCLUDE_SP_DISCOVERY_H_ 7 #define LIBSP_INCLUDE_SP_DISCOVERY_H_ 8 9 #include "sp_api_defines.h" 10 #include "sp_api_types.h" 11 #include <stdbool.h> 12 #include <stdint.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 struct sp_uuid { 19 uint8_t uuid[16]; 20 }; 21 22 #if CFG_FFA_VERSION >= FFA_VERSION_1_1 23 enum sp_partition_id_type { 24 sp_partition_id_type_pe_endpoint_id = 0, 25 sp_partition_id_type_sepid_independent, 26 sp_partition_id_type_sepid_dependent, 27 sp_partition_id_type_auxiliary_id 28 }; 29 30 enum sp_execution_state { 31 sp_execution_state_aarch32 = 0, 32 sp_execution_state_aarch64, 33 }; 34 #endif /* CFG_FFA_VERSION */ 35 36 struct sp_partition_info { 37 uint16_t partition_id; 38 uint16_t execution_context_count; 39 bool supports_direct_requests; 40 bool can_send_direct_requests; 41 bool supports_indirect_requests; 42 #if CFG_FFA_VERSION >= FFA_VERSION_1_1 43 enum sp_partition_id_type partition_id_type; 44 bool inform_vm_create; 45 bool inform_vm_destroy; 46 enum sp_execution_state execution_state; 47 struct sp_uuid uuid; 48 #endif /* CFG_FFA_VERSION */ 49 }; 50 51 /** 52 * @brief Queries the FF-A version of the FF-A instance. 53 * 54 * @param[out] major The major FF-A version 55 * @param[out] minor The minor FF-A version 56 * 57 * @return The SP API result 58 */ 59 sp_result sp_discovery_ffa_version_get(uint16_t *major, uint16_t *minor); 60 61 /** 62 * @brief Queries the 16 bit FF-A ID of the calling partition. 63 * 64 * @param[out] id The 16 bit FF-A ID of the calling partition 65 * 66 * @return The SP API result 67 */ 68 sp_result sp_discovery_own_id_get(uint16_t *id); 69 70 /** 71 * @brief Queries the 16 bit FF-A ID of a partition by its UUID. 72 * 73 * @param[in] uuid The UUID of the partition 74 * @param[out] id The 16 bit FF-A ID of the partition 75 * 76 * @return The SP API result 77 */ 78 sp_result sp_discovery_partition_id_get(const struct sp_uuid *uuid, 79 uint16_t *id); 80 81 /** 82 * @brief Queries the information about a partition by its UUID. 83 * 84 * @param[in] uuid The UUID of the partition 85 * @param[out] info The partition information 86 * @param[in,out] count As an input value it specifies the count of partition 87 * info structures that would fit into the output buffer. 88 * As an output it indicates the count of the valid 89 * entries in the buffer. 90 * 91 * @return The SP API result 92 */ 93 sp_result sp_discovery_partition_info_get(const struct sp_uuid *uuid, 94 struct sp_partition_info *info, 95 uint32_t *count); 96 97 /** 98 * @brief Queries partition information of all partitions. 99 * 100 * @param[out] info The partition information buffer 101 * @param[in,out] count As an input value it specifies the count of partition 102 * info structures that would fit into the output buffer. 103 * As an output it indicates the count of the valid 104 * entries in the buffer. 105 * 106 * @return The SP API result 107 */ 108 sp_result sp_discovery_partition_info_get_all(struct sp_partition_info info[], 109 uint32_t *count); 110 111 #if CFG_FFA_VERSION >= FFA_VERSION_1_1 112 /** 113 * @brief Queries the count of partitions. 114 * 115 * @param[in] uuid The UUID of the partition 116 * @param[out] count The count of matching partitions 117 * 118 * @return The SP API result 119 */ 120 sp_result sp_discovery_partition_info_get_count(const struct sp_uuid *uuid, 121 uint32_t *count); 122 #endif /* CFG_FFA_VERSION */ 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 #endif /* LIBSP_INCLUDE_SP_DISCOVERY_H_ */ 129