Line data Source code
1 1 : /*
2 : * Copyright (c) 2020 Google LLC
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief Header for commands to interact with the simulator outside of normal
10 : * device interface.
11 : * @ingroup ec_host_cmd_simulator
12 : */
13 :
14 : #ifndef ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
15 : #define ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
16 :
17 : /**
18 : * @brief Interface to EC Host Command Simulator
19 : * @defgroup ec_host_cmd_simulator Simulator
20 : * @ingroup ec_host_cmd_interface
21 : * @{
22 : */
23 :
24 : /* For ec_host_cmd_backend_api_send function pointer type */
25 : #include <zephyr/mgmt/ec_host_cmd/backend.h>
26 :
27 : /**
28 : * @brief Install callback for when this device would sends data to host
29 : *
30 : * When this host command simulator device should send data to the host, it
31 : * will call the callback parameter provided by this function. Note that
32 : * only one callback may be installed at a time. Calling this a second time
33 : * will override the first callback installation.
34 : *
35 : * @param cb Callback that is called when device would send data to host.
36 : * @param tx_buf Pointer of a pointer to the tx buf structure where data will
37 : * be sent.
38 : */
39 1 : void ec_host_cmd_backend_sim_install_send_cb(ec_host_cmd_backend_api_send cb,
40 : struct ec_host_cmd_tx_buf **tx_buf);
41 :
42 : /**
43 : * @brief Simulate receiving data from host as passed in to this function
44 : *
45 : * Calling this function simulates that data was sent from the host to the DUT.
46 : *
47 : * @param buffer The buffer that contains the data to receive.
48 : * @param len The number of bytes that are received from the above buffer.
49 : *
50 : * @retval 0 if successful
51 : * @retval -ENOMEM if len is greater than the RX buffer size.
52 : * @retval -EBUSY if the host command framework is busy with another request.
53 : */
54 1 : int ec_host_cmd_backend_sim_data_received(const uint8_t *buffer, size_t len);
55 :
56 : /**
57 : * @}
58 : */
59 :
60 : #endif /* ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_ */
|