blob: 7c024152ff9f6777eaac55b5808476b52512909f [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.
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, MA 02110-1301 USA
19 */
20
21#include <console/console.h>
22#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000023#include <arch/ioapic.h>
Uwe Hermanncc447302008-12-15 12:15:49 +000024#include <device/pci.h>
25#include <string.h>
26#include <stdint.h>
27
Myles Watson08e0fb82010-03-22 16:33:25 +000028static void *smp_write_config_table(void *v)
Uwe Hermanncc447302008-12-15 12:15:49 +000029{
Uwe Hermannda22d212010-10-30 21:27:13 +000030 int ioapic_id, ioapic_ver, isa_bus;
Uwe Hermanncc447302008-12-15 12:15:49 +000031 struct mp_config_table *mc;
32
33 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Uwe Hermanncc447302008-12-15 12:15:49 +000034
Uwe Hermann55dc2232010-10-25 15:32:07 +000035 mptable_init(mc, "P2B-DS ", LAPIC_ADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000036
37 smp_write_processors(mc);
38
Uwe Hermannda22d212010-10-30 21:27:13 +000039 mptable_write_buses(mc, NULL, &isa_bus);
Uwe Hermanncc447302008-12-15 12:15:49 +000040
Uwe Hermannda22d212010-10-30 21:27:13 +000041 ioapic_id = 2;
42 ioapic_ver = 0x11; /* External Intel 82093AA IOAPIC. */
43 smp_write_ioapic(mc, ioapic_id, ioapic_ver, IO_APIC_ADDR);
Uwe Hermanncc447302008-12-15 12:15:49 +000044
Uwe Hermannda22d212010-10-30 21:27:13 +000045 /* Legacy Interrupts */
46 mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0);
Uwe Hermanncc447302008-12-15 12:15:49 +000047
Uwe Hermannda22d212010-10-30 21:27:13 +000048 /* I/O Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
49 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x13, ioapic_id, 0x13);
50 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 +000051
Uwe Hermannda22d212010-10-30 21:27:13 +000052 /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */
53 smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 0x1, 0x0, MP_APIC_ALL, 0x0);
54 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 0x1, 0x0, MP_APIC_ALL, 0x1);
Uwe Hermanncc447302008-12-15 12:15:49 +000055
Uwe Hermannda22d212010-10-30 21:27:13 +000056 /* Compute the checksums. */
Uwe Hermanncc447302008-12-15 12:15:49 +000057 mc->mpe_checksum =
58 smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
59 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000060 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
Uwe Hermanncc447302008-12-15 12:15:49 +000061 mc, smp_next_mpe_entry(mc));
62 return smp_next_mpe_entry(mc);
63}
64
65unsigned long write_smp_table(unsigned long addr)
66{
67 void *v;
68 v = smp_write_floating_table(addr);
69 return (unsigned long)smp_write_config_table(v);
70}