Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 1 | /* |
| 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 Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 23 | #include <arch/ioapic.h> |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 24 | #include <device/pci.h> |
| 25 | #include <string.h> |
| 26 | #include <stdint.h> |
| 27 | |
Myles Watson | 08e0fb8 | 2010-03-22 16:33:25 +0000 | [diff] [blame] | 28 | static void *smp_write_config_table(void *v) |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 29 | { |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 30 | int ioapic_id, ioapic_ver, isa_bus; |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 31 | struct mp_config_table *mc; |
| 32 | |
| 33 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 34 | |
Uwe Hermann | c36d506 | 2010-12-16 19:51:38 +0000 | [diff] [blame] | 35 | mptable_init(mc, LAPIC_ADDR); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 36 | |
| 37 | smp_write_processors(mc); |
| 38 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 39 | mptable_write_buses(mc, NULL, &isa_bus); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 40 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 41 | ioapic_id = 2; |
| 42 | ioapic_ver = 0x11; /* External Intel 82093AA IOAPIC. */ |
| 43 | smp_write_ioapic(mc, ioapic_id, ioapic_ver, IO_APIC_ADDR); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 44 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 45 | /* Legacy Interrupts */ |
| 46 | mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 47 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 48 | /* 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 Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 51 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 52 | /* Local Ints: Type Trigger Polarity Bus ID IRQ APIC ID PIN# */ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 53 | mptable_lintsrc(mc, 0x1); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 54 | |
Uwe Hermann | da22d21 | 2010-10-30 21:27:13 +0000 | [diff] [blame] | 55 | /* Compute the checksums. */ |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 56 | mc->mpe_checksum = |
| 57 | smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); |
| 58 | mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 59 | printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 60 | mc, smp_next_mpe_entry(mc)); |
| 61 | return smp_next_mpe_entry(mc); |
| 62 | } |
| 63 | |
| 64 | unsigned long write_smp_table(unsigned long addr) |
| 65 | { |
| 66 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame^] | 67 | v = smp_write_floating_table(addr, 0); |
Uwe Hermann | cc44730 | 2008-12-15 12:15:49 +0000 | [diff] [blame] | 68 | return (unsigned long)smp_write_config_table(v); |
| 69 | } |