summaryrefslogtreecommitdiff
path: root/src/commonlib/bsd/elog.c
blob: 62149daa42bb4057390d38c2e90ac3483d2550fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
}