soc/amd/common/fsp: factor out read_fsp_resources from root_complex.c
Factor out the common FSP-specific code to report the usable and reserved memory resources read from the HOBs that FSP has put into memory. This both reduces code duplication and also moves FSP-specific code out of the SoC code into the FSP-specific common AMD SoC code folder. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ib373c52030209235559c9cd383f48ee1b3f8f79b Reviewed-on: https://review.coreboot.org/c/coreboot/+/76759 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <fsp/util.h>
|
|
||||||
#include <soc/iomap.h>
|
#include <soc/iomap.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@@ -106,8 +105,6 @@ static void read_resources(struct device *dev)
|
|||||||
{
|
{
|
||||||
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
const struct hob_header *hob_iterator;
|
|
||||||
const struct hob_resource *res;
|
|
||||||
|
|
||||||
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
||||||
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
||||||
@@ -146,26 +143,7 @@ static void read_resources(struct device *dev)
|
|||||||
/* Reserve fixed IOMMU MMIO region */
|
/* Reserve fixed IOMMU MMIO region */
|
||||||
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
||||||
|
|
||||||
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
read_fsp_resources(dev, &idx);
|
||||||
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n",
|
|
||||||
__func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
|
||||||
continue; /* 0 through low usable was set above */
|
|
||||||
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
|
||||||
continue; /* Done separately */
|
|
||||||
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
|
||||||
ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
|
||||||
reserved_ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else
|
|
||||||
printk(BIOS_ERR, "failed to set resources for type %d\n",
|
|
||||||
res->type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void root_complex_init(struct device *dev)
|
static void root_complex_init(struct device *dev)
|
||||||
|
@@ -22,4 +22,6 @@ void read_non_pci_resources(struct device *domain, unsigned int *idx);
|
|||||||
uint32_t get_iohc_misc_smn_base(struct device *domain);
|
uint32_t get_iohc_misc_smn_base(struct device *domain);
|
||||||
const struct non_pci_mmio_reg *get_iohc_non_pci_mmio_regs(size_t *count);
|
const struct non_pci_mmio_reg *get_iohc_non_pci_mmio_regs(size_t *count);
|
||||||
|
|
||||||
|
void read_fsp_resources(struct device *dev, unsigned int *idx);
|
||||||
|
|
||||||
#endif /* AMD_BLOCK_ROOT_COMPLEX_H */
|
#endif /* AMD_BLOCK_ROOT_COMPLEX_H */
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y)
|
ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y)
|
||||||
romstage-y += fsp_reset.c
|
romstage-y += fsp_reset.c
|
||||||
romstage-y += fsp_validate.c
|
romstage-y += fsp_validate.c
|
||||||
|
ramstage-y += fsp_report_resources.c
|
||||||
ramstage-y += fsp_reset.c
|
ramstage-y += fsp_reset.c
|
||||||
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += fsp-acpi.c
|
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += fsp-acpi.c
|
||||||
ramstage-$(CONFIG_SOC_AMD_COMMON_FSP_CCX_CPPC_HOB) += fsp_ccx_cppc_hob.c
|
ramstage-$(CONFIG_SOC_AMD_COMMON_FSP_CCX_CPPC_HOB) += fsp_ccx_cppc_hob.c
|
||||||
|
35
src/soc/amd/common/fsp/fsp_report_resources.c
Normal file
35
src/soc/amd/common/fsp/fsp_report_resources.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
|
||||||
|
#include <amdblocks/root_complex.h>
|
||||||
|
#include <cbmem.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <device/device.h>
|
||||||
|
#include <fsp/util.h>
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
void read_fsp_resources(struct device *dev, unsigned int *idx)
|
||||||
|
{
|
||||||
|
const uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
|
const struct hob_header *hob_iterator;
|
||||||
|
const struct hob_resource *res;
|
||||||
|
|
||||||
|
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
||||||
|
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
||||||
|
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
||||||
|
/* 0 through low usable is already reported by the root complex code */
|
||||||
|
continue;
|
||||||
|
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
||||||
|
continue; /* Done separately */
|
||||||
|
|
||||||
|
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
||||||
|
ram_range(dev, (*idx)++, res->addr, res->length);
|
||||||
|
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
||||||
|
reserved_ram_range(dev, (*idx)++, res->addr, res->length);
|
||||||
|
else
|
||||||
|
printk(BIOS_ERR, "failed to set resources for type %d\n", res->type);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,7 +16,6 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <fsp/util.h>
|
|
||||||
#include <soc/iomap.h>
|
#include <soc/iomap.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@@ -121,8 +120,6 @@ static void read_resources(struct device *dev)
|
|||||||
{
|
{
|
||||||
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
const struct hob_header *hob_iterator;
|
|
||||||
const struct hob_resource *res;
|
|
||||||
|
|
||||||
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
||||||
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
||||||
@@ -161,26 +158,7 @@ static void read_resources(struct device *dev)
|
|||||||
/* Reserve fixed IOMMU MMIO region */
|
/* Reserve fixed IOMMU MMIO region */
|
||||||
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
||||||
|
|
||||||
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
read_fsp_resources(dev, &idx);
|
||||||
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n",
|
|
||||||
__func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
|
||||||
continue; /* 0 through low usable was set above */
|
|
||||||
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
|
||||||
continue; /* Done separately */
|
|
||||||
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
|
||||||
ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
|
||||||
reserved_ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else
|
|
||||||
printk(BIOS_ERR, "Failed to set resources for type %d\n",
|
|
||||||
res->type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void root_complex_init(struct device *dev)
|
static void root_complex_init(struct device *dev)
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <fsp/amd_misc_data.h>
|
#include <fsp/amd_misc_data.h>
|
||||||
#include <fsp/util.h>
|
|
||||||
#include <soc/iomap.h>
|
#include <soc/iomap.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@@ -149,8 +148,6 @@ static void read_resources(struct device *dev)
|
|||||||
{
|
{
|
||||||
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
const struct hob_header *hob_iterator;
|
|
||||||
const struct hob_resource *res;
|
|
||||||
|
|
||||||
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
||||||
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
||||||
@@ -189,26 +186,7 @@ static void read_resources(struct device *dev)
|
|||||||
/* Reserve fixed IOMMU MMIO region */
|
/* Reserve fixed IOMMU MMIO region */
|
||||||
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
||||||
|
|
||||||
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
read_fsp_resources(dev, &idx);
|
||||||
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n",
|
|
||||||
__func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
|
||||||
continue; /* 0 through low usable was set above */
|
|
||||||
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
|
||||||
continue; /* Done separately */
|
|
||||||
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
|
||||||
ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
|
||||||
reserved_ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else
|
|
||||||
printk(BIOS_ERR, "Failed to set resources for type %d\n",
|
|
||||||
res->type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void root_complex_init(struct device *dev)
|
static void root_complex_init(struct device *dev)
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <fsp/util.h>
|
|
||||||
#include <soc/iomap.h>
|
#include <soc/iomap.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@@ -121,8 +120,6 @@ static void read_resources(struct device *dev)
|
|||||||
{
|
{
|
||||||
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
const struct hob_header *hob_iterator;
|
|
||||||
const struct hob_resource *res;
|
|
||||||
|
|
||||||
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
||||||
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
||||||
@@ -161,26 +158,7 @@ static void read_resources(struct device *dev)
|
|||||||
/* Reserve fixed IOMMU MMIO region */
|
/* Reserve fixed IOMMU MMIO region */
|
||||||
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
||||||
|
|
||||||
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
read_fsp_resources(dev, &idx);
|
||||||
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n",
|
|
||||||
__func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
|
||||||
continue; /* 0 through low usable was set above */
|
|
||||||
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
|
||||||
continue; /* Done separately */
|
|
||||||
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
|
||||||
ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
|
||||||
reserved_ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else
|
|
||||||
printk(BIOS_ERR, "Failed to set resources for type %d\n",
|
|
||||||
res->type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void root_complex_init(struct device *dev)
|
static void root_complex_init(struct device *dev)
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
#include <fsp/util.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <soc/iomap.h>
|
#include <soc/iomap.h>
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@@ -106,8 +105,6 @@ static void read_resources(struct device *dev)
|
|||||||
{
|
{
|
||||||
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
uint32_t mem_usable = (uintptr_t)cbmem_top();
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
const struct hob_header *hob_iterator;
|
|
||||||
const struct hob_resource *res;
|
|
||||||
|
|
||||||
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
uintptr_t early_reserved_dram_start, early_reserved_dram_end;
|
||||||
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
const struct memmap_early_dram *e = memmap_get_early_dram_usage();
|
||||||
@@ -144,25 +141,7 @@ static void read_resources(struct device *dev)
|
|||||||
/* Reserve fixed IOMMU MMIO region */
|
/* Reserve fixed IOMMU MMIO region */
|
||||||
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE);
|
||||||
|
|
||||||
if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
|
read_fsp_resources(dev, &idx);
|
||||||
printk(BIOS_ERR, "%s incomplete because no HOB list was found\n", __func__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
|
|
||||||
continue; /* 0 through low usable was set above */
|
|
||||||
if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
|
|
||||||
continue; /* Done separately */
|
|
||||||
|
|
||||||
if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
|
|
||||||
ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
|
|
||||||
reserved_ram_range(dev, idx++, res->addr, res->length);
|
|
||||||
else
|
|
||||||
printk(BIOS_ERR, "failed to set resources for type %d\n",
|
|
||||||
res->type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void root_complex_init(struct device *dev)
|
static void root_complex_init(struct device *dev)
|
||||||
|
Reference in New Issue
Block a user