aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/elog/elog_internal.h
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2012-06-23 16:08:47 -0700
committerRonald G. Minnich <rminnich@gmail.com>2012-07-24 23:43:39 +0200
commit7d2b81c18d891a11420088c37cb17bb1c8d73ba9 (patch)
treedce384542c66cfcbd3185bafcfd5eae1ec239b65 /src/drivers/elog/elog_internal.h
parentd2e00b92ce0d3b60b7467ff51d3184d9c57dcb10 (diff)
ELOG: Add support for flash based event log
This is based around the SMBIOS event log specification but expanded with OEM event types to support more specific and relevant system events. It requires flash storage and a minimum 4K block (or flash block size) that should be allocated in the FMAP. A copy of the event log is maintained in memory for convenience and speed and the in-memory copy is written to flash at specific points. The log is automatically shunk when it reaches a configurable full threshold in order to not get stuck with a full log that needs OS help to clear. ELOG implements the specification published here: http://code.google.com/p/firmware-event-log/wiki/FirmwareEventLogDesign And is similar to what we use in other firmware at Google. This implementation does not support double-buffered flash regions. This is done because speed is valued over the log reliability and it keeps the code simpler for the first version. This is a large commit and by itself it just provides a new driver that is made available to coreboot. Without additional patches it is not very useful, but the end result is an event log that will contain entries like this: 171 | 2012-06-23 16:02:55 | System boot | 285 172 | 2012-06-23 16:02:55 | EC Event | Power Button 173 | 2012-06-23 16:02:55 | SUS Power Fail 174 | 2012-06-23 16:02:55 | System Reset 175 | 2012-06-23 16:02:55 | ACPI Wake | S5 Change-Id: I985524c67f525c8a268eccbd856c1a4c2a426889 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: http://review.coreboot.org/1311 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/drivers/elog/elog_internal.h')
-rw-r--r--src/drivers/elog/elog_internal.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/drivers/elog/elog_internal.h b/src/drivers/elog/elog_internal.h
new file mode 100644
index 0000000000..2a6a0b7fc4
--- /dev/null
+++ b/src/drivers/elog/elog_internal.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#ifndef ELOG_INTERNAL_H_
+#define ELOG_INTERNAL_H_
+
+/* ELOG header */
+struct elog_header {
+ u32 magic;
+ u8 version;
+ u8 header_size;
+ u8 reserved[2];
+} __attribute__ ((packed));
+
+/* ELOG related constants */
+#define ELOG_SIGNATURE 0x474f4c45 /* 'ELOG' */
+#define ELOG_VERSION 1
+
+typedef enum elog_descriptor_type {
+ ELOG_DESCRIPTOR_UNKNOWN,
+ ELOG_DESCRIPTOR_MEMORY,
+ ELOG_DESCRIPTOR_FLASH,
+} elog_descriptor_type;
+
+typedef enum elog_area_state {
+ ELOG_AREA_UNDEFINED, /* Initial boot strap state */
+ ELOG_AREA_EMPTY, /* Entire area is empty */
+ ELOG_AREA_HAS_CONTENT, /* Area has some content */
+} elog_area_state;
+
+typedef enum elog_header_state {
+ ELOG_HEADER_INVALID,
+ ELOG_HEADER_VALID,
+} elog_header_state;
+
+typedef enum elog_event_buffer_state {
+ ELOG_EVENT_BUFFER_OK,
+ ELOG_EVENT_BUFFER_CORRUPTED,
+} elog_event_buffer_state;
+
+/*
+ * Internal handler for event log buffers
+ */
+struct elog_descriptor {
+ elog_descriptor_type type;
+ elog_area_state area_state;
+ elog_header_state header_state;
+ elog_event_buffer_state event_buffer_state;
+ struct elog_header *staging_header;
+ void *backing_store;
+ u8 *data;
+ u16 total_size;
+ u16 data_size;
+ u16 next_event_offset;
+ u16 last_event_offset;
+ u16 last_event_size;
+ u16 event_count;
+};
+
+#endif /* ELOG_INTERNAL_H_ */