| 
    Zephyr Project API
    3.4.0
    
   A Scalable Open Source RTOS 
   | 
 
EC Host Command Interface. More...
Data Structures | |
| struct | ec_host_cmd_rx_ctx | 
| Context for host command backend and handler to pass rx data.  More... | |
| struct | ec_host_cmd_tx_buf | 
| Context for host command backend and handler to pass tx data.  More... | |
| struct | ec_host_cmd_backend_api | 
| struct | ec_host_cmd | 
| struct | ec_host_cmd_handler_args | 
| Arguments passed into every installed host command handler.  More... | |
| struct | ec_host_cmd_handler | 
| Structure use for statically registering host command handlers.  More... | |
| struct | ec_host_cmd_request_header | 
| Header for requests from host to embedded controller.  More... | |
| struct | ec_host_cmd_response_header | 
| Header for responses from embedded controller to host.  More... | |
Macros | |
| #define | EC_HOST_CMD_HANDLER(_id, _function, _version_mask, _request_type, _response_type) | 
| Statically define and register a host command handler.  More... | |
| #define | EC_HOST_CMD_HANDLER_UNBOUND(_id, _function, _version_mask) | 
| Statically define and register a host command handler without sizes.  More... | |
Typedefs | |
| typedef int(* | ec_host_cmd_backend_api_init) (const struct ec_host_cmd_backend *backend, struct ec_host_cmd_rx_ctx *rx_ctx, struct ec_host_cmd_tx_buf *tx) | 
| Initialize a host command backend.  More... | |
| typedef int(* | ec_host_cmd_backend_api_send) (const struct ec_host_cmd_backend *backend) | 
| Sends data to the host.  More... | |
| typedef enum ec_host_cmd_status(* | ec_host_cmd_handler_cb) (struct ec_host_cmd_handler_args *args) | 
Enumerations | |
| enum | ec_host_cmd_status {  EC_HOST_CMD_SUCCESS = 0 , EC_HOST_CMD_INVALID_COMMAND = 1 , EC_HOST_CMD_ERROR = 2 , EC_HOST_CMD_INVALID_PARAM = 3 , EC_HOST_CMD_ACCESS_DENIED = 4 , EC_HOST_CMD_INVALID_RESPONSE = 5 , EC_HOST_CMD_INVALID_VERSION = 6 , EC_HOST_CMD_INVALID_CHECKSUM = 7 , EC_HOST_CMD_IN_PROGRESS = 8 , EC_HOST_CMD_UNAVAILABLE = 9 , EC_HOST_CMD_TIMEOUT = 10 , EC_HOST_CMD_OVERFLOW = 11 , EC_HOST_CMD_INVALID_HEADER = 12 , EC_HOST_CMD_REQUEST_TRUNCATED = 13 , EC_HOST_CMD_RESPONSE_TOO_BIG = 14 , EC_HOST_CMD_BUS_ERROR = 15 , EC_HOST_CMD_BUSY = 16 , EC_HOST_CMD_INVALID_HEADER_VERSION = 17 , EC_HOST_CMD_INVALID_HEADER_CRC = 18 , EC_HOST_CMD_INVALID_DATA_CRC = 19 , EC_HOST_CMD_DUP_UNAVAILABLE = 20 , EC_HOST_CMD_MAX = UINT16_MAX }  | 
Functions | |
| struct ec_host_cmd_backend * | ec_host_cmd_backend_get_espi (const struct device *dev) | 
| Get the eSPI Host Command backend pointer.  More... | |
| struct ec_host_cmd_backend * | ec_host_cmd_backend_get_shi_npcx (void) | 
| Get the SHI NPCX Host Command backend pointer.  More... | |
| struct ec_host_cmd_backend * | ec_host_cmd_backend_get_shi_ite (void) | 
| Get the SHI ITE Host Command backend pointer.  More... | |
| struct ec_host_cmd_backend * | ec_host_cmd_backend_get_uart (const struct device *dev) | 
| Get the UART Host Command backend pointer.  More... | |
| int | ec_host_cmd_init (struct ec_host_cmd_backend *backend) | 
| Initialize the host command subsystem.  More... | |
| 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.  More... | |
| const struct ec_host_cmd * | ec_host_cmd_get_hc (void) | 
| Get the main ec host command structure.  More... | |
| FUNC_NORETURN void | ec_host_cmd_task (void) | 
| The thread function for Host Command subsystem.  More... | |
EC Host Command Interface.
| #define EC_HOST_CMD_HANDLER | ( | _id, | |
| _function, | |||
| _version_mask, | |||
| _request_type, | |||
| _response_type | |||
| ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
Statically define and register a host command handler.
Helper macro to statically define and register a host command handler that has a compile-time-fixed sizes for its both request and response structures.
| _id | Id of host command to handle request for. | 
| _function | Name of handler function. | 
| _version_mask | The bitfield of all versions that the _function supports. E.g. BIT(0) corresponds to version 0. | 
| _request_type | The datatype of the request parameters for _function. | 
| _response_type | The datatype of the response parameters for _function. | 
| #define EC_HOST_CMD_HANDLER_UNBOUND | ( | _id, | |
| _function, | |||
| _version_mask | |||
| ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
Statically define and register a host command handler without sizes.
Helper macro to statically define and register a host command handler whose request or response structure size is not known as compile time.
| _id | Id of host command to handle request for. | 
| _function | Name of handler function. | 
| _version_mask | The bitfield of all versions that the _function supports. E.g. BIT(0) corresponds to version 0. | 
| typedef int(* ec_host_cmd_backend_api_init) (const struct ec_host_cmd_backend *backend, struct ec_host_cmd_rx_ctx *rx_ctx, struct ec_host_cmd_tx_buf *tx) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Initialize a host command backend.
This routine initializes a host command backend. It includes initialization a device used to communication and setting up buffers. This function is called by the ec_host_cmd_init function.
| [in] | backend | Pointer to the backend structure for the driver instance. | 
| [in,out] | rx_ctx | Pointer to the receive context object. These objects are used to receive data from the driver when the host sends data. The buf member can be assigned by the backend. | 
| [in,out] | tx | Pointer to the transmit buffer object. The buf and len_max members can be assigned by the backend. These objects are used to send data by the backend with the ec_host_cmd_backend_api_send function. | 
| 0 | if successful | 
| typedef int(* ec_host_cmd_backend_api_send) (const struct ec_host_cmd_backend *backend) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Sends data to the host.
Sends data from tx buf that was passed via ec_host_cmd_backend_api_init function.
| backend | Pointer to the backed to send data. | 
| 0 | if successful. | 
| typedef enum ec_host_cmd_status(* ec_host_cmd_handler_cb) (struct ec_host_cmd_handler_args *args) | 
| enum ec_host_cmd_status | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
| struct ec_host_cmd_backend * ec_host_cmd_backend_get_espi | ( | const struct device * | dev | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Get the eSPI Host Command backend pointer.
Get the eSPI pointer backend and pass a pointer to eSPI device instance that will be used for the Host Command communication.
| dev | Pointer to eSPI device instance. | 
| The | eSPI backend pointer. | 
| struct ec_host_cmd_backend * ec_host_cmd_backend_get_shi_ite | ( | void | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Get the SHI ITE Host Command backend pointer.
| the | SHI ITE backend pointer | 
| struct ec_host_cmd_backend * ec_host_cmd_backend_get_shi_npcx | ( | void | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Get the SHI NPCX Host Command backend pointer.
| the | SHI NPCX backend pointer | 
| struct ec_host_cmd_backend * ec_host_cmd_backend_get_uart | ( | const struct device * | dev | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/backend.h>
Get the UART Host Command backend pointer.
Get the UART pointer backend and pass a pointer to UART device instance that will be used for the Host Command communication.
| dev | Pointer to UART device instance. | 
| The | UART backend pointer. | 
| const struct ec_host_cmd * ec_host_cmd_get_hc | ( | void | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
Get the main ec host command structure.
This routine returns a pointer to the main host command structure. It allows the application code to get inside information for any reason e.g. the host command thread id.
| A | pointer to the main host command structure | 
| int ec_host_cmd_init | ( | struct ec_host_cmd_backend * | backend | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
Initialize the host command subsystem.
This routine initializes the host command subsystem. It includes initialization of a backend and the handler. When the application configures the zephyr,host-cmd-espi-backend/zephyr,host-cmd-shi-backend/ zephyr,host-cmd-uart-backend chosen node and  CONFIG_EC_HOST_CMD_INITIALIZE_AT_BOOT   is set, the chosen backend automatically calls this routine at  CONFIG_EC_HOST_CMD_INIT_PRIORITY  . Applications that require a run-time selection of the backend must set  CONFIG_EC_HOST_CMD_INITIALIZE_AT_BOOT   to n and must explicitly call this routine.
| [in] | backend | Pointer to the backend structure to initialize. | 
| 0 | if successful | 
| int ec_host_cmd_send_response | ( | enum ec_host_cmd_status | status, | 
| const struct ec_host_cmd_handler_args * | args | ||
| ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
Send the host command response.
This routine sends the host command response. It should be used to send IN_PROGRESS status or if the host command handler doesn't return e.g. reboot command.
| [in] | status | Host command status to be sent. | 
| [in] | args | Pointer of a structure passed to the handler. | 
| 0 | if successful. | 
| FUNC_NORETURN void ec_host_cmd_task | ( | void | ) | 
#include <include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h>
The thread function for Host Command subsystem.
This routine calls the Host Command thread entry function. If  CONFIG_EC_HOST_CMD_DEDICATED_THREAD   is not defined, a new thread is not created, and this function has to be called by application code. It doesn't return.