diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-08-01 17:59:21 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-02 15:02:34 -0700 |
commit | ec99f3913791bfe1935735ddcda18bd29ffcfd18 (patch) | |
tree | 0b75a5b223870dc29d9dafef419b7462337f8516 /include/event_log.h | |
parent | 7ed19ed220b795f9bc28832e7bddb891c383b4b2 (diff) | |
download | chrome-ec-ec99f3913791bfe1935735ddcda18bd29ffcfd18.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.
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>
Diffstat (limited to 'include/event_log.h')
-rw-r--r-- | include/event_log.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 */ |