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.
|
|
|
|
*/
|
2006-07-19 17:32:49 +02:00
|
|
|
|
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>
|
2009-10-26 18:04:28 +01:00
|
|
|
#include <cbmem.h>
|
2011-08-14 20:56:34 +02:00
|
|
|
#include <smbios.h>
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2016-04-19 22:17:08 +02:00
|
|
|
#define MAX_COREBOOT_TABLE_SIZE CONFIG_COREBOOT_TABLE_SIZE
|
|
|
|
|
2014-02-19 02:36:05 +01:00
|
|
|
void 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-10-26 18:04:28 +01:00
|
|
|
unsigned long high_table_pointer;
|
2009-02-28 00:09:55 +01:00
|
|
|
|
2010-04-27 08:56:47 +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
|
2014-01-06 20:40:27 +01:00
|
|
|
* in case our data structures grow beyond 0x400. Only GDT
|
2010-04-27 08:56:47 +02:00
|
|
|
* 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
|
|
|
|
Clean up #ifs
Replace #if CONFIG_FOO==1 with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1[[:space:]]*\$,#if \1," {} +
Replace #if (CONFIG_FOO==1) with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1)[[:space:]]*\$,#if \1," {} +
Replace #if CONFIG_FOO==0 with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0[[:space:]]*\$,#if \!\1," {} +
Replace #if (CONFIG_FOO==0) with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0)[[:space:]]*\$,#if \!\1," {} +
(and some manual changes to fix false positives)
Change-Id: Iac6ca7605a5f99885258cf1a9a2473a92de27c42
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/1004
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Martin Roth <martin@se-eng.com>
2012-05-05 15:29:32 +02:00
|
|
|
#if CONFIG_GENERATE_PIRQ_TABLE
|
2009-10-26 18:04:28 +01:00
|
|
|
#define MAX_PIRQ_TABLE_SIZE (4 * 1024)
|
|
|
|
post_code(0x9a);
|
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-10-26 18:04:28 +01:00
|
|
|
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_PIRQ, MAX_PIRQ_TABLE_SIZE);
|
|
|
|
if (high_table_pointer) {
|
|
|
|
unsigned long new_high_table_pointer;
|
|
|
|
new_high_table_pointer = write_pirq_routing_table(high_table_pointer);
|
|
|
|
// FIXME make pirq table code intelligent enough to know how
|
|
|
|
// much space it's going to need.
|
|
|
|
if (new_high_table_pointer > (high_table_pointer + MAX_PIRQ_TABLE_SIZE)) {
|
|
|
|
printk(BIOS_ERR, "ERROR: Increase PIRQ size.\n");
|
|
|
|
}
|
|
|
|
printk(BIOS_DEBUG, "PIRQ table: %ld bytes.\n",
|
|
|
|
new_high_table_pointer - high_table_pointer);
|
2009-02-28 00:09:55 +01:00
|
|
|
}
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2009-10-26 18:04:28 +01:00
|
|
|
#endif
|
|
|
|
|
Clean up #ifs
Replace #if CONFIG_FOO==1 with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1[[:space:]]*\$,#if \1," {} +
Replace #if (CONFIG_FOO==1) with #if CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*1)[[:space:]]*\$,#if \1," {} +
Replace #if CONFIG_FOO==0 with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0[[:space:]]*\$,#if \!\1," {} +
Replace #if (CONFIG_FOO==0) with #if !CONFIG_FOO:
find src -name \*.[ch] -exec sed -i "s,#if[[:space:]]*(\(CONFIG_[A-Z0-9_]*\)[[:space:]]*==[[:space:]]*0)[[:space:]]*\$,#if \!\1," {} +
(and some manual changes to fix false positives)
Change-Id: Iac6ca7605a5f99885258cf1a9a2473a92de27c42
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/1004
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Martin Roth <martin@se-eng.com>
2012-05-05 15:29:32 +02:00
|
|
|
#if CONFIG_GENERATE_MP_TABLE
|
2009-10-26 18:04:28 +01:00
|
|
|
#define MAX_MP_TABLE_SIZE (4 * 1024)
|
|
|
|
post_code(0x9b);
|
|
|
|
|
|
|
|
/* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
|
|
|
|
rom_table_end = write_smp_table(rom_table_end);
|
|
|
|
rom_table_end = ALIGN(rom_table_end, 1024);
|
|
|
|
|
|
|
|
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_MPTABLE, MAX_MP_TABLE_SIZE);
|
|
|
|
if (high_table_pointer) {
|
|
|
|
unsigned long new_high_table_pointer;
|
|
|
|
new_high_table_pointer = write_smp_table(high_table_pointer);
|
|
|
|
// FIXME make mp table code intelligent enough to know how
|
|
|
|
// much space it's going to need.
|
|
|
|
if (new_high_table_pointer > (high_table_pointer + MAX_MP_TABLE_SIZE)) {
|
|
|
|
printk(BIOS_ERR, "ERROR: Increase MP table size.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "MP table: %ld bytes.\n",
|
|
|
|
new_high_table_pointer - high_table_pointer);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_GENERATE_MP_TABLE */
|
2009-05-26 16:07:44 +02:00
|
|
|
|
2014-01-03 15:55:40 +01:00
|
|
|
#if CONFIG_HAVE_ACPI_TABLES
|
2014-08-28 23:03:15 +02:00
|
|
|
#define MAX_ACPI_SIZE (144 * 1024)
|
2014-11-28 10:24:19 +01:00
|
|
|
|
2009-10-26 18:04:28 +01:00
|
|
|
post_code(0x9c);
|
|
|
|
|
|
|
|
/* Write ACPI tables to F segment and high tables area */
|
|
|
|
|
|
|
|
/* Ok, this is a bit hacky still, because some day we want to have this
|
2010-04-27 08:56:47 +02:00
|
|
|
* completely dynamic. But right now we are setting fixed sizes.
|
2009-10-26 18:04:28 +01:00
|
|
|
* It's probably still better than the old high_table_base code because
|
|
|
|
* now at least we know when we have an overflow in the area.
|
|
|
|
*
|
|
|
|
* We want to use 1MB - 64K for Resume backup. We use 512B for TOC and
|
|
|
|
* 512 byte for GDT, 4K for PIRQ and 4K for MP table and 8KB for the
|
|
|
|
* coreboot table. This leaves us with 47KB for all of ACPI. Let's see
|
|
|
|
* how far we get.
|
|
|
|
*/
|
|
|
|
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_ACPI, MAX_ACPI_SIZE);
|
|
|
|
if (high_table_pointer) {
|
|
|
|
unsigned long acpi_start = high_table_pointer;
|
|
|
|
unsigned long new_high_table_pointer;
|
|
|
|
|
2009-05-26 21:39:14 +02:00
|
|
|
rom_table_end = ALIGN(rom_table_end, 16);
|
2009-10-26 18:04:28 +01:00
|
|
|
new_high_table_pointer = write_acpi_tables(high_table_pointer);
|
|
|
|
if (new_high_table_pointer > ( high_table_pointer + MAX_ACPI_SIZE)) {
|
|
|
|
printk(BIOS_ERR, "ERROR: Increase ACPI size\n");
|
|
|
|
}
|
2016-01-06 23:21:02 +01:00
|
|
|
printk(BIOS_DEBUG, "ACPI tables: %ld bytes.\n",
|
2009-10-26 18:04:28 +01:00
|
|
|
new_high_table_pointer - high_table_pointer);
|
|
|
|
|
|
|
|
/* Now we need to create a low table copy of the RSDP. */
|
|
|
|
|
|
|
|
/* First we look for the high table RSDP */
|
|
|
|
while (acpi_start < new_high_table_pointer) {
|
2009-05-26 21:39:14 +02:00
|
|
|
if (memcmp(((acpi_rsdp_t *)acpi_start)->signature, RSDP_SIG, 8) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
acpi_start++;
|
|
|
|
}
|
2009-10-26 18:04:28 +01:00
|
|
|
|
|
|
|
/* Now, if we found the RSDP, we take the RSDT and XSDT pointer
|
|
|
|
* from it in order to write the low RSDP
|
|
|
|
*/
|
|
|
|
if (acpi_start < new_high_table_pointer) {
|
2009-07-21 23:38:33 +02:00
|
|
|
acpi_rsdp_t *low_rsdp = (acpi_rsdp_t *)rom_table_end,
|
|
|
|
*high_rsdp = (acpi_rsdp_t *)acpi_start;
|
|
|
|
|
2014-10-26 20:42:08 +01:00
|
|
|
/* Technically rsdp length varies but coreboot always
|
|
|
|
writes longest size available. */
|
|
|
|
memcpy(low_rsdp, high_rsdp, sizeof(acpi_rsdp_t));
|
2009-05-26 21:39:14 +02:00
|
|
|
} else {
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_ERR, "ERROR: Didn't find RSDP in high table.\n");
|
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
|
|
|
}
|
2004-01-28 17:56:14 +01:00
|
|
|
|
2009-10-26 18:04:28 +01:00
|
|
|
#endif
|
2011-08-14 20:56:34 +02:00
|
|
|
#define MAX_SMBIOS_SIZE 2048
|
|
|
|
#if CONFIG_GENERATE_SMBIOS_TABLES
|
|
|
|
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_SMBIOS, MAX_SMBIOS_SIZE);
|
|
|
|
if (high_table_pointer) {
|
|
|
|
unsigned long new_high_table_pointer;
|
2009-05-26 16:07:44 +02:00
|
|
|
|
2011-08-14 20:56:34 +02:00
|
|
|
new_high_table_pointer = smbios_write_tables(high_table_pointer);
|
|
|
|
rom_table_end = ALIGN(rom_table_end, 16);
|
|
|
|
memcpy((void *)rom_table_end, (void *)high_table_pointer, sizeof(struct smbios_entry));
|
|
|
|
rom_table_end += sizeof(struct smbios_entry);
|
|
|
|
|
|
|
|
if (new_high_table_pointer > ( high_table_pointer + MAX_SMBIOS_SIZE)) {
|
|
|
|
printk(BIOS_ERR, "ERROR: Increase SMBIOS size\n");
|
|
|
|
}
|
2016-01-06 23:21:02 +01:00
|
|
|
printk(BIOS_DEBUG, "SMBIOS tables: %ld bytes.\n",
|
2011-08-14 20:56:34 +02:00
|
|
|
new_high_table_pointer - high_table_pointer);
|
|
|
|
} else {
|
|
|
|
unsigned long new_rom_table_end = smbios_write_tables(rom_table_end);
|
|
|
|
printk(BIOS_DEBUG, "SMBIOS size %ld bytes\n", new_rom_table_end - rom_table_end);
|
|
|
|
rom_table_end = ALIGN(new_rom_table_end, 16);
|
|
|
|
}
|
|
|
|
#endif
|
2008-11-11 21:20:54 +01:00
|
|
|
|
2013-03-23 06:12:19 +01:00
|
|
|
post_code(0x9e);
|
|
|
|
|
2009-10-26 18:04:28 +01:00
|
|
|
post_code(0x9d);
|
|
|
|
|
2009-10-27 22:49:33 +01:00
|
|
|
high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE, MAX_COREBOOT_TABLE_SIZE);
|
2009-10-26 18:04:28 +01:00
|
|
|
|
|
|
|
if (high_table_pointer) {
|
|
|
|
unsigned long new_high_table_pointer;
|
2009-05-26 16:07:44 +02:00
|
|
|
|
2013-09-04 12:05:01 +02:00
|
|
|
/* FIXME: The high_table_base parameter is not reference when tables are high,
|
|
|
|
* or high_table_pointer >1 MB.
|
|
|
|
*/
|
|
|
|
u64 fixme_high_tables_base = 0;
|
|
|
|
|
2009-05-26 16:07:44 +02:00
|
|
|
/* Also put a forwarder entry into 0-4K */
|
2009-10-26 18:04:28 +01:00
|
|
|
new_high_table_pointer = write_coreboot_table(low_table_start, low_table_end,
|
2013-09-04 12:05:01 +02:00
|
|
|
fixme_high_tables_base, high_table_pointer);
|
2009-10-26 18:04:28 +01:00
|
|
|
|
|
|
|
if (new_high_table_pointer > (high_table_pointer +
|
|
|
|
MAX_COREBOOT_TABLE_SIZE))
|
2010-03-22 12:42:32 +01:00
|
|
|
printk(BIOS_ERR, "%s: coreboot table didn't fit (%lx)\n",
|
2009-10-26 18:04:28 +01:00
|
|
|
__func__, new_high_table_pointer -
|
|
|
|
high_table_pointer);
|
|
|
|
|
2016-01-06 23:21:02 +01:00
|
|
|
printk(BIOS_DEBUG, "coreboot table: %ld bytes.\n",
|
2009-10-26 18:04:28 +01:00
|
|
|
new_high_table_pointer - high_table_pointer);
|
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 */
|
2014-02-03 08:36:51 +01:00
|
|
|
write_coreboot_table(low_table_start, low_table_end,
|
2010-09-13 16:47:22 +02:00
|
|
|
rom_table_start, rom_table_end);
|
2009-03-17 15:38:48 +01:00
|
|
|
}
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|