summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-12 10:40:51 -0700
committerGerrit <chrome-bot@google.com>2012-07-12 18:10:30 -0700
commit02d820786c2fda890411494ddbc9e6d2ddf90f32 (patch)
tree264cbf06f8a0bc14c52be1dae895abe6efd88b39 /util
parentc304ff7d81a2a3072e5388584b232413a76f3343 (diff)
downloadchrome-ec-02d820786c2fda890411494ddbc9e6d2ddf90f32.tar.gz
Support new-style LPC command interface in EC, ectool
Both EC and ectool are still backwards-compatible to the old interface. BUG=chrome-os-partner:11275 TEST=manual From U-boot prompt: mkbp hash // test old host talking to new EC From root shell: ectool echash // test new host talking to new EC You can also update just the OS and use an old EC, and verify that 'ectool echash' still works, which tests a new host talking to an old EC. Change-Id: I2afbb208cb16836f842ba119b74b1ab6a38ce5d5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27313
Diffstat (limited to 'util')
-rw-r--r--util/burn_my_ec.c15
-rw-r--r--util/comm-host.h2
-rw-r--r--util/comm-i2c.c15
-rw-r--r--util/comm-lpc.c120
-rw-r--r--util/ectool.c89
-rw-r--r--util/lbplay.c12
6 files changed, 187 insertions, 66 deletions
diff --git a/util/burn_my_ec.c b/util/burn_my_ec.c
index 5af1a8e63a..afc14d3359 100644
--- a/util/burn_my_ec.c
+++ b/util/burn_my_ec.c
@@ -23,10 +23,10 @@ enum ec_current_image get_version(enum ec_current_image *version_ptr)
char build_info[EC_HOST_PARAM_SIZE];
int res;
- res = ec_command(EC_CMD_GET_VERSION, NULL, 0, &r, sizeof(r));
+ res = ec_command(EC_CMD_GET_VERSION, 0, NULL, 0, &r, sizeof(r));
if (res < 0)
return res;
- res = ec_command(EC_CMD_GET_BUILD_INFO, NULL, 0, build_info,
+ res = ec_command(EC_CMD_GET_BUILD_INFO, 0, NULL, 0, build_info,
sizeof(build_info));
if (res < 0)
return res;
@@ -73,7 +73,7 @@ int flash_partition(enum ec_current_image part, const uint8_t *payload,
if (current == part) {
rst_req.cmd = part == EC_IMAGE_RO ?
EC_REBOOT_JUMP_RW_A : EC_REBOOT_JUMP_RO;
- ec_command(EC_CMD_REBOOT_EC, &rst_req, sizeof(rst_req),
+ ec_command(EC_CMD_REBOOT_EC, 0, &rst_req, sizeof(rst_req),
NULL, 0);
/* wait EC reboot */
usleep(500000);
@@ -83,7 +83,8 @@ int flash_partition(enum ec_current_image part, const uint8_t *payload,
part_name[part], size, offset);
er_req.size = size;
er_req.offset = offset;
- res = ec_command(EC_CMD_FLASH_ERASE, &er_req, sizeof(er_req), NULL, 0);
+ res = ec_command(EC_CMD_FLASH_ERASE, 0,
+ &er_req, sizeof(er_req), NULL, 0);
if (res < 0) {
fprintf(stderr, "Erase failed : %d\n", res);
return -1;
@@ -96,8 +97,8 @@ int flash_partition(enum ec_current_image part, const uint8_t *payload,
wr_req.offset = offset + i;
wr_req.size = MIN(size - i, sizeof(wr_req.data));
memcpy(wr_req.data, payload + i, wr_req.size);
- res = ec_command(EC_CMD_FLASH_WRITE, &wr_req, sizeof(wr_req),
- NULL, 0);
+ res = ec_command(EC_CMD_FLASH_WRITE, 0,
+ &wr_req, sizeof(wr_req), NULL, 0);
if (res < 0) {
fprintf(stderr, "Write error at 0x%08x : %d\n", i, res);
return -1;
@@ -110,7 +111,7 @@ int flash_partition(enum ec_current_image part, const uint8_t *payload,
for (i = 0; i < size; i += sizeof(rd_resp)) {
rd_req.offset = offset + i;
rd_req.size = MIN(size - i, sizeof(rd_resp));
- res = ec_command(EC_CMD_FLASH_READ, &rd_req, sizeof(rd_req),
+ res = ec_command(EC_CMD_FLASH_READ, 0, &rd_req, sizeof(rd_req),
&rd_resp, sizeof(rd_resp));
if (res < 0) {
fprintf(stderr, "Read error at 0x%08x : %d\n", i, res);
diff --git a/util/comm-host.h b/util/comm-host.h
index 7a3f856bf9..a16057abf5 100644
--- a/util/comm-host.h
+++ b/util/comm-host.h
@@ -19,7 +19,7 @@ int comm_init(void);
* none), or a negative number if error; errors are -EC_RES_* constants from
* ec_commands.h.
*/
-int ec_command(int command, const void *indata, int insize,
+int ec_command(int command, int version, const void *indata, int insize,
void *outdata, int outsize);
/*
diff --git a/util/comm-i2c.c b/util/comm-i2c.c
index 5020db3ecf..5ff71700fd 100644
--- a/util/comm-i2c.c
+++ b/util/comm-i2c.c
@@ -75,7 +75,7 @@ int comm_init(void)
/* Sends a command to the EC. Returns the command status code, or
* -1 if other error. */
-int ec_command(int command, const void *indata, int insize,
+int ec_command(int command, int version, const void *indata, int insize,
void *outdata, int outsize)
{
struct i2c_rdwr_ioctl_data data;
@@ -89,6 +89,11 @@ int ec_command(int command, const void *indata, int insize,
uint8_t sum;
struct i2c_msg i2c_msg[2];
+ if (version > 0) {
+ fprintf(stderr, "Command versions >0 unsupported.\n");
+ return -EC_RES_ERROR;
+ }
+
if (i2c_fd < 0)
return -EC_RES_ERROR;
@@ -194,7 +199,7 @@ uint8_t read_mapped_mem8(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xff;
@@ -209,7 +214,7 @@ uint16_t read_mapped_mem16(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xffff;
@@ -224,7 +229,7 @@ uint32_t read_mapped_mem32(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xffffffff;
@@ -239,7 +244,7 @@ int read_mapped_string(uint8_t offset, char *buf)
p.offset = offset;
p.size = EC_MEMMAP_TEXT_MAX;
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
buf, EC_MEMMAP_TEXT_MAX) < 0) {
*buf = 0;
return -1;
diff --git a/util/comm-lpc.c b/util/comm-lpc.c
index 54686dbcbb..2e4fe0f08d 100644
--- a/util/comm-lpc.c
+++ b/util/comm-lpc.c
@@ -14,6 +14,8 @@
#define INITIAL_UDELAY 5 /* 5 us */
#define MAXIMUM_UDELAY 10000 /* 10 ms */
+static int lpc_cmd_args_supported;
+
int comm_init(void)
{
int i;
@@ -48,6 +50,20 @@ int comm_init(void)
return -4;
}
+ /*
+ * Test if LPC command args are supported.
+ *
+ * The cheapest way to do this is by looking for the memory-mapped
+ * flag. This is faster than sending a new-style 'hello' command and
+ * seeing whether the EC sets the EC_HOST_ARGS_FLAG_FROM_HOST flag
+ * in args when it responds.
+ */
+ if (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID) == 'E' &&
+ inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1) == 'C' &&
+ (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_HOST_CMD_FLAGS) &
+ EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED))
+ lpc_cmd_args_supported = 1;
+
return 0;
}
@@ -81,14 +97,15 @@ static int wait_for_ec(int status_addr, int timeout_usec)
return -1; /* Timeout */
}
-int ec_command(int command, const void *indata, int insize,
- void *outdata, int outsize) {
+/* Old-style command interface, without args */
+static int ec_command_old(int command, const void *indata, int insize,
+ void *outdata, int outsize) {
uint8_t *d;
int i;
- int cmd_addr = EC_LPC_ADDR_HOST_CMD;
- int data_addr = EC_LPC_ADDR_HOST_DATA;
- int param_addr = EC_LPC_ADDR_OLD_PARAM;
+ const int cmd_addr = EC_LPC_ADDR_HOST_CMD;
+ const int data_addr = EC_LPC_ADDR_HOST_DATA;
+ const int param_addr = EC_LPC_ADDR_OLD_PARAM;
if (insize > EC_OLD_PARAM_SIZE) {
fprintf(stderr, "Data size too big\n");
@@ -135,6 +152,99 @@ int ec_command(int command, const void *indata, int insize,
return outsize;
}
+int ec_command(int command, int version, const void *indata, int insize,
+ void *outdata, int outsize) {
+
+ const int cmd_addr = EC_LPC_ADDR_HOST_CMD;
+ const int data_addr = EC_LPC_ADDR_HOST_DATA;
+ const int args_addr = EC_LPC_ADDR_HOST_ARGS;
+ const int param_addr = EC_LPC_ADDR_HOST_PARAM;
+
+ struct ec_lpc_host_args args;
+ const uint8_t *d;
+ uint8_t *dout;
+ int csum;
+ int i;
+
+ /* Fall back to old-style command interface if args aren't supported */
+ if (!lpc_cmd_args_supported)
+ return ec_command_old(command, indata, insize,
+ outdata, outsize);
+
+ /* Fill in args */
+ args.flags = EC_HOST_ARGS_FLAG_FROM_HOST;
+ args.command_version = version;
+ args.data_size = insize;
+
+ /* Calculate checksum */
+ csum = command + args.flags + args.command_version + args.data_size;
+ for (i = 0, d = (const uint8_t *)indata; i < insize; i++, d++)
+ csum += *d;
+
+ args.checksum = (uint8_t)csum;
+
+ /* Write args */
+ for (i = 0, d = (const uint8_t *)&args; i < sizeof(args); i++, d++)
+ outb(*d, args_addr + i);
+
+ /* Write data, if any */
+ /* TODO: optimized copy using outl() */
+ for (i = 0, d = (uint8_t *)indata; i < insize; i++, d++)
+ outb(*d, param_addr + i);
+
+ outb(command, cmd_addr);
+
+ if (wait_for_ec(cmd_addr, 1000000)) {
+ fprintf(stderr, "Timeout waiting for EC response\n");
+ return -EC_RES_ERROR;
+ }
+
+ /* Check result */
+ i = inb(data_addr);
+ if (i) {
+ fprintf(stderr, "EC returned error result code %d\n", i);
+ return -i;
+ }
+
+ /* Read back args */
+ for (i = 0, dout = (uint8_t *)&args; i < sizeof(args); i++, dout++)
+ *dout = inb(args_addr + i);
+
+ /*
+ * If EC didn't modify args flags, then somehow we sent a new-style
+ * command to an old EC, which means it would have read its params
+ * from the wrong place.
+ */
+ if (!(args.flags & EC_HOST_ARGS_FLAG_TO_HOST)) {
+ fprintf(stderr, "EC protocol mismatch\n");
+ return -EC_RES_INVALID_RESPONSE;
+ }
+
+ if (args.data_size > outsize) {
+ fprintf(stderr, "EC returned too much data\n");
+ return -EC_RES_INVALID_RESPONSE;
+ }
+
+ /* Read data, if any */
+ /* TODO: optimized copy using outl() */
+ for (i = 0, dout = (uint8_t *)outdata; i < args.data_size; i++, dout++)
+ *dout = inb(param_addr + i);
+
+ /* Verify checksum */
+ csum = command + args.flags + args.command_version + args.data_size;
+ for (i = 0, d = (const uint8_t *)outdata; i < args.data_size; i++, d++)
+ csum += *d;
+
+ if (args.checksum != (uint8_t)csum) {
+ fprintf(stderr, "EC response has invalid checksum\n");
+ return -EC_RES_INVALID_CHECKSUM;
+ }
+
+ /* Return actual amount of data received */
+ return args.data_size;
+}
+
+
uint8_t read_mapped_mem8(uint8_t offset)
{
return inb(EC_LPC_ADDR_MEMMAP + offset);
diff --git a/util/ectool.c b/util/ectool.c
index 74ed7d9d70..a9f66594a8 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -220,7 +220,7 @@ int cmd_hello(int argc, char *argv[])
p.in_data = 0xa0b0c0d0;
- rv = ec_command(EC_CMD_HELLO, &p, sizeof(p), &r, sizeof(r));
+ rv = ec_command(EC_CMD_HELLO, 0, &p, sizeof(p), &r, sizeof(r));
if (rv < 0)
return rv;
@@ -253,7 +253,8 @@ int cmd_cmdversions(int argc, char *argv[])
}
p.cmd = cmd;
- rv = ec_command(EC_CMD_GET_CMD_VERSIONS, &p, sizeof(p), &r, sizeof(r));
+ rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &p, sizeof(p),
+ &r, sizeof(r));
if (rv < 0) {
if (rv == -EC_RES_INVALID_PARAM)
printf("Command 0x%02x not supported by EC.\n", cmd);
@@ -273,10 +274,11 @@ int cmd_version(int argc, char *argv[])
char build_string[EC_HOST_PARAM_SIZE];
int rv;
- rv = ec_command(EC_CMD_GET_VERSION, NULL, 0, &r, sizeof(r));
+ rv = ec_command(EC_CMD_GET_VERSION, 0,
+ NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
- rv = ec_command(EC_CMD_GET_BUILD_INFO,
+ rv = ec_command(EC_CMD_GET_BUILD_INFO, 0,
NULL, 0, build_string, sizeof(build_string));
if (rv < 0)
return rv;
@@ -334,7 +336,7 @@ int cmd_read_test(int argc, char *argv[])
for (i = 0; i < size; i += sizeof(r.data)) {
p.offset = offset + i / sizeof(uint32_t);
p.size = MIN(size - i, sizeof(r.data));
- rv = ec_command(EC_CMD_READ_TEST, &p, sizeof(p),
+ rv = ec_command(EC_CMD_READ_TEST, 0, &p, sizeof(p),
&r, sizeof(r));
if (rv < 0) {
fprintf(stderr, "Read error at offset %d\n", i);
@@ -376,7 +378,7 @@ int cmd_reboot_ec(int argc, char *argv[])
* That reboots the AP as well, so unlikely we'll be around
* to see a return code from this...
*/
- return ec_command(EC_CMD_REBOOT, NULL, 0, NULL, 0);
+ return ec_command(EC_CMD_REBOOT, 0, NULL, 0, NULL, 0);
}
/* Parse command */
@@ -408,7 +410,7 @@ int cmd_reboot_ec(int argc, char *argv[])
}
}
- return ec_command(EC_CMD_REBOOT_EC, &p, sizeof(p), NULL, 0);
+ return ec_command(EC_CMD_REBOOT_EC, 0, &p, sizeof(p), NULL, 0);
}
@@ -417,7 +419,7 @@ int cmd_flash_info(int argc, char *argv[])
struct ec_response_flash_info r;
int rv;
- rv = ec_command(EC_CMD_FLASH_INFO, NULL, 0, &r, sizeof(r));
+ rv = ec_command(EC_CMD_FLASH_INFO, 0, NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -466,7 +468,7 @@ int cmd_flash_read(int argc, char *argv[])
for (i = 0; i < size; i += sizeof(rdata)) {
p.offset = offset + i;
p.size = MIN(size - i, sizeof(rdata));
- rv = ec_command(EC_CMD_FLASH_READ,
+ rv = ec_command(EC_CMD_FLASH_READ, 0,
&p, sizeof(p), rdata, sizeof(rdata));
if (rv < 0) {
fprintf(stderr, "Read error at offset %d\n", i);
@@ -517,7 +519,7 @@ int cmd_flash_write(int argc, char *argv[])
p.offset = offset + i;
p.size = MIN(size - i, sizeof(p.data));
memcpy(p.data, buf + i, p.size);
- rv = ec_command(EC_CMD_FLASH_WRITE, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_FLASH_WRITE, 0, &p, sizeof(p), NULL, 0);
if (rv < 0) {
fprintf(stderr, "Write error at offset %d\n", i);
free(buf);
@@ -552,7 +554,7 @@ int cmd_flash_erase(int argc, char *argv[])
}
printf("Erasing %d bytes at offset %d...\n", p.size, p.offset);
- if (ec_command(EC_CMD_FLASH_ERASE, &p, sizeof(p), NULL, 0) < 0)
+ if (ec_command(EC_CMD_FLASH_ERASE, 0, &p, sizeof(p), NULL, 0) < 0)
return -1;
printf("done.\n");
@@ -639,7 +641,7 @@ int cmd_temp_sensor_info(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_TEMP_SENSOR_GET_INFO,
+ rv = ec_command(EC_CMD_TEMP_SENSOR_GET_INFO, 0,
&p, sizeof(p), &r, sizeof(r));
if (rv < 0)
return rv;
@@ -676,7 +678,7 @@ int cmd_thermal_get_threshold(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_THERMAL_GET_THRESHOLD,
+ rv = ec_command(EC_CMD_THERMAL_GET_THRESHOLD, 0,
&p, sizeof(p), &r, sizeof(r));
if (rv < 0)
return rv;
@@ -722,7 +724,8 @@ int cmd_thermal_set_threshold(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_THERMAL_SET_THRESHOLD, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_THERMAL_SET_THRESHOLD, 0,
+ &p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -737,7 +740,7 @@ int cmd_thermal_auto_fan_ctrl(int argc, char *argv[])
{
int rv;
- rv = ec_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, NULL, 0, NULL, 0);
+ rv = ec_command(EC_CMD_THERMAL_AUTO_FAN_CTRL, 0, NULL, 0, NULL, 0);
if (rv < 0)
return rv;
@@ -780,7 +783,8 @@ int cmd_pwm_set_fan_rpm(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_PWM_SET_FAN_TARGET_RPM, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_PWM_SET_FAN_TARGET_RPM, 0,
+ &p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -794,7 +798,7 @@ int cmd_pwm_get_keyboard_backlight(int argc, char *argv[])
struct ec_response_pwm_get_keyboard_backlight r;
int rv;
- rv = ec_command(EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT,
+ rv = ec_command(EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT, 0,
NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -824,7 +828,7 @@ int cmd_pwm_set_keyboard_backlight(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT,
+ rv = ec_command(EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -850,7 +854,7 @@ int cmd_fanduty(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_PWM_SET_FAN_DUTY, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_PWM_SET_FAN_DUTY, 0, &p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -924,7 +928,7 @@ static int lb_do_cmd(enum lightbar_command cmd,
{
int r;
ptr->in.cmd = cmd;
- r = ec_command(EC_CMD_LIGHTBAR_CMD,
+ r = ec_command(EC_CMD_LIGHTBAR_CMD, 0,
ptr, lb_command_paramcount[cmd].insize,
ptr, lb_command_paramcount[cmd].outsize);
return r;
@@ -1043,7 +1047,7 @@ static int cmd_vboot(int argc, char **argv)
if (argc == 1) { /* no args = get */
param.in.cmd = VBOOT_CMD_GET_FLAGS;
- r = ec_command(EC_CMD_VBOOT_CMD,
+ r = ec_command(EC_CMD_VBOOT_CMD, 0,
&param,
vb_command_paramcount[param.in.cmd].insize,
&param,
@@ -1067,7 +1071,7 @@ static int cmd_vboot(int argc, char **argv)
param.in.cmd = VBOOT_CMD_SET_FLAGS;
param.in.set_flags.val = v;
- r = ec_command(EC_CMD_VBOOT_CMD,
+ r = ec_command(EC_CMD_VBOOT_CMD, 0,
&param,
vb_command_paramcount[param.in.cmd].insize,
&param,
@@ -1099,7 +1103,7 @@ int cmd_usb_charge_set_mode(int argc, char *argv[])
printf("Setting port %d to mode %d...\n", p.usb_port_id, p.mode);
- rv = ec_command(EC_CMD_USB_CHARGE_SET_MODE,
+ rv = ec_command(EC_CMD_USB_CHARGE_SET_MODE, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1140,7 +1144,7 @@ int cmd_kbpress(int argc, char *argv[])
p.row,
p.col);
- rv = ec_command(EC_CMD_MKBP_SIMULATE_KEY,
+ rv = ec_command(EC_CMD_MKBP_SIMULATE_KEY, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1154,7 +1158,7 @@ int cmd_pstore_info(int argc, char *argv[])
struct ec_response_pstore_info r;
int rv;
- rv = ec_command(EC_CMD_PSTORE_INFO, NULL, 0, &r, sizeof(r));
+ rv = ec_command(EC_CMD_PSTORE_INFO, 0, NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -1200,7 +1204,7 @@ int cmd_pstore_read(int argc, char *argv[])
for (i = 0; i < size; i += EC_PSTORE_SIZE_MAX) {
p.offset = offset + i;
p.size = MIN(size - i, EC_PSTORE_SIZE_MAX);
- rv = ec_command(EC_CMD_PSTORE_READ,
+ rv = ec_command(EC_CMD_PSTORE_READ, 0,
&p, sizeof(p), rdata, sizeof(rdata));
if (rv < 0) {
fprintf(stderr, "Read error at offset %d\n", i);
@@ -1251,7 +1255,8 @@ int cmd_pstore_write(int argc, char *argv[])
p.offset = offset + i;
p.size = MIN(size - i, EC_PSTORE_SIZE_MAX);
memcpy(p.data, buf + i, p.size);
- rv = ec_command(EC_CMD_PSTORE_WRITE, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_PSTORE_WRITE, 0,
+ &p, sizeof(p), NULL, 0);
if (rv < 0) {
fprintf(stderr, "Write error at offset %d\n", i);
free(buf);
@@ -1284,7 +1289,7 @@ int cmd_host_event_get_smi_mask(int argc, char *argv[])
struct ec_response_host_event_mask r;
int rv;
- rv = ec_command(EC_CMD_HOST_EVENT_GET_SMI_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_GET_SMI_MASK, 0,
NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -1299,7 +1304,7 @@ int cmd_host_event_get_sci_mask(int argc, char *argv[])
struct ec_response_host_event_mask r;
int rv;
- rv = ec_command(EC_CMD_HOST_EVENT_GET_SCI_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_GET_SCI_MASK, 0,
NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -1314,7 +1319,7 @@ int cmd_host_event_get_wake_mask(int argc, char *argv[])
struct ec_response_host_event_mask r;
int rv;
- rv = ec_command(EC_CMD_HOST_EVENT_GET_WAKE_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0,
NULL, 0, &r, sizeof(r));
if (rv < 0)
return rv;
@@ -1340,7 +1345,7 @@ int cmd_host_event_set_smi_mask(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_HOST_EVENT_SET_SMI_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_SET_SMI_MASK, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1366,7 +1371,7 @@ int cmd_host_event_set_sci_mask(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_HOST_EVENT_SET_SCI_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_SET_SCI_MASK, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1392,7 +1397,7 @@ int cmd_host_event_set_wake_mask(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_HOST_EVENT_SET_WAKE_MASK,
+ rv = ec_command(EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1418,7 +1423,7 @@ int cmd_host_event_clear(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_HOST_EVENT_CLEAR,
+ rv = ec_command(EC_CMD_HOST_EVENT_CLEAR, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1465,7 +1470,7 @@ int cmd_wireless(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS,
+ rv = ec_command(EC_CMD_SWITCH_ENABLE_WIRELESS, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1512,7 +1517,7 @@ int cmd_i2c_read(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_I2C_READ, &p, sizeof(p), &r, sizeof(r));
+ rv = ec_command(EC_CMD_I2C_READ, 0, &p, sizeof(p), &r, sizeof(r));
if (rv < 0)
return rv;
@@ -1566,7 +1571,7 @@ int cmd_i2c_write(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_I2C_WRITE, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_I2C_WRITE, 0, &p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1593,7 +1598,7 @@ int cmd_lcd_backlight(int argc, char *argv[])
return -1;
}
- rv = ec_command(EC_CMD_SWITCH_ENABLE_BKLIGHT,
+ rv = ec_command(EC_CMD_SWITCH_ENABLE_BKLIGHT, 0,
&p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
@@ -1669,7 +1674,7 @@ int cmd_chipinfo(int argc, char *argv[])
printf("Chip info:\n");
- rv = ec_command(EC_CMD_GET_CHIP_INFO, NULL, 0, &info, sizeof(info));
+ rv = ec_command(EC_CMD_GET_CHIP_INFO, 0, NULL, 0, &info, sizeof(info));
if (rv < 0)
return rv;
printf(" vendor: %s\n", info.vendor);
@@ -1732,7 +1737,7 @@ int cmd_ec_hash(int argc, char *argv[])
if (argc < 2) {
/* Get hash status */
p.cmd = EC_VBOOT_HASH_GET;
- if (ec_command(EC_CMD_VBOOT_HASH,
+ if (ec_command(EC_CMD_VBOOT_HASH, 0,
&p, sizeof(p), &r, sizeof(r)) < 0)
return -1;
@@ -1742,7 +1747,7 @@ int cmd_ec_hash(int argc, char *argv[])
if (argc == 2 && !strcasecmp(argv[1], "abort")) {
/* Abort hash calculation */
p.cmd = EC_VBOOT_HASH_ABORT;
- if (ec_command(EC_CMD_VBOOT_HASH,
+ if (ec_command(EC_CMD_VBOOT_HASH, 0,
&p, sizeof(p), &r, sizeof(r)) < 0)
return -1;
return 0;
@@ -1789,7 +1794,7 @@ int cmd_ec_hash(int argc, char *argv[])
p.nonce_size = 0;
printf("Hashing %d bytes at offset %d...\n", p.size, p.offset);
- if (ec_command(EC_CMD_VBOOT_HASH, &p, sizeof(p), &r, sizeof(r)) < 0)
+ if (ec_command(EC_CMD_VBOOT_HASH, 0, &p, sizeof(p), &r, sizeof(r)) < 0)
return -1;
/* Start command doesn't wait for hashing to finish */
diff --git a/util/lbplay.c b/util/lbplay.c
index 1345a01b07..9121623f91 100644
--- a/util/lbplay.c
+++ b/util/lbplay.c
@@ -47,7 +47,7 @@ static void lb_cmd_noargs(enum lightbar_command cmd)
{
struct ec_params_lightbar_cmd param;
param.in.cmd = cmd;
- ec_command(EC_CMD_LIGHTBAR_CMD,
+ ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param, lb_command_paramcount[param.in.cmd].insize,
&param, lb_command_paramcount[param.in.cmd].outsize);
}
@@ -72,7 +72,7 @@ void lightbar_brightness(int newval)
struct ec_params_lightbar_cmd param;
param.in.cmd = LIGHTBAR_CMD_BRIGHTNESS;
param.in.brightness.num = newval;
- ec_command(EC_CMD_LIGHTBAR_CMD,
+ ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param, lb_command_paramcount[param.in.cmd].insize,
&param, lb_command_paramcount[param.in.cmd].outsize);
}
@@ -82,7 +82,7 @@ void lightbar_sequence(enum lightbar_sequence num)
struct ec_params_lightbar_cmd param;
param.in.cmd = LIGHTBAR_CMD_SEQ;
param.in.seq.num = num;
- ec_command(EC_CMD_LIGHTBAR_CMD,
+ ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param, lb_command_paramcount[param.in.cmd].insize,
&param, lb_command_paramcount[param.in.cmd].outsize);
}
@@ -94,7 +94,7 @@ void lightbar_reg(uint8_t ctrl, uint8_t reg, uint8_t val)
param.in.reg.ctrl = ctrl;
param.in.reg.reg = reg;
param.in.reg.value = val;
- ec_command(EC_CMD_LIGHTBAR_CMD,
+ ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param, lb_command_paramcount[param.in.cmd].insize,
&param, lb_command_paramcount[param.in.cmd].outsize);
}
@@ -107,7 +107,7 @@ void lightbar_rgb(int led, int red, int green, int blue)
param.in.rgb.red = red;
param.in.rgb.green = green;
param.in.rgb.blue = blue;
- ec_command(EC_CMD_LIGHTBAR_CMD,
+ ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param, lb_command_paramcount[param.in.cmd].insize,
&param, lb_command_paramcount[param.in.cmd].outsize);
}
@@ -121,7 +121,7 @@ void wait_for_ec_to_stop(void)
do {
usleep(100000);
param.in.cmd = LIGHTBAR_CMD_GET_SEQ;
- r = ec_command(EC_CMD_LIGHTBAR_CMD,
+ r = ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param,
lb_command_paramcount[param.in.cmd].insize,
&param,