[coreboot-gerrit] New patch to review for coreboot: drivers/elog: use offsets for checking cleared buffers
Aaron Durbin (adurbin@chromium.org)
gerrit at coreboot.org
Sat Aug 6 08:32:45 CEST 2016
Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16096
-gerrit
commit e0cba00b9147701ae7579465b03e50b79bc705b8
Author: Aaron Durbin <adurbin at chromium.org>
Date: Thu Aug 4 10:21:06 2016 -0500
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 at chromium.org>
---
src/drivers/elog/elog.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 30578ce..654a60c 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;
}
More information about the coreboot-gerrit
mailing list