From 9b1f3cc6fb129789f1dd28160a83a1ea59dd123a Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 30 Dec 2020 17:30:12 -0800 Subject: cbfs: Pull handling of the CBFS_CACHE mem_pool into CBFS core This patch pulls control of the memory pool serving allocations from the CBFS_CACHE memlayout area into cbfs.c and makes it a core part of the CBFS API. Previously, platforms would independently instantiate this as part of boot_device_ro() (mostly through cbfs_spi.c). The new cbfs_cache pool is exported as a global so these platforms can still use it to directly back rdev_mmap() on their boot device, but the cbfs_cache can now also use it to directly make allocations itself. This is used to allow transparent decompression support in cbfs_map(). Signed-off-by: Julius Werner Change-Id: I0d52b6a8f582a81a19fd0fd663bb89eab55a49d9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49333 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/drivers/spi/cbfs_spi.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c index 0034460b98..7e648a34ce 100644 --- a/src/drivers/spi/cbfs_spi.c +++ b/src/drivers/spi/cbfs_spi.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -77,21 +78,7 @@ static const struct region_device_ops spi_ops = { }; static struct mmap_helper_region_device mdev = - MMAP_HELPER_REGION_INIT(&spi_ops, 0, CONFIG_ROM_SIZE); - -static void switch_to_postram_cache(int unused) -{ - /* - * Call boot_device_init() to ensure spi_flash is initialized before - * backing mdev with postram cache. This prevents the mdev backing from - * being overwritten if spi_flash was not accessed before dram was up. - */ - boot_device_init(); - if (_preram_cbfs_cache != _postram_cbfs_cache) - mmap_helper_device_init(&mdev, _postram_cbfs_cache, - REGION_SIZE(postram_cbfs_cache)); -} -ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache); + MMAP_HELPER_DEV_INIT(&spi_ops, 0, CONFIG_ROM_SIZE, &cbfs_cache); void boot_device_init(void) { @@ -105,8 +92,6 @@ void boot_device_init(void) return; spi_flash_init_done = true; - - mmap_helper_device_init(&mdev, _cbfs_cache, REGION_SIZE(cbfs_cache)); } /* Return the CBFS boot device. */ -- cgit v1.2.3