coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pci_routing_info.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
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, 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].irq);
40  }
41 
42  *entries = routing_table_entries;
43 
44  return routing_table;
45 }
#define printk(level,...)
Definition: stdlib.h:16
const struct pci_routing_info * get_pci_routing_table(size_t *entries)
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define PCI_FUNC(devfn)
Definition: pci_def.h:550
#define PCI_SLOT(devfn)
Definition: pci_def.h:549
#define NULL
Definition: stddef.h:19
unsigned int uint32_t
Definition: stdint.h:14
Definition: x86.c:23
Each PCI bridge has its INTx lines routed to one of the GNB IO-APIC PCI groups.
Definition: amd_pci_util.h:48