Angel Pons | 0c58dc6 | 2020-04-03 01:21:09 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 4 | #include <arch/smp/mpspec.h> |
| 5 | #include <arch/ioapic.h> |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 6 | |
| 7 | static void *smp_write_config_table(void *v) |
| 8 | { |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 9 | struct mp_config_table *mc; |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 10 | int isa_bus; |
| 11 | |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 12 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 13 | |
Kyösti Mälkki | dea42e0 | 2021-05-31 20:26:16 +0300 | [diff] [blame] | 14 | mptable_init(mc); |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 15 | |
Elyes HAOUAS | 8da96e5 | 2016-09-22 21:20:54 +0200 | [diff] [blame] | 16 | smp_write_processors(mc); |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 17 | |
| 18 | mptable_write_buses(mc, NULL, &isa_bus); |
| 19 | |
| 20 | /* I/O APICs: APIC ID Version State Address */ |
Felix Held | 0d19289 | 2024-02-06 16:55:29 +0100 | [diff] [blame^] | 21 | u8 ioapic_id = smp_write_ioapic_from_hw(mc, IO_APIC_ADDR); |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 22 | |
| 23 | /* Legacy Interrupts */ |
Kyösti Mälkki | 860cff9 | 2021-06-07 22:20:57 +0300 | [diff] [blame] | 24 | mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0); |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 25 | |
| 26 | smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, isa_bus, 0x00, MP_APIC_ALL, 0x00); |
| 27 | smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x00, MP_APIC_ALL, 0x01); |
Kyösti Mälkki | 860cff9 | 2021-06-07 22:20:57 +0300 | [diff] [blame] | 28 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x01, 0x00, ioapic_id, 0x10); /* PCIe root 0.01.0 */ |
| 29 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x02, 0x00, ioapic_id, 0x10); /* VGA 0.02.0 */ |
| 30 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1b, 0x00, ioapic_id, 0x16); /* HD Audio 0:1b.0 */ |
| 31 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x00, ioapic_id, 0x11); /* PCIe 0:1c.0 */ |
| 32 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x01, ioapic_id, 0x10); /* PCIe 0:1c.1 */ |
| 33 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x02, ioapic_id, 0x12); /* PCIe 0:1c.2 */ |
| 34 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x03, ioapic_id, 0x13); /* PCIe 0:1c.3 */ |
| 35 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x00, ioapic_id, 0x15); /* USB 0:1d.0 */ |
| 36 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x01, ioapic_id, 0x13); /* USB 0:1d.1 */ |
| 37 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x02, ioapic_id, 0x12); /* USB 0:1d.2 */ |
| 38 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x03, ioapic_id, 0x10); /* USB 0:1d.3 */ |
| 39 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x00, ioapic_id, 0x12); /* LPC 0:1f.0 */ |
| 40 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x01, ioapic_id, 0x13); /* IDE 0:1f.1 */ |
| 41 | smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x03, ioapic_id, 0x10); /* SATA 0:1f.3 */ |
| 42 | smp_write_pci_intsrc(mc, mp_INT, 0x03, 0x03, 0x00, ioapic_id, 0x13); /* Firewire 3:03.0 */ |
Mono | 9b90824 | 2014-03-02 18:40:36 +0100 | [diff] [blame] | 43 | |
| 44 | mptable_lintsrc(mc, isa_bus); |
| 45 | return mptable_finalize(mc); |
| 46 | } |
| 47 | |
| 48 | unsigned long write_smp_table(unsigned long addr) |
| 49 | { |
| 50 | void *v; |
| 51 | v = smp_write_floating_table(addr, 0); |
| 52 | return (unsigned long)smp_write_config_table(v); |
| 53 | } |