Move elog_internal.h to commonlib/bsd/include
Move elog_internal.h to commonlib/bsd/include/bsd/. And rename it from elog_internal.h to elog.h. Since this file will be included from util/ it also converts the "uNN" types into "uintNN_t" types. The two defines that are not used by util/ are moved to drivers/elog/elog.c, the only file that includes them. Move also the function elog_verify_header() from drivers/elog/, to commonlib/bsd/elog.c since this function will be called from util/ as well. The rationale behind moving elog's defines & structs to commonlib/bsd/include is to make them available to util/ tools and/or payloads (should it be needed in the future). The files that are being relicensed to BSD were coded by Duncan Laurie, and he is Ok with the relicense. BUG=b:172210863 Signed-off-by: Ricardo Quesada <ricardoq@google.com> Change-Id: Ia1aefea705ddd417a1d9e978bb18ab6d9a60cad6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56404 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
parent
470ca5714f
commit
d45e70c124
|
@ -53,3 +53,7 @@ ramstage-y += bsd/lz4_wrapper.c
|
||||||
postcar-y += bsd/lz4_wrapper.c
|
postcar-y += bsd/lz4_wrapper.c
|
||||||
|
|
||||||
ramstage-y += sort.c
|
ramstage-y += sort.c
|
||||||
|
|
||||||
|
romstage-y += bsd/elog.c
|
||||||
|
ramstage-y += bsd/elog.c
|
||||||
|
smm-y += 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;
|
||||||
|
}
|
|
@ -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_ */
|
|
@ -1,12 +1,14 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
|
||||||
#include <acpi/acpi.h>
|
#include <acpi/acpi.h>
|
||||||
#include <bootstate.h>
|
|
||||||
#include <cbmem.h>
|
|
||||||
#include <console/console.h>
|
|
||||||
#include <bcd.h>
|
#include <bcd.h>
|
||||||
#include <boot_device.h>
|
#include <boot_device.h>
|
||||||
|
#include <bootstate.h>
|
||||||
|
#include <cbmem.h>
|
||||||
|
#include <commonlib/bsd/elog.h>
|
||||||
#include <commonlib/region.h>
|
#include <commonlib/region.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <elog.h>
|
||||||
#include <fmap.h>
|
#include <fmap.h>
|
||||||
#include <lib.h>
|
#include <lib.h>
|
||||||
#include <post.h>
|
#include <post.h>
|
||||||
|
@ -14,8 +16,9 @@
|
||||||
#include <smbios.h>
|
#include <smbios.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elog.h>
|
|
||||||
#include "elog_internal.h"
|
#define ELOG_MIN_AVAILABLE_ENTRIES 2 /* Shrink when this many can't fit */
|
||||||
|
#define ELOG_SHRINK_PERCENTAGE 25 /* Percent of total area to remove */
|
||||||
|
|
||||||
#if CONFIG(ELOG_DEBUG)
|
#if CONFIG(ELOG_DEBUG)
|
||||||
#define elog_debug(STR...) printk(BIOS_DEBUG, STR)
|
#define elog_debug(STR...) printk(BIOS_DEBUG, STR)
|
||||||
|
@ -239,24 +242,8 @@ static int elog_is_header_valid(void)
|
||||||
|
|
||||||
header = rdev_mmap(mirror_dev_get(), 0, sizeof(*header));
|
header = rdev_mmap(mirror_dev_get(), 0, sizeof(*header));
|
||||||
|
|
||||||
if (header == NULL) {
|
if (elog_verify_header(header) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "ELOG: could not map header.\n");
|
printk(BIOS_ERR, "ELOG: failed to verify header.\n");
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header->magic != ELOG_SIGNATURE) {
|
|
||||||
printk(BIOS_ERR, "ELOG: header magic 0x%X != 0x%X\n",
|
|
||||||
header->magic, ELOG_SIGNATURE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (header->version != ELOG_VERSION) {
|
|
||||||
printk(BIOS_ERR, "ELOG: header version %u != %u\n",
|
|
||||||
header->version, ELOG_VERSION);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (header->header_size != sizeof(*header)) {
|
|
||||||
printk(BIOS_ERR, "ELOG: header size mismatch %u != %zu\n",
|
|
||||||
header->header_size, sizeof(*header));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
||||||
|
|
||||||
#ifndef ELOG_INTERNAL_H_
|
|
||||||
#define ELOG_INTERNAL_H_
|
|
||||||
|
|
||||||
/* ELOG header */
|
|
||||||
struct elog_header {
|
|
||||||
u32 magic;
|
|
||||||
u8 version;
|
|
||||||
u8 header_size;
|
|
||||||
u8 reserved[2];
|
|
||||||
} __packed;
|
|
||||||
|
|
||||||
/* ELOG related constants */
|
|
||||||
#define ELOG_SIGNATURE 0x474f4c45 /* 'ELOG' */
|
|
||||||
#define ELOG_VERSION 1
|
|
||||||
#define ELOG_MIN_AVAILABLE_ENTRIES 2 /* Shrink when this many can't fit */
|
|
||||||
#define ELOG_SHRINK_PERCENTAGE 25 /* Percent of total area to remove */
|
|
||||||
|
|
||||||
/* SMBIOS event log header */
|
|
||||||
struct event_header {
|
|
||||||
u8 type;
|
|
||||||
u8 length;
|
|
||||||
u8 year;
|
|
||||||
u8 month;
|
|
||||||
u8 day;
|
|
||||||
u8 hour;
|
|
||||||
u8 minute;
|
|
||||||
u8 second;
|
|
||||||
} __packed;
|
|
||||||
|
|
||||||
/* SMBIOS Type 15 related constants */
|
|
||||||
#define ELOG_HEADER_TYPE_OEM 0x88
|
|
||||||
|
|
||||||
#endif /* ELOG_INTERNAL_H_ */
|
|
Loading…
Reference in New Issue