Debian Codegraph @

src/soc/amd/common/fsp/fsp_report_resources.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <amdblocks/root_complex.h>
4 #include <cbmem.h>
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <fsp/util.h>
8 #include <types.h>
9
10 void read_fsp_resources(struct device *dev, unsigned long *idx)
11 {
12 const uint32_t mem_usable = cbmem_top();
13 const struct hob_header *hob_iterator;
14 const struct hob_resource *res;
15
16 if (fsp_hob_iterator_init(&hob_iterator) != CB_SUCCESS) {
17 printk(BIOS_ERR, "%s incomplete because no HOB list was found\n", __func__);
18 return;
19 }
20
21 while (fsp_hob_iterator_get_next_resource(&hob_iterator, &res) == CB_SUCCESS) {
22 if (res->type == EFI_RESOURCE_SYSTEM_MEMORY && res->addr < mem_usable)
23 /* 0 through low usable is already reported by the root complex code */
24 continue;
25 if (res->type == EFI_RESOURCE_MEMORY_MAPPED_IO)
26 continue; /* Done separately */
27
28 if (res->type == EFI_RESOURCE_SYSTEM_MEMORY)
29 ram_range(dev, (*idx)++, res->addr, res->length);
30 else if (res->type == EFI_RESOURCE_MEMORY_RESERVED)
31 reserved_ram_range(dev, (*idx)++, res->addr, res->length);
32 else
33 printk(BIOS_ERR, "failed to set resources for type %d\n", res->type);
34 }
35 }