summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/lm4/mock_lpc.c27
-rw-r--r--test/charging.tasklist1
-rw-r--r--test/flash.c60
-rw-r--r--test/flash_test_util.py29
-rw-r--r--test/hello.tasklist1
-rw-r--r--test/kb_debounce.tasklist1
-rw-r--r--test/kb_deghost.tasklist1
-rw-r--r--test/mutex.tasklist1
-rw-r--r--test/pingpong.tasklist1
-rw-r--r--test/power_button.tasklist1
-rw-r--r--test/scancode.tasklist1
-rw-r--r--test/thermal.py6
-rw-r--r--test/thermal.tasklist1
-rw-r--r--test/timer_calib.tasklist1
-rw-r--r--test/timer_dos.tasklist1
-rw-r--r--test/timer_jump.py11
-rw-r--r--test/typematic.tasklist1
17 files changed, 112 insertions, 33 deletions
diff --git a/chip/lm4/mock_lpc.c b/chip/lm4/mock_lpc.c
index 52495bc9c9..5b31ec4bc2 100644
--- a/chip/lm4/mock_lpc.c
+++ b/chip/lm4/mock_lpc.c
@@ -6,24 +6,26 @@
/* Mock LPC module for Chrome EC */
#include "board.h"
+#include "common.h"
+#include "ec_commands.h"
#include "lpc.h"
#include "registers.h"
#include "uart.h"
-void lpc_set_host_events(uint32_t mask)
+void lpc_set_host_event_state(uint32_t mask)
{
uart_printf("Host event: %x\n", mask);
}
-uint32_t lpc_get_host_events(void)
+uint32_t lpc_get_host_event_state(void)
{
/* Not implemented */
return 0;
}
-void lpc_clear_host_events(uint32_t mask)
+void lpc_clear_host_event_state(uint32_t mask)
{
uart_printf("Clear host event: %x\n", mask);
}
@@ -61,3 +63,22 @@ void lpc_comx_put_char(int c)
/* Not implemented */
return;
}
+
+
+void host_send_response(enum ec_status result, const uint8_t *data, int size)
+{
+ /* Not implemented */
+ return;
+}
+
+
+uint8_t *lpc_get_memmap_range(void)
+{
+ return (uint8_t *)LPC_POOL_CMD_DATA + EC_HOST_PARAM_SIZE * 2;
+}
+
+
+uint8_t *host_get_buffer(void)
+{
+ return (uint8_t *)LPC_POOL_CMD_DATA;
+}
diff --git a/test/charging.tasklist b/test/charging.tasklist
index 4a0d674e91..ae93e63291 100644
--- a/test/charging.tasklist
+++ b/test/charging.tasklist
@@ -23,4 +23,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/flash.c b/test/flash.c
index 6f822d88ec..2ab0b749fb 100644
--- a/test/flash.c
+++ b/test/flash.c
@@ -22,17 +22,25 @@ DECLARE_CONSOLE_COMMAND(rosize, ro_image_size,
"Report size of RO image",
NULL);
+/* TODO(victoryang@): We should introduce a function to send fake host command
+ * just like ec_command in ectool. See crosbug/p/11350 */
static int hc_flash_info(int argc, char **argv)
{
- uint8_t data[EC_PARAM_SIZE];
+ uint8_t data[EC_HOST_PARAM_SIZE];
enum ec_status res;
- int resp_size;
- struct ec_response_flash_info *r =
- (struct ec_response_flash_info *)data;
-
- res = host_command_process(EC_CMD_FLASH_INFO, data, &resp_size);
+ struct ec_response_flash_info *r;
+ struct host_cmd_handler_args args =
+ { .command = EC_CMD_FLASH_INFO,
+ .version = 0,
+ .params = NULL,
+ .params_size = 0,
+ .response = data,
+ .response_size = EC_HOST_PARAM_SIZE };
+
+ res = host_command_process(&args);
if (res != EC_RES_SUCCESS)
return EC_ERROR_UNKNOWN;
+ r = (struct ec_response_flash_info *)args.response;
uart_printf("flash_size = %d\n", r->flash_size);
uart_printf("write_block_size = %d\n", r->write_block_size);
uart_printf("erase_block_size = %d\n", r->erase_block_size);
@@ -45,13 +53,17 @@ DECLARE_CONSOLE_COMMAND(hcflashinfo, hc_flash_info,
static int hc_flash_read(int argc, char **argv)
{
- uint8_t data[EC_PARAM_SIZE];
+ uint8_t data[EC_HOST_PARAM_SIZE];
enum ec_status res;
- int resp_size;
struct ec_params_flash_read *p =
(struct ec_params_flash_read *)data;
- struct ec_response_flash_read *r =
- (struct ec_response_flash_read *)data;
+ struct host_cmd_handler_args args =
+ { .command = EC_CMD_FLASH_READ,
+ .version = 0,
+ .params = data,
+ .params_size = EC_HOST_PARAM_SIZE,
+ .response = data,
+ .response_size = EC_HOST_PARAM_SIZE };
char *e;
int i, size;
@@ -66,11 +78,11 @@ static int hc_flash_read(int argc, char **argv)
if (*e)
return EC_ERROR_PARAM2;
- res = host_command_process(EC_CMD_FLASH_READ, data, &resp_size);
+ res = host_command_process(&args);
if (res != EC_RES_SUCCESS)
return EC_ERROR_UNKNOWN;
for (i = 0; i < size; ++i) {
- uart_printf("%02x", r->data[i]);
+ uart_printf("%02x", args.response[i]);
if ((i & 31) == 31)
uart_puts("\n");
}
@@ -81,11 +93,17 @@ DECLARE_CONSOLE_COMMAND(hcflashread, hc_flash_read,
static int hc_flash_write(int argc, char **argv)
{
- uint8_t data[EC_PARAM_SIZE];
+ uint8_t data[EC_HOST_PARAM_SIZE];
enum ec_status res;
- int resp_size;
struct ec_params_flash_write *p =
(struct ec_params_flash_write *)data;
+ struct host_cmd_handler_args args =
+ { .command = EC_CMD_FLASH_WRITE,
+ .version = 0,
+ .params = data,
+ .params_size = EC_HOST_PARAM_SIZE,
+ .response = data,
+ .response_size = EC_HOST_PARAM_SIZE };
char *e;
int i, size;
int seed, mult, add;
@@ -115,7 +133,7 @@ static int hc_flash_write(int argc, char **argv)
seed = seed * mult + add;
}
- res = host_command_process(EC_CMD_FLASH_WRITE, data, &resp_size);
+ res = host_command_process(&args);
if (res != EC_RES_SUCCESS)
return EC_ERROR_UNKNOWN;
return EC_SUCCESS;
@@ -125,11 +143,17 @@ DECLARE_CONSOLE_COMMAND(hcflashwrite, hc_flash_write,
static int hc_flash_erase(int argc, char **argv)
{
- uint8_t data[EC_PARAM_SIZE];
+ uint8_t data[EC_HOST_PARAM_SIZE];
enum ec_status res;
- int resp_size;
struct ec_params_flash_erase *p =
(struct ec_params_flash_erase *)data;
+ struct host_cmd_handler_args args =
+ { .command = EC_CMD_FLASH_ERASE,
+ .version = 0,
+ .params = data,
+ .params_size = EC_HOST_PARAM_SIZE,
+ .response = data,
+ .response_size = EC_HOST_PARAM_SIZE };
char *e;
int size;
@@ -144,7 +168,7 @@ static int hc_flash_erase(int argc, char **argv)
if (*e)
return EC_ERROR_PARAM2;
- res = host_command_process(EC_CMD_FLASH_ERASE, data, &resp_size);
+ res = host_command_process(&args);
if (res != EC_RES_SUCCESS)
return EC_ERROR_UNKNOWN;
return EC_SUCCESS;
diff --git a/test/flash_test_util.py b/test/flash_test_util.py
index 476f3b2d09..06eea777da 100644
--- a/test/flash_test_util.py
+++ b/test/flash_test_util.py
@@ -6,6 +6,7 @@
#
import random
+import re
# Fixed random seed.
random.seed(1234)
@@ -30,15 +31,29 @@ def test_erase(helper, offset, size):
helper.ec_command("hcflasherase %d %d" % (offset, size))
helper.wait_output("Flash erase at %x size %x" % (offset, size))
+def _get_read_ref(helper, offset, size):
+ ret = []
+ retsub = []
+ assert size % 4 == 0
+ while size > 0:
+ helper.ec_command("rw %d" % offset)
+ h = helper.wait_output("read.*=\s+0x(?P<h>[0-9a-f]+)", use_re=True)["h"]
+ # Change endianess here
+ retsub.append(re.sub('(..)(..)(..)(..)', r'\4\3\2\1', h))
+ if len(retsub) == 8:
+ ret.append(''.join(retsub))
+ retsub = []
+ size = size - 4
+ offset = offset + 4
+ if retsub:
+ ret.append(''.join(retsub))
+ return ret
+
def test_read(helper, offset, size):
+ ref = _get_read_ref(helper, offset, size)
helper.ec_command("hcflashread %d %d" % (offset, size))
- while size > 0:
- cur_size = size if size <= 32 else 32
- expect_str = ''.join([("%02x" % (x & 0xff)) for x in
- range(offset, offset + cur_size)])
- helper.wait_output(expect_str)
- offset = offset + cur_size
- size = size - cur_size
+ for line in ref:
+ helper.wait_output(line)
def test_write(helper, offset, size, expect_fail=False):
seed = random.randint(2, 10000)
diff --git a/test/hello.tasklist b/test/hello.tasklist
index 43cd7841a5..6c33988331 100644
--- a/test/hello.tasklist
+++ b/test/hello.tasklist
@@ -16,4 +16,5 @@
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL) \
TASK(VBOOTHASH, vboot_hash_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/kb_debounce.tasklist b/test/kb_debounce.tasklist
index 996cceeacb..253871f365 100644
--- a/test/kb_debounce.tasklist
+++ b/test/kb_debounce.tasklist
@@ -22,4 +22,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/kb_deghost.tasklist b/test/kb_deghost.tasklist
index c949371ae5..3bb24f5eb1 100644
--- a/test/kb_deghost.tasklist
+++ b/test/kb_deghost.tasklist
@@ -22,4 +22,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/mutex.tasklist b/test/mutex.tasklist
index 54ed049101..c617fc5387 100644
--- a/test/mutex.tasklist
+++ b/test/mutex.tasklist
@@ -7,6 +7,7 @@
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL) \
TASK(VBOOTHASH, vboot_hash_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
TASK(MTX3C, mutex_random_task, NULL) \
TASK(MTX3B, mutex_random_task, NULL) \
diff --git a/test/pingpong.tasklist b/test/pingpong.tasklist
index 28cc227280..ce8f7febd9 100644
--- a/test/pingpong.tasklist
+++ b/test/pingpong.tasklist
@@ -7,6 +7,7 @@
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL) \
TASK(VBOOTHASH, vboot_hash_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
TASK(TESTA, TaskAbc, (void *)'A') \
TASK(TESTB, TaskAbc, (void *)'B') \
diff --git a/test/power_button.tasklist b/test/power_button.tasklist
index ac4c48dc2f..b576e38f30 100644
--- a/test/power_button.tasklist
+++ b/test/power_button.tasklist
@@ -22,4 +22,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/scancode.tasklist b/test/scancode.tasklist
index 996cceeacb..253871f365 100644
--- a/test/scancode.tasklist
+++ b/test/scancode.tasklist
@@ -22,4 +22,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/thermal.py b/test/thermal.py
index 30090b6b74..3a0453c3bb 100644
--- a/test/thermal.py
+++ b/test/thermal.py
@@ -82,7 +82,11 @@ def test(helper):
# Set CPU temperature to trigger warning and throttle CPU
helper.ec_command("setcputemp %d" % config[CPU]['warning'])
helper.wait_output("Throttle CPU.", timeout=11)
- helper.wait_output("Host event: 200", timeout=2)
+ host_event = helper.wait_output("Host event: (?P<h>\d+)", use_re=True,
+ timeout=2)["h"]
+ if (int(host_event, 16) & 0x200) == 0:
+ helper.trace("Fail to get thermal overload event")
+ return False
# Lower CPU temperature and check CPU is not throttled
helper.ec_command("setcputemp %d" % (config[CPU]['warning']-5))
diff --git a/test/thermal.tasklist b/test/thermal.tasklist
index 56d87219d6..fe620078e8 100644
--- a/test/thermal.tasklist
+++ b/test/thermal.tasklist
@@ -20,4 +20,5 @@
TASK(THERMAL, thermal_task, NULL) \
TASK(PWM, pwm_task, NULL) \
TASK(X86POWER, x86_power_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/timer_calib.tasklist b/test/timer_calib.tasklist
index 012931ab85..b17b961296 100644
--- a/test/timer_calib.tasklist
+++ b/test/timer_calib.tasklist
@@ -8,4 +8,5 @@
TASK(WATCHDOG, watchdog_task, NULL) \
TASK(VBOOTHASH, vboot_hash_task, NULL) \
TASK(TESTTMR, timer_calib_task, (void *)'T')\
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)
diff --git a/test/timer_dos.tasklist b/test/timer_dos.tasklist
index 8361010247..1a19829cbb 100644
--- a/test/timer_dos.tasklist
+++ b/test/timer_dos.tasklist
@@ -7,6 +7,7 @@
#define CONFIG_TASK_LIST \
TASK(WATCHDOG, watchdog_task, NULL) \
TASK(VBOOTHASH, vboot_hash_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL) \
TASK(TMRA, TaskTimer, (void *)1234) \
TASK(TMRB, TaskTimer, (void *)5678) \
diff --git a/test/timer_jump.py b/test/timer_jump.py
index 2f2302e327..07b67f1793 100644
--- a/test/timer_jump.py
+++ b/test/timer_jump.py
@@ -11,15 +11,18 @@ DELAY = 5
ERROR_MARGIN = 0.5
def test(helper):
- helper.wait_output("Console is enabled")
- helper.ec_command("sysjump ro")
- helper.wait_output("Console is enabled")
+ helper.wait_output("idle task started")
+ helper.ec_command("sysinfo")
+ copy = helper.wait_output("Copy:\s+(?P<c>\S+)", use_re=True)["c"]
+ if copy != "RO":
+ helper.ec_command("sysjump ro")
+ helper.wait_output("idle task started")
helper.ec_command("gettime")
ec_start_time = helper.wait_output("Time: 0x[0-9a-f]* = (?P<t>[\d\.]+) s",
use_re=True)["t"]
time.sleep(DELAY)
helper.ec_command("sysjump a")
- helper.wait_output("Console is enabled")
+ helper.wait_output("idle task started")
helper.ec_command("gettime")
ec_end_time = helper.wait_output("Time: 0x[0-9a-f]* = (?P<t>[\d\.]+) s",
use_re=True)["t"]
diff --git a/test/typematic.tasklist b/test/typematic.tasklist
index 996cceeacb..253871f365 100644
--- a/test/typematic.tasklist
+++ b/test/typematic.tasklist
@@ -22,4 +22,5 @@
TASK(I8042CMD, i8042_command_task, NULL) \
TASK(KEYSCAN, keyboard_scan_task, NULL) \
TASK(POWERBTN, power_button_task, NULL) \
+ TASK(HOSTCMD, host_command_task, NULL) \
TASK(CONSOLE, console_task, NULL)