blob: ef5ff8d1a02dff2849a6fe227aec10e24a86b562 [file] [log] [blame]
Uwe Hermanncc447302008-12-15 12:15:49 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Uwe Hermanncc447302008-12-15 12:15:49 +000015 */
16
17#include <console/console.h>
18#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000019#include <arch/ioapic.h>
Uwe Hermanncc447302008-12-15 12:15:49 +000020#include <device/pci.h>
21#include <string.h>
22#include <stdint.h>
23
Myles Watson08e0fb82010-03-22 16:33:25 +000024static void *smp_write_config_table(void *v)
Uwe Hermanncc447302008-12-15 12:15:49 +000025{
Uwe Hermannda22d212010-10-30 21:27:13 +000026 int ioapic_id, ioapic_ver, isa_bus;
Uwe Hermanncc447302008-12-15 12:15:49 +000027 struct mp_config_table *mc;
28
29 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Uwe Hermanncc447302008-12-15 12:15:49 +000030
Patrick Georgic8feedd2012-02-16 18:43:25 +010031 mptable_init(mc, LOCAL_APIC_ADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000032
33 smp_write_processors(mc);
34
Uwe Hermannda22d212010-10-30 21:27:13 +000035 mptable_write_buses(mc, NULL, &isa_bus);
Uwe Hermanncc447302008-12-15 12:15:49 +000036
Uwe Hermannda22d212010-10-30 21:27:13 +000037 ioapic_id = 2;
38 ioapic_ver = 0x11; /* External Intel 82093AA IOAPIC. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080039 smp_write_ioapic(mc, ioapic_id, ioapic_ver, VIO_APIC_VADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000040
Uwe Hermannda22d212010-10-30 21:27:13 +000041 /* Legacy Interrupts */
42 mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0);
Uwe Hermanncc447302008-12-15 12:15:49 +000043
Uwe Hermannda22d212010-10-30 21:27:13 +000044 /* I/O Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
45 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x13, ioapic_id, 0x13);
46 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 +000047
Uwe Hermannda22d212010-10-30 21:27:13 +000048 /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
Patrick Georgi6eb7a532011-10-07 21:42:52 +020049 mptable_lintsrc(mc, 0x1);
Uwe Hermanncc447302008-12-15 12:15:49 +000050
Uwe Hermannda22d212010-10-30 21:27:13 +000051 /* Compute the checksums. */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +020052 return mptable_finalize(mc);
Uwe Hermanncc447302008-12-15 12:15:49 +000053}
54
55unsigned long write_smp_table(unsigned long addr)
56{
57 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +020058 v = smp_write_floating_table(addr, 0);
Uwe Hermanncc447302008-12-15 12:15:49 +000059 return (unsigned long)smp_write_config_table(v);
60}