blob: 588694f6b340cec5832a74e4a0936a8685542a60 [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>
25#include <cpu/x86/lapic.h>
26#include <console/console.h>
27#include <string.h>
28#include <stdint.h>
29
Myles Watson08e0fb82010-03-22 16:33:25 +000030static void *smp_write_config_table(void *v)
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000031{
32 static const char sig[4] = MPC_SIGNATURE;
33 static const char oem[8] = "COREBOOT";
34 static const char productid[12] = "VIA VT8454C ";
35 struct mp_config_table *mc;
Patrick Georgi20979582010-09-24 18:42:56 +000036 int isa_bus;
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000037
38 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
39 memset(mc, 0, sizeof(*mc));
40
41 memcpy(mc->mpc_signature, sig, sizeof(sig));
42 mc->mpc_length = sizeof(*mc); /* initially just the header */
43 mc->mpc_spec = 0x04;
44 mc->mpc_checksum = 0; /* not yet computed */
45 memcpy(mc->mpc_oem, oem, sizeof(oem));
46 memcpy(mc->mpc_productid, productid, sizeof(productid));
47 mc->mpc_oemptr = 0;
48 mc->mpc_oemsize = 0;
49 mc->mpc_entry_count = 0; /* No entries yet... */
50 mc->mpc_lapic = LAPIC_ADDR;
51 mc->mpe_length = 0;
52 mc->mpe_checksum = 0;
53 mc->reserved = 0;
54
55 smp_write_processors(mc);
Patrick Georgi20979582010-09-24 18:42:56 +000056 mptable_write_buses(mc, NULL, &isa_bus);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000057
58 /* I/O APICs: APIC ID Version State Address */
59 smp_write_ioapic(mc, 2, 17, 0xfec00000);
60
Patrick Georgi20979582010-09-24 18:42:56 +000061 mptable_add_isa_interrupts(mc, isa_bus, 0x2, 0);
Patrick Georgic5b87c82010-05-20 15:28:19 +000062
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000063 /* I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
64 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x40, 0x2, 0x14);
65 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x41, 0x2, 0x16);
66 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x42, 0x2, 0x15);
67 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x0, 0x43, 0x2, 0x17);
68 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x80, 0x4, 0x2, 0x11);
69 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x11);
70 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 +000071
72 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
73 smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x0);
74 smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x1);
75
76 /* Compute the checksums */
77 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
78 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000079 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 +000080 return smp_next_mpe_entry(mc);
81}
82
83unsigned long write_smp_table(unsigned long addr)
84{
85 void *v;
86 v = smp_write_floating_table(addr);
87 return (unsigned long)smp_write_config_table(v);
88}