Zephyr Project API  3.4.0
A Scalable Open Source RTOS
ec_host_cmd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_EC_HOST_CMD_H_
8#define ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_EC_HOST_CMD_H_
9
17#include <stdint.h>
18#include <zephyr/kernel.h>
20#include <zephyr/sys/__assert.h>
22
27#ifdef CONFIG_EC_HOST_CMD_DEDICATED_THREAD
28 struct k_thread thread;
29#endif /* CONFIG_EC_HOST_CMD_DEDICATED_THREAD */
30};
31
37 void *reserved;
46 const void *input_buf;
55};
56
82};
83
98#define EC_HOST_CMD_HANDLER(_id, _function, _version_mask, _request_type, _response_type) \
99 const STRUCT_SECTION_ITERABLE(ec_host_cmd_handler, __cmd##_id) = { \
100 .id = _id, \
101 .handler = _function, \
102 .version_mask = _version_mask, \
103 .min_rqt_size = sizeof(_request_type), \
104 .min_rsp_size = sizeof(_response_type), \
105 }
106
118#define EC_HOST_CMD_HANDLER_UNBOUND(_id, _function, _version_mask) \
119 const STRUCT_SECTION_ITERABLE(ec_host_cmd_handler, __cmd##_id) = { \
120 .id = _id, \
121 .handler = _function, \
122 .version_mask = _version_mask, \
123 .min_rqt_size = 0, \
124 .min_rsp_size = 0, \
125 }
126
156} __packed;
157
179} __packed;
180
181/*
182 * Host command response codes (16-bit).
183 */
227
228 EC_HOST_CMD_MAX = UINT16_MAX /* Force enum to be 16 bits. */
229} __packed;
230
248
261 const struct ec_host_cmd_handler_args *args);
262
272const struct ec_host_cmd *ec_host_cmd_get_hc(void);
273
274#ifndef CONFIG_EC_HOST_CMD_DEDICATED_THREAD
282FUNC_NORETURN void ec_host_cmd_task(void);
283#endif
284
289#endif /* ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_EC_HOST_CMD_H_ */
static struct k_thread thread[2]
Definition: atomic.c:26
Public APIs for Host Command backends that respond to host commands.
enum ec_host_cmd_status(* ec_host_cmd_handler_cb)(struct ec_host_cmd_handler_args *args)
Definition: ec_host_cmd.h:57
int ec_host_cmd_send_response(enum ec_host_cmd_status status, const struct ec_host_cmd_handler_args *args)
Send the host command response.
ec_host_cmd_status
Definition: ec_host_cmd.h:184
FUNC_NORETURN void ec_host_cmd_task(void)
The thread function for Host Command subsystem.
int ec_host_cmd_init(struct ec_host_cmd_backend *backend)
Initialize the host command subsystem.
const struct ec_host_cmd * ec_host_cmd_get_hc(void)
Get the main ec host command structure.
@ EC_HOST_CMD_BUSY
Definition: ec_host_cmd.h:218
@ EC_HOST_CMD_REQUEST_TRUNCATED
Definition: ec_host_cmd.h:212
@ EC_HOST_CMD_INVALID_DATA_CRC
Definition: ec_host_cmd.h:224
@ EC_HOST_CMD_DUP_UNAVAILABLE
Definition: ec_host_cmd.h:226
@ EC_HOST_CMD_ERROR
Definition: ec_host_cmd.h:190
@ EC_HOST_CMD_INVALID_HEADER
Definition: ec_host_cmd.h:210
@ EC_HOST_CMD_INVALID_HEADER_VERSION
Definition: ec_host_cmd.h:220
@ EC_HOST_CMD_IN_PROGRESS
Definition: ec_host_cmd.h:202
@ EC_HOST_CMD_SUCCESS
Definition: ec_host_cmd.h:186
@ EC_HOST_CMD_INVALID_VERSION
Definition: ec_host_cmd.h:198
@ EC_HOST_CMD_INVALID_CHECKSUM
Definition: ec_host_cmd.h:200
@ EC_HOST_CMD_UNAVAILABLE
Definition: ec_host_cmd.h:204
@ EC_HOST_CMD_INVALID_HEADER_CRC
Definition: ec_host_cmd.h:222
@ EC_HOST_CMD_MAX
Definition: ec_host_cmd.h:228
@ EC_HOST_CMD_INVALID_COMMAND
Definition: ec_host_cmd.h:188
@ EC_HOST_CMD_ACCESS_DENIED
Definition: ec_host_cmd.h:194
@ EC_HOST_CMD_TIMEOUT
Definition: ec_host_cmd.h:206
@ EC_HOST_CMD_BUS_ERROR
Definition: ec_host_cmd.h:216
@ EC_HOST_CMD_INVALID_PARAM
Definition: ec_host_cmd.h:192
@ EC_HOST_CMD_OVERFLOW
Definition: ec_host_cmd.h:208
@ EC_HOST_CMD_RESPONSE_TOO_BIG
Definition: ec_host_cmd.h:214
@ EC_HOST_CMD_INVALID_RESPONSE
Definition: ec_host_cmd.h:196
Public kernel APIs.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
#define UINT16_MAX
Definition: stdint.h:28
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Definition: backend.h:24
Arguments passed into every installed host command handler.
Definition: ec_host_cmd.h:35
uint16_t command
Definition: ec_host_cmd.h:39
uint16_t output_buf_size
Definition: ec_host_cmd.h:54
void * output_buf
Definition: ec_host_cmd.h:50
const void * input_buf
Definition: ec_host_cmd.h:46
uint16_t input_buf_size
Definition: ec_host_cmd.h:48
void * reserved
Definition: ec_host_cmd.h:37
uint16_t output_buf_max
Definition: ec_host_cmd.h:52
uint8_t version
Definition: ec_host_cmd.h:44
Structure use for statically registering host command handlers.
Definition: ec_host_cmd.h:61
uint16_t version_mask
Definition: ec_host_cmd.h:71
uint16_t min_rsp_size
Definition: ec_host_cmd.h:81
ec_host_cmd_handler_cb handler
Definition: ec_host_cmd.h:63
uint16_t id
Definition: ec_host_cmd.h:65
uint16_t min_rqt_size
Definition: ec_host_cmd.h:76
Header for requests from host to embedded controller.
Definition: ec_host_cmd.h:134
uint16_t cmd_id
Definition: ec_host_cmd.h:146
uint8_t cmd_ver
Definition: ec_host_cmd.h:151
uint8_t prtcl_ver
Definition: ec_host_cmd.h:139
uint8_t checksum
Definition: ec_host_cmd.h:144
uint8_t reserved
Definition: ec_host_cmd.h:153
uint16_t data_len
Definition: ec_host_cmd.h:155
Header for responses from embedded controller to host.
Definition: ec_host_cmd.h:165
uint8_t prtcl_ver
Definition: ec_host_cmd.h:167
uint16_t reserved
Definition: ec_host_cmd.h:178
uint16_t result
Definition: ec_host_cmd.h:174
uint8_t checksum
Definition: ec_host_cmd.h:172
uint16_t data_len
Definition: ec_host_cmd.h:176
Context for host command backend and handler to pass rx data.
Definition: backend.h:41
Context for host command backend and handler to pass tx data.
Definition: backend.h:60
Definition: ec_host_cmd.h:23
struct ec_host_cmd_rx_ctx rx_ctx
Definition: ec_host_cmd.h:24
struct ec_host_cmd_backend * backend
Definition: ec_host_cmd.h:26
struct ec_host_cmd_tx_buf tx
Definition: ec_host_cmd.h:25
Definition: thread.h:245