blob: bd1891defacf23a2d9e98a91b0716415bb7ec5ad [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Patrick Georgiac959032020-05-05 22:49:26 +02002/* SPDX-License-Identifier: GPL-2.0-or-later */
Uwe Hermanncc447302008-12-15 12:15:49 +00003
Uwe Hermanncc447302008-12-15 12:15:49 +00004#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +00005#include <arch/ioapic.h>
Uwe Hermanncc447302008-12-15 12:15:49 +00006#include <stdint.h>
7
Myles Watson08e0fb82010-03-22 16:33:25 +00008static void *smp_write_config_table(void *v)
Uwe Hermanncc447302008-12-15 12:15:49 +00009{
Uwe Hermannda22d212010-10-30 21:27:13 +000010 int ioapic_id, ioapic_ver, isa_bus;
Uwe Hermanncc447302008-12-15 12:15:49 +000011 struct mp_config_table *mc;
12
13 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Uwe Hermanncc447302008-12-15 12:15:49 +000014
Patrick Georgic8feedd2012-02-16 18:43:25 +010015 mptable_init(mc, LOCAL_APIC_ADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000016
17 smp_write_processors(mc);
18
Uwe Hermannda22d212010-10-30 21:27:13 +000019 mptable_write_buses(mc, NULL, &isa_bus);
Uwe Hermanncc447302008-12-15 12:15:49 +000020
Uwe Hermannda22d212010-10-30 21:27:13 +000021 ioapic_id = 2;
22 ioapic_ver = 0x11; /* External Intel 82093AA IOAPIC. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080023 smp_write_ioapic(mc, ioapic_id, ioapic_ver, VIO_APIC_VADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000024
Uwe Hermannda22d212010-10-30 21:27:13 +000025 /* Legacy Interrupts */
26 mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0);
Uwe Hermanncc447302008-12-15 12:15:49 +000027
Uwe Hermannda22d212010-10-30 21:27:13 +000028 /* I/O Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
29 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x13, ioapic_id, 0x13);
30 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x18, ioapic_id, 0x13);
Patrick Georgic5b87c82010-05-20 15:28:19 +000031
Uwe Hermannda22d212010-10-30 21:27:13 +000032 /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020033 mptable_lintsrc(mc, 0x1);
Uwe Hermanncc447302008-12-15 12:15:49 +000034
Uwe Hermannda22d212010-10-30 21:27:13 +000035 /* Compute the checksums. */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020036 return mptable_finalize(mc);
Uwe Hermanncc447302008-12-15 12:15:49 +000037}
38
39unsigned long write_smp_table(unsigned long addr)
40{
41 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020042 v = smp_write_floating_table(addr, 0);
Uwe Hermanncc447302008-12-15 12:15:49 +000043 return (unsigned long)smp_write_config_table(v);
44}