2009-02-28 00:09:55 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
2009-05-26 16:07:44 +02:00
|
|
|
* Copyright (C) 2003 Eric Biederman
|
|
|
|
* Copyright (C) 2005 Steve Magnani
|
2009-02-28 00:09:55 +01:00
|
|
|
* Copyright (C) 2008-2009 coresystems GmbH
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-07-19 17:32:49 +02:00
|
|
|
|
|
|
|
/* 2006.1 yhlu add mptable cross 0x467 processing */
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <cpu/cpu.h>
|
|
|
|
#include <boot/tables.h>
|
2008-01-18 17:16:45 +01:00
|
|
|
#include <boot/coreboot_tables.h>
|
2003-04-22 21:02:15 +02:00
|
|
|
#include <arch/pirq_routing.h>
|
|
|
|
#include <arch/smp/mpspec.h>
|
2004-01-28 17:56:14 +01:00
|
|
|
#include <arch/acpi.h>
|
2007-10-24 00:17:45 +02:00
|
|
|
#include <string.h>
|
2008-11-11 21:20:54 +01:00
|
|
|
#include <cpu/x86/multiboot.h>
|
2008-01-18 17:16:45 +01:00
|
|
|
#include "coreboot_table.h"
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2005-09-12 20:41:30 +02:00
|
|
|
// Global Descriptor Table, defined in c_start.S
|
|
|
|
extern uint8_t gdt;
|
|
|
|
extern uint8_t gdt_end;
|
|
|
|
|
|
|
|
/* i386 lgdt argument */
|
|
|
|
struct gdtarg {
|
2006-07-19 17:32:49 +02:00
|
|
|
unsigned short limit;
|
|
|
|
unsigned int base;
|
2005-09-12 20:41:30 +02:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
// Copy GDT to new location and reload it
|
|
|
|
void move_gdt(unsigned long newgdt)
|
|
|
|
{
|
|
|
|
uint16_t num_gdt_bytes = &gdt_end - &gdt;
|
2006-07-19 17:32:49 +02:00
|
|
|
struct gdtarg gdtarg;
|
|
|
|
|
|
|
|
printk_debug("Moving GDT to %#lx...", newgdt);
|
|
|
|
memcpy((void*)newgdt, &gdt, num_gdt_bytes);
|
|
|
|
gdtarg.base = newgdt;
|
|
|
|
gdtarg.limit = num_gdt_bytes - 1;
|
|
|
|
__asm__ __volatile__ ("lgdt %0\n\t" : : "m" (gdtarg));
|
|
|
|
printk_debug("ok\n");
|
2005-09-12 20:41:30 +02:00
|
|
|
}
|
|
|
|
|
2009-02-28 00:09:55 +01:00
|
|
|
uint64_t high_tables_base = 0;
|
|
|
|
uint64_t high_tables_size;
|
|
|
|
|
2004-10-14 22:54:17 +02:00
|
|
|
struct lb_memory *write_tables(void)
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
2009-04-06 16:00:53 +02:00
|
|
|
unsigned long low_table_start, low_table_end;
|
2003-04-22 21:02:15 +02:00
|
|
|
unsigned long rom_table_start, rom_table_end;
|
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
/* Even if high tables are configured, some tables are copied both to
|
|
|
|
* the low and the high area, so payloads and OSes don't need to know
|
|
|
|
* about the high tables.
|
2009-02-28 00:09:55 +01:00
|
|
|
*/
|
2009-05-26 21:39:14 +02:00
|
|
|
unsigned long high_table_end=0;
|
2009-02-28 00:09:55 +01:00
|
|
|
|
|
|
|
if (high_tables_base) {
|
2009-03-17 15:38:48 +01:00
|
|
|
printk_debug("High Tables Base is %llx.\n", high_tables_base);
|
2009-02-28 00:09:55 +01:00
|
|
|
high_table_end = high_tables_base;
|
|
|
|
} else {
|
2009-05-26 16:07:44 +02:00
|
|
|
printk_err("ERROR: High Tables Base is not set.\n");
|
2009-02-28 00:09:55 +01:00
|
|
|
}
|
|
|
|
|
2007-04-06 22:27:40 +02:00
|
|
|
rom_table_start = 0xf0000;
|
2003-04-22 21:02:15 +02:00
|
|
|
rom_table_end = 0xf0000;
|
2009-05-26 16:07:44 +02:00
|
|
|
|
|
|
|
/* Start low addr at 0x500, so we don't run into conflicts with the BDA
|
|
|
|
* in case our data structures grow beyound 0x400. Only multiboot, GDT
|
|
|
|
* and the coreboot table use low_tables.
|
2003-04-22 21:02:15 +02:00
|
|
|
*/
|
|
|
|
low_table_start = 0;
|
2009-05-26 16:07:44 +02:00
|
|
|
low_table_end = 0x500;
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x99);
|
2004-04-15 19:33:21 +02:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
/* This table must be between 0x0f0000 and 0x100000 */
|
2005-08-10 17:16:44 +02:00
|
|
|
rom_table_end = write_pirq_routing_table(rom_table_end);
|
2009-05-26 16:07:44 +02:00
|
|
|
rom_table_end = ALIGN(rom_table_end, 1024);
|
|
|
|
|
|
|
|
/* And add a high table version for those payloads that
|
|
|
|
* want to live in the F segment
|
|
|
|
*/
|
2009-02-28 00:09:55 +01:00
|
|
|
if (high_tables_base) {
|
|
|
|
high_table_end = write_pirq_routing_table(high_table_end);
|
2009-05-26 16:07:44 +02:00
|
|
|
high_table_end = ALIGN(high_table_end, 1024);
|
2009-02-28 00:09:55 +01:00
|
|
|
}
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x9a);
|
|
|
|
|
|
|
|
/* Write ACPI tables to F segment and high tables area */
|
2009-04-28 16:49:21 +02:00
|
|
|
#if HAVE_ACPI_TABLES == 1
|
2009-05-01 00:45:41 +02:00
|
|
|
if (high_tables_base) {
|
2009-05-26 21:39:14 +02:00
|
|
|
unsigned long acpi_start = high_table_end;
|
|
|
|
rom_table_end = ALIGN(rom_table_end, 16);
|
2009-05-01 00:45:41 +02:00
|
|
|
high_table_end = write_acpi_tables(high_table_end);
|
2009-05-26 21:39:14 +02:00
|
|
|
while (acpi_start < high_table_end) {
|
|
|
|
if (memcmp(((acpi_rsdp_t *)acpi_start)->signature, RSDP_SIG, 8) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
acpi_start++;
|
|
|
|
}
|
|
|
|
if (acpi_start != high_table_end) {
|
|
|
|
acpi_write_rsdp((acpi_rsdp_t *)rom_table_end, ((acpi_rsdp_t *)acpi_start)->rsdt_address);
|
|
|
|
} else {
|
|
|
|
printk_err("ERROR: Didn't find RSDP in high table.\n");
|
|
|
|
}
|
2009-05-26 16:07:44 +02:00
|
|
|
high_table_end = ALIGN(high_table_end, 1024);
|
2009-05-26 21:39:14 +02:00
|
|
|
rom_table_end = ALIGN(rom_table_end + sizeof(acpi_rsdp_t), 16);
|
2009-05-26 16:07:44 +02:00
|
|
|
} else {
|
|
|
|
rom_table_end = write_acpi_tables(rom_table_end);
|
|
|
|
rom_table_end = ALIGN(rom_table_end, 1024);
|
2009-05-01 00:45:41 +02:00
|
|
|
}
|
2009-05-13 16:39:59 +02:00
|
|
|
#endif
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x9b);
|
2006-07-19 17:32:49 +02:00
|
|
|
|
2009-03-12 18:42:20 +01:00
|
|
|
#if HAVE_MP_TABLE == 1
|
2006-07-19 17:32:49 +02:00
|
|
|
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
|
2009-05-26 16:07:44 +02:00
|
|
|
rom_table_end = write_smp_table(rom_table_end);
|
|
|
|
rom_table_end = ALIGN(rom_table_end, 1024);
|
2009-04-27 22:00:29 +02:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
/* ... and a copy in the high tables */
|
2009-04-27 22:00:29 +02:00
|
|
|
if (high_tables_base) {
|
|
|
|
high_table_end = write_smp_table(high_table_end);
|
2009-05-26 16:07:44 +02:00
|
|
|
high_table_end = ALIGN(high_table_end, 1024);
|
2009-04-27 22:00:29 +02:00
|
|
|
}
|
2009-03-12 18:42:20 +01:00
|
|
|
#endif /* HAVE_MP_TABLE */
|
2007-04-06 22:27:40 +02:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x9c);
|
2004-01-28 17:56:14 +01:00
|
|
|
|
2005-09-12 20:41:30 +02:00
|
|
|
// Relocate the GDT to reserved memory, so it won't get clobbered
|
2009-02-28 00:09:55 +01:00
|
|
|
if (high_tables_base) {
|
|
|
|
move_gdt(high_table_end);
|
|
|
|
high_table_end += &gdt_end - &gdt;
|
2009-05-26 16:07:44 +02:00
|
|
|
high_table_end = ALIGN(high_table_end, 1024);
|
2009-02-28 00:09:55 +01:00
|
|
|
} else {
|
|
|
|
move_gdt(low_table_end);
|
|
|
|
low_table_end += &gdt_end - &gdt;
|
|
|
|
}
|
2009-05-26 16:07:44 +02:00
|
|
|
|
|
|
|
post_code(0x9d);
|
2005-09-12 20:41:30 +02:00
|
|
|
|
2008-11-11 21:20:54 +01:00
|
|
|
#if CONFIG_MULTIBOOT
|
|
|
|
/* The Multiboot information structure */
|
|
|
|
rom_table_end = write_multiboot_info(
|
|
|
|
low_table_start, low_table_end,
|
|
|
|
rom_table_start, rom_table_end);
|
|
|
|
#endif
|
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x9e);
|
|
|
|
|
2009-03-17 15:38:48 +01:00
|
|
|
if (high_tables_base) {
|
2009-05-26 16:07:44 +02:00
|
|
|
/* Also put a forwarder entry into 0-4K */
|
2009-03-17 15:38:48 +01:00
|
|
|
write_coreboot_table(low_table_start, low_table_end,
|
2009-05-26 21:39:14 +02:00
|
|
|
high_tables_base, high_table_end);
|
|
|
|
if (high_table_end > high_tables_base + high_tables_size)
|
|
|
|
printk_err("%s: High tables didn't fit in %llx (%llx)\n",
|
|
|
|
__func__, high_tables_size, high_table_end -
|
|
|
|
high_tables_base);
|
2009-03-17 15:38:48 +01:00
|
|
|
} else {
|
2009-05-26 16:07:44 +02:00
|
|
|
/* The coreboot table must be in 0-4K or 960K-1M */
|
2009-03-17 15:38:48 +01:00
|
|
|
write_coreboot_table(low_table_start, low_table_end,
|
|
|
|
rom_table_start, rom_table_end);
|
|
|
|
}
|
2009-02-28 00:09:55 +01:00
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
post_code(0x9f);
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
return get_lb_mem();
|
|
|
|
}
|