Patrick Georgi | 02363b5 | 2020-05-05 20:48:50 +0200 | [diff] [blame] | 1 | /* This file is part of the coreboot project. */ |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 2 | /* |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 13 | */ |
| 14 | |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 15 | #include <arch/smp/mpspec.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 16 | #include <arch/ioapic.h> |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 17 | #include <stdint.h> |
| 18 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 19 | static void *smp_write_config_table(void *v) |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 20 | { |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 21 | int ioapic_id, ioapic_ver, isa_bus; |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 22 | struct mp_config_table *mc; |
| 23 | |
| 24 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 25 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 26 | mptable_init(mc, LOCAL_APIC_ADDR); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 27 | |
| 28 | smp_write_processors(mc); |
| 29 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 30 | mptable_write_buses(mc, NULL, &isa_bus); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 31 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 32 | ioapic_id = 2; |
| 33 | ioapic_ver = 0x11; /* External Intel 82093AA IOAPIC. */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 34 | smp_write_ioapic(mc, ioapic_id, ioapic_ver, VIO_APIC_VADDR); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 35 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 36 | /* Legacy Interrupts */ |
| 37 | mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 38 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 39 | /* I/O Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */ |
| 40 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x13, ioapic_id, 0x13); |
| 41 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x18, ioapic_id, 0x13); |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 42 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 43 | /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 44 | mptable_lintsrc(mc, 0x1); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 45 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 46 | /* Compute the checksums. */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 47 | return mptable_finalize(mc); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | unsigned long write_smp_table(unsigned long addr) |
| 51 | { |
| 52 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 53 | v = smp_write_floating_table(addr, 0); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 54 | return (unsigned long)smp_write_config_table(v); |
| 55 | } |