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
45
46
47
48
49
50
51
52
|
/* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#if !defined(__CROS_EC_HOST_COMMAND_H) || \
defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H)
#error "This file must only be included from host_command.h. " \
"Include host_command.h directly"
#endif
#define __CROS_EC_ZEPHYR_HOST_COMMAND_H
#include <init.h>
/** Node in a list of host-command handlers */
struct zshim_host_command_node {
struct host_command *cmd;
struct zshim_host_command_node *next;
};
/**
* Runtime helper for DECLARE_HOST_COMMAND setup data.
*
* @param routine Handler for the host command
* @param command Command to handle (EC_CMD_...)
* @param version_mask Mask of supported versions; use EC_VER_MASK() to select
* a version
*/
void zshim_setup_host_command(
int command,
enum ec_status (*routine)(struct host_cmd_handler_args *args),
int version_mask, struct zshim_host_command_node *entry);
/**
* See include/host_command.h for documentation.
*/
#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
_DECLARE_HOST_COMMAND_1(command, routine, version_mask, __LINE__)
#define _DECLARE_HOST_COMMAND_1(command, routine, version_mask, line) \
_DECLARE_HOST_COMMAND_2(command, routine, version_mask, line)
#define _DECLARE_HOST_COMMAND_2(command, routine, version_mask, line) \
static int _setup_host_command_##line(const struct device *unused) \
{ \
ARG_UNUSED(unused); \
static struct host_command cmd; \
static struct zshim_host_command_node lst; \
lst.cmd = &cmd; \
zshim_setup_host_command(command, routine, version_mask, \
&lst); \
return 0; \
} \
SYS_INIT(_setup_host_command_##line, APPLICATION, 1)
|