drivers/mrc_cache: Always generate an FMAP region
This automatically generates an FMAP region for the MRC_CACHE driver which is easier to handle than a cbfsfile. Adds some spaces and more comments to Makefile.inc to improve readability. Tested on Thinkpad x200 with some proof of concept patches. Change-Id: Iaaca36b1123b094ec1bbe5df4fb25660919173ca Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/23150 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
1e931f3e47
commit
82aa8338c7
66
Makefile.inc
66
Makefile.inc
|
@ -776,7 +776,11 @@ FMAP_BIOS_BASE := $(call int-subtract, $(CONFIG_ROM_SIZE) $(CONFIG_CBFS_SIZE))
|
||||||
FMAP_BIOS_SIZE := $(shell echo $(CONFIG_CBFS_SIZE) | tr A-F a-f)
|
FMAP_BIOS_SIZE := $(shell echo $(CONFIG_CBFS_SIZE) | tr A-F a-f)
|
||||||
# position and size of flashmap, relative to BIOS_BASE
|
# position and size of flashmap, relative to BIOS_BASE
|
||||||
FMAP_FMAP_BASE := 0
|
FMAP_FMAP_BASE := 0
|
||||||
FMAP_FMAP_SIZE := 0x100
|
FMAP_FMAP_SIZE := 0x200
|
||||||
|
|
||||||
|
#
|
||||||
|
# X86 CONSOLE FMAP region
|
||||||
|
#
|
||||||
# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled
|
# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled
|
||||||
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
FMAP_CONSOLE_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE))
|
FMAP_CONSOLE_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE))
|
||||||
|
@ -787,8 +791,36 @@ FMAP_CONSOLE_BASE := 0
|
||||||
FMAP_CONSOLE_SIZE := 0
|
FMAP_CONSOLE_SIZE := 0
|
||||||
FMAP_CONSOLE_ENTRY :=
|
FMAP_CONSOLE_ENTRY :=
|
||||||
endif # ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
endif # ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
|
|
||||||
|
#
|
||||||
|
# X86 RW_MRC_CACHE FMAP region
|
||||||
|
#
|
||||||
|
# position, size and entry line of MRC_CACHE relative to BIOS_BASE, if enabled
|
||||||
|
ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
|
FMAP_MRC_CACHE_BASE := $(call int-align, $(call int-add, $(FMAP_CONSOLE_BASE) \
|
||||||
|
$(FMAP_CONSOLE_SIZE)), 0x10000)
|
||||||
|
else
|
||||||
|
FMAP_MRC_CACHE_BASE := $(call int-align, $(call int-add, $(FMAP_FMAP_BASE) \
|
||||||
|
$(FMAP_FMAP_SIZE)), 0x10000)
|
||||||
|
endif
|
||||||
|
FMAP_MRC_CACHE_SIZE := $(CONFIG_MRC_SETTINGS_CACHE_SIZE)
|
||||||
|
FMAP_MRC_CACHE_ENTRY := RW_MRC_CACHE@$(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE)
|
||||||
|
else # ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
FMAP_MRC_CACHE_BASE := 0
|
||||||
|
FMAP_MRC_CACHE_SIZE := 0
|
||||||
|
FMAP_MRC_CACHE_ENTRY :=
|
||||||
|
endif # ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
|
||||||
|
#
|
||||||
|
# X86 COREBOOT default cbfs FMAP region
|
||||||
|
#
|
||||||
# position and size of CBFS, relative to BIOS_BASE
|
# position and size of CBFS, relative to BIOS_BASE
|
||||||
|
ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
FMAP_CBFS_BASE := $(call int-add, $(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE))
|
||||||
|
else
|
||||||
FMAP_CBFS_BASE := $(call int-add, $(FMAP_CONSOLE_SIZE) $(FMAP_FMAP_SIZE))
|
FMAP_CBFS_BASE := $(call int-add, $(FMAP_CONSOLE_SIZE) $(FMAP_FMAP_SIZE))
|
||||||
|
endif
|
||||||
FMAP_CBFS_SIZE := $(call int-subtract, $(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE))
|
FMAP_CBFS_SIZE := $(call int-subtract, $(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE))
|
||||||
else # ifeq ($(CONFIG_ARCH_X86),y)
|
else # ifeq ($(CONFIG_ARCH_X86),y)
|
||||||
DEFAULT_FLASHMAP:=$(top)/util/cbfstool/default.fmd
|
DEFAULT_FLASHMAP:=$(top)/util/cbfstool/default.fmd
|
||||||
|
@ -802,6 +834,10 @@ FMAP_BIOS_SIZE := $(CONFIG_CBFS_SIZE)
|
||||||
# position and size of flashmap, relative to BIOS_BASE
|
# position and size of flashmap, relative to BIOS_BASE
|
||||||
FMAP_FMAP_BASE := 0x20000
|
FMAP_FMAP_BASE := 0x20000
|
||||||
FMAP_FMAP_SIZE := 0x100
|
FMAP_FMAP_SIZE := 0x100
|
||||||
|
|
||||||
|
#
|
||||||
|
# NON-X86 CONSOLE FMAP region
|
||||||
|
#
|
||||||
# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled
|
# position, size and entry line of CONSOLE relative to BIOS_BASE, if enabled
|
||||||
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
FMAP_CONSOLE_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE))
|
FMAP_CONSOLE_BASE := $(call int-add, $(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE))
|
||||||
|
@ -812,8 +848,33 @@ FMAP_CONSOLE_BASE := 0
|
||||||
FMAP_CONSOLE_SIZE := 0
|
FMAP_CONSOLE_SIZE := 0
|
||||||
FMAP_CONSOLE_ENTRY :=
|
FMAP_CONSOLE_ENTRY :=
|
||||||
endif # ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
endif # ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
|
|
||||||
|
#
|
||||||
|
# NON-X86 RW_MRC_CACHE FMAP region
|
||||||
|
#
|
||||||
|
# position, size and entry line of MRC_CACHE relative to BIOS_BASE, if enabled
|
||||||
|
ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
ifeq ($(CONFIG_CONSOLE_SPI_FLASH),y)
|
||||||
|
FMAP_MRC_CACHE_BASE := $(call int-align, $(call int-add, $(FMAP_CONSOLE_BASE) \
|
||||||
|
$(FMAP_CONSOLE_SIZE)), 0x10000)
|
||||||
|
else
|
||||||
|
FMAP_MRC_CACHE_BASE := $(call int-align, $(call int-add, $(FMAP_FMAP_BASE) \
|
||||||
|
$(FMAP_FMAP_SIZE)), 0x10000)
|
||||||
|
endif
|
||||||
|
FMAP_MRC_CACHE_SIZE := $(CONFIG_MRC_SETTINGS_CACHE_SIZE)
|
||||||
|
FMAP_MRC_CACHE_ENTRY := RW_MRC_CACHE@$(FMAP_MRC_CACHE_BASE) $(FMAP_MRC_CACHE_SIZE)
|
||||||
|
else # ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
FMAP_MRC_CACHE_BASE := 0
|
||||||
|
FMAP_MRC_CACHE_SIZE := 0
|
||||||
|
FMAP_MRC_CACHE_ENTRY :=
|
||||||
|
endif # ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
||||||
|
|
||||||
|
#
|
||||||
|
# NON-X86 COREBOOT default cbfs FMAP region
|
||||||
|
#
|
||||||
# position and size of CBFS, relative to BIOS_BASE
|
# position and size of CBFS, relative to BIOS_BASE
|
||||||
FMAP_CBFS_BASE := $(call int-add,$(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE) $(FMAP_CONSOLE_SIZE))
|
FMAP_CBFS_BASE := $(call int-add,$(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE) $(FMAP_CONSOLE_SIZE) \
|
||||||
|
$(FMAP_MRC_CACHE_SIZE))
|
||||||
FMAP_CBFS_SIZE := $(call int-subtract,$(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE))
|
FMAP_CBFS_SIZE := $(call int-subtract,$(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE))
|
||||||
endif # ifeq ($(CONFIG_ARCH_X86),y)
|
endif # ifeq ($(CONFIG_ARCH_X86),y)
|
||||||
|
|
||||||
|
@ -825,6 +886,7 @@ $(obj)/fmap.fmd: $(top)/Makefile.inc $(DEFAULT_FLASHMAP) $(obj)/config.h
|
||||||
-e "s,##FMAP_BASE##,$(FMAP_FMAP_BASE)," \
|
-e "s,##FMAP_BASE##,$(FMAP_FMAP_BASE)," \
|
||||||
-e "s,##FMAP_SIZE##,$(FMAP_FMAP_SIZE)," \
|
-e "s,##FMAP_SIZE##,$(FMAP_FMAP_SIZE)," \
|
||||||
-e "s,##CONSOLE_ENTRY##,$(FMAP_CONSOLE_ENTRY)," \
|
-e "s,##CONSOLE_ENTRY##,$(FMAP_CONSOLE_ENTRY)," \
|
||||||
|
-e "s,##MRC_CACHE_ENTRY##,$(FMAP_MRC_CACHE_ENTRY)," \
|
||||||
-e "s,##CBFS_BASE##,$(FMAP_CBFS_BASE)," \
|
-e "s,##CBFS_BASE##,$(FMAP_CBFS_BASE)," \
|
||||||
-e "s,##CBFS_SIZE##,$(FMAP_CBFS_SIZE)," \
|
-e "s,##CBFS_SIZE##,$(FMAP_CBFS_SIZE)," \
|
||||||
$(DEFAULT_FLASHMAP) > $@.tmp
|
$(DEFAULT_FLASHMAP) > $@.tmp
|
||||||
|
|
|
@ -5,10 +5,6 @@ config CACHE_MRC_SETTINGS
|
||||||
|
|
||||||
if CACHE_MRC_SETTINGS
|
if CACHE_MRC_SETTINGS
|
||||||
|
|
||||||
config MRC_SETTINGS_CACHE_BASE
|
|
||||||
hex
|
|
||||||
default 0xfffe0000
|
|
||||||
|
|
||||||
config MRC_SETTINGS_CACHE_SIZE
|
config MRC_SETTINGS_CACHE_SIZE
|
||||||
hex
|
hex
|
||||||
default 0x10000
|
default 0x10000
|
||||||
|
|
|
@ -1,19 +1,2 @@
|
||||||
ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
romstage-$(CONFIG_CACHE_MRC_SETTINGS) += mrc_cache.c
|
||||||
|
ramstage-$(CONFIG_CACHE_MRC_SETTINGS) += mrc_cache.c
|
||||||
romstage-y += mrc_cache.c
|
|
||||||
ramstage-y += mrc_cache.c
|
|
||||||
|
|
||||||
# Create and add the MRC cache to the cbfs image
|
|
||||||
ifneq ($(CONFIG_CHROMEOS),y)
|
|
||||||
$(obj)/mrc.cache: $(obj)/config.h
|
|
||||||
dd if=/dev/zero count=1 \
|
|
||||||
bs=$(shell printf "%d" $(CONFIG_MRC_SETTINGS_CACHE_SIZE) ) | \
|
|
||||||
tr '\000' '\377' > $@
|
|
||||||
|
|
||||||
cbfs-files-y += mrc.cache
|
|
||||||
mrc.cache-file := $(obj)/mrc.cache
|
|
||||||
mrc.cache-position := $(CONFIG_MRC_SETTINGS_CACHE_BASE)
|
|
||||||
mrc.cache-type := mrc_cache
|
|
||||||
endif # ifneq ($(CONFIG_CHROMEOS),y)
|
|
||||||
|
|
||||||
endif # ifeq ($(CONFIG_CACHE_MRC_SETTINGS),y)
|
|
||||||
|
|
|
@ -98,28 +98,11 @@ static const struct cache_region *cache_regions[] = {
|
||||||
|
|
||||||
static int lookup_region_by_name(const char *name, struct region *r)
|
static int lookup_region_by_name(const char *name, struct region *r)
|
||||||
{
|
{
|
||||||
/* This assumes memory mapped boot media just under 4GiB. */
|
|
||||||
const uint32_t pointer_base_32bit = -CONFIG_ROM_SIZE;
|
|
||||||
|
|
||||||
if (fmap_locate_area(name, r) == 0)
|
if (fmap_locate_area(name, r) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* CHROMEOS builds must get their MRC cache from FMAP. */
|
|
||||||
if (IS_ENABLED(CONFIG_CHROMEOS)) {
|
|
||||||
printk(BIOS_ERR, "MRC: Chrome OS lookup failure.\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_BOOT_DEVICE_MEMORY_MAPPED))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Base is in the form of a pointer. Make it an offset. */
|
|
||||||
r->offset = CONFIG_MRC_SETTINGS_CACHE_BASE - pointer_base_32bit;
|
|
||||||
r->size = CONFIG_MRC_SETTINGS_CACHE_SIZE;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct cache_region *lookup_region_type(int type)
|
static const struct cache_region *lookup_region_type(int type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -11,6 +11,7 @@ FLASH@##ROM_BASE## ##ROM_SIZE## {
|
||||||
BIOS@##BIOS_BASE## ##BIOS_SIZE## {
|
BIOS@##BIOS_BASE## ##BIOS_SIZE## {
|
||||||
FMAP@##FMAP_BASE## ##FMAP_SIZE##
|
FMAP@##FMAP_BASE## ##FMAP_SIZE##
|
||||||
##CONSOLE_ENTRY##
|
##CONSOLE_ENTRY##
|
||||||
|
##MRC_CACHE_ENTRY##
|
||||||
COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
|
COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ FLASH@##ROM_BASE## ##ROM_SIZE## {
|
||||||
BOOTBLOCK 128K
|
BOOTBLOCK 128K
|
||||||
FMAP@##FMAP_BASE## ##FMAP_SIZE##
|
FMAP@##FMAP_BASE## ##FMAP_SIZE##
|
||||||
##CONSOLE_ENTRY##
|
##CONSOLE_ENTRY##
|
||||||
|
##MRC_CACHE_ENTRY##
|
||||||
COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
|
COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue