coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
acpi_prt.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <acpi/acpi.h>
4 #include <acpi/acpigen.h>
5 #include <acpi/acpigen_pci.h>
7 #include <arch/ioapic.h>
8 #include <device/device.h>
9 
10 static void acpigen_write_PRT_GSI(const struct pci_routing_info *routing_info)
11 {
12  unsigned int irq;
13 
14  acpigen_write_package(4); /* Package - APIC Routing */
15  for (unsigned int i = 0; i < 4; ++i) {
16  /* GNB IO-APIC is located after the FCH IO-APIC */
17  irq = IO_APIC_INTERRUPTS;
18  irq += pci_calculate_irq(routing_info, i);
19 
21  0, /* There is only one device attached to the bridge */
22  i, /* pin */
23  irq);
24  }
25  acpigen_pop_len(); /* Package - APIC Routing */
26 }
27 
28 static void acpigen_write_PRT_PIC(const struct pci_routing_info *routing_info)
29 {
30  unsigned int irq;
31  char link_template[] = "\\_SB.INTX";
32 
33  acpigen_write_package(4); /* Package - PIC Routing */
34  for (unsigned int i = 0; i < 4; ++i) {
35  irq = pci_calculate_irq(routing_info, i);
36 
37  link_template[8] = 'A' + (irq % 8);
38 
40  0, /* There is only one device attached to the bridge */
41  i, /* pin */
42  link_template /* Source */,
43  0 /* Source Index */);
44  }
45  acpigen_pop_len(); /* Package - PIC Routing */
46 }
47 
48 /*
49  * This method writes a PCI _PRT table that uses the GNB IO-APIC / PIC :
50  * Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table
51  * {
52  * If (PICM)
53  * {
54  * Return (Package (0x04)
55  * {
56  * Package (0x04)
57  * {
58  * 0x0000FFFF,
59  * 0x00,
60  * 0x00,
61  * 0x00000034
62  * },
63  *
64  * Package (0x04)
65  * {
66  * 0x0000FFFF,
67  * 0x01,
68  * 0x00,
69  * 0x00000035
70  * },
71  *
72  * Package (0x04)
73  * {
74  * 0x0000FFFF,
75  * 0x02,
76  * 0x00,
77  * 0x00000036
78  * },
79  *
80  * Package (0x04)
81  * {
82  * 0x0000FFFF,
83  * 0x03,
84  * 0x00,
85  * 0x00000037
86  * }
87  * })
88  * }
89  * Else
90  * {
91  * Return (Package (0x04)
92  * {
93  * Package (0x04)
94  * {
95  * 0x0000FFFF,
96  * 0x00,
97  * \_SB.INTA,
98  * 0x00000000
99  * },
100  *
101  * Package (0x04)
102  * {
103  * 0x0000FFFF,
104  * 0x01,
105  * \_SB.INTB,
106  * 0x00000000
107  * },
108  *
109  * Package (0x04)
110  * {
111  * 0x0000FFFF,
112  * 0x02,
113  * \_SB.INTC,
114  * 0x00000000
115  * },
116  *
117  * Package (0x04)
118  * {
119  * 0x0000FFFF,
120  * 0x03,
121  * \_SB.INTD,
122  * 0x00000000
123  * }
124  * })
125  * }
126  * }
127  */
128 void acpigen_write_pci_GNB_PRT(const struct device *dev)
129 {
130  const struct pci_routing_info *routing_info =
132 
133  if (!routing_info)
134  return;
135 
136  acpigen_write_method("_PRT", 0);
137 
138  /* If (PICM) */
140  acpigen_emit_namestring("PICM");
141 
142  /* Return (Package{...}) */
144  acpigen_write_PRT_GSI(routing_info);
145 
146  /* Else */
148 
149  /* Return (Package{...}) */
151  acpigen_write_PRT_PIC(routing_info);
152 
153  acpigen_pop_len(); /* End Else */
154 
155  acpigen_pop_len(); /* Method */
156 }
157 
158  /*
159  * This method writes a PCI _PRT table that uses the FCH IO-APIC / PIC :
160  * Name (_PRT, Package (0x04)
161  * {
162  * Package (0x04)
163  * {
164  * 0x0000FFFF,
165  * 0x00,
166  * \_SB.INTA,
167  * 0x00000000
168  * },
169  *
170  * Package (0x04)
171  * {
172  * 0x0000FFFF,
173  * 0x01,
174  * \_SB.INTB,
175  * 0x00000000
176  * },
177  *
178  * Package (0x04)
179  * {
180  * 0x0000FFFF,
181  * 0x02,
182  * \_SB.INTC,
183  * 0x00000000
184  * },
185  *
186  * Package (0x04)
187  * {
188  * 0x0000FFFF,
189  * 0x03,
190  * \_SB.INTD,
191  * 0x00000000
192  * }
193  * })
194  */
195 void acpigen_write_pci_FCH_PRT(const struct device *dev)
196 {
197  const struct pci_routing_info *routing_info =
199 
200  if (!routing_info)
201  return;
202 
203  acpigen_write_name("_PRT");
204  acpigen_write_PRT_PIC(routing_info);
205 }
static void acpigen_write_PRT_PIC(const struct pci_routing_info *routing_info)
Definition: acpi_prt.c:28
void acpigen_write_pci_GNB_PRT(const struct device *dev)
Definition: acpi_prt.c:128
static void acpigen_write_PRT_GSI(const struct pci_routing_info *routing_info)
Definition: acpi_prt.c:10
void acpigen_write_pci_FCH_PRT(const struct device *dev)
Definition: acpi_prt.c:195
void acpigen_write_if(void)
Definition: acpigen.c:1437
void acpigen_emit_namestring(const char *namepath)
Definition: acpigen.c:275
void acpigen_pop_len(void)
Definition: acpigen.c:37
char * acpigen_write_package(int nr_el)
Definition: acpigen.c:86
void acpigen_emit_byte(unsigned char b)
Definition: acpigen.c:61
void acpigen_write_method(const char *name, int nargs)
Definition: acpigen.c:758
void acpigen_write_else(void)
Definition: acpigen.c:1510
void acpigen_write_name(const char *name)
Definition: acpigen.c:320
void acpigen_write_PRT_GSI_entry(unsigned int pci_dev, unsigned int acpi_pin, unsigned int gsi)
Definition: acpigen_pci.c:28
void acpigen_write_PRT_source_entry(unsigned int pci_dev, unsigned int acpi_pin, const char *source_path, unsigned int index)
Definition: acpigen_pci.c:43
#define IO_APIC_INTERRUPTS
Definition: ioapic.h:8
@ RETURN_OP
Definition: acpigen.h:146
unsigned int pci_calculate_irq(const struct pci_routing_info *routing_info, unsigned int pin)
const struct pci_routing_info * get_pci_routing_info(unsigned int devfn)
struct pci_path pci
Definition: path.h:116
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int devfn
Definition: path.h:54
Each PCI bridge has its INTx lines routed to one of the GNB IO-APIC PCI groups.
Definition: amd_pci_util.h:48