summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/lm4/lpc.c112
-rw-r--r--include/ec_commands.h39
-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
8 files changed, 324 insertions, 80 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index b0aeb3fdc0..993208679d 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -41,6 +41,8 @@ static uint8_t * const cmd_params = (uint8_t *)LPC_POOL_CMD_DATA +
EC_LPC_ADDR_HOST_PARAM - EC_LPC_ADDR_HOST_ARGS;
static uint8_t * const old_params = (uint8_t *)LPC_POOL_CMD_DATA +
EC_LPC_ADDR_OLD_PARAM - EC_LPC_ADDR_HOST_ARGS;
+static struct ec_lpc_host_args * const lpc_host_args =
+ (struct ec_lpc_host_args *)LPC_POOL_CMD_DATA;
/* Configure GPIOs for module */
static void configure_gpio(void)
@@ -128,11 +130,47 @@ uint8_t *lpc_get_memmap_range(void)
void host_send_response(enum ec_status result)
{
+ uint8_t *out;
int size = host_cmd_args.response_size;
- uint8_t *out = old_params;
+ int max_size;
+
+ /* Handle negative size */
+ if (size < 0) {
+ result = EC_RES_INVALID_RESPONSE;
+ size = 0;
+ }
+
+ if (lpc_host_args->flags & EC_HOST_ARGS_FLAG_FROM_HOST) {
+ /* New-style response */
+ int csum;
+ int i;
+
+ lpc_host_args->flags =
+ (lpc_host_args->flags & ~EC_HOST_ARGS_FLAG_FROM_HOST) |
+ EC_HOST_ARGS_FLAG_TO_HOST;
+
+ out = cmd_params;
+ max_size = EC_HOST_PARAM_SIZE;
+
+ lpc_host_args->data_size = size;
+
+ csum = host_cmd_args.command + lpc_host_args->flags +
+ lpc_host_args->command_version +
+ lpc_host_args->data_size;
+
+ for (i = 0; i < size; i++)
+ csum += host_cmd_args.response[i];
+
+ lpc_host_args->checksum = (uint8_t)csum;
+ } else {
+ /* Old-style response */
+ lpc_host_args->flags = 0;
+ out = old_params;
+ max_size = EC_OLD_PARAM_SIZE;
+ }
/* Fail if response doesn't fit in the param buffer */
- if (size < 0 || size > EC_OLD_PARAM_SIZE)
+ if (size > max_size)
result = EC_RES_INVALID_RESPONSE;
else if (host_cmd_args.response != out)
memcpy(out, host_cmd_args.response, size);
@@ -348,6 +386,56 @@ static void handle_acpi_command(void)
lpc_generate_sci();
}
+/* Handle an incoming host command */
+static void handle_host_command(int cmd)
+{
+ host_cmd_args.command = cmd;
+
+ /* See if we have an old or new style command */
+ if (lpc_host_args->flags & EC_HOST_ARGS_FLAG_FROM_HOST) {
+ /* New style command */
+ int size = lpc_host_args->data_size;
+ int csum, i;
+
+ host_cmd_args.version = lpc_host_args->command_version;
+ host_cmd_args.params = cmd_params;
+ host_cmd_args.params_size = size;
+ host_cmd_args.response = cmd_params;
+ host_cmd_args.response_max = EC_HOST_PARAM_SIZE;
+ host_cmd_args.response_size = 0;
+
+ /* Verify params size */
+ if (size > EC_HOST_PARAM_SIZE) {
+ host_send_response(EC_RES_INVALID_PARAM);
+ return;
+ }
+
+ /* Verify checksum */
+ csum = host_cmd_args.command + lpc_host_args->flags +
+ lpc_host_args->command_version +
+ lpc_host_args->data_size;
+
+ for (i = 0; i < size; i++)
+ csum += cmd_params[i];
+
+ if ((uint8_t)csum != lpc_host_args->checksum) {
+ host_send_response(EC_RES_INVALID_CHECKSUM);
+ return;
+ }
+
+ } else {
+ /* Old style command */
+ host_cmd_args.version = 0;
+ host_cmd_args.params = old_params;
+ host_cmd_args.params_size = EC_OLD_PARAM_SIZE;
+ host_cmd_args.response = old_params;
+ host_cmd_args.response_max = EC_OLD_PARAM_SIZE;
+ host_cmd_args.response_size = 0;
+ }
+
+ /* Hand off to host command handler */
+ host_command_received(&host_cmd_args);
+}
/* LPC interrupt handler */
static void lpc_interrupt(void)
@@ -368,17 +456,10 @@ static void lpc_interrupt(void)
LM4_LPC_ST(LPC_CH_CMD) |= LPC_STATUS_MASK_BUSY;
/*
- * Read the command byte and pass to the host command handler.
- * This clears the FRMH bit in the status byte.
+ * Read the command byte. This clears the FRMH bit in the
+ * status byte.
*/
- host_cmd_args.command = LPC_POOL_CMD[0];
- host_cmd_args.version = 0;
- host_cmd_args.params = old_params;
- host_cmd_args.params_size = EC_OLD_PARAM_SIZE;
- host_cmd_args.response = old_params;
- host_cmd_args.response_max = EC_OLD_PARAM_SIZE;
- host_cmd_args.response_size = 0;
- host_command_received(&host_cmd_args);
+ handle_host_command(LPC_POOL_CMD[0]);
}
#endif
@@ -579,9 +660,14 @@ static int lpc_init(void)
*LPC_POOL_MEMMAP = *LPC_POOL_MEMMAP;
}
- /* Initialize memory map to all zero */
+ /* Initialize host args and memory map to all zero */
+ memset(lpc_host_args, 0, sizeof(*lpc_host_args));
memset(lpc_get_memmap_range(), 0, EC_MEMMAP_SIZE);
+ /* We support LPC args */
+ *(lpc_get_memmap_range() + EC_MEMMAP_HOST_CMD_FLAGS) =
+ EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED;
+
/* Enable LPC interrupt */
task_enable_irq(LM4_IRQ_LPC);
diff --git a/include/ec_commands.h b/include/ec_commands.h
index d028b96671..ab9d83833b 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -73,6 +73,7 @@
#define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
#define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
#define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
+#define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host command interface flags */
#define EC_MEMMAP_SWITCHES 0x30
#define EC_MEMMAP_HOST_EVENTS 0x34
#define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
@@ -106,6 +107,10 @@
/* Was fake developer mode switch; now unused. Remove in next refactor. */
#define EC_SWITCH_IGNORE0 0x20
+/* Host command interface flags */
+/* Host command interface supports LPC args (LPC interface only) */
+#define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
+
/* Wireless switch flags */
#define EC_WIRELESS_SWITCH_WLAN 0x01
#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02
@@ -149,7 +154,6 @@
(EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
/* Host command response codes */
-/* TODO: move these so they don't overlap SCI/SMI data? */
enum ec_status {
EC_RES_SUCCESS = 0,
EC_RES_INVALID_COMMAND = 1,
@@ -158,6 +162,7 @@ enum ec_status {
EC_RES_ACCESS_DENIED = 4,
EC_RES_INVALID_RESPONSE = 5,
EC_RES_INVALID_VERSION = 6,
+ EC_RES_INVALID_CHECKSUM = 7,
};
/*
@@ -199,6 +204,38 @@ enum host_event_code {
/* Host event mask */
#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
+/* Arguments at EC_LPC_ADDR_HOST_ARGS */
+struct ec_lpc_host_args {
+ uint8_t flags;
+ uint8_t command_version;
+ uint8_t data_size;
+ /*
+ * Checksum; sum of command + flags + command_version + data_size +
+ * all params/response data bytes.
+ */
+ uint8_t checksum;
+} __packed;
+
+/* Flags for ec_lpc_host_args.flags */
+/*
+ * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command
+ * params.
+ *
+ * If EC gets a command and this flag is not set, this is an old-style command.
+ * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
+ * unknown length. EC must respond with an old-style response (that is,
+ * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
+ */
+#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
+/*
+ * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
+ *
+ * If EC responds to a command and this flag is not set, this is an old-style
+ * response. Command version is 0 and response data from EC is at
+ * EC_LPC_ADDR_OLD_PARAM with unknown length.
+ */
+#define EC_HOST_ARGS_FLAG_TO_HOST 0x02
+
/*
* Notes on commands:
*
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,