diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-08-01 17:59:21 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-08-04 17:02:08 +0000 |
commit | f53329ca9e143140751e9d92404ad2bba7dac5a2 (patch) | |
tree | 2bf87a985f2e0c52926519e6cea2d48a17292191 /include | |
parent | e0c59ab9a4abba234b74f7bf9e7a807223832733 (diff) | |
download | chrome-ec-f53329ca9e143140751e9d92404ad2bba7dac5a2.tar.gz |
pd_log: Make PD logging more generic for general purpose logging
We can re-use our pd_log FIFO for other purposes, such as TPM logging.
Carve out event_log, a generic logging module which pd_log is compatible
with.
Conflicts:
(deleted boards)
board/fizz/board.h
board/nefario/board.h
board/reef_it8320/board.h
board/scarlet/board.h
board/zoombini/board.h
BUG=b:63760920
TEST=On kevin, verify PD logging is still functional and entries are
seen in dmesg.
BRANCH=None
Change-Id: I8e6ad6f93e9eebc676aca64652c60f81da471a94
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/597314
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit ec99f3913791bfe1935735ddcda18bd29ffcfd18)
Reviewed-on: https://chromium-review.googlesource.com/599500
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 4 | ||||
-rw-r--r-- | include/ec_commands.h | 6 | ||||
-rw-r--r-- | include/event_log.h | 35 |
3 files changed, 42 insertions, 3 deletions
diff --git a/include/config.h b/include/config.h index 1a05fbd086..f960fa7237 100644 --- a/include/config.h +++ b/include/config.h @@ -2438,8 +2438,8 @@ /* Record main PD events in a circular buffer */ #undef CONFIG_USB_PD_LOGGING -/* The size in bytes of the FIFO used for PD events logging */ -#undef CONFIG_USB_PD_LOG_SIZE +/* The size in bytes of the FIFO used for event logging */ +#define CONFIG_EVENT_LOG_SIZE 512 /* Save power by waking up on VBUS rather than polling CC */ #define CONFIG_USB_PD_LOW_POWER diff --git a/include/ec_commands.h b/include/ec_commands.h index bfa68b52fb..b223b98772 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3905,7 +3905,11 @@ struct __ec_align2 ec_params_charge_port_override { int16_t override_port; /* Override port# */ }; -/* Read (and delete) one entry of PD event log */ +/* + * Read (and delete) one entry of PD event log. + * TODO(crbug.com/751742): Make this host command more generic to accommodate + * future non-PD logs that use the same internal EC event_log. + */ #define EC_CMD_PD_GET_LOG_ENTRY 0x0115 struct __ec_align4 ec_response_pd_log { diff --git a/include/event_log.h b/include/event_log.h new file mode 100644 index 0000000000..45b10a3a2d --- /dev/null +++ b/include/event_log.h @@ -0,0 +1,35 @@ +/* Copyright 2017 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_EVENT_LOG_H +#define __CROS_EC_EVENT_LOG_H + +struct event_log_entry { + uint32_t timestamp; /* relative timestamp in milliseconds */ + uint8_t type; /* event type, caller-defined */ + uint8_t size; /* [7:5] caller-def'd [4:0] payload size in bytes */ + uint16_t data; /* type-defined data payload */ + uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */ +} __packed; + +#define EVENT_LOG_SIZE_MASK 0x1f +#define EVENT_LOG_SIZE(size) ((size) & EVENT_LOG_SIZE_MASK) + +/* The timestamp is the microsecond counter shifted to get about a ms. */ +#define EVENT_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */ +/* Returned in the "type" field, when there is no entry available */ +#define EVENT_LOG_NO_ENTRY 0xff + +/* Add an entry to the event log. */ +void log_add_event(uint8_t type, uint8_t size, uint16_t data, + void *payload, uint32_t timestamp); + +/* + * Remove and return an entry from the event log, if available. + * Returns size of log entry *r. + */ +int log_dequeue_event(struct event_log_entry *r); + +#endif /* __CROS_EC_EVENT_LOG_H */ |