coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mptable.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <arch/smp/mpspec.h>
5 #include <arch/ioapic.h>
6 
7 static void *smp_write_config_table(void *v)
8 {
9  struct mp_config_table *mc;
10  struct device *riser = NULL, *firewire = NULL;
11  int firewire_bus = 0, riser_bus = 0, isa_bus;
12 
13  mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
14 
15  mptable_init(mc);
16 
18 
19  firewire = dev_find_device(0x104c, 0x8023, 0);
20  if (firewire) {
21  firewire_bus = firewire->bus->secondary;
22  }
23 
24  /* If a riser card is used, this riser is detected on bus 4, so its secondary bus is the */
25  /* highest bus number on the pci bus. */
26  riser = dev_find_device(0x3388, 0x0021, 0);
27  if (!riser)
28  riser = dev_find_device(0x3388, 0x0022, 0);
29  if (riser) {
30  riser_bus = riser->link_list->secondary;
31  }
32 
33  mptable_write_buses(mc, NULL, &isa_bus);
34 
35  /* I/O APICs: APIC ID Version State Address */
37 
38  /* Legacy Interrupts */
39  mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0);
40 
41  /* Builtin devices on Bus 0 */
42  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x01, 0, ioapic_id, 0x10);
43  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x02, 0, ioapic_id, 0x10);
44  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1f, 1, ioapic_id, 0x13);
45  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 0, ioapic_id, 0x17);
46  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 1, ioapic_id, 0x13);
47  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 2, ioapic_id, 0x12);
48  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 3, ioapic_id, 0x10);
49  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1b, 0, ioapic_id, 0x10);
50  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 0, ioapic_id, 0x10);
51  smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 1, ioapic_id, 0x11);
52 
53  /* Internal PCI bus (Firewire, PCI slot) */
54  if (firewire) {
55  smp_write_pci_intsrc(mc, mp_INT, firewire_bus, 0x00, 0, ioapic_id, 0x10);
56  smp_write_pci_intsrc(mc, mp_INT, firewire_bus, 0x01, 0, ioapic_id, 0x14);
57  }
58 
59  if (riser) {
60  /* Old riser card */
61  /* riser slot top 5:8.0 */
62  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x08, 0, ioapic_id, 0x14);
63  /* riser slot middle 5:9.0 */
64  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x09, 0, ioapic_id, 0x15);
65  /* riser slot bottom 5:a.0 */
66  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0a, 0, ioapic_id, 0x16);
67 
68  /* New Riser Card */
69  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0c, 0, ioapic_id, 0x14);
70  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0d, 0, ioapic_id, 0x15);
71  smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0e, 0, ioapic_id, 0x16);
72  }
73 
74  /* PCIe slot */
75  smp_write_pci_intsrc(mc, mp_INT, 0x1, 0x00, 0, ioapic_id, 0x10);
76  smp_write_pci_intsrc(mc, mp_INT, 0x1, 0x00, 1, ioapic_id, 0x11);
77 
78  /* Onboard Ethernet */
79  smp_write_pci_intsrc(mc, mp_INT, 0x2, 0x00, 0, ioapic_id, 0x10);
80 
81  /* Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
82  mptable_lintsrc(mc, isa_bus);
83 
84  /* Compute the checksums */
85  return mptable_finalize(mc);
86 }
87 
88 unsigned long write_smp_table(unsigned long addr)
89 {
90  void *v;
92  return (unsigned long)smp_write_config_table(v);
93 }
unsigned long write_smp_table(unsigned long addr)
Definition: mptable.c:48
#define VIO_APIC_VADDR
Definition: ioapic.h:7
static u32 addr
Definition: cirrus.c:14
struct device * dev_find_device(u16 vendor, u16 device, struct device *from)
Find a device of a given vendor and type.
Definition: device_util.c:42
static void * smp_write_config_table(void *v)
Definition: mptable.c:7
void * smp_write_floating_table(unsigned long addr, unsigned int virtualwire)
Definition: mpspec.c:84
@ mp_INT
Definition: mpspec.h:117
void * mptable_finalize(struct mp_config_table *mc)
Definition: mpspec.c:504
void mptable_lintsrc(struct mp_config_table *mc, unsigned long bus_isa)
Definition: mpspec.c:418
void mptable_init(struct mp_config_table *mc)
Definition: mpspec.c:14
#define SMP_FLOATING_TABLE_LEN
Definition: mpspec.h:26
void smp_write_processors(struct mp_config_table *mc)
Definition: mpspec.c:146
u8 smp_write_ioapic_from_hw(struct mp_config_table *mc, void *apicaddr)
Definition: mpspec.c:224
void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_bus)
Definition: mpspec.c:465
void smp_write_pci_intsrc(struct mp_config_table *mc, u8 irqtype, u8 srcbus, u8 dev, u8 pirq, u8 dstapic, u8 dstirq)
Definition: mpspec.c:264
void mptable_add_isa_interrupts(struct mp_config_table *mc, unsigned long bus_isa, unsigned long apicid, int external)
Definition: mpspec.c:426
#define NULL
Definition: stddef.h:19
uint8_t u8
Definition: stdint.h:45
uint16_t secondary
Definition: device.h:84
Definition: device.h:107
DEVTREE_CONST struct bus * link_list
Definition: device.h:139