blob: 52aa55bf7a0df34116433962bc52defdc65cabfe [file] [log] [blame]
J-Alvesd1aae292020-10-08 17:16:58 +01001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef CACTUS_TEST_CMDS
8#define CACTUS_TEST_CMDS
9
10#include <debug.h>
11#include <ffa_helpers.h>
12
13/**
14 * Success and error return to be sent over a msg response.
15 */
J-Alves9b28d062020-11-30 11:42:49 +000016#define CACTUS_SUCCESS U(0)
17#define CACTUS_ERROR U(-1)
J-Alvesd1aae292020-10-08 17:16:58 +010018
19/**
20 * Get command from struct smc_ret_values.
21 */
22#define CACTUS_GET_CMD(smc_ret) smc_ret.ret3
23
24/**
25 * Template for commands to be sent to CACTUS partitions over direct
26 * messages interfaces.
27 */
28#define CACTUS_SEND_CMD(source, dest, cmd, val0, val1, val2, val3) \
29 ffa_msg_send_direct_req64_5args(source, dest, cmd, \
30 val0, val1, val2, val3)
31
32#define PRINT_CMD(smc_ret) \
33 VERBOSE("cmd %lx; args: %lx, %lx, %lx, %lx\n", \
34 smc_ret.ret3, smc_ret.ret4, smc_ret.ret5, \
35 smc_ret.ret6, smc_ret.ret7)
36
37/**
J-Alves28672f92020-11-09 15:34:31 +000038 * With this test command the sender transmits a 64-bit value that it then
39 * expects to receive on the respective command response.
40 *
41 * The id is the hex representation of the string 'echo'.
42 */
43#define CACTUS_ECHO_CMD U(0x6563686f)
44
45#define CACTUS_ECHO_SEND_CMD(source, dest, echo_val) \
46 CACTUS_SEND_CMD(source, dest, CACTUS_ECHO_CMD, echo_val,\
47 0, 0, 0)
48
49#define CACTUS_ECHO_GET_VAL(smc_ret) smc_ret.ret4
50
51/**
52 * Command to request a cactus secure partition to send an echo command to
53 * another partition.
54 *
55 * The sender of this command expects to receive CACTUS_SUCCESS if the requested
56 * echo interaction happened successfully, or CACTUS_ERROR otherwise.
57 */
58#define CACTUS_REQ_ECHO_CMD (CACTUS_ECHO_CMD + 1)
59
60#define CACTUS_REQ_ECHO_SEND_CMD(source, dest, echo_dest, echo_val) \
61 CACTUS_SEND_CMD(source, dest, CACTUS_REQ_ECHO_CMD, echo_val, \
62 echo_dest, 0, 0)
63
64#define CACTUS_REQ_ECHO_GET_ECHO_DEST(smc_ret) smc_ret.ret5
65
66/**
J-Alvesd1aae292020-10-08 17:16:58 +010067 * Command to notify cactus of a memory management operation. The cmd value
68 * should be the memory management smc function id.
69 */
70#define CACTUS_MEM_SEND_CMD(source, dest, mem_func, handle) \
71 CACTUS_SEND_CMD(source, dest, mem_func, handle, 0, 0, 0)
72
73#define CACTUS_MEM_SEND_GET_HANDLE(smc_ret) smc_ret.ret4
74
75/**
76 * Template for responses to CACTUS commands.
77 */
78#define CACTUS_RESPONSE(source, dest, response) \
79 ffa_msg_send_direct_resp(source, dest, response)
80
81#define CACTUS_SUCCESS_RESP(source, dest) \
82 CACTUS_RESPONSE(source, dest, CACTUS_SUCCESS)
83
84#define CACTUS_ERROR_RESP(source, dest) \
85 CACTUS_RESPONSE(source, dest, CACTUS_ERROR)
86
87#define CACTUS_GET_RESPONSE(smc_ret) smc_ret.ret3
88
J-Alves28672f92020-11-09 15:34:31 +000089#define CACTUS_IS_SUCCESS_RESP(smc_ret) \
90 (CACTUS_GET_RESPONSE(smc_ret) == CACTUS_SUCCESS)
91
J-Alvesd1aae292020-10-08 17:16:58 +010092#endif