blob: 4d963ac4ce9f798df9106ccf8f5abb1f65bd9f95 [file] [log] [blame]
J-Alveseeb25472021-03-11 09:54:21 +00001/*
Daniel Boulbyce386b12022-03-29 18:36:36 +01002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
J-Alveseeb25472021-03-11 09:54:21 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <ffa_helpers.h>
8#include <spm_common.h>
9
10/**
11 * Pairs a command id with a function call, to handle the command ID.
12 */
13struct cactus_cmd_handler {
14 const uint64_t id;
Daniel Boulbyce386b12022-03-29 18:36:36 +010015 struct ffa_value (*fn)(const struct ffa_value *args,
16 struct mailbox_buffers *mb);
J-Alveseeb25472021-03-11 09:54:21 +000017};
18
19/**
20 * Helper to create the name of a handler function.
21 */
22#define CACTUS_HANDLER_FN_NAME(name) cactus_##name##_handler
23
24/**
25 * Define handler's function signature.
26 */
27#define CACTUS_HANDLER_FN(name) \
Daniel Boulbyce386b12022-03-29 18:36:36 +010028 static struct ffa_value CACTUS_HANDLER_FN_NAME(name)( \
29 const struct ffa_value *args, struct mailbox_buffers *mb)
J-Alveseeb25472021-03-11 09:54:21 +000030
31/**
32 * Helper to define Cactus command handler, and pair it with a command ID.
33 * It also creates a table with this information, to be traversed by
34 * 'cactus_handle_cmd' function.
35 */
36#define CACTUS_CMD_HANDLER(name, ID) \
37 CACTUS_HANDLER_FN(name); \
38 struct cactus_cmd_handler name __section(".cactus_handler") = { \
39 .id = ID, .fn = CACTUS_HANDLER_FN_NAME(name), \
40 }; \
41 CACTUS_HANDLER_FN(name)
42
Daniel Boulbyce386b12022-03-29 18:36:36 +010043bool cactus_handle_cmd(struct ffa_value *cmd_args, struct ffa_value *ret,
J-Alveseeb25472021-03-11 09:54:21 +000044 struct mailbox_buffers *mb);