summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2023-01-11 17:55:09 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-16 00:46:34 +0000
commit654c7f10f0447d04cdafee9ea19f887f964d8940 (patch)
treec86673bfc91c80cf1eb1df29fe30b1e15a317afa
parent0893963bfd157ad6310266381b921b8f007ef31d (diff)
downloadchrome-ec-654c7f10f0447d04cdafee9ea19f887f964d8940.tar.gz
zephyr/test: Update tests to use EC CMD API
This refactors the unit tests to use the EC host command API. Calls to the generic host_command_process(...) are replaced with type-checked host command API calls that perform the same operation. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes Change-Id: I1b925a04271dd50c3c7c0a3481cd30ba762b1561 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4172828 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/test/ap_power/src/host_command.c7
-rw-r--r--zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c28
-rw-r--r--zephyr/test/drivers/chargesplash/src/chargesplash.c4
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/utils.h29
-rw-r--r--zephyr/test/drivers/common/src/utils.c96
-rw-r--r--zephyr/test/drivers/default/src/espi.c92
-rw-r--r--zephyr/test/drivers/default/src/i2c.c47
-rw-r--r--zephyr/test/drivers/default/src/i2c_passthru.c37
-rw-r--r--zephyr/test/drivers/default/src/lid_switch.c12
-rw-r--r--zephyr/test/drivers/default/src/locate_chip.c22
-rw-r--r--zephyr/test/drivers/default/src/power_common.c62
-rw-r--r--zephyr/test/drivers/default/src/uart_hostcmd.c18
-rw-r--r--zephyr/test/drivers/default/src/usb_mux.c15
-rw-r--r--zephyr/test/drivers/default/src/vboot_hash.c30
-rw-r--r--zephyr/test/drivers/default/src/vstore.c23
-rw-r--r--zephyr/test/drivers/flash/src/flash.c45
-rw-r--r--zephyr/test/drivers/host_cmd/src/adc.c10
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_cut_off.c16
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_display_soc.c5
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_v2.c25
-rw-r--r--zephyr/test/drivers/host_cmd/src/charge_manager.c33
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_cmd_versions.c15
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c9
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command.c15
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c11
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands.c26
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c52
-rw-r--r--zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c13
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_chip_info.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_control.c16
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_log.c18
-rw-r--r--zephyr/test/drivers/host_cmd/src/tablet_mode.c20
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_control.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c45
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c8
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c8
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/mkbp_event.c37
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/mkbp_info.c55
-rw-r--r--zephyr/test/drivers/led_driver/src/led_common.c25
-rw-r--r--zephyr/test/drivers/locate_chip/src/locate_chip.c4
-rw-r--r--zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c15
-rw-r--r--zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c25
-rw-r--r--zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c28
-rw-r--r--zephyr/test/drivers/system/src/system.c6
-rw-r--r--zephyr/test/drivers/system/src/system_board_version_default.c6
-rw-r--r--zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c12
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c5
-rw-r--r--zephyr/test/krabby/src/power_seq.c24
-rw-r--r--zephyr/test/qcom_power/src/main.c12
-rw-r--r--zephyr/test/system_common/src/get_version.c10
-rw-r--r--zephyr/test/system_common/src/reboot.c4
-rw-r--r--zephyr/test/system_safe_mode/src/system_safe_mode.c7
-rw-r--r--zephyr/test/vboot_efs2/src/main.c5
53 files changed, 385 insertions, 815 deletions
diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c
index f0b3b0d732..1898bb86b5 100644
--- a/zephyr/test/ap_power/src/host_command.c
+++ b/zephyr/test/ap_power/src/host_command.c
@@ -16,12 +16,9 @@ ZTEST(host_cmd, test_hibernate_get)
.seconds = 0,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_HIBERNATION_DELAY, 0, response, params);
-
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_hibernation_delay(NULL, &params, &response));
params.seconds = 123;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(123, response.hibernate_delay, NULL);
}
diff --git a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
index 897155485c..6c31880625 100644
--- a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
+++ b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
@@ -254,10 +254,8 @@ ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_port)
.partner_type = TYPEC_PARTNER_SOP,
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_INVALID_PARAM,
"Failed to see port error");
}
@@ -272,10 +270,8 @@ ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_type)
.partner_type = TYPEC_PARTNER_SOP_PRIME_PRIME + 1,
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_INVALID_PARAM,
"Failed to see port error");
}
@@ -290,10 +286,8 @@ ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_count)
.partner_type = TYPEC_PARTNER_SOP,
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_INVALID_PARAM,
"Failed to see port error");
}
@@ -350,10 +344,8 @@ ZTEST_F(ap_vdm_control, test_send_vdm_sop_attention_bad)
.partner_type = TYPEC_PARTNER_SOP,
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_INVALID_PARAM,
"Failed to see port error");
}
@@ -370,16 +362,14 @@ ZTEST_F(ap_vdm_control, test_send_vdm_req_in_progress)
.partner_type = TYPEC_PARTNER_SOP,
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
/*
* First command should succeed, but given no time to process the second
* should return busy
*/
- zassert_equal(host_command_process(&args), EC_RES_SUCCESS,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_SUCCESS,
"Failed to send successful request");
- zassert_equal(host_command_process(&args), EC_RES_BUSY,
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_BUSY,
"Failed to see busy");
}
@@ -489,11 +479,9 @@ ZTEST_F(ap_vdm_control, test_vdm_request_bad_port)
{
struct ec_response_typec_vdm_response vdm_resp;
struct ec_params_typec_vdm_response params = { .port = 88 };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_TYPEC_VDM_RESPONSE, 0, vdm_resp, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
- "Failed to see bad port");
+ zassert_equal(ec_cmd_typec_vdm_response(NULL, &params, &vdm_resp),
+ EC_RES_INVALID_PARAM, "Failed to see bad port");
}
ZTEST_F(ap_vdm_control, test_vdm_request_in_progress)
diff --git a/zephyr/test/drivers/chargesplash/src/chargesplash.c b/zephyr/test/drivers/chargesplash/src/chargesplash.c
index 27b3678bd8..8ca872155b 100644
--- a/zephyr/test/drivers/chargesplash/src/chargesplash.c
+++ b/zephyr/test/drivers/chargesplash/src/chargesplash.c
@@ -29,10 +29,8 @@ chargesplash_hostcmd(enum ec_chargesplash_cmd cmd,
struct ec_response_chargesplash *response)
{
struct ec_params_chargesplash params = { .cmd = cmd };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_CHARGESPLASH, 0, *response, params);
- return host_command_process(&args);
+ return ec_cmd_chargesplash(NULL, &params, response);
}
static bool is_chargesplash_requested(void)
diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h
index 98f65bf966..8f7c7773f3 100644
--- a/zephyr/test/drivers/common/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/common/include/test/drivers/utils.h
@@ -105,10 +105,9 @@ void acpi_write(uint8_t acpi_addr, uint8_t write_byte);
static inline struct ec_response_get_features host_cmd_get_features(void)
{
struct ec_response_get_features response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response);
- zassert_ok(host_command_process(&args), "Failed to get features");
+ zassert_ok(ec_cmd_get_features(NULL, &response),
+ "Failed to get features");
return response;
}
@@ -128,10 +127,8 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum)
.cmd = CHARGE_STATE_CMD_GET_STATE,
};
struct ec_response_charge_state response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response),
"Failed to get charge state for chgnum %d", chgnum);
return response;
}
@@ -149,10 +146,8 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port)
{
struct ec_params_usb_pd_power_info params = { .port = port };
struct ec_response_usb_pd_power_info response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_USB_PD_POWER_INFO, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_usb_pd_power_info(NULL, &params, &response),
"Failed to get power info for port %d", port);
return response;
}
@@ -170,10 +165,8 @@ static inline struct ec_response_typec_status host_cmd_typec_status(int port)
{
struct ec_params_typec_status params = { .port = port };
struct ec_response_typec_status response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_status(NULL, &params, &response),
"Failed to get Type-C state for port %d", port);
return response;
}
@@ -194,10 +187,8 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
{
struct ec_params_usb_pd_control params = { .port = port, .swap = swap };
struct ec_response_usb_pd_control response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_usb_pd_control(NULL, &params, &response),
"Failed to process usb_pd_control_swap for port %d, swap %d",
port, swap);
return response;
@@ -215,10 +206,8 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
static inline void host_cmd_pd_control(int port, enum ec_pd_control_cmd cmd)
{
struct ec_params_pd_control params = { .chip = port, .subcmd = cmd };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_pd_control(NULL, &params),
"Failed to process pd_control for port %d, cmd %d", port,
cmd);
}
@@ -239,10 +228,8 @@ host_cmd_charge_control(enum ec_charge_control_mode mode,
.upper = -1,
} };
struct ec_response_charge_control response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_charge_control_v2(NULL, &params, &response),
"Failed to get charge control values");
return response;
diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c
index 000348df9e..1651b26546 100644
--- a/zephyr/test/drivers/common/src/utils.c
+++ b/zephyr/test/drivers/common/src/utils.c
@@ -227,10 +227,8 @@ enum ec_status host_cmd_host_event(enum ec_host_event_action action,
.action = action,
.mask_type = mask_type,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_HOST_EVENT, 0, *r, params);
- ret_val = host_command_process(&args);
+ ret_val = ec_cmd_host_event(NULL, &params, r);
return ret_val;
}
@@ -244,10 +242,8 @@ void host_cmd_motion_sense_dump(int max_sensor_count,
.max_sensor_count = max_sensor_count,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 4, *response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_motion_sense_cmd_v4(NULL, &params, response),
"Failed to get motion_sense dump");
}
@@ -260,10 +256,8 @@ int host_cmd_motion_sense_data(uint8_t sensor_num,
.sensor_num = sensor_num,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 4, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v4(NULL, &params, response);
}
int host_cmd_motion_sense_info(uint8_t cmd_version, uint8_t sensor_num,
@@ -291,10 +285,8 @@ int host_cmd_motion_sense_ec_rate(uint8_t sensor_num, int data_rate_ms,
.data = data_rate_ms,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_odr(uint8_t sensor_num, int32_t odr, bool round_up,
@@ -308,10 +300,8 @@ int host_cmd_motion_sense_odr(uint8_t sensor_num, int32_t odr, bool round_up,
.roundup = round_up,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_range(uint8_t sensor_num, int32_t range,
@@ -326,10 +316,8 @@ int host_cmd_motion_sense_range(uint8_t sensor_num, int32_t range,
.roundup = round_up,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_offset(uint8_t sensor_num, uint16_t flags,
@@ -346,10 +334,8 @@ int host_cmd_motion_sense_offset(uint8_t sensor_num, uint16_t flags,
.offset = { offset_x, offset_y, offset_z },
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_scale(uint8_t sensor_num, uint16_t flags,
@@ -366,10 +352,8 @@ int host_cmd_motion_sense_scale(uint8_t sensor_num, uint16_t flags,
.scale = { scale_x, scale_y, scale_z },
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_calib(uint8_t sensor_num, bool enable,
@@ -382,10 +366,8 @@ int host_cmd_motion_sense_calib(uint8_t sensor_num, bool enable,
.enable = enable,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_fifo_flush(uint8_t sensor_num,
@@ -397,10 +379,8 @@ int host_cmd_motion_sense_fifo_flush(uint8_t sensor_num,
.sensor_num = sensor_num,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_fifo_info(struct ec_response_motion_sense *response)
@@ -408,10 +388,8 @@ int host_cmd_motion_sense_fifo_info(struct ec_response_motion_sense *response)
struct ec_params_motion_sense params = {
.cmd = MOTIONSENSE_CMD_FIFO_INFO,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_fifo_read(uint8_t buffer_length,
@@ -423,10 +401,8 @@ int host_cmd_motion_sense_fifo_read(uint8_t buffer_length,
.max_data_vector = buffer_length,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_int_enable(int8_t enable,
@@ -438,10 +414,8 @@ int host_cmd_motion_sense_int_enable(int8_t enable,
.enable = enable,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_spoof(uint8_t sensor_num, uint8_t enable,
@@ -457,10 +431,8 @@ int host_cmd_motion_sense_spoof(uint8_t sensor_num, uint8_t enable,
.components = { values0, values1, values2 },
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_kb_wake_angle(
@@ -472,10 +444,8 @@ int host_cmd_motion_sense_kb_wake_angle(
.data = data,
},
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_lid_angle(struct ec_response_motion_sense *response)
@@ -483,10 +453,8 @@ int host_cmd_motion_sense_lid_angle(struct ec_response_motion_sense *response)
struct ec_params_motion_sense params = {
.cmd = MOTIONSENSE_CMD_LID_ANGLE,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
int host_cmd_motion_sense_tablet_mode_lid_angle(
@@ -499,10 +467,8 @@ int host_cmd_motion_sense_tablet_mode_lid_angle(
.lid_angle = lid_angle,
.hys_degree = hys_degree,
} };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_MOTION_SENSE_CMD, 1, *response, params);
- return host_command_process(&args);
+ return ec_cmd_motion_sense_cmd_v1(NULL, &params, response);
}
void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type,
@@ -530,10 +496,8 @@ void host_cmd_typec_control_enter_mode(int port, enum typec_mode mode)
.command = TYPEC_CONTROL_COMMAND_ENTER_MODE,
.mode_to_enter = mode
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -542,10 +506,8 @@ void host_cmd_typec_control_exit_modes(int port)
struct ec_params_typec_control params = {
.port = port, .command = TYPEC_CONTROL_COMMAND_EXIT_MODES
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -557,10 +519,8 @@ void host_cmd_typec_control_usb_mux_set(int port,
.command = TYPEC_CONTROL_COMMAND_USB_MUX_SET,
.mux_params = mux_set,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -571,10 +531,8 @@ void host_cmd_typec_control_clear_events(int port, uint32_t events)
.command = TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
.clear_events_mask = events,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -585,10 +543,8 @@ void host_cmd_typec_control_bist_share_mode(int port, int enable)
.command = TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE,
.bist_share_mode = enable
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -599,10 +555,8 @@ void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req)
.command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
.vdm_req_params = vdm_req,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_control(NULL, &params),
"Failed to send Type-C control for port %d", port);
}
@@ -610,10 +564,8 @@ struct ec_response_typec_vdm_response host_cmd_typec_vdm_response(int port)
{
struct ec_params_typec_vdm_response params = { .port = port };
struct ec_response_typec_vdm_response response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_TYPEC_VDM_RESPONSE, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_typec_vdm_response(NULL, &params, &response),
"Failed to get Type-C state for port %d", port);
return response;
}
diff --git a/zephyr/test/drivers/default/src/espi.c b/zephyr/test/drivers/default/src/espi.c
index d81718d422..86428d4ba6 100644
--- a/zephyr/test/drivers/default/src/espi.c
+++ b/zephyr/test/drivers/default/src/espi.c
@@ -36,11 +36,9 @@ static void espi_after(void *state)
ZTEST_USER(espi, test_host_command_get_protocol_info)
{
struct ec_response_get_protocol_info response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_GET_PROTOCOL_INFO, 0, response);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_get_protocol_info(&args, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.protocol_versions, BIT(3));
zassert_equal(response.max_request_packet_size, EC_LPC_HOST_PACKET_SIZE,
@@ -55,12 +53,9 @@ ZTEST_USER(espi, test_host_command_usb_pd_power_info)
/* Only test we've enabled the command */
struct ec_response_usb_pd_power_info response;
struct ec_params_usb_pd_power_info params = { .port = PORT };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_USB_PD_POWER_INFO, 0, response, params);
+ struct host_cmd_handler_args args;
- args.params = &params;
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_usb_pd_power_info(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
}
@@ -69,11 +64,9 @@ ZTEST_USER(espi, test_host_command_typec_status)
/* Only test we've enabled the command */
struct ec_params_typec_status params = { .port = PORT };
struct ec_response_typec_status response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_typec_status(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
}
@@ -85,20 +78,17 @@ ZTEST_USER(espi, test_host_command_gpio_get_v0)
};
struct ec_response_gpio_get response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 0, response, p);
+ struct host_cmd_handler_args args;
set_ac_enabled(true);
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_gpio_get(&args, &p, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_true(response.val);
set_ac_enabled(false);
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_gpio_get(&args, &p, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_false(response.val);
}
@@ -114,21 +104,18 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_by_name)
};
struct ec_response_gpio_get_v1 response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p);
+ struct host_cmd_handler_args args;
set_ac_enabled(true);
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response));
zassert_equal(args.response_size, sizeof(response.get_value_by_name),
NULL);
zassert_true(response.get_info.val);
set_ac_enabled(false);
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response));
zassert_equal(args.response_size, sizeof(response.get_value_by_name),
NULL);
zassert_false(response.get_info.val);
@@ -141,11 +128,9 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_count)
};
struct ec_response_gpio_get_v1 response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
+ zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL);
zassert_equal(args.response_size, sizeof(response.get_count), NULL);
zassert_equal(response.get_count.val, GPIO_COUNT, NULL);
}
@@ -161,21 +146,18 @@ ZTEST_USER(espi, test_host_command_gpio_get_v1_get_info)
};
struct ec_response_gpio_get_v1 response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, p);
+ struct host_cmd_handler_args args;
set_ac_enabled(true);
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
+ zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL);
zassert_equal(args.response_size, sizeof(response), NULL);
zassert_ok(strcmp(response.get_info.name, AC_OK_OD_GPIO_NAME), NULL);
zassert_true(response.get_info.val, NULL);
set_ac_enabled(false);
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
+ zassert_ok(ec_cmd_gpio_get_v1(&args, &p, &response), NULL);
zassert_equal(args.response_size, sizeof(response), NULL);
zassert_ok(strcmp(response.get_info.name, AC_OK_OD_GPIO_NAME), NULL);
zassert_false(response.get_info.val, NULL);
@@ -192,18 +174,15 @@ ZTEST_USER(espi, test_host_command_gpio_set)
.val = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, p);
-
/* Force value to 1 to see change */
zassert_ok(gpio_pin_set_dt(gp, 1), NULL);
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_gpio_set(NULL, &p), NULL);
zassert_equal(gpio_pin_get_dt(gp), p.val, NULL);
p.val = 1;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_gpio_set(NULL, &p), NULL);
zassert_equal(gpio_pin_get_dt(gp), p.val, NULL);
}
@@ -211,10 +190,9 @@ ZTEST(espi, test_hc_gpio_get_v0_invalid_name)
{
struct ec_response_gpio_get response;
struct ec_params_gpio_get params = { .name = "INVALID_GPIO_NAME" };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 0, response, params);
- zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_ERROR, ec_cmd_gpio_get(NULL, &params, &response),
+ NULL);
}
ZTEST(espi, test_hc_gpio_get_v1_get_by_name_invalid_name)
@@ -224,10 +202,9 @@ ZTEST(espi, test_hc_gpio_get_v1_get_by_name_invalid_name)
.subcmd = EC_GPIO_GET_BY_NAME,
.get_value_by_name.name = "INVALID_GPIO_NAME",
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params);
- zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_ERROR,
+ ec_cmd_gpio_get_v1(NULL, &params, &response), NULL);
}
ZTEST(espi, test_hc_gpio_get_v1_get_info_invalid_index)
@@ -237,10 +214,9 @@ ZTEST(espi, test_hc_gpio_get_v1_get_info_invalid_index)
.subcmd = EC_GPIO_GET_INFO,
.get_info.index = GPIO_COUNT,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params);
- zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_ERROR,
+ ec_cmd_gpio_get_v1(NULL, &params, &response), NULL);
}
ZTEST(espi, test_hc_gpio_get_v1_invalid_subcmd)
@@ -249,20 +225,17 @@ ZTEST(espi, test_hc_gpio_get_v1_invalid_subcmd)
struct ec_params_gpio_get_v1 params = {
.subcmd = EC_CMD_GPIO_GET,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GPIO_GET, 1, response, params);
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_gpio_get_v1(NULL, &params, &response), NULL);
}
/* EC_CMD_GET_FEATURES */
ZTEST_USER(espi, test_host_command_ec_cmd_get_features)
{
struct ec_response_get_features response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response);
- int rv = host_command_process(&args);
+ int rv = ec_cmd_get_features(NULL, &response);
zassert_equal(rv, EC_RES_SUCCESS, "Expected %d, but got %d",
EC_RES_SUCCESS, rv);
@@ -285,11 +258,10 @@ ZTEST_USER(espi, test_host_command_ec_cmd_get_features)
ZTEST(espi, test_hc_gpio_set_system_is_locked)
{
struct ec_params_gpio_set params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, params);
system_is_locked_fake.return_val = 1;
- zassert_equal(EC_RES_ACCESS_DENIED, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_ACCESS_DENIED, ec_cmd_gpio_set(NULL, &params),
+ NULL);
}
ZTEST(espi, test_hc_gpio_set_invalid_gpio_name)
@@ -298,10 +270,8 @@ ZTEST(espi, test_hc_gpio_set_invalid_gpio_name)
.name = "",
.val = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, params);
- zassert_equal(EC_RES_ERROR, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_ERROR, ec_cmd_gpio_set(NULL, &params), NULL);
}
ZTEST_SUITE(espi, drivers_predicate_post_main, NULL, espi_before, espi_after,
diff --git a/zephyr/test/drivers/default/src/i2c.c b/zephyr/test/drivers/default/src/i2c.c
index ca27fedbb2..b171f7dab9 100644
--- a/zephyr/test/drivers/default/src/i2c.c
+++ b/zephyr/test/drivers/default/src/i2c.c
@@ -18,18 +18,15 @@ ZTEST_USER(i2c, test_i2c_set_speed_success)
.port = I2C_PORT_USB_C0,
.cmd = EC_I2C_CONTROL_GET_SPEED,
};
- struct host_cmd_handler_args get_args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, get_params);
+ struct host_cmd_handler_args get_args;
struct ec_params_i2c_control set_params = {
.port = I2C_PORT_USB_C0,
.cmd = EC_I2C_CONTROL_SET_SPEED,
};
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params);
+ struct host_cmd_handler_args set_args;
/* Get the speed: 100. */
- zassert_ok(host_command_process(&get_args), NULL);
- zassert_ok(get_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL);
zassert_equal(get_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 100,
"response.cmd_response.speed_khz = %d",
@@ -37,16 +34,14 @@ ZTEST_USER(i2c, test_i2c_set_speed_success)
/* Set the speed to 400. */
set_params.cmd_params.speed_khz = 400;
- zassert_ok(host_command_process(&set_args), NULL);
- zassert_ok(set_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL);
zassert_equal(set_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 100,
"response.cmd_response.speed_khz = %d",
response.cmd_response.speed_khz);
/* Get the speed to verify. */
- zassert_ok(host_command_process(&get_args), NULL);
- zassert_ok(get_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL);
zassert_equal(get_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 400,
"response.cmd_response.speed_khz = %d",
@@ -54,16 +49,14 @@ ZTEST_USER(i2c, test_i2c_set_speed_success)
/* Set the speed to 1000. */
set_params.cmd_params.speed_khz = 1000;
- zassert_ok(host_command_process(&set_args), NULL);
- zassert_ok(set_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL);
zassert_equal(set_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 400,
"response.cmd_response.speed_khz = %d",
response.cmd_response.speed_khz);
/* Get the speed to verify. */
- zassert_ok(host_command_process(&get_args), NULL);
- zassert_ok(get_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&get_args, &get_params, &response), NULL);
zassert_equal(get_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 1000,
"response.cmd_response.speed_khz = %d",
@@ -71,8 +64,7 @@ ZTEST_USER(i2c, test_i2c_set_speed_success)
/* Set the speed back to 100. */
set_params.cmd_params.speed_khz = 100;
- zassert_ok(host_command_process(&set_args), NULL);
- zassert_ok(set_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_control(&set_args, &set_params, &response), NULL);
zassert_equal(set_args.response_size, sizeof(response), NULL);
zassert_equal(response.cmd_response.speed_khz, 1000,
"response.cmd_response.speed_khz = %d",
@@ -87,11 +79,10 @@ ZTEST_USER(i2c, test_i2c_set_speed_not_dynamic)
.cmd = EC_I2C_CONTROL_SET_SPEED,
.cmd_params.speed_khz = 400,
};
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params);
/* Set the speed to 400 on a bus which doesn't support dynamic-speed. */
- zassert_equal(EC_RES_ERROR, host_command_process(&set_args), NULL);
+ zassert_equal(EC_RES_ERROR,
+ ec_cmd_i2c_control(NULL, &set_params, &response), NULL);
}
ZTEST_USER(i2c, test_i2c_control_wrong_port)
@@ -101,12 +92,10 @@ ZTEST_USER(i2c, test_i2c_control_wrong_port)
.port = 10,
.cmd = EC_I2C_CONTROL_GET_SPEED,
};
- struct host_cmd_handler_args get_args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, get_params);
/* Set the .port=10, which is not defined. */
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&get_args),
- NULL);
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_i2c_control(NULL, &get_params, &response), NULL);
}
ZTEST_USER(i2c, test_i2c_control_wrong_cmd)
@@ -116,12 +105,10 @@ ZTEST_USER(i2c, test_i2c_control_wrong_cmd)
.port = I2C_PORT_USB_C0,
.cmd = 10,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, params);
/* Call the .cmd=10, which is not defined. */
- zassert_equal(EC_RES_INVALID_COMMAND, host_command_process(&args),
- NULL);
+ zassert_equal(EC_RES_INVALID_COMMAND,
+ ec_cmd_i2c_control(NULL, &params, &response), NULL);
}
ZTEST_USER(i2c, test_i2c_set_speed_wrong_freq)
@@ -132,12 +119,10 @@ ZTEST_USER(i2c, test_i2c_set_speed_wrong_freq)
.cmd = EC_I2C_CONTROL_SET_SPEED,
.cmd_params.speed_khz = 123,
};
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND(EC_CMD_I2C_CONTROL, 0, response, set_params);
/* Set the speed to 123 KHz (an invalid speed). */
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&set_args),
- NULL);
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_i2c_control(NULL, &set_params, &response), NULL);
}
static void i2c_freq_reset(void)
diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c
index afefc4b553..21726ea8f6 100644
--- a/zephyr/test/drivers/default/src/i2c_passthru.c
+++ b/zephyr/test/drivers/default/src/i2c_passthru.c
@@ -112,37 +112,39 @@ ZTEST_USER(i2c_passthru, test_passthru_protect)
.port = I2C_PORT_SENSOR,
.subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE,
};
- struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params);
/* Check the protect status: 0 (unprotected) */
- zassert_ok(host_command_process(&status_args), NULL);
- zassert_ok(status_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_passthru_protect(&status_args, &status_params,
+ &response),
+ NULL);
zassert_equal(status_args.response_size, sizeof(response), NULL);
zassert_equal(response.status, 0, "response.status = %d",
response.status);
/* Protect the bus */
- zassert_ok(host_command_process(&enable_args), NULL);
- zassert_ok(enable_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params, &response),
+ NULL);
/* Check the protect status: 1 (protected) */
- zassert_ok(host_command_process(&status_args), NULL);
- zassert_ok(status_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_passthru_protect(&status_args, &status_params,
+ &response),
+ NULL);
zassert_equal(status_args.response_size, sizeof(response), NULL);
zassert_equal(response.status, 1, "response.status = %d",
response.status);
/* Error case: wrong subcmd */
status_params.subcmd = 10;
- zassert_equal(host_command_process(&status_args),
+ zassert_equal(ec_cmd_i2c_passthru_protect(NULL, &status_params,
+ &response),
EC_RES_INVALID_COMMAND, NULL);
status_params.subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_STATUS;
/* Error case: wrong port */
status_params.port = 10;
- zassert_equal(host_command_process(&status_args), EC_RES_INVALID_PARAM,
- NULL);
+ zassert_equal(ec_cmd_i2c_passthru_protect(NULL, &status_params,
+ &response),
+ EC_RES_INVALID_PARAM, NULL);
status_params.port = I2C_PORT_SENSOR;
/* Error case: response size not enough */
@@ -164,8 +166,7 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs)
.port = I2C_PORT_SENSOR,
.subcmd = EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS,
};
- struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params);
+ struct ec_response_i2c_passthru_protect enable_response;
uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul));
uint8_t *out_data;
uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) +
@@ -182,8 +183,9 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs)
system_is_locked_fake.return_val = false;
/* Protect the all TCPC buses */
- zassert_ok(host_command_process(&enable_args), NULL);
- zassert_ok(enable_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params,
+ &enable_response),
+ NULL);
passthru_params->port = I2C_PORT_USB_C0;
passthru_params->num_msgs = 2;
@@ -211,8 +213,9 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs)
system_is_locked_fake.return_val = true;
/* Protect the all TCPC buses */
- zassert_ok(host_command_process(&enable_args), NULL);
- zassert_ok(enable_args.result, NULL);
+ zassert_ok(ec_cmd_i2c_passthru_protect(NULL, &enable_params,
+ &enable_response),
+ NULL);
zassert_equal(host_command_process(&passthru_args),
EC_RES_ACCESS_DENIED);
diff --git a/zephyr/test/drivers/default/src/lid_switch.c b/zephyr/test/drivers/default/src/lid_switch.c
index 744701d40c..f71e590d62 100644
--- a/zephyr/test/drivers/default/src/lid_switch.c
+++ b/zephyr/test/drivers/default/src/lid_switch.c
@@ -60,17 +60,12 @@ static void lid_switch_after(void *unused)
struct ec_params_force_lid_open params = {
.enabled = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_FORCE_LID_OPEN, 0, params);
int res;
- res = host_command_process(&args);
+ res = ec_cmd_force_lid_open(NULL, &params);
if (res)
TC_ERROR("host_command_process() failed (%d)\n", res);
- if (args.result)
- TC_ERROR("args.result != 0 (%d != 0)\n", args.result);
-
res = emul_lid_open();
if (res)
TC_ERROR("emul_lid_open() failed (%d)\n", res);
@@ -287,16 +282,13 @@ ZTEST(lid_switch, test_hc_force_lid_open)
struct ec_params_force_lid_open params = {
.enabled = 1,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_FORCE_LID_OPEN, 0, params);
/* Start closed. */
zassert_ok(emul_lid_close());
k_sleep(K_MSEC(100));
zassert_equal(lid_is_open(), 0);
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_force_lid_open(NULL, &params));
k_sleep(K_MSEC(100));
zassert_equal(lid_is_open(), 1);
}
diff --git a/zephyr/test/drivers/default/src/locate_chip.c b/zephyr/test/drivers/default/src/locate_chip.c
index c54031c5df..5efaa439f3 100644
--- a/zephyr/test/drivers/default/src/locate_chip.c
+++ b/zephyr/test/drivers/default/src/locate_chip.c
@@ -20,13 +20,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc)
int ret;
struct ec_params_locate_chip p;
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
p.type = EC_CHIP_TYPE_TCPC;
p.index = 0;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret);
zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d",
@@ -39,7 +37,7 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc)
p.type = EC_CHIP_TYPE_TCPC;
p.index = 1;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret);
zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d",
@@ -58,13 +56,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_tcpc_overflow)
int ret;
struct ec_params_locate_chip p;
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
p.type = EC_CHIP_TYPE_TCPC;
p.index = 10;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_OVERFLOW, "Unexpected return value: %d", ret);
}
@@ -77,13 +73,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_eeprom)
int ret;
struct ec_params_locate_chip p;
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
p.type = EC_CHIP_TYPE_CBI_EEPROM;
p.index = 0;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_SUCCESS, "Unexpected return value: %d", ret);
zassert_equal(r.bus_type, EC_BUS_TYPE_I2C, "Unexpected bus_type: %d",
@@ -102,13 +96,11 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_eeprom_overflow)
int ret;
struct ec_params_locate_chip p;
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
p.type = EC_CHIP_TYPE_CBI_EEPROM;
p.index = 1;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_OVERFLOW, "Unexpected return value: %d", ret);
}
@@ -121,11 +113,9 @@ ZTEST_USER(locate_chip, test_hc_locate_chip_invalid)
int ret;
struct ec_params_locate_chip p;
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
p.type = EC_CHIP_TYPE_COUNT;
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_INVALID_PARAM, "Unexpected return value: %d",
ret);
diff --git a/zephyr/test/drivers/default/src/power_common.c b/zephyr/test/drivers/default/src/power_common.c
index 2b8ba4ac88..58ca3977f9 100644
--- a/zephyr/test/drivers/default/src/power_common.c
+++ b/zephyr/test/drivers/default/src/power_common.c
@@ -247,13 +247,6 @@ ZTEST(power_common_no_tasks, test_power_exit_hard_off)
ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3)
{
struct ec_params_reboot_ap_on_g3_v1 params;
- struct host_cmd_handler_args args = {
- .command = EC_CMD_REBOOT_AP_ON_G3,
- .version = 0,
- .send_response = stub_send_response_callback,
- .params = &params,
- .params_size = sizeof(params),
- };
int delay_ms;
int64_t before_time;
@@ -269,7 +262,7 @@ ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3)
zassert_equal(POWER_S0, power_get_state());
/* Test version 0 (no delay argument) */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_reboot_ap_on_g3(NULL));
/* Go to G3 and check if reboot is triggered */
power_set_state(POWER_G3);
@@ -277,10 +270,9 @@ ZTEST(power_common_no_tasks, test_power_reboot_ap_at_g3)
zassert_equal(POWER_G3S5, power_get_state());
/* Test version 1 (with delay argument) */
- args.version = 1;
delay_ms = 3000;
params.reboot_ap_at_g3_delay = delay_ms / 1000; /* in seconds */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_reboot_ap_on_g3_v1(NULL, &params));
/* Go to G3 and check if reboot is triggered after delay */
power_set_state(POWER_G3);
@@ -295,8 +287,6 @@ ZTEST(power_common, test_power_hc_smart_discharge)
{
struct ec_response_smart_discharge response;
struct ec_params_smart_discharge params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params);
const struct emul *emul = EMUL_DT_GET(BATTERY_NODE);
struct i2c_common_emul_data *common_data =
emul_smart_battery_get_i2c_common_data(emul);
@@ -311,7 +301,8 @@ ZTEST(power_common, test_power_hc_smart_discharge)
/* Test fail when battery capacity is not available */
i2c_common_emul_set_read_fail_reg(common_data, SB_FULL_CHARGE_CAPACITY);
- zassert_equal(EC_RES_UNAVAILABLE, host_command_process(&args));
+ zassert_equal(EC_RES_UNAVAILABLE,
+ ec_cmd_smart_discharge(NULL, &params, &response));
i2c_common_emul_set_read_fail_reg(common_data,
I2C_COMMON_EMUL_NO_FAIL_REG);
@@ -319,13 +310,15 @@ ZTEST(power_common, test_power_hc_smart_discharge)
params.drate.hibern = 10;
params.drate.cutoff = 100;
/* Test fail on higher discahrge in hibernation than cutoff */
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_smart_discharge(NULL, &params, &response));
/* Setup discharge rates */
params.drate.hibern = 10;
params.drate.cutoff = 0;
/* Test fail on only one discharge rate set to 0 */
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_smart_discharge(NULL, &params, &response));
/* Setup correct parameters */
hours_to_zero = 1000;
@@ -341,7 +334,8 @@ ZTEST(power_common, test_power_hc_smart_discharge)
params.hours_to_zero = hours_to_zero;
/* Test if correct values are set */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_smart_discharge(NULL, &params, &response));
zassert_equal(hibern_drate, response.drate.hibern);
zassert_equal(cutoff_drate, response.drate.cutoff);
zassert_equal(hours_to_zero, response.hours_to_zero);
@@ -360,7 +354,8 @@ ZTEST(power_common, test_power_hc_smart_discharge)
cutoff_cap = cutoff_drate * hours_to_zero / 1000;
/* Test that command doesn't change drate but apply new hours to zero */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_smart_discharge(NULL, &params, &response));
zassert_equal(hibern_drate, response.drate.hibern);
zassert_equal(cutoff_drate, response.drate.cutoff);
zassert_equal(hours_to_zero, response.hours_to_zero);
@@ -374,7 +369,8 @@ ZTEST(power_common, test_power_hc_smart_discharge)
params.flags = 0;
/* Test that command doesn't change drate and dzone */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_smart_discharge(NULL, &params, &response));
zassert_equal(hibern_drate, response.drate.hibern);
zassert_equal(cutoff_drate, response.drate.cutoff);
zassert_equal(hours_to_zero, response.hours_to_zero);
@@ -390,8 +386,6 @@ ZTEST(power_common, test_power_board_system_is_idle)
{
struct ec_response_smart_discharge response;
struct ec_params_smart_discharge params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params);
struct sbat_emul_bat_data *bat;
const struct emul *emul = EMUL_DT_GET(BATTERY_NODE);
struct i2c_common_emul_data *common_data =
@@ -408,7 +402,8 @@ ZTEST(power_common, test_power_board_system_is_idle)
params.hours_to_zero = 1000; /* h */
params.flags = EC_SMART_DISCHARGE_FLAGS_SET;
/* Set stay-up and cutoff zones */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_smart_discharge(NULL, &params, &response));
/* Test shutdown ignore is send when target time is in future */
target = 1125;
@@ -508,8 +503,6 @@ static void setup_hibernation_delay(void *state)
{
struct ec_response_smart_discharge response;
struct ec_params_smart_discharge params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_SMART_DISCHARGE, 0, response, params);
struct sbat_emul_bat_data *bat;
const struct emul *emul = EMUL_DT_GET(BATTERY_NODE);
ARG_UNUSED(state);
@@ -521,7 +514,8 @@ static void setup_hibernation_delay(void *state)
params.drate.cutoff = 10; /* uA */
params.hours_to_zero = 10000; /* h */
params.flags = EC_SMART_DISCHARGE_FLAGS_SET;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_smart_discharge(NULL, &params, &response));
/*
* Make sure that battery is in safe zone in good condition to
* not trigger hibernate in charge_state_v2.c
@@ -543,8 +537,6 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
{
struct ec_response_hibernation_delay response;
struct ec_params_hibernation_delay params;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_HIBERNATION_DELAY, 0, response, params);
uint32_t h_delay;
int sleep_time;
@@ -559,7 +551,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Set hibernate delay */
h_delay = 9;
params.seconds = h_delay;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(0, response.time_g3, "Time from last G3 enter %d != 0",
response.time_g3);
@@ -578,7 +571,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Get hibernate delay */
params.seconds = 0;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(sleep_time, response.time_g3,
"Time from last G3 enter %d != %d", response.time_g3,
@@ -597,7 +591,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Get hibernate delay */
params.seconds = 0;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(h_delay, response.time_g3,
"Time from last G3 enter %d != %d", response.time_g3,
@@ -616,7 +611,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Get hibernate delay */
params.seconds = 0;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
/* After hibernation, remaining time shouldn't be negative */
zassert_equal(0, response.time_remaining, "Time to hibernation %d != 0",
@@ -633,7 +629,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Get hibernate delay */
params.seconds = 0;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(0, response.time_g3,
"Time from last G3 enter %d should be 0 on AC",
@@ -650,7 +647,8 @@ ZTEST(power_common_hibernation, test_power_hc_hibernation_delay)
/* Get hibernate delay */
params.seconds = 0;
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_hibernation_delay(NULL, &params, &response));
zassert_equal(0, response.time_g3,
"Time from last G3 enter %d should be 0 on state != G3",
diff --git a/zephyr/test/drivers/default/src/uart_hostcmd.c b/zephyr/test/drivers/default/src/uart_hostcmd.c
index 907dba929f..5e45d98980 100644
--- a/zephyr/test/drivers/default/src/uart_hostcmd.c
+++ b/zephyr/test/drivers/default/src/uart_hostcmd.c
@@ -28,11 +28,9 @@ static void setup_snapshots_and_messages(void *unused)
char response[1024];
struct host_cmd_handler_args read_args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_CONSOLE_READ, 0, response);
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0);
/* Set first snapshot before first message */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
cputs(CC_COMMAND, msg1);
/* Read everything from buffer */
@@ -44,7 +42,7 @@ static void setup_snapshots_and_messages(void *unused)
} while (read_args.response_size != 0);
/* Set second snapshot after first message */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
cputs(CC_COMMAND, msg2);
}
@@ -60,8 +58,6 @@ static void test_uart_hc_read_next(int ver)
struct ec_params_console_read_v1 params;
struct host_cmd_handler_args read_args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_CONSOLE_READ, ver, response);
- struct host_cmd_handler_args snap_args =
- BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0);
char *msg1_start;
char *msg2_start;
char *msg3_start;
@@ -90,7 +86,7 @@ static void test_uart_hc_read_next(int ver)
msg1_start);
/* Set new snapshot which should include message 2 */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
read_args.response_size = 0;
zassert_equal(EC_RES_SUCCESS, host_command_process(&read_args));
@@ -123,7 +119,7 @@ static void test_uart_hc_read_next(int ver)
read_args.response_size);
/* Set new snapshot which should include message 3 */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
read_args.response_size = 0;
zassert_equal(EC_RES_SUCCESS, host_command_process(&read_args));
@@ -163,8 +159,6 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1)
struct ec_params_console_read_v1 params;
struct host_cmd_handler_args read_args =
BUILD_HOST_COMMAND(EC_CMD_CONSOLE_READ, 1, response, params);
- struct host_cmd_handler_args snap_args =
- BUILD_HOST_COMMAND_SIMPLE(EC_CMD_CONSOLE_SNAPSHOT, 0);
params.subcmd = CONSOLE_READ_RECENT;
@@ -183,7 +177,7 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1)
response);
/* Set new snapshot after second message */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
/* Only message between two last snapshots should be read */
read_args.response_size = 0;
@@ -210,7 +204,7 @@ ZTEST_USER(uart_hostcmd, test_uart_hc_read_recent_v1)
read_args.response_size);
/* Set new snapshot */
- zassert_equal(EC_RES_SUCCESS, host_command_process(&snap_args));
+ zassert_equal(EC_RES_SUCCESS, ec_cmd_console_snapshot(NULL));
/* This time only third message should be read */
read_args.response_size = 0;
diff --git a/zephyr/test/drivers/default/src/usb_mux.c b/zephyr/test/drivers/default/src/usb_mux.c
index 0e89cf2398..cad47c75a7 100644
--- a/zephyr/test/drivers/default/src/usb_mux.c
+++ b/zephyr/test/drivers/default/src/usb_mux.c
@@ -819,13 +819,13 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info)
{
struct ec_response_usb_pd_mux_info response;
struct ec_params_usb_pd_mux_info params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_USB_PD_MUX_INFO, 0, response, params);
+ struct host_cmd_handler_args args;
mux_state_t exp_mode;
/* Test invalid port parameter */
params.port = 5;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_usb_pd_mux_info(NULL, &params, &response));
/* Set correct port for rest of the test */
params.port = USBC_PORT_C1;
@@ -833,13 +833,15 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info)
/* Test error on getting mux mode */
set_proxy_get_mux_state_seq(USB_PD_MUX_USB_ENABLED);
proxy_get_fake.return_val = EC_ERROR_UNKNOWN;
- zassert_equal(EC_RES_ERROR, host_command_process(&args));
+ zassert_equal(EC_RES_ERROR,
+ ec_cmd_usb_pd_mux_info(NULL, &params, &response));
/* Test getting mux mode */
reset_proxy_fakes();
exp_mode = USB_PD_MUX_USB_ENABLED;
set_proxy_get_mux_state_seq(exp_mode);
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_usb_pd_mux_info(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(exp_mode, response.flags, "mode is 0x%x (!= 0x%x)",
response.flags, exp_mode);
@@ -850,7 +852,8 @@ ZTEST(usb_init_mux, test_usb_mux_hc_mux_info)
exp_mode = USB_PD_MUX_USB_ENABLED | USB_PD_MUX_HPD_LVL |
USB_PD_MUX_HPD_IRQ;
set_proxy_get_mux_state_seq(exp_mode);
- zassert_equal(EC_RES_SUCCESS, host_command_process(&args));
+ zassert_equal(EC_RES_SUCCESS,
+ ec_cmd_usb_pd_mux_info(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(exp_mode, response.flags, "mode is 0x%x (!= 0x%x)",
response.flags, exp_mode);
diff --git a/zephyr/test/drivers/default/src/vboot_hash.c b/zephyr/test/drivers/default/src/vboot_hash.c
index 61d4260a23..101fc2f6dc 100644
--- a/zephyr/test/drivers/default/src/vboot_hash.c
+++ b/zephyr/test/drivers/default/src/vboot_hash.c
@@ -21,36 +21,29 @@ ZTEST_USER(vboot_hash, test_hostcmd_abort)
.offset = EC_VBOOT_HASH_OFFSET_RO,
.size = 0,
};
- struct host_cmd_handler_args start_args = BUILD_HOST_COMMAND(
- EC_CMD_VBOOT_HASH, 0, response, start_params);
+ struct host_cmd_handler_args start_args;
struct ec_params_vboot_hash abort_params = {
.cmd = EC_VBOOT_HASH_ABORT,
};
- struct host_cmd_handler_args abort_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_VBOOT_HASH, 0, abort_params);
struct ec_params_vboot_hash get_params = {
.cmd = EC_VBOOT_HASH_GET,
};
- struct host_cmd_handler_args get_args =
- BUILD_HOST_COMMAND(EC_CMD_VBOOT_HASH, 0, response, get_params);
+ struct host_cmd_handler_args get_args;
/* Start hashing. The command doesn't wait to finish. */
- zassert_ok(host_command_process(&start_args));
- zassert_ok(start_args.result);
+ zassert_ok(ec_cmd_vboot_hash(&start_args, &start_params, &response));
zassert_equal(start_args.response_size, sizeof(response));
zassert_equal(response.status, EC_VBOOT_HASH_STATUS_BUSY,
"response.status = %d", response.status);
/* Abort it immediately */
- zassert_ok(host_command_process(&abort_args));
- zassert_ok(abort_args.result);
+ zassert_ok(ec_cmd_vboot_hash(NULL, &abort_params, &response));
/* Give it a bit time. The abort is being processed in the background */
k_msleep(20);
/* Get the hash result. Should be NONE. */
- zassert_ok(host_command_process(&get_args));
- zassert_ok(get_args.result);
+ zassert_ok(ec_cmd_vboot_hash(&get_args, &get_params, &response));
zassert_equal(get_args.response_size, sizeof(response));
zassert_equal(response.status, EC_VBOOT_HASH_STATUS_NONE,
"response.status = %d", response.status);
@@ -65,12 +58,10 @@ ZTEST_USER(vboot_hash, test_hostcmd_recalc)
.offset = EC_VBOOT_HASH_OFFSET_RO,
.size = 0,
};
- struct host_cmd_handler_args recalc_args = BUILD_HOST_COMMAND(
- EC_CMD_VBOOT_HASH, 0, response, recalc_params);
+ struct host_cmd_handler_args recalc_args;
/* Recalculate the hash. The command waits to finish. */
- zassert_ok(host_command_process(&recalc_args));
- zassert_ok(recalc_args.result);
+ zassert_ok(ec_cmd_vboot_hash(&recalc_args, &recalc_params, &response));
zassert_equal(recalc_args.response_size, sizeof(response));
zassert_equal(response.status, EC_VBOOT_HASH_STATUS_DONE,
"response.status = %d", response.status);
@@ -88,12 +79,11 @@ ZTEST_USER(vboot_hash, test_hostcmd_hash_arbitrary_size)
/* arbitrary size */
.size = 0x12345,
};
- struct host_cmd_handler_args recalc_args = BUILD_HOST_COMMAND(
- EC_CMD_VBOOT_HASH, 0, response, recalc_params);
+ struct host_cmd_handler_args recalc_args;
/* Recalculate the hash. The command waits to finish. */
- zassert_ok(host_command_process(&recalc_args), NULL);
- zassert_ok(recalc_args.result, NULL);
+ zassert_ok(ec_cmd_vboot_hash(&recalc_args, &recalc_params, &response),
+ NULL);
zassert_equal(recalc_args.response_size, sizeof(response), NULL);
zassert_equal(response.status, EC_VBOOT_HASH_STATUS_DONE,
"response.status = %d", response.status);
diff --git a/zephyr/test/drivers/default/src/vstore.c b/zephyr/test/drivers/default/src/vstore.c
index 923d14ff00..876655f66a 100644
--- a/zephyr/test/drivers/default/src/vstore.c
+++ b/zephyr/test/drivers/default/src/vstore.c
@@ -58,11 +58,10 @@ ZTEST_USER(vstore, test_vstore_read_bad_slot)
.slot = CONFIG_VSTORE_SLOT_COUNT,
};
struct ec_response_vstore_read response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_VSTORE_READ, 0, response, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
- "Failed to fail on invalid slot %d", params.slot);
+ zassert_equal(ec_cmd_vstore_read(NULL, &params, &response),
+ EC_RES_INVALID_PARAM, "Failed to fail on invalid slot %d",
+ params.slot);
}
ZTEST_USER(vstore, test_vstore_write_bad_slot)
@@ -84,8 +83,6 @@ static void do_vstore_write_read(unsigned int slot)
.slot = slot,
/* .data is set up below */
};
- struct host_cmd_handler_args write_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_VSTORE_WRITE, 0, write_params);
struct ec_params_vstore_read read_params = {
.slot = slot,
};
@@ -101,8 +98,7 @@ static void do_vstore_write_read(unsigned int slot)
write_params.data[i] = i + 1;
/* Write to a slot */
- zassert_ok(host_command_process(&write_args), NULL);
- zassert_ok(write_args.result, NULL);
+ zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL);
/* Check that it is now locked */
zassert_ok(host_command_process(&info_args), NULL);
@@ -121,7 +117,8 @@ static void do_vstore_write_read(unsigned int slot)
EC_VSTORE_SLOT_SIZE, "response.data did not match");
/* Try to write to it again */
- zassert_equal(host_command_process(&write_args), EC_RES_ACCESS_DENIED,
+ zassert_equal(ec_cmd_vstore_write(NULL, &write_params),
+ EC_RES_ACCESS_DENIED,
"Failed to fail on writing locked slot %d",
write_params.slot);
@@ -144,8 +141,7 @@ static void do_vstore_write_read(unsigned int slot)
/* Clear locks and try the write again, this time with zero bytes */
vstore_clear_lock();
memset(write_params.data, '\0', EC_VSTORE_SLOT_SIZE);
- zassert_ok(host_command_process(&write_args), NULL);
- zassert_ok(write_args.result, NULL);
+ zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL);
/* Check that it is now locked */
zassert_ok(host_command_process(&info_args), NULL);
@@ -182,8 +178,6 @@ ZTEST_USER(vstore, test_vstore_state)
.slot = 0,
/* .data is set up below */
};
- struct host_cmd_handler_args write_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_VSTORE_WRITE, 0, write_params);
struct ec_params_reboot_ec reboot_params = {
.cmd = EC_REBOOT_JUMP_RW,
@@ -203,8 +197,7 @@ ZTEST_USER(vstore, test_vstore_state)
write_params.data[i] = i + 1;
/* Write to a slot */
- zassert_ok(host_command_process(&write_args), NULL);
- zassert_ok(write_args.result, NULL);
+ zassert_ok(ec_cmd_vstore_write(NULL, &write_params), NULL);
/* Set up so we get back to this test on a reboot */
if (!setjmp(env)) {
diff --git a/zephyr/test/drivers/flash/src/flash.c b/zephyr/test/drivers/flash/src/flash.c
index c0b0d9ef4f..17bb1da373 100644
--- a/zephyr/test/drivers/flash/src/flash.c
+++ b/zephyr/test/drivers/flash/src/flash.c
@@ -37,13 +37,11 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_asserted)
.mask = 0,
.flags = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_FLASH_PROTECT, 0, response, params);
/* The original flags not 0 as GPIO WP_L asserted */
uint32_t expected_flags = EC_FLASH_PROTECT_GPIO_ASSERTED;
/* Get the flash protect */
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
@@ -51,14 +49,14 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_asserted)
params.mask = EC_FLASH_PROTECT_RO_AT_BOOT;
params.flags = EC_FLASH_PROTECT_RO_AT_BOOT;
expected_flags |= EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
/* Disable RO_AT_BOOT; should change nothing as GPIO WP_L is asserted */
params.mask = EC_FLASH_PROTECT_RO_AT_BOOT;
params.flags = 0;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
@@ -66,21 +64,21 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_asserted)
params.mask = EC_FLASH_PROTECT_ALL_NOW;
params.flags = EC_FLASH_PROTECT_ALL_NOW;
expected_flags |= EC_FLASH_PROTECT_ALL_NOW;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
/* Disable ALL_NOW; should change nothing as GPIO WP_L is asserted */
params.mask = EC_FLASH_PROTECT_ALL_NOW;
params.flags = 0;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
/* Disable RO_AT_BOOT; should change nothing as GPIO WP_L is asserted */
params.mask = EC_FLASH_PROTECT_RO_AT_BOOT;
params.flags = 0;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
}
@@ -92,15 +90,13 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
.mask = 0,
.flags = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_FLASH_PROTECT, 0, response, params);
/* The original flags 0 as GPIO WP_L deasserted */
uint32_t expected_flags = 0;
zassert_ok(gpio_wp_l_set(1), NULL);
/* Get the flash protect */
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
@@ -108,7 +104,7 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
params.mask = EC_FLASH_PROTECT_RO_AT_BOOT;
params.flags = EC_FLASH_PROTECT_RO_AT_BOOT;
expected_flags |= EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
@@ -117,7 +113,7 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
params.flags = 0;
expected_flags &=
~(EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW);
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
@@ -125,14 +121,14 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
params.mask = EC_FLASH_PROTECT_RO_AT_BOOT;
params.flags = EC_FLASH_PROTECT_RO_AT_BOOT;
expected_flags |= EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
/* Enable ALL_NOW; should change nothing as GPIO WP_L is deasserted */
params.mask = EC_FLASH_PROTECT_ALL_NOW;
params.flags = EC_FLASH_PROTECT_ALL_NOW;
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_protect(NULL, &params, &response), NULL);
zassert_equal(response.flags, expected_flags, "response.flags = %d",
response.flags);
}
@@ -166,8 +162,6 @@ ZTEST_USER(flash, test_hostcmd_flash_write_and_erase)
.offset = 0x10000,
.size = 0x10000,
};
- struct host_cmd_handler_args erase_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_FLASH_ERASE, 0, erase_params);
/* The write host command structs need to be filled run-time */
struct ec_params_flash_write *write_params =
@@ -193,7 +187,7 @@ ZTEST_USER(flash, test_hostcmd_flash_write_and_erase)
"readback data not expected: 0x%x", in_buf[0]);
/* Flash erase */
- zassert_ok(host_command_process(&erase_args), NULL);
+ zassert_ok(ec_cmd_flash_erase(NULL, &erase_params), NULL);
/* Flash read and compare the readback data */
zassert_ok(host_command_process(&read_args), NULL);
@@ -213,10 +207,8 @@ static void test_region_info(uint32_t region, uint32_t expected_offset,
struct ec_params_flash_region_info params = {
.region = region,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_FLASH_REGION_INFO, 1, response, params);
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_flash_region_info_v1(NULL, &params, &response), NULL);
zassert_equal(response.offset, expected_offset, NULL);
zassert_equal(response.size, expected_size, NULL);
}
@@ -259,10 +251,9 @@ ZTEST_USER(flash, test_hostcmd_flash_region_info_active_invalid)
/* Get an invalid region */
.region = 10,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_FLASH_REGION_INFO, 1, response, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, NULL);
+ zassert_equal(ec_cmd_flash_region_info_v1(NULL, &params, &response),
+ EC_RES_INVALID_PARAM, NULL);
}
ZTEST_USER(flash, test_hostcmd_flash_info_1)
@@ -302,7 +293,7 @@ ZTEST_USER(flash, test_hostcmd_flash_info_1)
* Flash sector description not supported in FLASH_INFO
* version 1 command
*/
- zassert_equal(host_command_process(&args),
+ zassert_equal(ec_cmd_flash_info_v1(NULL, &response),
EC_RES_INVALID_VERSION, NULL);
}
}
@@ -702,11 +693,9 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size,
.offset = offset,
.size = size,
};
- struct host_cmd_handler_args erase_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_FLASH_ERASE, 0, erase_params);
int rv;
- rv = host_command_process(&erase_args);
+ rv = ec_cmd_flash_erase(NULL, &erase_params);
zassert_ok(rv, "Got %d", rv);
if (make_write) {
diff --git a/zephyr/test/drivers/host_cmd/src/adc.c b/zephyr/test/drivers/host_cmd/src/adc.c
index f283ef17d5..a6e9beb62c 100644
--- a/zephyr/test/drivers/host_cmd/src/adc.c
+++ b/zephyr/test/drivers/host_cmd/src/adc.c
@@ -24,10 +24,7 @@ ZTEST(hc_adc, normal_path)
adc_read_channel_fake.return_val = 123;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_ADC_READ, UINT8_C(0), response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_adc_read(NULL, &params, &response);
zassert_ok(ret, "Host command returned %u", ret);
zassert_equal(1, adc_read_channel_fake.call_count);
@@ -42,10 +39,7 @@ ZTEST(hc_adc, bad_ch_number)
struct ec_response_adc_read response;
uint16_t ret;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_ADC_READ, UINT8_C(0), response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_adc_read(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, ret, "Host command returned %u",
ret);
diff --git a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
index 019362f3c8..2960823592 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
@@ -54,23 +54,19 @@ ZTEST_SUITE(host_cmd_battery_cut_off, drivers_predicate_post_main,
ZTEST_USER_F(host_cmd_battery_cut_off, test_fail_sb_write)
{
int rv;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_SIMPLE(EC_CMD_BATTERY_CUT_OFF, UINT8_C(0));
/* Force a failure on the battery i2c write to 0x00 */
i2c_common_emul_set_write_fail_reg(fixture->i2c_emul, 0);
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_cut_off(NULL);
zassert_equal(EC_RES_ERROR, rv, "Expected 0, but got %d", rv);
}
ZTEST_USER(host_cmd_battery_cut_off, test_cutoff_battery)
{
int rv;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_SIMPLE(EC_CMD_BATTERY_CUT_OFF, UINT8_C(0));
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_cut_off(NULL);
zassert_equal(EC_RES_SUCCESS, rv, "Expected 0, but got %d", rv);
zassert_true(battery_is_cut_off(), NULL);
}
@@ -81,10 +77,8 @@ ZTEST_USER(host_cmd_battery_cut_off, test_cutoff_v1)
struct ec_params_battery_cutoff params = {
.flags = 0,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_BATTERY_CUT_OFF, UINT8_C(1), params);
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_cut_off_v1(NULL, &params);
zassert_equal(EC_RES_SUCCESS, rv, "Expected 0, but got %d", rv);
zassert_true(battery_is_cut_off(), NULL);
}
@@ -95,10 +89,8 @@ ZTEST_USER(host_cmd_battery_cut_off, test_cutoff_at_shutdown)
struct ec_params_battery_cutoff params = {
.flags = EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_BATTERY_CUT_OFF, UINT8_C(1), params);
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_cut_off_v1(NULL, &params);
zassert_equal(EC_RES_SUCCESS, rv, "Expected 0, but got %d", rv);
zassert_false(battery_is_cut_off(), NULL);
hook_notify(HOOK_CHIPSET_SHUTDOWN);
diff --git a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
index 6af3d35043..34a3881b5d 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
@@ -17,10 +17,9 @@ ZTEST_USER(battery_display_soc, happy_path)
const uint32_t host_shutdown_charge_as_tenths =
CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE * 10;
struct ec_response_display_soc response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_DISPLAY_SOC, 0, response);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_display_soc(&args, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.display_soc, charge_get_display_charge());
diff --git a/zephyr/test/drivers/host_cmd/src/battery_v2.c b/zephyr/test/drivers/host_cmd/src/battery_v2.c
index e6ccc09964..3b0d54e7ee 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_v2.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_v2.c
@@ -19,10 +19,7 @@ ZTEST(host_cmd_battery_v2, test_get_static__invalid_index)
};
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_BATTERY_GET_STATIC, 0, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_get_static(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, rv, "Got %d", rv);
}
@@ -34,10 +31,7 @@ ZTEST(host_cmd_battery_v2, test_get_static__v0)
struct ec_response_battery_static_info response;
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_BATTERY_GET_STATIC, 0, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_get_static(NULL, &params, &response);
zassert_ok(rv, "Got %d", rv);
/* Validate all of the fields */
@@ -67,10 +61,7 @@ ZTEST(host_cmd_battery_v2, test_get_static__v1)
struct ec_response_battery_static_info_v1 response;
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_BATTERY_GET_STATIC, 1, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_get_static_v1(NULL, &params, &response);
zassert_ok(rv, "Got %d", rv);
/* Validate all of the fields */
@@ -129,10 +120,7 @@ ZTEST(host_cmd_battery_v2, test_get_dynamic__invalid_index)
};
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_BATTERY_GET_DYNAMIC, 0, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_get_dynamic(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, rv, "Got %d", rv);
}
@@ -144,10 +132,7 @@ ZTEST(host_cmd_battery_v2, test_get_dynamic)
};
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_BATTERY_GET_DYNAMIC, 0, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_battery_get_dynamic(NULL, &params, &response);
zassert_ok(rv, "Got %d", rv);
/* Validate the data */
diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c
index 6bbf7a3ae3..d947b5653f 100644
--- a/zephyr/test/drivers/host_cmd/src/charge_manager.c
+++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c
@@ -12,10 +12,8 @@
ZTEST_USER(charge_manager, test_port_count)
{
struct ec_response_charge_port_count response = { 0 };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_CHARGE_PORT_COUNT, 0, response);
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_port_count(NULL, &response));
zassert_equal(CHARGE_PORT_COUNT, response.port_count,
"Expected %d, but got %d", CHARGE_PORT_COUNT,
response.port_count);
@@ -24,24 +22,22 @@ ZTEST_USER(charge_manager, test_port_count)
ZTEST_USER(charge_manager, test_port_override__port_out_of_bounds)
{
struct ec_params_charge_port_override params = { 0 };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, params);
params.override_port = OVERRIDE_DONT_CHARGE - 1;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_pd_charge_port_override(NULL, &params));
params.override_port = CHARGE_PORT_COUNT;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_pd_charge_port_override(NULL, &params));
}
ZTEST_USER(charge_manager, test_port_override__0_from_off)
{
struct ec_params_charge_port_override params = { 0 };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, params);
params.override_port = 0;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pd_charge_port_override(NULL, &params));
}
ZTEST_USER(charge_manager, test_charge_state_get_debug_params)
@@ -50,8 +46,6 @@ ZTEST_USER(charge_manager, test_charge_state_get_debug_params)
.cmd = CHARGE_STATE_CMD_GET_PARAM,
};
struct ec_response_charge_state response = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
/* Check that the following get commands work on these debug parameters.
* The values being asserted are the default values when nothing is
@@ -61,31 +55,32 @@ ZTEST_USER(charge_manager, test_charge_state_get_debug_params)
* default/src/integration/usbc).
*/
params.get_param.param = CS_PARAM_DEBUG_CTL_MODE;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_MANUAL_CURRENT;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0xffffffff, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_MANUAL_VOLTAGE;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0xffffffff, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_SEEMS_DEAD;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_SEEMS_DISCONNECTED;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_BATT_REMOVED;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_charge_state(NULL, &params, &response));
zassert_equal(0, response.get_param.value);
params.get_param.param = CS_PARAM_DEBUG_MAX;
- zassert_equal(EC_ERROR_INVAL, host_command_process(&args));
+ zassert_equal(EC_ERROR_INVAL,
+ ec_cmd_charge_state(NULL, &params, &response));
}
ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL,
diff --git a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
index 0fa7ab3770..0a6aba7cbc 100644
--- a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
+++ b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
@@ -16,10 +16,9 @@ ZTEST_USER(hc_get_cmd_versions, test_v0__both_versions)
.cmd = EC_CMD_GET_CMD_VERSIONS,
};
struct ec_response_get_cmd_versions response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_CMD_VERSIONS, 0, response, params);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_get_cmd_versions(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.version_mask, EC_VER_MASK(0) | EC_VER_MASK(1));
}
@@ -30,10 +29,9 @@ ZTEST_USER(hc_get_cmd_versions, test_v1__only_v0)
.cmd = EC_CMD_HELLO,
};
struct ec_response_get_cmd_versions response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_CMD_VERSIONS, 1, response, params);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_get_cmd_versions_v1(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.version_mask, EC_VER_MASK(0));
}
@@ -45,10 +43,9 @@ ZTEST_USER(hc_get_cmd_versions, test_v1__bad_cmd)
.cmd = UINT16_MAX,
};
struct ec_response_get_cmd_versions response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_CMD_VERSIONS, 1, response, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+ zassert_equal(ec_cmd_get_cmd_versions_v1(NULL, &params, &response),
+ EC_RES_INVALID_PARAM);
}
ZTEST_SUITE(hc_get_cmd_versions, drivers_predicate_post_main, NULL, NULL, NULL,
diff --git a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
index 2d9410232d..3071749821 100644
--- a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
+++ b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
@@ -15,10 +15,8 @@ ZTEST_USER(host_cmd_get_pd_port_caps, test_good_index)
{
struct ec_params_get_pd_port_caps params = { .port = 0 };
struct ec_response_get_pd_port_caps response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_PD_PORT_CAPS, 0, response, params);
- zassert_ok(host_command_process(&args),
+ zassert_ok(ec_cmd_get_pd_port_caps(NULL, &params, &response),
"Failed to process get_pd_port_caps for port %d",
params.port);
@@ -37,10 +35,9 @@ ZTEST_USER(host_cmd_get_pd_port_caps, test_bad_index)
{
struct ec_params_get_pd_port_caps params = { .port = 32 };
struct ec_response_get_pd_port_caps response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_PD_PORT_CAPS, 0, response, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_get_pd_port_caps(NULL, &params, &response),
+ EC_RES_INVALID_PARAM,
"Failed to fail get_pd_port_caps for port %d",
params.port);
}
diff --git a/zephyr/test/drivers/host_cmd/src/host_command.c b/zephyr/test/drivers/host_cmd/src/host_command.c
index a9f0fcb941..e1168648d9 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command.c
@@ -17,10 +17,7 @@ ZTEST(host_cmd_host_commands, get_command_versions__v1)
};
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_CMD_VERSIONS, 1, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_get_cmd_versions_v1(NULL, &params, &response);
zassert_ok(rv, "Got %d", rv);
zassert_equal(EC_VER_MASK(0) | EC_VER_MASK(1), response.version_mask);
@@ -35,10 +32,7 @@ ZTEST(host_cmd_host_commands, get_command_versions__invalid_cmd)
};
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GET_CMD_VERSIONS, 1, response, params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_get_cmd_versions_v1(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, rv, "Got %d", rv);
}
@@ -48,10 +42,7 @@ ZTEST(host_cmd_host_commands, get_comms_status)
struct ec_response_get_comms_status response;
int rv;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_GET_COMMS_STATUS, 0, response);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_get_comms_status(NULL, &response);
zassert_ok(rv, "Got %d", rv);
diff --git a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
index f4bf956e9b..cdabe3044d 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
@@ -17,14 +17,13 @@ ZTEST_USER(hc_test_protocol, test_echo_max_buffer_size)
.ec_result = EC_SUCCESS,
};
struct ec_response_test_protocol response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_TEST_PROTOCOL, 0, response, params);
+ struct host_cmd_handler_args args;
/* Set first and last bytes of input array */
params.buf[0] = 0x1;
params.buf[ARRAY_SIZE(params.buf) - 1] = 0x2;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_test_protocol(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
/* Check contents are echoed back in response */
@@ -40,8 +39,7 @@ ZTEST_USER(hc_test_protocol, test_echo_min_buffer_size_failing_command)
.ec_result = EC_ERROR_TRY_AGAIN,
};
struct ec_response_test_protocol response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_TEST_PROTOCOL, 0, response, params);
+ struct host_cmd_handler_args args;
/*
* Set first and last bytes of input array, neither will be written to
@@ -50,7 +48,8 @@ ZTEST_USER(hc_test_protocol, test_echo_min_buffer_size_failing_command)
params.buf[0] = 0x1;
params.buf[ARRAY_SIZE(params.buf) - 1] = 0x2;
- zassert_equal(host_command_process(&args), params.ec_result);
+ zassert_equal(ec_cmd_test_protocol(&args, &params, &response),
+ params.ec_result);
zassert_equal(args.response_size, params.ret_len);
/* Check contents were never echoed back as intended */
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands.c b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
index 537610443a..2367fcf451 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
@@ -161,22 +161,6 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_clear_cmd)
}
}
-static enum ec_status host_event_mask_cmd_helper(uint32_t command,
- uint32_t mask)
-{
- enum ec_status ret_val;
-
- struct ec_params_host_event_mask params = {
- .mask = mask,
- };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(command, 0, params);
-
- ret_val = host_command_process(&args);
-
- return ret_val;
-}
-
/**
* @brief TestPurpose: Verify EC_CMD_HOST_EVENT_CLEAR clear host command.
*/
@@ -195,7 +179,10 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_clear__cmd)
zassert_true(events & mask, "events=0x%X", events);
- ret_val = host_event_mask_cmd_helper(EC_CMD_HOST_EVENT_CLEAR, mask);
+ ret_val = ec_cmd_host_event_clear(NULL,
+ &(struct ec_params_host_event_mask){
+ .mask = mask,
+ });
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
@@ -224,7 +211,10 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_clear_b_cmd)
events_b = result.value;
zassert_true(events_b & mask, "events_b=0x%X", events_b);
- ret_val = host_event_mask_cmd_helper(EC_CMD_HOST_EVENT_CLEAR_B, mask);
+ ret_val = ec_cmd_host_event_clear_b(NULL,
+ &(struct ec_params_host_event_mask){
+ .mask = mask,
+ });
zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
EC_RES_SUCCESS, ret_val);
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
index b0ba438bbb..3183636c44 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
@@ -13,22 +13,11 @@
#define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)
-static enum ec_status
-host_event_get_wake_mask_helper(struct ec_response_host_event_mask *r)
-{
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0, *r);
-
- return host_command_process(&args);
-}
-
static enum ec_status host_event_set_wake_mask_helper(uint32_t mask)
{
struct ec_params_host_event_mask params = { .mask = mask };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0, params);
- return host_command_process(&args);
+ return ec_cmd_host_event_set_wake_mask(NULL, &params);
}
/**
@@ -39,7 +28,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_wake_mask_helper(&result);
+ rv = ec_cmd_host_event_get_wake_mask(NULL, &result);
if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
} else {
@@ -58,7 +47,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- rv = host_event_get_wake_mask_helper(&result);
+ rv = ec_cmd_host_event_get_wake_mask(NULL, &result);
if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
} else {
@@ -74,7 +63,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
zassert_ok(host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- host_event_get_wake_mask_helper(&result);
+ ec_cmd_host_event_get_wake_mask(NULL, &result);
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected wake mask 0x%08x, returned mask 0x%08x",
@@ -84,22 +73,11 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
zassert_ok(host_event_set_wake_mask_helper(0));
}
-static enum ec_status
-host_event_get_smi_mask_helper(struct ec_response_host_event_mask *r)
-{
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_HOST_EVENT_GET_SMI_MASK, 0, *r);
-
- return host_command_process(&args);
-}
-
static enum ec_status host_event_set_smi_mask_helper(uint32_t mask)
{
struct ec_params_host_event_mask params = { .mask = mask };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_EVENT_SET_SMI_MASK, 0, params);
- return host_command_process(&args);
+ return ec_cmd_host_event_set_smi_mask(NULL, &params);
}
/**
@@ -110,7 +88,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- rv = host_event_get_smi_mask_helper(&result);
+ rv = ec_cmd_host_event_get_smi_mask(NULL, &result);
if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
} else {
@@ -130,7 +108,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- rv = host_event_get_smi_mask_helper(&result);
+ rv = ec_cmd_host_event_get_smi_mask(NULL, &result);
if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
} else {
@@ -146,7 +124,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
zassert_ok(host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- zassert_ok(host_event_get_smi_mask_helper(&result));
+ zassert_ok(ec_cmd_host_event_get_smi_mask(NULL, &result));
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SMI mask 0x%08x, returned mask 0x%08x",
@@ -159,10 +137,7 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
static enum ec_status
host_event_get_b_helper(struct ec_response_host_event_mask *r)
{
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_HOST_EVENT_GET_B, 0, *r);
-
- return host_command_process(&args);
+ return ec_cmd_host_event_get_b(NULL, r);
}
/**
@@ -187,19 +162,14 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b)
static enum ec_status
host_event_get_sci_mask_helper(struct ec_response_host_event_mask *r)
{
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_HOST_EVENT_GET_SCI_MASK, 0, *r);
-
- return host_command_process(&args);
+ return ec_cmd_host_event_get_sci_mask(NULL, r);
}
static enum ec_status host_event_set_sci_mask_helper(uint32_t mask)
{
struct ec_params_host_event_mask params = { .mask = mask };
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_EVENT_SET_SCI_MASK, 0, params);
- return host_command_process(&args);
+ return ec_cmd_host_event_set_sci_mask(NULL, &params);
}
/**
diff --git a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
index e77230cfaf..7c1d3a8500 100644
--- a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
+++ b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
@@ -31,11 +31,9 @@ static void keyboard_mkbp_after(void *fixture)
{
struct keyboard_mkbp_commands_fixture *f = fixture;
struct ec_params_mkbp_set_config req = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_MKBP_SET_CONFIG, 0, req);
req.config = f->config;
- host_command_process(&args);
+ ec_cmd_mkbp_set_config(NULL, &req);
}
ZTEST_SUITE(keyboard_mkbp_commands, drivers_predicate_post_main,
@@ -50,10 +48,7 @@ ZTEST_USER(keyboard_mkbp_commands, test_mkbp_get_config_cmd)
enum ec_status ret_val;
struct ec_response_mkbp_get_config resp;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_MKBP_GET_CONFIG, 0, resp);
-
- ret_val = host_command_process(&args);
+ ret_val = ec_cmd_mkbp_get_config(NULL, &resp);
zassert_ok(ret_val, "Expected=%d, returned=%d", EC_SUCCESS, ret_val);
}
@@ -65,8 +60,6 @@ ZTEST_USER(keyboard_mkbp_commands, test_mkbp_set_config_cmd)
{
enum ec_status ret_val;
struct ec_params_mkbp_set_config req = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_MKBP_SET_CONFIG, 0, req);
get_keyscan_config(&req.config);
@@ -76,7 +69,7 @@ ZTEST_USER(keyboard_mkbp_commands, test_mkbp_set_config_cmd)
EC_MKBP_VALID_OUTPUT_SETTLE | EC_MKBP_VALID_DEBOUNCE_DOWN |
EC_MKBP_VALID_DEBOUNCE_UP | EC_MKBP_VALID_FIFO_MAX_DEPTH;
- ret_val = host_command_process(&args);
+ ret_val = ec_cmd_mkbp_set_config(NULL, &req);
zassert_ok(ret_val, "Expected=%d, returned=%d", EC_SUCCESS, ret_val);
}
diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
index e016bec97b..12d426fa30 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
@@ -19,10 +19,8 @@ static enum ec_status run_pd_chip_info(int port,
struct ec_response_pd_chip_info_v1 *resp)
{
struct ec_params_pd_chip_info params = { .port = port, .live = true };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, *resp, params);
- return host_command_process(&args);
+ return ec_cmd_pd_chip_info_v1(NULL, &params, resp);
}
ZTEST_USER(host_cmd_pd_chip_info, test_good_index)
diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c
index a881a8e0ea..701e8e7be2 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_control.c
@@ -20,12 +20,10 @@ ZTEST_USER(host_cmd_pd_control, test_bad_index)
{
struct ec_params_pd_control params = { .chip = BAD_PORT,
.subcmd = PD_RESET };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ zassert_equal(ec_cmd_pd_control(NULL, &params), EC_RES_INVALID_PARAM,
"Failed to fail pd_control for port %d", params.chip);
}
@@ -33,10 +31,8 @@ ZTEST_USER(host_cmd_pd_control, test_unimplemented_command)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,
.subcmd = PD_CHIP_ON };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_COMMAND,
+ zassert_equal(ec_cmd_pd_control(NULL, &params), EC_RES_INVALID_COMMAND,
"Failed to fail pd_control for port %d", params.chip);
}
@@ -97,26 +93,22 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_low_battery)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,
.subcmd = PD_SUSPEND };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
/* Suspending the port for firmware update should fail at critical low
* battery.
*/
test_set_battery_level(1);
- zassert_equal(host_command_process(&args), EC_RES_BUSY);
+ zassert_equal(ec_cmd_pd_control(NULL, &params), EC_RES_BUSY);
}
ZTEST_USER(host_cmd_pd_control, test_control_disable)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,
.subcmd = PD_RESET };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
host_cmd_pd_control(TEST_PORT, PD_CONTROL_DISABLE);
- zassert_equal(host_command_process(&args), EC_RES_ACCESS_DENIED,
+ zassert_equal(ec_cmd_pd_control(NULL, &params), EC_RES_ACCESS_DENIED,
"Access was not denied for port %d", params.chip);
/*
diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c
index 819f020890..75873ac7dd 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_log.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_log.c
@@ -68,10 +68,9 @@ ZTEST_USER(pd_log, test_bad_type)
struct ec_params_pd_write_log_entry params = {
.type = PD_EVENT_ACC_BASE,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_WRITE_LOG_ENTRY, UINT8_C(0), params);
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_pd_write_log_entry(NULL, &params), NULL);
}
ZTEST_USER(pd_log, test_bad_port)
@@ -79,11 +78,10 @@ ZTEST_USER(pd_log, test_bad_port)
struct ec_params_pd_write_log_entry params = {
.type = PD_EVENT_MCU_BASE,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_WRITE_LOG_ENTRY, UINT8_C(0), params);
params.port = board_get_usb_pd_port_count() + 1;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args), NULL);
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_pd_write_log_entry(NULL, &params), NULL);
}
ZTEST_USER_F(pd_log, test_mcu_charge)
@@ -92,10 +90,8 @@ ZTEST_USER_F(pd_log, test_mcu_charge)
.type = PD_EVENT_MCU_CHARGE,
.port = 0,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_WRITE_LOG_ENTRY, UINT8_C(0), params);
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_pd_write_log_entry(NULL, &params), NULL);
zassert_equal(sizeof(struct event_log_entry) + PD_LOG_ENTRY_DATA_SIZE,
log_dequeue_event(&fixture->log_entry), NULL);
zassert_equal(params.type, fixture->log_entry.type, NULL);
@@ -112,10 +108,8 @@ ZTEST_USER_F(pd_log, test_mcu_connect)
.type = PD_EVENT_MCU_CONNECT,
.port = 0,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PD_WRITE_LOG_ENTRY, UINT8_C(0), params);
- zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(ec_cmd_pd_write_log_entry(NULL, &params), NULL);
zassert_equal(sizeof(struct event_log_entry),
log_dequeue_event(&fixture->log_entry), NULL);
zassert_equal(params.type, fixture->log_entry.type, NULL);
diff --git a/zephyr/test/drivers/host_cmd/src/tablet_mode.c b/zephyr/test/drivers/host_cmd/src/tablet_mode.c
index a84faa035f..4e7f0cd0f1 100644
--- a/zephyr/test/drivers/host_cmd/src/tablet_mode.c
+++ b/zephyr/test/drivers/host_cmd/src/tablet_mode.c
@@ -42,10 +42,7 @@ ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_on)
.tablet_mode = TABLET_MODE_FORCE_TABLET
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_set_tablet_mode(NULL, &params);
zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
rv);
/* Return 1 if in tablet mode, 0 otherwise */
@@ -61,10 +58,7 @@ ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_off)
.tablet_mode = TABLET_MODE_FORCE_CLAMSHELL
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_set_tablet_mode(NULL, &params);
zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
rv);
/* Return 1 if in tablet mode, 0 otherwise */
@@ -80,10 +74,7 @@ ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_reset)
.tablet_mode = TABLET_MODE_DEFAULT
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_set_tablet_mode(NULL, &params);
zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
rv);
/* Return 1 if in tablet mode, 0 otherwise */
@@ -99,10 +90,7 @@ ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_invalid_parameter)
.tablet_mode = 0xEE /* Sufficiently random, bad value.*/
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
-
- rv = host_command_process(&args);
+ rv = ec_cmd_set_tablet_mode(NULL, &params);
zassert_equal(EC_RES_INVALID_PARAM, rv,
"Expected EC_RES_INVALID_PARAM, but got %d", rv);
/* Return 1 if in tablet mode, 0 otherwise */
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
index f926c2b7ca..93aeb33a45 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
@@ -41,10 +41,8 @@ run_usb_pd_control(int port, struct ec_response_usb_pd_control_v2 *resp)
.mux = USB_PD_CTRL_MUX_NO_CHANGE,
.swap = USB_PD_CTRL_SWAP_NONE
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, 2, *resp, params);
- return host_command_process(&args);
+ return ec_cmd_usb_pd_control_v2(NULL, &params, resp);
}
ZTEST_USER(host_cmd_usb_pd_control, test_good_index_no_partner)
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
index d95461f274..c197175b01 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
@@ -14,21 +14,20 @@
ZTEST_USER(usb_pd_host_cmd, test_hc_pd_host_event_status)
{
struct ec_response_host_event_status response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_PD_HOST_EVENT_STATUS, 0, response);
+ struct host_cmd_handler_args args;
/* Clear events */
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pd_host_event_status(&args, &response));
/* Send arbitrary event */
pd_send_host_event(1);
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pd_host_event_status(&args, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_true(response.status & 1);
/* Send again to make sure the host command cleared the event */
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pd_host_event_status(&args, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.status, 0);
}
@@ -51,10 +50,9 @@ ZTEST_USER(usb_pd_host_cmd, test_hc_remote_hash_entry__bad_dev_id)
/* Dev ID can't be 0 */
.dev_id = 0,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_PD_RW_HASH_ENTRY, 0, params);
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+ zassert_equal(ec_cmd_usb_pd_rw_hash_entry(NULL, &params),
+ EC_RES_INVALID_PARAM);
}
ZTEST_USER(usb_pd_host_cmd, test_hc_remote_hash_entry__add_entry)
@@ -63,13 +61,11 @@ ZTEST_USER(usb_pd_host_cmd, test_hc_remote_hash_entry__add_entry)
/* Arbitrary dev_id */
.dev_id = 1,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_PD_RW_HASH_ENTRY, 0, params);
memset(rw_hash_table, 0,
RW_HASH_ENTRIES * sizeof(struct ec_params_usb_pd_rw_hash_entry));
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_usb_pd_rw_hash_entry(NULL, &params));
zassert_mem_equal(test_find_hc_remote_hash_entry(params.dev_id),
&params, sizeof(params));
}
@@ -87,19 +83,15 @@ ZTEST_USER(usb_pd_host_cmd, test_hc_remote_hash_entry__update_entry)
/* Arbitrary different reserved bytes */
.reserved = 3,
};
- struct host_cmd_handler_args initial_args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_PD_RW_HASH_ENTRY, 0, initial_entry);
- struct host_cmd_handler_args update_args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_PD_RW_HASH_ENTRY, 0, update_entry);
memset(rw_hash_table, 0,
RW_HASH_ENTRIES * sizeof(struct ec_params_usb_pd_rw_hash_entry));
- zassert_ok(host_command_process(&initial_args));
+ zassert_ok(ec_cmd_usb_pd_rw_hash_entry(NULL, &initial_entry));
zassert_mem_equal(test_find_hc_remote_hash_entry(initial_entry.dev_id),
&initial_entry, sizeof(initial_entry));
- zassert_ok(host_command_process(&update_args));
+ zassert_ok(ec_cmd_usb_pd_rw_hash_entry(NULL, &update_entry));
zassert_mem_equal(test_find_hc_remote_hash_entry(update_entry.dev_id),
&update_entry, sizeof(update_entry));
}
@@ -107,11 +99,9 @@ ZTEST_USER(usb_pd_host_cmd, test_hc_remote_hash_entry__update_entry)
ZTEST_USER(usb_pd_host_cmd, test_host_command_hc_pd_ports)
{
struct ec_response_usb_pd_ports response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_USB_PD_PORTS, 0, response);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
- zassert_ok(args.result);
+ zassert_ok(ec_cmd_usb_pd_ports(&args, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.num_ports, CONFIG_USB_PD_PORT_MAX_COUNT);
}
@@ -144,19 +134,19 @@ ZTEST_USER(usb_pd_host_cmd, test_typec_control_invalid_args)
.port = 0,
.command = TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
/* Setting the TBT UFP responses is not supported by default. */
- zassert_equal(host_command_process(&args), EC_RES_UNAVAILABLE);
+ zassert_equal(ec_cmd_typec_control(NULL, &params), EC_RES_UNAVAILABLE);
/* Neither is mux setting. */
params.command = TYPEC_CONTROL_COMMAND_USB_MUX_SET;
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+ zassert_equal(ec_cmd_typec_control(NULL, &params),
+ EC_RES_INVALID_PARAM);
/* This is not a valid enum value but should be representable. */
params.command = 0xff;
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+ zassert_equal(ec_cmd_typec_control(NULL, &params),
+ EC_RES_INVALID_PARAM);
}
ZTEST_USER(usb_pd_host_cmd, test_typec_status_invalid_args)
@@ -169,7 +159,8 @@ ZTEST_USER(usb_pd_host_cmd, test_typec_status_invalid_args)
BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params);
/* An invalid port should result in an error. */
- zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+ zassert_equal(ec_cmd_typec_status(NULL, &params, &response),
+ EC_RES_INVALID_PARAM);
params.port = 0;
args.response_max = sizeof(struct ec_response_typec_status) - 1;
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
index 2865d7efc3..77131d5d5f 100644
--- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
+++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
@@ -33,10 +33,8 @@ static uint16_t set_backlight_percent_helper(uint8_t percent)
struct ec_params_pwm_set_keyboard_backlight params = {
.percent = percent
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT, 0, params);
- return host_command_process(&args);
+ return ec_cmd_pwm_set_keyboard_backlight(NULL, &params);
}
ZTEST(keyboard_backlight, host_command_set_backlight__normal)
@@ -69,10 +67,8 @@ ZTEST(keyboard_backlight, host_command_get_backlight__normal)
k_sleep(K_MSEC(50));
struct ec_response_pwm_get_keyboard_backlight response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT, 0, response);
- ret = host_command_process(&args);
+ ret = ec_cmd_pwm_get_keyboard_backlight(NULL, &response);
zassert_ok(ret, "Host command failed: %d", ret);
zassert_equal(expected_percentage, response.percent, NULL);
zassert_equal(1, response.enabled, "Got 0x%02x", response.enabled);
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
index ddd5b2d66f..71961c0a86 100644
--- a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
+++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
@@ -240,10 +240,8 @@ ZTEST(keyboard_scan, host_command_simulate_key__locked)
zassert_true(system_is_locked(), "Expecting locked system.");
struct ec_params_mkbp_simulate_key params;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_MKBP_SIMULATE_KEY, 0, params);
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_simulate_key(NULL, &params);
zassert_equal(EC_RES_ACCESS_DENIED, ret, "Command returned %u", ret);
}
@@ -258,10 +256,8 @@ ZTEST(keyboard_scan, host_command_simulate_key__bad_params)
.col = KEYBOARD_COLS_MAX,
.row = KEYBOARD_ROWS,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_MKBP_SIMULATE_KEY, 0, params);
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_simulate_key(NULL, &params);
zassert_equal(EC_RES_INVALID_PARAM, ret, "Command returned %u", ret);
}
diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
index d45c058d67..5184158cef 100644
--- a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
+++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
@@ -42,10 +42,8 @@ ZTEST(mkbp_event, test_host_command_get_events__empty)
/* Issue a host command to get the next event (from any source) */
uint16_t ret;
struct ec_response_get_next_event response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_NEXT_EVENT, 0, response);
- ret = host_command_process(&args);
+ ret = ec_cmd_get_next_event(NULL, &response);
zassert_equal(EC_RES_UNAVAILABLE, ret,
"Expected EC_RES_UNAVAILABLE but got %d", ret);
}
@@ -71,20 +69,18 @@ ZTEST(mkbp_event, test_host_command_host_event_wake_mask)
{
struct ec_response_mkbp_event_wake_mask response = { 0 };
struct ec_params_mkbp_event_wake_mask params = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
/* Set the wake mask to 0x12345678 */
params.action = SET_WAKE_MASK;
params.mask_type = EC_MKBP_HOST_EVENT_WAKE_MASK;
params.new_wake_mask = 0x12345678;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_mkbp_wake_mask(NULL, &params, &response));
/* Get the wake mask */
params.action = GET_WAKE_MASK;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_mkbp_wake_mask(NULL, &params, &response));
zassert_equal(0x12345678, response.wake_mask);
}
@@ -92,20 +88,18 @@ ZTEST(mkbp_event, test_host_command_event_wake_mask)
{
struct ec_response_mkbp_event_wake_mask response = { 0 };
struct ec_params_mkbp_event_wake_mask params = { 0 };
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
/* Set the wake mask to 0x87654321 */
params.action = SET_WAKE_MASK;
params.mask_type = EC_MKBP_EVENT_WAKE_MASK;
params.new_wake_mask = 0x87654321;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_mkbp_wake_mask(NULL, &params, &response));
/* Get the wake mask */
params.action = GET_WAKE_MASK;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_mkbp_wake_mask(NULL, &params, &response));
zassert_equal(0x87654321, response.wake_mask);
}
@@ -116,19 +110,20 @@ ZTEST(mkbp_event, test_host_command_wake_mask__invalid_args)
.action = -1,
.mask_type = -1,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
/* Check invalid action */
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_mkbp_wake_mask(NULL, &params, &response));
/* Check invalid mask type in getter */
params.action = GET_WAKE_MASK;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_mkbp_wake_mask(NULL, &params, &response));
/* Check invalid mask type in setter */
params.action = SET_WAKE_MASK;
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM,
+ ec_cmd_mkbp_wake_mask(NULL, &params, &response));
}
ZTEST(mkbp_event, test_console_command_wake_mask_event)
@@ -172,10 +167,8 @@ ZTEST(mkbp_event, test_host_command_get_events__get_event)
/* Retrieve this event via host command */
struct ec_response_get_next_event response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_NEXT_EVENT, 0, response);
- ret = host_command_process(&args);
+ ret = ec_cmd_get_next_event(NULL, &response);
zassert_equal(EC_RES_SUCCESS, ret, "Expected EC_RES_SUCCESS but got %d",
ret);
@@ -237,17 +230,15 @@ ZTEST(mkbp_event, test_host_command_get_events__get_event_v2)
/* Retrieve these events via host commands */
struct ec_response_get_next_event response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_NEXT_EVENT, 2, response);
- ret = host_command_process(&args);
+ ret = ec_cmd_get_next_event_v2(NULL, &response);
zassert_equal(EC_RES_SUCCESS, ret, "Expected EC_RES_SUCCESS but got %d",
ret);
zassert_true((response.event_type & EC_MKBP_HAS_MORE_EVENTS) != 0,
"Expected EC_MKBP_HAS_MORE_EVENTS but got 0x%x",
response.event_type);
- ret = host_command_process(&args);
+ ret = ec_cmd_get_next_event_v2(NULL, &response);
zassert_equal(EC_RES_SUCCESS, ret, "Expected EC_RES_SUCCESS but got %d",
ret);
zassert_true((response.event_type & EC_MKBP_HAS_MORE_EVENTS) == 0,
diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
index 6fd1b0f975..2e3e3ecf94 100644
--- a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
+++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
@@ -25,10 +25,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__keyboard_info)
.info_type = EC_MKBP_INFO_KBD,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(KEYBOARD_ROWS, response.rows, NULL);
zassert_equal(KEYBOARD_COLS_MAX, response.cols, NULL);
@@ -45,10 +42,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__supported_buttons)
.event_type = EC_MKBP_EVENT_BUTTON,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(get_supported_buttons(), response.buttons, NULL);
}
@@ -64,10 +58,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__supported_switches)
.event_type = EC_MKBP_EVENT_SWITCH,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(get_supported_switches(), response.switches, NULL);
}
@@ -83,10 +74,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__supported_invalid)
.event_type = EC_MKBP_EVENT_COUNT, /* Unsupported */
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_RES_INVALID_PARAM, ret,
"Host command didn't fail properly: %d", ret);
}
@@ -111,10 +99,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_keyboard_matrix)
.event_type = EC_MKBP_EVENT_KEY_MATRIX,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_true(response.key_matrix[KEYBOARD_COL_KEY_R] &
@@ -131,10 +116,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_host_events)
.event_type = EC_MKBP_EVENT_HOST_EVENT,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal((uint32_t)host_get_events(), response.host_event, NULL);
}
@@ -148,10 +130,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_host_events64)
.event_type = EC_MKBP_EVENT_HOST_EVENT64,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(host_get_events(), response.host_event64, NULL);
}
@@ -165,10 +144,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_buttons)
.event_type = EC_MKBP_EVENT_BUTTON,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(mkbp_get_button_state(), response.buttons, NULL);
}
@@ -182,10 +158,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_switches)
.event_type = EC_MKBP_EVENT_SWITCH,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_SUCCESS, ret, "Host command failed: %d", ret);
zassert_equal(mkbp_get_switch_state(), response.switches, NULL);
}
@@ -199,10 +172,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__current_invalid)
.event_type = EC_MKBP_EVENT_COUNT, /* Unsupported */
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_RES_INVALID_PARAM, ret, "Host command failed: %d",
ret);
}
@@ -215,10 +185,7 @@ ZTEST(mkbp_info, host_command_mkbp_info__invalid)
.info_type = -1, /* Unsupported */
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_MKBP_INFO, 0, response, request);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_mkbp_info_get_next_data(NULL, &request, &response);
zassert_equal(EC_RES_ERROR, ret, "Host command failed: %d", ret);
}
diff --git a/zephyr/test/drivers/led_driver/src/led_common.c b/zephyr/test/drivers/led_driver/src/led_common.c
index 2b113499a0..7bab7498db 100644
--- a/zephyr/test/drivers/led_driver/src/led_common.c
+++ b/zephyr/test/drivers/led_driver/src/led_common.c
@@ -27,10 +27,7 @@ ZTEST(led_common, host_command__query)
[EC_LED_COLOR_WHITE] = 1, [EC_LED_COLOR_AMBER] = 0,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LED_CONTROL, 1, response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_led_control_v1(NULL, &params, &response);
zassert_ok(ret, "Host command returned %d", ret);
zassert_mem_equal(expected_brightness_ranges, response.brightness_range,
@@ -48,10 +45,7 @@ ZTEST(led_common, host_command__invalid_led)
.flags = EC_LED_FLAGS_QUERY,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LED_CONTROL, 1, response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_led_control_v1(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, ret, "Host command returned %d",
ret);
@@ -72,10 +66,7 @@ ZTEST(led_common, host_command__supported_channel)
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LED_CONTROL, 1, response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_led_control_v1(NULL, &params, &response);
zassert_equal(EC_RES_INVALID_PARAM, ret, "Host command returned %d",
ret);
@@ -96,10 +87,7 @@ ZTEST(led_common, host_command__manual_control)
},
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LED_CONTROL, 1, response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_led_control_v1(NULL, &params, &response);
zassert_equal(EC_RES_SUCCESS, ret, "Host command returned %d", ret);
zassert_true(
@@ -123,10 +111,7 @@ ZTEST(led_common, host_command__auto_control)
.flags = EC_LED_FLAGS_AUTO,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LED_CONTROL, 1, response, params);
-
- ret = host_command_process(&args);
+ ret = ec_cmd_led_control_v1(NULL, &params, &response);
zassert_equal(EC_RES_SUCCESS, ret, "Host command returned %d", ret);
zassert_equal(1, board_led_auto_control_fake.call_count,
diff --git a/zephyr/test/drivers/locate_chip/src/locate_chip.c b/zephyr/test/drivers/locate_chip/src/locate_chip.c
index 881b17a54c..3cb9a9f3bc 100644
--- a/zephyr/test/drivers/locate_chip/src/locate_chip.c
+++ b/zephyr/test/drivers/locate_chip/src/locate_chip.c
@@ -17,10 +17,8 @@ ZTEST_USER(locate_chip, test_invalid_request_for_eeprom)
.type = EC_CHIP_TYPE_CBI_EEPROM,
};
struct ec_response_locate_chip r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_LOCATE_CHIP, 0, r, p);
- ret = host_command_process(&args);
+ ret = ec_cmd_locate_chip(NULL, &p, &r);
zassert_equal(ret, EC_RES_UNAVAILABLE, "Unexpected return value: %d",
ret);
diff --git a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
index 521b4c735b..616951c558 100644
--- a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
+++ b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
@@ -74,8 +74,7 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__bad_event)
.suspend_params = { 0 },
};
struct ec_response_host_sleep_event_v1 r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, 1, r, p);
+ struct host_cmd_handler_args args;
/* Clear garbage for verifiable value */
r.resume_response.sleep_transitions = 0;
@@ -83,7 +82,7 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__bad_event)
power_chipset_handle_host_sleep_event_fake.custom_fake =
_test_power_chipset_handle_host_sleep_event;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event_v1(&args, &p, &r));
zassert_equal(args.response_size, 0);
zassert_equal(power_chipset_handle_host_sleep_event_fake.call_count, 1);
zassert_equal(power_chipset_handle_host_sleep_event_fake.arg0_val,
@@ -102,8 +101,7 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__s3_suspend)
.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND,
};
struct ec_response_host_sleep_event_v1 r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, 1, r, p);
+ struct host_cmd_handler_args args;
/* Set m/lsb of uint16_t to check for type coercion errors */
p.suspend_params.sleep_timeout_ms = BIT(15) + 1;
@@ -111,7 +109,7 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__s3_suspend)
power_chipset_handle_host_sleep_event_fake.custom_fake =
_test_power_chipset_handle_host_sleep_event;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event_v1(&args, &p, &r));
zassert_equal(args.response_size, 0);
zassert_equal(power_chipset_handle_host_sleep_event_fake.call_count, 1);
zassert_equal(power_chipset_handle_host_sleep_event_fake.arg0_val,
@@ -130,13 +128,12 @@ ZTEST_USER(power_host_sleep, test_non_existent_sleep_event_v1__s3_resume)
.sleep_event = HOST_SLEEP_EVENT_S3_RESUME,
};
struct ec_response_host_sleep_event_v1 r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, 1, r, p);
+ struct host_cmd_handler_args args;
power_chipset_handle_host_sleep_event_fake.custom_fake =
_test_power_chipset_handle_host_sleep_event;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event_v1(&args, &p, &r));
zassert_equal(args.response_size, sizeof(r));
zassert_equal(power_chipset_handle_host_sleep_event_fake.call_count, 1);
zassert_equal(power_chipset_handle_host_sleep_event_fake.arg0_val,
diff --git a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
index ddc406e58c..ac8c88adbe 100644
--- a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
+++ b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
@@ -25,10 +25,7 @@ ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__kblight)
.duty = PWM_PERCENT_TO_RAW(56),
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PWM_SET_DUTY, 0, p);
-
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pwm_set_duty(NULL, &p));
zassert_equal(kblight_get(), PWM_RAW_TO_PERCENT(p.duty));
}
@@ -41,10 +38,7 @@ ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__displight)
.duty = PWM_PERCENT_TO_RAW(72)
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PWM_SET_DUTY, 0, p);
-
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pwm_set_duty(NULL, &p));
zassert_equal(displight_get(), PWM_RAW_TO_PERCENT(p.duty));
}
@@ -57,10 +51,7 @@ ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__bad_pwm_type)
p.pwm_type = EC_PWM_TYPE_COUNT,
};
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_PWM_SET_DUTY, 0, p);
-
- zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+ zassert_equal(EC_RES_INVALID_PARAM, ec_cmd_pwm_set_duty(NULL, &p));
}
ZTEST(shim_pwm_hc, test_pwm_get_duty_hc__kblight)
@@ -71,13 +62,12 @@ ZTEST(shim_pwm_hc, test_pwm_get_duty_hc__kblight)
};
struct ec_response_pwm_get_duty r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_PWM_GET_DUTY, 0, r, p);
+ struct host_cmd_handler_args args;
/* Set kblight percentage to arbitrary 56% */
kblight_set(56);
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pwm_get_duty(&args, &p, &r));
zassert_equal(args.response_size, sizeof(r));
zassert_equal(r.duty, PWM_PERCENT_TO_RAW(56));
}
@@ -90,13 +80,12 @@ ZTEST(shim_pwm_hc, test_pwm_get_duty_hc__displight)
};
struct ec_response_pwm_get_duty r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_PWM_GET_DUTY, 0, r, p);
+ struct host_cmd_handler_args args;
/* Set displight percentage to arbitrary 72% */
displight_set(72);
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_pwm_get_duty(&args, &p, &r));
zassert_equal(args.response_size, sizeof(r));
zassert_equal(r.duty, PWM_PERCENT_TO_RAW(72));
}
diff --git a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
index ded293d80a..432ad1d4f4 100644
--- a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
+++ b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
@@ -18,21 +18,17 @@ ZTEST_USER(rtc_shim, test_hc_rtc_set_get_value)
{
struct ec_params_rtc set_value;
struct ec_response_rtc get_value;
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_RTC_SET_VALUE, 0, set_value);
- struct host_cmd_handler_args get_args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_RTC_GET_VALUE, 0, get_value);
/* Initially set/get arbitrary value */
set_value.time = 1337;
- zassert_ok(host_command_process(&set_args));
- zassert_ok(host_command_process(&get_args));
+ zassert_ok(ec_cmd_rtc_set_value(NULL, &set_value));
+ zassert_ok(ec_cmd_rtc_get_value(NULL, &get_value));
zassert_equal(get_value.time, set_value.time);
/* One more time to be sure the test is creating the value change */
set_value.time = 1776;
- zassert_ok(host_command_process(&set_args));
- zassert_ok(host_command_process(&get_args));
+ zassert_ok(ec_cmd_rtc_set_value(NULL, &set_value));
+ zassert_ok(ec_cmd_rtc_get_value(NULL, &get_value));
zassert_equal(get_value.time, set_value.time);
}
@@ -40,21 +36,17 @@ ZTEST_USER(rtc_shim, test_hc_rtc_set_get_alarm)
{
struct ec_params_rtc set_value;
struct ec_response_rtc get_value;
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_RTC_SET_ALARM, 0, set_value);
- struct host_cmd_handler_args get_args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_RTC_GET_ALARM, 0, get_value);
/* Initially set/get zero value */
set_value.time = 0;
- zassert_ok(host_command_process(&set_args));
- zassert_ok(host_command_process(&get_args));
+ zassert_ok(ec_cmd_rtc_set_alarm(NULL, &set_value));
+ zassert_ok(ec_cmd_rtc_get_alarm(NULL, &get_value));
zassert_equal(get_value.time, set_value.time);
/* One more time to be sure the test is creating the value change */
set_value.time = 1776;
- zassert_ok(host_command_process(&set_args));
- zassert_ok(host_command_process(&get_args));
+ zassert_ok(ec_cmd_rtc_set_alarm(NULL, &set_value));
+ zassert_ok(ec_cmd_rtc_get_alarm(NULL, &get_value));
/*
* The RTC driver adds 1 second to the alarm time to compensate for
* truncation error. For example, 7 seconds is returned when the
@@ -67,8 +59,6 @@ ZTEST_USER(rtc_shim, test_hc_rtc_set_get_alarm)
ZTEST(rtc_shim, test_hc_rtc_set_alarm_can_fire_cb)
{
struct ec_params_rtc set_value;
- struct host_cmd_handler_args set_args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_RTC_SET_ALARM, 0, set_value);
#ifdef CONFIG_HOSTCMD_X86
/* Enable the RTC event to fire */
@@ -88,7 +78,7 @@ ZTEST(rtc_shim, test_hc_rtc_set_alarm_can_fire_cb)
/* Initially set arbitrary value of alarm in 2 seconds*/
set_value.time = 2;
- zassert_ok(host_command_process(&set_args));
+ zassert_ok(ec_cmd_rtc_set_alarm(NULL, &set_value));
/* Set fake driver time forward to hit the alarm in 2 seconds */
/*
diff --git a/zephyr/test/drivers/system/src/system.c b/zephyr/test/drivers/system/src/system.c
index b615dfc2df..2bd8554994 100644
--- a/zephyr/test/drivers/system/src/system.c
+++ b/zephyr/test/drivers/system/src/system.c
@@ -26,12 +26,10 @@ FAKE_VOID_FUNC(jump_to_image, uintptr_t);
ZTEST_USER(system, test_hostcmd_sysinfo)
{
struct ec_response_sysinfo response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_SYSINFO, 0, response);
+ struct host_cmd_handler_args args;
/* Simply issue the command and get the results */
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
+ zassert_ok(ec_cmd_sysinfo(&args, &response), NULL);
zassert_equal(args.response_size, sizeof(response), NULL);
zassert_equal(response.reset_flags, 0, "response.reset_flags = %d",
response.reset_flags);
diff --git a/zephyr/test/drivers/system/src/system_board_version_default.c b/zephyr/test/drivers/system/src/system_board_version_default.c
index 0ef11a8c39..d6fe399988 100644
--- a/zephyr/test/drivers/system/src/system_board_version_default.c
+++ b/zephyr/test/drivers/system/src/system_board_version_default.c
@@ -11,12 +11,10 @@
ZTEST_USER(system, test_hostcmd_board_version)
{
struct ec_response_board_version response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
- EC_CMD_GET_BOARD_VERSION, 0, response);
+ struct host_cmd_handler_args args;
/* Get the board version, which is default 0. */
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
+ zassert_ok(ec_cmd_get_board_version(&args, &response), NULL);
zassert_equal(args.response_size, sizeof(response), NULL);
zassert_equal(response.board_version, 0, "response.board_version = %d",
response.board_version);
diff --git a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
index 7594a6158e..e651bb57d8 100644
--- a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
+++ b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
@@ -96,9 +96,7 @@ ZTEST(usb_port_power_dumb, host_command__enable)
.usb_port_id = PORT_ID,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_CHARGE_SET_MODE, 0, params);
- ret = host_command_process(&args);
+ ret = ec_cmd_usb_charge_set_mode(NULL, &params);
zassert_ok(ret, "Host command returned %d", ret);
zassert_true(check_gpio_status_for_port(PORT_ID), NULL);
@@ -113,9 +111,7 @@ ZTEST(usb_port_power_dumb, host_command__invalid_port_id)
.usb_port_id = UINT8_MAX,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_CHARGE_SET_MODE, 0, params);
- ret = host_command_process(&args);
+ ret = ec_cmd_usb_charge_set_mode(NULL, &params);
zassert_equal(EC_RES_ERROR, ret, "Host command returned %d", ret);
zassert_false(check_gpio_status_for_port(PORT_ID), NULL);
@@ -129,9 +125,7 @@ ZTEST(usb_port_power_dumb, host_command__invalid_mode)
.usb_port_id = PORT_ID,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_USB_CHARGE_SET_MODE, 0, params);
- ret = host_command_process(&args);
+ ret = ec_cmd_usb_charge_set_mode(NULL, &params);
zassert_equal(EC_RES_ERROR, ret, "Host command returned %d", ret);
zassert_false(check_gpio_status_for_port(PORT_ID), NULL);
diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
index e966878a74..f23af9356d 100644
--- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
+++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
@@ -301,10 +301,9 @@ ZTEST_F(usbc_alt_mode, verify_discovery_via_pd_host_cmd)
struct ec_params_usb_pd_info_request params = { .port = TEST_PORT };
struct ec_params_usb_pd_discovery_entry response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_USB_PD_DISCOVERY, 0, response, params);
+ struct host_cmd_handler_args args;
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_usb_pd_discovery(&args, &params, &response));
zassert_equal(args.response_size, sizeof(response));
zassert_equal(response.ptype, IDH_PTYPE_AMA);
zassert_equal(response.vid, USB_VID_GOOGLE);
diff --git a/zephyr/test/krabby/src/power_seq.c b/zephyr/test/krabby/src/power_seq.c
index 9f55baf278..6931a3395d 100644
--- a/zephyr/test/krabby/src/power_seq.c
+++ b/zephyr/test/krabby/src/power_seq.c
@@ -141,11 +141,9 @@ ZTEST(power_seq, test_host_sleep_success)
zassert_equal(power_get_state(), POWER_S0);
/* Suspend for 30 seconds */
- zassert_ok(host_command_process(
- &(struct host_cmd_handler_args)BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, 0,
- (struct ec_params_host_sleep_event){
- .sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND })));
+ zassert_ok(ec_cmd_host_sleep_event(
+ NULL, &(struct ec_params_host_sleep_event){
+ .sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND }));
k_sleep(K_MSEC(1));
set_signal_state(POWER_S3);
k_sleep(K_SECONDS(30));
@@ -153,11 +151,9 @@ ZTEST(power_seq, test_host_sleep_success)
/* Resume */
set_signal_state(POWER_S0);
- zassert_ok(host_command_process(
- &(struct host_cmd_handler_args)BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, 0,
- (struct ec_params_host_sleep_event){
- .sleep_event = HOST_SLEEP_EVENT_S3_RESUME })));
+ zassert_ok(ec_cmd_host_sleep_event(
+ NULL, &(struct ec_params_host_sleep_event){
+ .sleep_event = HOST_SLEEP_EVENT_S3_RESUME }));
zassert_equal(power_get_state(), POWER_S0);
/* Verify that EC_HOST_EVENT_HANG_DETECT is not triggered */
@@ -174,11 +170,9 @@ ZTEST(power_seq, test_host_sleep_hang)
zassert_equal(power_get_state(), POWER_S0);
/* Send HOST_SLEEP_EVENT_S3_SUSPEND and hang for 30 seconds */
- zassert_ok(host_command_process(
- &(struct host_cmd_handler_args)BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, 0,
- (struct ec_params_host_sleep_event){
- .sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND })));
+ zassert_ok(ec_cmd_host_sleep_event(
+ NULL, &(struct ec_params_host_sleep_event){
+ .sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND }));
k_sleep(K_SECONDS(30));
/* Verify that EC_HOST_EVENT_HANG_DETECT is triggered */
diff --git a/zephyr/test/qcom_power/src/main.c b/zephyr/test/qcom_power/src/main.c
index 2697a8c3aa..eb033e62f3 100644
--- a/zephyr/test/qcom_power/src/main.c
+++ b/zephyr/test/qcom_power/src/main.c
@@ -304,10 +304,8 @@ ZTEST(qcom_power, test_request_sleep)
struct ec_params_host_sleep_event params = {
.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, UINT8_C(0), params);
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event(NULL, &params));
zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1));
k_sleep(K_SECONDS(16));
zassert_equal(power_get_state(), POWER_S3);
@@ -322,11 +320,9 @@ ZTEST(qcom_power, test_request_sleep_timeout)
struct ec_params_host_sleep_event params = {
.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, UINT8_C(0), params);
shell_backend_dummy_clear_output(get_ec_shell());
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event(NULL, &params));
k_sleep(K_SECONDS(16));
zassert_equal(power_get_state(), POWER_S0);
buffer = shell_backend_dummy_get_output(get_ec_shell(), &buffer_size);
@@ -450,8 +446,6 @@ ZTEST(qcom_power, test_host_sleep_event_resume)
struct ec_params_host_sleep_event params = {
.sleep_event = HOST_SLEEP_EVENT_S3_RESUME,
};
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
- EC_CMD_HOST_SLEEP_EVENT, UINT8_C(0), params);
/* Get into S3 first */
power_signal_enable_interrupt(GPIO_AP_SUSPEND);
@@ -468,7 +462,7 @@ ZTEST(qcom_power, test_host_sleep_event_resume)
power_get_state());
/* Call host command to notify ec resume is done. */
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_host_sleep_event(NULL, &params));
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_S0, "power_state=%d",
power_get_state());
diff --git a/zephyr/test/system_common/src/get_version.c b/zephyr/test/system_common/src/get_version.c
index a5e4fd5365..073c9a0662 100644
--- a/zephyr/test/system_common/src/get_version.c
+++ b/zephyr/test/system_common/src/get_version.c
@@ -29,10 +29,9 @@ ZTEST(host_cmd_get_version, test_get_version_v1)
{
int ret;
struct ec_response_get_version_v1 r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_VERSION, 1, r);
+ struct host_cmd_handler_args args;
- ret = host_command_process(&args);
+ ret = ec_cmd_get_version_v1(&args, &r);
zassert_equal(ret, EC_SUCCESS, "Unexpected return value: %d", ret);
@@ -54,10 +53,9 @@ ZTEST(host_cmd_get_version, test_get_version_v0)
{
int ret;
struct ec_response_get_version r;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_VERSION, 0, r);
+ struct host_cmd_handler_args args;
- ret = host_command_process(&args);
+ ret = ec_cmd_get_version(&args, &r);
zassert_equal(ret, EC_SUCCESS, "Unexpected return value: %d", ret);
diff --git a/zephyr/test/system_common/src/reboot.c b/zephyr/test/system_common/src/reboot.c
index 18b5f0fd38..e5d494cd4c 100644
--- a/zephyr/test/system_common/src/reboot.c
+++ b/zephyr/test/system_common/src/reboot.c
@@ -121,8 +121,6 @@ ZTEST(host_cmd_reboot, test_reboot)
int ret;
int i;
struct ec_params_reboot_ec p;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND_PARAMS(EC_CMD_REBOOT_EC, 0, p);
int reboot_at_shutdown;
struct {
@@ -216,7 +214,7 @@ ZTEST(host_cmd_reboot, test_reboot)
RESET_FAKE(system_reset);
RESET_FAKE(system_hibernate);
- ret = host_command_process(&args);
+ ret = ec_cmd_reboot_ec(NULL, &p);
zassert_equal(ret, tests[i].expect_return,
"Unexpected return value (%d): %d", i, ret);
diff --git a/zephyr/test/system_safe_mode/src/system_safe_mode.c b/zephyr/test/system_safe_mode/src/system_safe_mode.c
index f286a45124..68c6dc4797 100644
--- a/zephyr/test/system_safe_mode/src/system_safe_mode.c
+++ b/zephyr/test/system_safe_mode/src/system_safe_mode.c
@@ -128,16 +128,13 @@ ZTEST_USER(system_safe_mode, test_blocked_command_in_safe_mode)
};
struct ec_response_gpio_get cmd_response;
- struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
- EC_CMD_GPIO_GET, 0, cmd_response, cmd_params);
-
zassert_false(system_is_in_safe_mode());
- zassert_ok(host_command_process(&args));
+ zassert_ok(ec_cmd_gpio_get(NULL, &cmd_params, &cmd_response));
k_sys_fatal_error_handler(K_ERR_CPU_EXCEPTION, NULL);
zassert_true(system_is_in_safe_mode());
- zassert_true(host_command_process(&args));
+ zassert_true(ec_cmd_gpio_get(NULL, &cmd_params, &cmd_response));
}
ZTEST_USER(system_safe_mode, test_panic_event_notify)
diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c
index d82a56eae5..4a76e7bd54 100644
--- a/zephyr/test/vboot_efs2/src/main.c
+++ b/zephyr/test/vboot_efs2/src/main.c
@@ -244,12 +244,11 @@ ZTEST(vboot_efs2, test_vboot_main_vboot_get_rw_hash_fail)
.offset = 0,
.size = 0x12345,
};
- struct host_cmd_handler_args hash_start_args = BUILD_HOST_COMMAND(
- EC_CMD_VBOOT_HASH, 0, response, hash_start_params);
shell_backend_dummy_clear_output(shell_zephyr);
- zassert_ok(host_command_process(&hash_start_args), NULL);
+ zassert_ok(ec_cmd_vboot_hash(NULL, &hash_start_params, &response),
+ NULL);
vboot_main();
outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size);