Debian Codegraph @

src/soc/amd/common/fsp/pci/pci_routing_info.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <amdblocks/amd_pci_util.h>
4 #include <console/console.h>
5 #include <device/pci_def.h>
6 #include <fsp/util.h>
7 #include <FspGuids.h>
8 #include <types.h>
9
10 const struct pci_routing_info *get_pci_routing_table(size_t *entries)
11 {
12 static const struct pci_routing_info *routing_table;
13 static size_t routing_table_entries;
14 size_t hob_size = 0;
15 const struct {
16 uint32_t num_of_entries;
17 struct pci_routing_info routing_table[];
18 } __packed *routing_hob;
19
20 if (routing_table) {
21 *entries = routing_table_entries;
22 return routing_table;
23 }
24
25 routing_hob = fsp_find_extension_hob_by_guid(AMD_FSP_PCIE_DEVFUNC_REMAP_HOB_GUID.b,
26 &hob_size);
27
28 if (routing_hob == NULL || hob_size == 0 || routing_hob->num_of_entries == 0) {
29 printk(BIOS_ERR, "Couldn't find valid PCIe interrupt routing HOB.\n");
30 return NULL;
31 }
32
33 routing_table = routing_hob->routing_table;
34 routing_table_entries = routing_hob->num_of_entries;
35
36 for (size_t i = 0; i < routing_table_entries; ++i) {
37 printk(BIOS_DEBUG, "%02x.%x: group: %u, swizzle: %u, bridge irq: %u\n",
38 PCI_SLOT(routing_table[i].devfn), PCI_FUNC(routing_table[i].devfn),
39 routing_table[i].group, routing_table[i].swizzle, routing_table[i].bridge_irq);
40 }
41
42 *entries = routing_table_entries;
43
44 return routing_table;
45 }