blob: 0692aa973cec70f8d94fa42d00e0c2da35f19f5d [file] [log] [blame]
J-Alves7581c382020-05-07 18:34:20 +01001/*
2 * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef FFA_HELPERS_H
8#define FFA_HELPERS_H
9
J-Alves8f08a052020-05-26 17:14:40 +010010#include <ffa_svc.h>
J-Alves7581c382020-05-07 18:34:20 +010011#include <tftf_lib.h>
12#include <utils_def.h>
13
14/* This error code must be different to the ones used by FFA */
15#define FFA_TFTF_ERROR -42
16
J-Alves5aecd982020-06-11 10:25:33 +010017/* Hypervisor ID at physical FFA instance */
18#define HYP_ID (0)
19
20/* By convention, SP IDs (as opposed to VM IDs) have bit 15 set */
21#define SP_ID(x) ((x) | (1 << 15))
22
23typedef unsigned short ffa_vm_id_t;
24typedef unsigned short ffa_vm_count_t;
25typedef unsigned short ffa_vcpu_count_t;
26
J-Alves7581c382020-05-07 18:34:20 +010027#ifndef __ASSEMBLY__
28
29#include <stdint.h>
30
Max Shvetsovc32f4782020-06-23 09:41:15 +010031struct mailbox_buffers {
32 const void *recv;
33 void *send;
34};
35
36struct ffa_partition_info {
37 /** The ID of the VM the information is about */
38 ffa_vm_id_t id;
39 /** The number of execution contexts implemented by the partition */
40 uint16_t exec_context;
41 /** The Partition's properties, e.g. supported messaging methods */
42 uint32_t properties;
43};
44
J-Alves5aecd982020-06-11 10:25:33 +010045/*
46 * TODO: In the future this file should be placed in a common folder, and not
47 * under tftf. The functions in this file are also used by SPs for SPM tests.
48 */
Max Shvetsovc17c1d32020-06-11 15:03:01 +010049bool check_spmc_execution_level(void);
J-Alves7581c382020-05-07 18:34:20 +010050smc_ret_values ffa_msg_send_direct_req(uint32_t source_id, uint32_t dest_id, uint32_t message);
51smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id, uint64_t message);
52smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id);
J-Alves8f08a052020-05-26 17:14:40 +010053smc_ret_values ffa_version(uint32_t input_version);
J-Alves5aecd982020-06-11 10:25:33 +010054smc_ret_values ffa_id_get(void);
55smc_ret_values ffa_msg_wait(void);
56smc_ret_values ffa_msg_send_direct_resp(ffa_vm_id_t source_id,
57 ffa_vm_id_t dest_id, uint32_t message);
58smc_ret_values ffa_error(int32_t error_code);
Max Shvetsovc17c1d32020-06-11 15:03:01 +010059smc_ret_values ffa_features(uint32_t feature);
Max Shvetsovc32f4782020-06-23 09:41:15 +010060smc_ret_values ffa_partition_info_get(const uint32_t uuid[4]);
61smc_ret_values ffa_rx_release(void);
J-Alves7581c382020-05-07 18:34:20 +010062
63#endif /* __ASSEMBLY__ */
64
65#endif /* FFA_HELPERS_H */