summaryrefslogtreecommitdiff
path: root/src/drivers/elog
diff options
context:
space:
mode:
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;
}