mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
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>
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* 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 */
|