diff options
Diffstat (limited to 'src/commonlib')
-rw-r--r-- | src/commonlib/Makefile.inc | 4 | ||||
-rw-r--r-- | src/commonlib/bsd/elog.c | 25 | ||||
-rw-r--r-- | src/commonlib/bsd/include/commonlib/bsd/elog.h | 39 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/commonlib/Makefile.inc b/src/commonlib/Makefile.inc index c5fa8ed85e..53975bcad8 100644 --- a/src/commonlib/Makefile.inc +++ b/src/commonlib/Makefile.inc @@ -53,3 +53,7 @@ ramstage-y += bsd/lz4_wrapper.c postcar-y += bsd/lz4_wrapper.c ramstage-y += sort.c + +romstage-y += bsd/elog.c +ramstage-y += bsd/elog.c +smm-y += bsd/elog.c 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; +} diff --git a/src/commonlib/bsd/include/commonlib/bsd/elog.h b/src/commonlib/bsd/include/commonlib/bsd/elog.h new file mode 100644 index 0000000000..6c58557fbe --- /dev/null +++ b/src/commonlib/bsd/include/commonlib/bsd/elog.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _COMMONLIB_BSD_ELOG_H_ +#define _COMMONLIB_BSD_ELOG_H_ + +#include <inttypes.h> + +#include <commonlib/bsd/cb_err.h> + +/* ELOG header */ +struct elog_header { + uint32_t magic; + uint8_t version; + uint8_t header_size; + uint8_t reserved[2]; +} __packed; + +/* ELOG related constants */ +#define ELOG_SIGNATURE 0x474f4c45 /* 'ELOG' */ +#define ELOG_VERSION 1 + +/* SMBIOS event log header */ +struct event_header { + uint8_t type; + uint8_t length; + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +} __packed; + +/* SMBIOS Type 15 related constants */ +#define ELOG_HEADER_TYPE_OEM 0x88 + +enum cb_err elog_verify_header(const struct elog_header *header); + +#endif /* _COMMONLIB_BSD_ELOG_H_ */ |