aboutsummaryrefslogtreecommitdiff
path: root/include/runtime_services/cactus_message_loop.h
blob: d69e77ce9b2478393e42fb2f8df641b4b9ff4671 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <ffa_helpers.h>
#include <spm_common.h>

/**
 * Pairs a command id with a function call, to handle the command ID.
 */
struct cactus_cmd_handler {
	const uint64_t id;
	smc_ret_values (*fn)(const smc_ret_values *args,
			     struct mailbox_buffers *mb);
};

/**
 * Helper to create the name of a handler function.
 */
#define CACTUS_HANDLER_FN_NAME(name) cactus_##name##_handler

/**
 * Define handler's function signature.
 */
#define CACTUS_HANDLER_FN(name)						\
	static smc_ret_values CACTUS_HANDLER_FN_NAME(name)(		\
		const smc_ret_values *args, struct mailbox_buffers *mb)

/**
 * Helper to define Cactus command handler, and pair it with a command ID.
 * It also creates a table with this information, to be traversed by
 * 'cactus_handle_cmd' function.
 */
#define CACTUS_CMD_HANDLER(name, ID)					\
	CACTUS_HANDLER_FN(name);					\
	struct cactus_cmd_handler name __section(".cactus_handler") = {	\
		.id = ID, .fn = CACTUS_HANDLER_FN_NAME(name),		\
	};								\
	CACTUS_HANDLER_FN(name)

bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret,
		       struct mailbox_buffers *mb);