Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35377 )
Change subject: coreboot_table: Add copy of FMAP ......................................................................
coreboot_table: Add copy of FMAP
For platform independend exposure of FMAP through a kernel module expose the FMAP through coreboot tables.
Create a copy of FMAP and place it in CBMEM.
Change-Id: I4e01c573c3edfa34dbba5fe7604d4f6e18b584d5 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/commonlib/include/commonlib/cbmem_id.h M src/commonlib/include/commonlib/coreboot_tables.h M src/lib/coreboot_table.c 3 files changed, 36 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/35377/1
diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h index 8d0ca46..30bf88a 100644 --- a/src/commonlib/include/commonlib/cbmem_id.h +++ b/src/commonlib/include/commonlib/cbmem_id.h @@ -76,6 +76,7 @@ #define CBMEM_ID_ROM1 0x524f4d31 #define CBMEM_ID_ROM2 0x524f4d32 #define CBMEM_ID_ROM3 0x524f4d33 +#define CBMEM_ID_FMAP 0x464d4150
#define CBMEM_ID_TO_NAME_TABLE \ { CBMEM_ID_ACPI, "ACPI " }, \ @@ -134,5 +135,6 @@ { CBMEM_ID_ROM0, "VGA ROM #0 "}, \ { CBMEM_ID_ROM1, "VGA ROM #1 "}, \ { CBMEM_ID_ROM2, "VGA ROM #2 "}, \ - { CBMEM_ID_ROM3, "VGA ROM #3 "}, + { CBMEM_ID_ROM3, "VGA ROM #3 "}, \ + { CBMEM_ID_FMAP, "FMAP "}, #endif /* _CBMEM_ID_H_ */ diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index 7bded2a..6816670 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -89,6 +89,7 @@ LB_TAG_VBOOT_WORKBUF = 0x0034, LB_TAG_MMC_INFO = 0x0035, LB_TAG_TCPA_LOG = 0x0036, + LB_TAG_FMAP = 0x0037, LB_TAG_CMOS_OPTION_TABLE = 0x00c8, LB_TAG_OPTION = 0x00c9, LB_TAG_OPTION_ENUM = 0x00ca, diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 95c2ae6..a72150c 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -336,7 +336,8 @@ {CBMEM_ID_ACPI_GNVS, LB_TAG_ACPI_GNVS}, {CBMEM_ID_VPD, LB_TAG_VPD}, {CBMEM_ID_WIFI_CALIBRATION, LB_TAG_WIFI_CALIBRATION}, - {CBMEM_ID_TCPA_LOG, LB_TAG_TCPA_LOG} + {CBMEM_ID_TCPA_LOG, LB_TAG_TCPA_LOG}, + {CBMEM_ID_FMAP, LB_TAG_FMAP}, }; int i;
@@ -476,6 +477,34 @@ return (unsigned long)rec + rec->size; }
+static void add_fmap_copy_cbmem(void) +{ + struct region_device fmrd; + + if (find_fmap_directory(&fmrd)) { + printk(BIOS_ERR, "Failed to find FMAP\n"); + return; + } + + void *fmap_cbmem = cbmem_add(CBMEM_ID_FMAP, region_device_sz(&fmrd)); + if (!fmap_cbmem) { + printk(BIOS_ERR, "Failed to allocate CBMEM\n"); + return; + } + + void *fmap_reg = rdev_mmap_full(&fmrd); + if (!fmap_reg) { + printk(BIOS_ERR, "Failed to mmap FMAP device\n"); + return; + } + + memcpy(fmap_cbmem, fmap_reg, region_device_sz(&fmrd)); + printk(BIOS_ERR, "fmap_cbmem %x\n", *((uint32_t*)(fmap_cbmem))); + printk(BIOS_ERR, "fmap_cbmem %x\n", *((uint32_t*)(fmap_cbmem+4))); + + rdev_munmap(&fmrd, fmap_reg); +} + size_t write_coreboot_forwarding_table(uintptr_t entry, uintptr_t target) { struct lb_header *head; @@ -563,6 +592,8 @@ if (CONFIG(BOOT_DEVICE_SPI_FLASH)) lb_spi_flash(head);
+ /* Add copy of FMAP to CBMEM */ + add_fmap_copy_cbmem(); add_cbmem_pointers(head);
/* Add board-specific table entries, if any. */