Files
system76-coreboot/src/lib/master_header_pointer.c
Arthur Heymans 75226bb879 Makefile.inc: Generate master header and pointer as C structs
The makefiles don't like cbfs file names with spaces in them so update
the file name with '_' instead of spaces. To keep the master header at
the top of cbfs, add a placeholder.

This removes the need to handle the cbfs master header in cbfstool.
This functionality will be dropped in a later CL.

On x86 reserve some space in the linker script to add the pointer.
On non-x86 generate a pointer inside a C struct file.

As a bonus this would actually fix the master header pointer mechanism
on Intel/APL as only the bootblock inside IFWI gets memory mapped.

TESTED on thinkpad X201: SeaBIOS correctly finds the cbfs master
header.

Change-Id: I3ba01be7da1f09a8cac287751497c18cda97d293
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59132
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
2022-05-12 11:11:53 +00:00

22 lines
629 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <commonlib/bsd/cbfs_serialized.h>
#include <endian.h>
#include <fmap_config.h>
#include <stdint.h>
#if ENV_X86
__attribute__((used, __section__(".header_pointer")))
#endif
#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
#define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
#else
#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
#endif
uint32_t header_pointer =
cpu_to_le32(COREBOOT_CBFS_START + ALIGN_UP(sizeof(struct cbfs_file)
+ sizeof("cbfs_master_header"),
CBFS_ATTRIBUTE_ALIGN));