blob: 3e16e579b0708b5a4078fd3d8d847b4fc4a69a95 [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-Alves1d203f12020-11-11 11:38:49 +000067 * Command to create a cyclic dependency between SPs, which could result in
68 * a deadlock. This aims at proving such scenario cannot happen.
69 * If the deadlock happens, the system will just hang.
70 * If the deadlock is prevented, the last partition to use the command will
71 * send response CACTUS_SUCCESS.
72 *
73 * The id is the hex representation of the string 'dead'.
74 */
75#define CACTUS_DEADLOCK_CMD U(0x64656164)
76
77#define CACTUS_DEADLOCK_SEND_CMD(source, dest, next_dest) \
78 CACTUS_SEND_CMD(source, dest, CACTUS_DEADLOCK_CMD, next_dest, \
79 0, 0, 0)
80
81#define CACTUS_DEADLOCK_GET_NEXT_DEST(smc_ret) smc_ret.ret4
82
83/**
84 * Command to request a sequence CACTUS_DEADLOCK_CMD between the partitions
85 * of specified IDs.
86 */
87#define CACTUS_REQ_DEADLOCK_CMD (CACTUS_DEADLOCK_CMD + 1)
88
89#define CACTUS_REQ_DEADLOCK_SEND_CMD(source, dest, next_dest1, next_dest2) \
90 CACTUS_SEND_CMD(source, dest, CACTUS_REQ_DEADLOCK_CMD, \
91 next_dest1, next_dest2, 0, 0)
92
93/*To get next_dest1 use CACTUS_DEADLOCK_GET_NEXT_DEST*/
94#define CACTUS_DEADLOCK_GET_NEXT_DEST2(smc_ret) smc_ret.ret5
95
96/**
J-Alvesd1aae292020-10-08 17:16:58 +010097 * Command to notify cactus of a memory management operation. The cmd value
98 * should be the memory management smc function id.
99 */
100#define CACTUS_MEM_SEND_CMD(source, dest, mem_func, handle) \
101 CACTUS_SEND_CMD(source, dest, mem_func, handle, 0, 0, 0)
102
103#define CACTUS_MEM_SEND_GET_HANDLE(smc_ret) smc_ret.ret4
104
105/**
106 * Template for responses to CACTUS commands.
107 */
108#define CACTUS_RESPONSE(source, dest, response) \
109 ffa_msg_send_direct_resp(source, dest, response)
110
111#define CACTUS_SUCCESS_RESP(source, dest) \
112 CACTUS_RESPONSE(source, dest, CACTUS_SUCCESS)
113
114#define CACTUS_ERROR_RESP(source, dest) \
115 CACTUS_RESPONSE(source, dest, CACTUS_ERROR)
116
117#define CACTUS_GET_RESPONSE(smc_ret) smc_ret.ret3
118
J-Alves28672f92020-11-09 15:34:31 +0000119#define CACTUS_IS_SUCCESS_RESP(smc_ret) \
120 (CACTUS_GET_RESPONSE(smc_ret) == CACTUS_SUCCESS)
121
J-Alvesd1aae292020-10-08 17:16:58 +0100122#endif