aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/elog
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-08-04 10:21:06 -0500
committerMartin Roth <martinroth@google.com>2016-08-08 22:02:50 +0200
commit422c440fa67d003a65196edac56318cd0da81bf6 (patch)
treea4300978edee6f1aac299a34102e7fda47a9733b /src/drivers/elog
parentbec07535ace0270a65d08e260ebfcd2f63ff5daf (diff)
drivers/elog: use offsets for checking cleared buffers
There's only 2 users of checking if the event buffer is cleared to the EOL value. Each were passing pointers of the in-memory mirror while also doing calculations for the size to check. Since the in-memory mirror is one big buffer the only thing required to know is the offset to start checking from. The check is always done through the end of the buffer. BUG=chrome-os-partner:55932 Change-Id: Icd4a7edc74407d6578fc93e9eb533abd3aa17277 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/16096 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/drivers/elog')
-rw-r--r--src/drivers/elog/elog.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 30578ce929..654a60c540 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -98,14 +98,16 @@ static u8 elog_checksum_event(struct event_header *event)
}
/*
- * Check if a raw buffer is filled with ELOG_TYPE_EOL byte
+ * Check if mirrored buffer is filled with ELOG_TYPE_EOL byte from the
+ * provided offset to the end of the mirrored buffer.
*/
-static int elog_is_buffer_clear(void *base, u32 size)
+static int elog_is_buffer_clear(size_t offset)
{
- u8 *current = base;
+ size_t size = total_size - offset;
+ u8 *current = offset + (u8 *)elog_area;
u8 *end = current + size;
- elog_debug("elog_is_buffer_clear(base=0x%p size=%u)\n", base, size);
+ elog_debug("elog_is_buffer_clear(offset=%zu size=%zu)\n", offset, size);
for (; current != end; current++) {
if (*current != ELOG_TYPE_EOL)
@@ -114,6 +116,17 @@ static int elog_is_buffer_clear(void *base, u32 size)
return 1;
}
+static int elog_event_buffer_is_clear(size_t offset)
+{
+ /*
+ * Events are appended relative to the end of the header. Update
+ * offset to include the header size.
+ */
+ offset += sizeof(struct elog_header);
+
+ return elog_is_buffer_clear(offset);
+}
+
/*
* Check that the ELOG area has been initialized and is valid.
*/
@@ -288,7 +301,7 @@ static void elog_update_event_buffer_state(void)
}
/* Ensure the remaining buffer is empty */
- if (!elog_is_buffer_clear(&elog_area->data[offset], log_size - offset))
+ if (!elog_event_buffer_is_clear(offset))
event_buffer_state = ELOG_EVENT_BUFFER_CORRUPTED;
/* Update ELOG state */
@@ -311,7 +324,7 @@ static void elog_scan_flash(void)
event_count = 0;
/* Check if the area is empty or not */
- if (elog_is_buffer_clear(elog_area, total_size)) {
+ if (elog_is_buffer_clear(0)) {
area_state = ELOG_AREA_EMPTY;
return;
}