aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/xeon_sp/skx/soc_acpi.c
diff options
context:
space:
mode:
authorMarc Jones <marcjones@sysproconsulting.com>2020-09-28 16:34:00 -0600
committerMarc Jones <marc@marcjonesconsulting.com>2020-10-06 15:27:14 +0000
commit301c7e67bf7191358a8d2308e087dcd2f811427f (patch)
tree283c69dc2f0662d3382297d214328ac03231bc2d /src/soc/intel/xeon_sp/skx/soc_acpi.c
parent70ddbd8ce18e5ea023e2cc5c5fb852f20e055d1d (diff)
soc/intel/xeon_sp/skx: Move get_srat_memory_entries()
Prepare for common ACPI code. Move get_srat_memory_entries() from soc_util.c to soc_acpi.c where the other srat ACPI functions are located. Change-Id: If26641497e1c16d5cf493490711aa08d6e1cb640 Signed-off-by: Marc Jones <marcjones@sysproconsulting.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45846 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/intel/xeon_sp/skx/soc_acpi.c')
-rw-r--r--src/soc/intel/xeon_sp/skx/soc_acpi.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/soc/intel/xeon_sp/skx/soc_acpi.c b/src/soc/intel/xeon_sp/skx/soc_acpi.c
index aeac5ab035..34ab4280e7 100644
--- a/src/soc/intel/xeon_sp/skx/soc_acpi.c
+++ b/src/soc/intel/xeon_sp/skx/soc_acpi.c
@@ -176,6 +176,67 @@ unsigned long acpi_create_srat_lapics(unsigned long current)
return current;
}
+static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem)
+{
+ const struct SystemMemoryMapHob *memory_map;
+ size_t hob_size;
+ const uint8_t mem_hob_guid[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID;
+ unsigned int mmap_index;
+
+ memory_map = fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
+ assert(memory_map != NULL && hob_size != 0);
+ printk(BIOS_DEBUG, "FSP_SYSTEM_MEMORYMAP_HOB_GUID hob_size: %ld\n", hob_size);
+
+ mmap_index = 0;
+ for (int e = 0; e < memory_map->numberEntries; ++e) {
+ const struct SystemMemoryMapElement *mem_element = &memory_map->Element[e];
+ uint64_t addr =
+ (uint64_t) ((uint64_t)mem_element->BaseAddress <<
+ MEM_ADDR_64MB_SHIFT_BITS);
+ uint64_t size =
+ (uint64_t) ((uint64_t)mem_element->ElementSize <<
+ MEM_ADDR_64MB_SHIFT_BITS);
+
+ printk(BIOS_DEBUG, "memory_map %d addr: 0x%llx, BaseAddress: 0x%x, size: 0x%llx, "
+ "ElementSize: 0x%x, reserved: %d\n",
+ e, addr, mem_element->BaseAddress, size,
+ mem_element->ElementSize, (mem_element->Type & MEM_TYPE_RESERVED));
+
+ assert(mmap_index < MAX_ACPI_MEMORY_AFFINITY_COUNT);
+
+ /* skip reserved memory region */
+ if (mem_element->Type & MEM_TYPE_RESERVED)
+ continue;
+
+ /* skip if this address is already added */
+ bool skip = false;
+ for (int idx = 0; idx < mmap_index; ++idx) {
+ uint64_t base_addr = ((uint64_t)srat_mem[idx].base_address_high << 32) +
+ srat_mem[idx].base_address_low;
+ if (addr == base_addr) {
+ skip = true;
+ break;
+ }
+ }
+ if (skip)
+ continue;
+
+ srat_mem[mmap_index].type = 1; /* Memory affinity structure */
+ srat_mem[mmap_index].length = sizeof(acpi_srat_mem_t);
+ srat_mem[mmap_index].base_address_low = (uint32_t) (addr & 0xffffffff);
+ srat_mem[mmap_index].base_address_high = (uint32_t) (addr >> 32);
+ srat_mem[mmap_index].length_low = (uint32_t) (size & 0xffffffff);
+ srat_mem[mmap_index].length_high = (uint32_t) (size >> 32);
+ srat_mem[mmap_index].proximity_domain = mem_element->SocketId;
+ srat_mem[mmap_index].flags = SRAT_ACPI_MEMORY_ENABLED;
+ if ((mem_element->Type & MEMTYPE_VOLATILE_MASK) == 0)
+ srat_mem[mmap_index].flags |= SRAT_ACPI_MEMORY_NONVOLATILE;
+ ++mmap_index;
+ }
+
+ return mmap_index;
+}
+
static unsigned long acpi_fill_srat(unsigned long current)
{
acpi_srat_mem_t srat_mem[MAX_ACPI_MEMORY_AFFINITY_COUNT];