blob: d77baea5ba77fd3749f7944733c5cd30bd65705b [file] [log] [blame]
Stefan Reinaueraeba92a2009-04-17 08:37:18 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 * MA 02110-1301 USA
20 */
21
22#include <device/device.h>
23#include <device/pci.h>
24#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000025#include <arch/ioapic.h>
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000026#include <cpu/x86/lapic.h>
27#include <console/console.h>
28#include <string.h>
29#include <stdint.h>
30
Myles Watson08e0fb82010-03-22 16:33:25 +000031static void *smp_write_config_table(void *v)
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000032{
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000033 struct mp_config_table *mc;
Patrick Georgi20979582010-09-24 18:42:56 +000034 int isa_bus;
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000035
36 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000037
Uwe Hermann55dc2232010-10-25 15:32:07 +000038 mptable_init(mc, "VT8454c ", LAPIC_ADDR);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000039
40 smp_write_processors(mc);
Patrick Georgi20979582010-09-24 18:42:56 +000041 mptable_write_buses(mc, NULL, &isa_bus);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000042
43 /* I/O APICs: APIC ID Version State Address */
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000044 smp_write_ioapic(mc, 2, 17, IO_APIC_ADDR);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000045
Patrick Georgi20979582010-09-24 18:42:56 +000046 mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
Patrick Georgic5b87c82010-05-20 15:28:19 +000047
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000048 /* I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
49 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x40, 0x2, 0x14);
50 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x41, 0x2, 0x16);
51 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x42, 0x2, 0x15);
52 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x43, 0x2, 0x17);
53 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x80, 0x4, 0x2, 0x11);
54 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x11);
55 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x2, 0x10, 0x2, 0x11);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000056
57 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Tobias Diedrichb907d322010-10-26 22:40:16 +000058 smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x0);
59 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x1);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000060
61 /* Compute the checksums */
62 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
63 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000064 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc));
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000065 return smp_next_mpe_entry(mc);
66}
67
68unsigned long write_smp_table(unsigned long addr)
69{
70 void *v;
71 v = smp_write_floating_table(addr);
72 return (unsigned long)smp_write_config_table(v);
73}