summaryrefslogtreecommitdiff
path: root/src/commonlib/bsd/elog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commonlib/bsd/elog.c')
-rw-r--r--src/commonlib/bsd/elog.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/commonlib/bsd/elog.c b/src/commonlib/bsd/elog.c
new file mode 100644
index 0000000000..62149daa42
--- /dev/null
+++ b/src/commonlib/bsd/elog.c
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+#include <commonlib/bsd/elog.h>
+#include <stddef.h>
+
+/*
+ * verify and validate if header is a valid coreboot Event Log header.
+ * return CB_ERR if invalid, otherwise CB_SUCCESS.
+ */
+enum cb_err elog_verify_header(const struct elog_header *header)
+{
+ if (header == NULL)
+ return CB_ERR;
+
+ if (header->magic != ELOG_SIGNATURE)
+ return CB_ERR;
+
+ if (header->version != ELOG_VERSION)
+ return CB_ERR;
+
+ if (header->header_size != sizeof(*header))
+ return CB_ERR;
+
+ return CB_SUCCESS;
+}