blob: 968aee8b86cc6a6330eace2a966612fc6b1af53a [file] [log] [blame]
Imre Kis66321592020-11-23 03:15:50 +01001/* SPDX-License-Identifier: BSD-3-Clause */
2/*
Jelle Sels318263e2022-12-07 14:15:39 +01003 * Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Imre Kis66321592020-11-23 03:15:50 +01004 */
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
15extern "C" {
16#endif
17
18struct sp_uuid {
19 uint8_t uuid[16];
20};
21
Imre Kis595c5d02024-01-15 15:28:19 +010022#if CFG_FFA_VERSION >= FFA_VERSION_1_1
23enum 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
30enum sp_execution_state {
31 sp_execution_state_aarch32 = 0,
32 sp_execution_state_aarch64,
33};
34#endif /* CFG_FFA_VERSION */
35
Imre Kis66321592020-11-23 03:15:50 +010036struct 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;
Imre Kis595c5d02024-01-15 15:28:19 +010042#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 */
Imre Kis66321592020-11-23 03:15:50 +010049};
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 */
59sp_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 */
68sp_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 */
78sp_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 *
Jelle Sels318263e2022-12-07 14:15:39 +010084 * @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.
Imre Kis66321592020-11-23 03:15:50 +010090 *
Jelle Sels318263e2022-12-07 14:15:39 +010091 * @return The SP API result
Imre Kis66321592020-11-23 03:15:50 +010092 */
93sp_result sp_discovery_partition_info_get(const struct sp_uuid *uuid,
Jelle Sels318263e2022-12-07 14:15:39 +010094 struct sp_partition_info *info,
95 uint32_t *count);
Imre Kis66321592020-11-23 03:15:50 +010096
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 */
108sp_result sp_discovery_partition_info_get_all(struct sp_partition_info info[],
109 uint32_t *count);
110
Imre Kis595c5d02024-01-15 15:28:19 +0100111#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 */
120sp_result sp_discovery_partition_info_get_count(const struct sp_uuid *uuid,
121 uint32_t *count);
122#endif /* CFG_FFA_VERSION */
123
Imre Kis66321592020-11-23 03:15:50 +0100124#ifdef __cplusplus
125}
126#endif
127
128#endif /* LIBSP_INCLUDE_SP_DISCOVERY_H_ */