Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/81389?usp=email )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: soc/amd/*/memmap: factor out common read_lower_soc_memmap_resources ......................................................................
soc/amd/*/memmap: factor out common read_lower_soc_memmap_resources
Since the code for reporting the memory map below cbmem_top is basically identical for all non-CAR AMD SoCs, factor this out into a common read_lower_soc_memmap_resources implementation.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: Id64462b97d144ccdf78ebb051d82a4aa37f8ee98 Reviewed-on: https://review.coreboot.org/c/coreboot/+/81389 Reviewed-by: Marshall Dawson marshalldawson3rd@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Matt DeVillier matt.devillier@amd.corp-partner.google.com --- M src/soc/amd/cezanne/memmap.c M src/soc/amd/common/block/cpu/noncar/memmap.c M src/soc/amd/common/block/include/amdblocks/memmap.h M src/soc/amd/genoa_poc/domain.c M src/soc/amd/glinda/memmap.c M src/soc/amd/mendocino/memmap.c M src/soc/amd/phoenix/memmap.c M src/soc/amd/picasso/memmap.c 8 files changed, 46 insertions(+), 173 deletions(-)
Approvals: Matt DeVillier: Looks good to me, but someone else must approve Marshall Dawson: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/soc/amd/cezanne/memmap.c b/src/soc/amd/cezanne/memmap.c index 6c8e932..bb1eca2 100644 --- a/src/soc/amd/cezanne/memmap.c +++ b/src/soc/amd/cezanne/memmap.c @@ -3,8 +3,6 @@ #include <amdblocks/iomap.h> #include <amdblocks/memmap.h> #include <amdblocks/root_complex.h> -#include <arch/vga.h> -#include <cbmem.h> #include <device/device.h> #include <stdint.h>
@@ -62,34 +60,7 @@ */ void read_soc_memmap_resources(struct device *dev, unsigned long *idx) { - uint32_t mem_usable = (uintptr_t)cbmem_top(); - - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - /* 0x0 - 0x9ffff */ - ram_range(dev, (*idx)++, 0, 0xa0000); - - /* 0xa0000 - 0xbffff: legacy VGA */ - mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); - - /* 0xc0000 - 0xfffff: Option ROM */ - reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); - - /* 1MiB - bottom of DRAM reserved for early coreboot usage */ - ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); - - /* DRAM reserved for early coreboot usage */ - reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); - - /* - * top of DRAM consumed early - low top usable RAM - * cbmem_top() accounts for low UMA and TSEG if they are used. - */ - ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); + read_lower_soc_memmap_resources(dev, idx);
/* Reserve fixed IOMMU MMIO region */ mmio_range(dev, (*idx)++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE); diff --git a/src/soc/amd/common/block/cpu/noncar/memmap.c b/src/soc/amd/common/block/cpu/noncar/memmap.c index e21cff8a3..2aaba83 100644 --- a/src/soc/amd/common/block/cpu/noncar/memmap.c +++ b/src/soc/amd/common/block/cpu/noncar/memmap.c @@ -2,9 +2,11 @@
#include <amdblocks/memmap.h> #include <amdblocks/smm.h> +#include <arch/vga.h> #include <console/console.h> #include <cbmem.h> #include <cpu/x86/smm.h> +#include <device/device.h> #include <memrange.h> #include <types.h>
@@ -21,7 +23,7 @@ e->size = REGION_SIZE(early_reserved_dram); }
-const struct memmap_early_dram *memmap_get_early_dram_usage(void) +static const struct memmap_early_dram *memmap_get_early_dram_usage(void) { struct memmap_early_dram *e = cbmem_find(CBMEM_ID_CB_EARLY_DRAM);
@@ -31,6 +33,39 @@ return e; }
+/* report SoC memory map up to cbmem_top */ +void read_lower_soc_memmap_resources(struct device *dev, unsigned long *idx) +{ + uint32_t mem_usable = (uintptr_t)cbmem_top(); + + uintptr_t early_reserved_dram_start, early_reserved_dram_end; + const struct memmap_early_dram *e = memmap_get_early_dram_usage(); + + early_reserved_dram_start = e->base; + early_reserved_dram_end = e->base + e->size; + + /* 0x0 - 0x9ffff */ + ram_range(dev, (*idx)++, 0, 0xa0000); + + /* 0xa0000 - 0xbffff: legacy VGA */ + mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); + + /* 0xc0000 - 0xfffff: Option ROM */ + reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); + + /* 1MiB - bottom of DRAM reserved for early coreboot usage */ + ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); + + /* DRAM reserved for early coreboot usage */ + reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); + + /* + * top of DRAM consumed early - low top usable RAM + * cbmem_top() accounts for low UMA and TSEG if they are used. + */ + ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); +} + void smm_region(uintptr_t *start, size_t *size) { static int once; diff --git a/src/soc/amd/common/block/include/amdblocks/memmap.h b/src/soc/amd/common/block/include/amdblocks/memmap.h index cc89d86..258b8b7 100644 --- a/src/soc/amd/common/block/include/amdblocks/memmap.h +++ b/src/soc/amd/common/block/include/amdblocks/memmap.h @@ -3,6 +3,7 @@ #ifndef AMD_BLOCK_MEMMAP_H #define AMD_BLOCK_MEMMAP_H
+#include <device/device.h> #include <stdint.h> #include <symbols.h>
@@ -15,7 +16,9 @@ };
void memmap_stash_early_dram_usage(void); -const struct memmap_early_dram *memmap_get_early_dram_usage(void); + +/* report SoC memory map up to cbmem_top */ +void read_lower_soc_memmap_resources(struct device *dev, unsigned long *idx);
void fsp_get_smm_region(uintptr_t *start, size_t *size);
diff --git a/src/soc/amd/genoa_poc/domain.c b/src/soc/amd/genoa_poc/domain.c index 6154908..88f386c 100644 --- a/src/soc/amd/genoa_poc/domain.c +++ b/src/soc/amd/genoa_poc/domain.c @@ -7,7 +7,6 @@ #include <amdblocks/root_complex.h> #include <amdblocks/smn.h> #include <arch/ioapic.h> -#include <cbmem.h> #include <console/console.h> #include <device/device.h> #include <types.h> @@ -18,28 +17,7 @@
void read_soc_memmap_resources(struct device *domain, unsigned long *idx) { - ram_from_to(domain, (*idx)++, 0, 0xa0000); - mmio_from_to(domain, (*idx)++, 0xa0000, 0xc0000); // legacy VGA - reserved_ram_from_to(domain, (*idx)++, 0xc0000, 1 * MiB); // Option ROM - - uint32_t mem_usable = (uintptr_t)cbmem_top(); - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - // 1MB - bottom of DRAM reserved for early coreboot usage - ram_from_to(domain, (*idx)++, 1 * MiB, early_reserved_dram_start); - - // DRAM reserved for early coreboot usage - reserved_ram_from_to(domain, (*idx)++, early_reserved_dram_start, - early_reserved_dram_end); - - // top of DRAM consumed early - low top usable RAM - // cbmem_top() accounts for low UMA and TSEG if they are used. - ram_from_to(domain, (*idx)++, early_reserved_dram_end, - mem_usable); + read_lower_soc_memmap_resources(domain, idx);
add_opensil_memmap(domain, idx); } diff --git a/src/soc/amd/glinda/memmap.c b/src/soc/amd/glinda/memmap.c index d347bae..feecdd7 100644 --- a/src/soc/amd/glinda/memmap.c +++ b/src/soc/amd/glinda/memmap.c @@ -3,8 +3,6 @@ #include <amdblocks/iomap.h> #include <amdblocks/memmap.h> #include <amdblocks/root_complex.h> -#include <arch/vga.h> -#include <cbmem.h> #include <device/device.h> #include <stdint.h>
@@ -62,34 +60,7 @@ */ void read_soc_memmap_resources(struct device *dev, unsigned long *idx) { - uint32_t mem_usable = (uintptr_t)cbmem_top(); - - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - /* 0x0 - 0x9ffff */ - ram_range(dev, (*idx)++, 0, 0xa0000); - - /* 0xa0000 - 0xbffff: legacy VGA */ - mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); - - /* 0xc0000 - 0xfffff: Option ROM */ - reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); - - /* 1MiB - bottom of DRAM reserved for early coreboot usage */ - ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); - - /* DRAM reserved for early coreboot usage */ - reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); - - /* - * top of DRAM consumed early - low top usable RAM - * cbmem_top() accounts for low UMA and TSEG if they are used. - */ - ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); + read_lower_soc_memmap_resources(dev, idx);
/* Reserve fixed IOMMU MMIO region */ mmio_range(dev, (*idx)++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE); diff --git a/src/soc/amd/mendocino/memmap.c b/src/soc/amd/mendocino/memmap.c index d347bae..feecdd7 100644 --- a/src/soc/amd/mendocino/memmap.c +++ b/src/soc/amd/mendocino/memmap.c @@ -3,8 +3,6 @@ #include <amdblocks/iomap.h> #include <amdblocks/memmap.h> #include <amdblocks/root_complex.h> -#include <arch/vga.h> -#include <cbmem.h> #include <device/device.h> #include <stdint.h>
@@ -62,34 +60,7 @@ */ void read_soc_memmap_resources(struct device *dev, unsigned long *idx) { - uint32_t mem_usable = (uintptr_t)cbmem_top(); - - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - /* 0x0 - 0x9ffff */ - ram_range(dev, (*idx)++, 0, 0xa0000); - - /* 0xa0000 - 0xbffff: legacy VGA */ - mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); - - /* 0xc0000 - 0xfffff: Option ROM */ - reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); - - /* 1MiB - bottom of DRAM reserved for early coreboot usage */ - ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); - - /* DRAM reserved for early coreboot usage */ - reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); - - /* - * top of DRAM consumed early - low top usable RAM - * cbmem_top() accounts for low UMA and TSEG if they are used. - */ - ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); + read_lower_soc_memmap_resources(dev, idx);
/* Reserve fixed IOMMU MMIO region */ mmio_range(dev, (*idx)++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE); diff --git a/src/soc/amd/phoenix/memmap.c b/src/soc/amd/phoenix/memmap.c index e516572..9e740cb 100644 --- a/src/soc/amd/phoenix/memmap.c +++ b/src/soc/amd/phoenix/memmap.c @@ -3,8 +3,6 @@ #include <amdblocks/iomap.h> #include <amdblocks/memmap.h> #include <amdblocks/root_complex.h> -#include <arch/vga.h> -#include <cbmem.h> #include <device/device.h> #include <stdint.h> #include <vendorcode/amd/opensil/stub/opensil.h> @@ -63,34 +61,7 @@ */ void read_soc_memmap_resources(struct device *dev, unsigned long *idx) { - uint32_t mem_usable = (uintptr_t)cbmem_top(); - - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - /* 0x0 - 0x9ffff */ - ram_range(dev, (*idx)++, 0, 0xa0000); - - /* 0xa0000 - 0xbffff: legacy VGA */ - mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); - - /* 0xc0000 - 0xfffff: Option ROM */ - reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); - - /* 1MiB - bottom of DRAM reserved for early coreboot usage */ - ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); - - /* DRAM reserved for early coreboot usage */ - reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); - - /* - * top of DRAM consumed early - low top usable RAM - * cbmem_top() accounts for low UMA and TSEG if they are used. - */ - ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); + read_lower_soc_memmap_resources(dev, idx);
/* Reserve fixed IOMMU MMIO region */ mmio_range(dev, (*idx)++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE); diff --git a/src/soc/amd/picasso/memmap.c b/src/soc/amd/picasso/memmap.c index 7ec7adf..2bbf285 100644 --- a/src/soc/amd/picasso/memmap.c +++ b/src/soc/amd/picasso/memmap.c @@ -3,8 +3,6 @@ #include <amdblocks/memmap.h> #include <amdblocks/iomap.h> #include <amdblocks/root_complex.h> -#include <arch/vga.h> -#include <cbmem.h> #include <device/device.h> #include <stdint.h>
@@ -62,32 +60,7 @@ */ void read_soc_memmap_resources(struct device *dev, unsigned long *idx) { - uint32_t mem_usable = (uintptr_t)cbmem_top(); - - uintptr_t early_reserved_dram_start, early_reserved_dram_end; - const struct memmap_early_dram *e = memmap_get_early_dram_usage(); - - early_reserved_dram_start = e->base; - early_reserved_dram_end = e->base + e->size; - - /* 0x0 - 0x9ffff */ - ram_range(dev, (*idx)++, 0, 0xa0000); - - /* 0xa0000 - 0xbffff: legacy VGA */ - mmio_range(dev, (*idx)++, VGA_MMIO_BASE, VGA_MMIO_SIZE); - - /* 0xc0000 - 0xfffff: Option ROM */ - reserved_ram_from_to(dev, (*idx)++, 0xc0000, 1 * MiB); - - /* 1MB - bottom of DRAM reserved for early coreboot usage */ - ram_from_to(dev, (*idx)++, 1 * MiB, early_reserved_dram_start); - - /* DRAM reserved for early coreboot usage */ - reserved_ram_from_to(dev, (*idx)++, early_reserved_dram_start, early_reserved_dram_end); - - /* top of DRAM consumed early - low top usable RAM - * cbmem_top() accounts for low UMA and TSEG if they are used. */ - ram_from_to(dev, (*idx)++, early_reserved_dram_end, mem_usable); + read_lower_soc_memmap_resources(dev, idx);
/* Reserve fixed IOMMU MMIO region */ mmio_range(dev, (*idx)++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);