Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3236
-gerrit
commit 06d13d81a95121389d29e61eaeef9e1db2381c18
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri May 10 00:51:43 2013 -0500
haswell: enable cache-as-ram migration
The haswell code allows for vboot ramstage verification.
However, that code path relies on accessing global cache-as-ram
variables after cache-as-ram is torn down. In order to avoid
that situation enable cache-as-ram migration.
Change-Id: I08998dca579c167699030e1e24ea0af8802c0758
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/cpu/intel/haswell/Kconfig | 1 +
src/cpu/intel/haswell/romstage.c | 5 -----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/cpu/intel/haswell/Kconfig b/src/cpu/intel/haswell/Kconfig
index 152059f..4c61b2d 100644
--- a/src/cpu/intel/haswell/Kconfig
+++ b/src/cpu/intel/haswell/Kconfig
@@ -18,6 +18,7 @@ config CPU_SPECIFIC_OPTIONS
#select AP_IN_SIPI_WAIT
select TSC_SYNC_MFENCE
select CPU_INTEL_FIRMWARE_INTERFACE_TABLE
+ select CAR_MIGRATION
config BOOTBLOCK_CPU_INIT
string
diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c
index 1093e6b..8196273 100644
--- a/src/cpu/intel/haswell/romstage.c
+++ b/src/cpu/intel/haswell/romstage.c
@@ -188,11 +188,6 @@ void * asmlinkage romstage_main(unsigned long bist)
/* Get the stack to use after cache-as-ram is torn down. */
romstage_stack_after_car = setup_romstage_stack_after_car();
-#if CONFIG_CONSOLE_CBMEM
- /* Keep this the last thing this function does. */
- cbmemc_reinit();
-#endif
-
return romstage_stack_after_car;
}
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3235
-gerrit
commit d8faf301ebc635561aa80b891da2340c24c025fa
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri May 10 00:45:37 2013 -0500
cbmem console: use cache-as-ram API and cleanup
Allow for automatic cache-as-ram migration for the cbmem
console. The code was refactored in the thought of making
it easier to read. The #ifdefs still exist, but they are no
longer sprinkled throughout the code. The cbmem_console_p
variable now exists globally in both romstage and ramstage.
However, the cbmem_console_p is referenced using the
cache-as-ram API. When cbmem is initialized the console
is automatically copied over by calling cbmemc_reinit()
through a callback.
Change-Id: I9f4a64e33c58b8b7318db27942e37c13804e6f2c
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/lib/cbmem_console.c | 93 +++++++++++++++++++++++++++++++------------------
1 file changed, 60 insertions(+), 33 deletions(-)
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c
index 2e22dec..efb8e86 100644
--- a/src/lib/cbmem_console.c
+++ b/src/lib/cbmem_console.c
@@ -34,6 +34,8 @@ struct cbmem_console {
u8 buffer_body[0];
} __attribute__ ((__packed__));
+static struct cbmem_console *cbmem_console_p CAR_GLOBAL;
+
#ifdef __PRE_RAM__
/*
* While running from ROM, before DRAM is initialized, some area in cache as
@@ -42,7 +44,6 @@ struct cbmem_console {
*/
static struct cbmem_console car_cbmem_console CAR_CBMEM;
-#define cbmem_console_p (&car_cbmem_console)
/*
* Once DRAM is initialized and the cache as ram mode is disabled, while still
@@ -54,6 +55,7 @@ static struct cbmem_console car_cbmem_console CAR_CBMEM;
* find out where the actual console log buffer is.
*/
#define CBMEM_CONSOLE_REDIRECT (*((struct cbmem_console **)0x600))
+
#else
/*
@@ -63,41 +65,64 @@ static struct cbmem_console car_cbmem_console CAR_CBMEM;
* during the ROM stage, once CBMEM becomes available at RAM stage.
*/
static u8 static_console[40000];
-static struct cbmem_console *cbmem_console_p;
#endif
+static inline struct cbmem_console *current_console(void)
+{
+#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__)
+ return car_get_var(cbmem_console_p);
+#else
+ /*
+ * This check allows to tell if the cache as RAM mode has been exited
+ * or not. If it has been exited, the real memory is being used
+ * (resulting in the variable on the stack located below
+ * DCACHE_RAM_BASE), use the redirect pointer to find out where the
+ * actual console buffer is.
+ */
+ if ((uintptr_t)__builtin_frame_address(0) <
+ (uintptr_t)CONFIG_DCACHE_RAM_BASE)
+ return CBMEM_CONSOLE_REDIRECT;
+ return car_get_var(cbmem_console_p);
+#endif /* CONFIG_CAR_MIGRATION */
+}
+
+static inline void current_console_set(struct cbmem_console *new_console_p)
+{
+#if CONFIG_CAR_MIGRATION || !defined(__PRE_RAM__)
+ car_set_var(cbmem_console_p, new_console_p);
+#else
+ CBMEM_CONSOLE_REDIRECT = new_console_p;
+#endif
+}
+
+static inline void init_console_ptr(void *storage, u32 total_space)
+{
+ struct cbmem_console *cbm_cons_p = storage;
+
+ /* Initialize the cache-as-ram pointer and underlying structure. */
+ car_set_var(cbmem_console_p, cbm_cons_p);
+ cbm_cons_p->buffer_size = total_space - sizeof(struct cbmem_console);
+ cbm_cons_p->buffer_cursor = 0;
+}
+
void cbmemc_init(void)
{
#ifdef __PRE_RAM__
- cbmem_console_p->buffer_size = CONFIG_CONSOLE_CAR_BUFFER_SIZE -
- sizeof(struct cbmem_console);
+ init_console_ptr(&car_cbmem_console, CONFIG_CONSOLE_CAR_BUFFER_SIZE);
#else
/*
* Initializing before CBMEM is available, use static buffer to store
* the log.
*/
- cbmem_console_p = (struct cbmem_console *) static_console;
- cbmem_console_p->buffer_size = sizeof(static_console) -
- sizeof(struct cbmem_console);
+ init_console_ptr(static_console, sizeof(static_console));
#endif
- cbmem_console_p->buffer_cursor = 0;
}
void cbmemc_tx_byte(unsigned char data)
{
- struct cbmem_console *cbm_cons_p = cbmem_console_p;
+ struct cbmem_console *cbm_cons_p = current_console();
u32 cursor;
-#ifdef __PRE_RAM__
- /*
- * This check allows to tell if the cache as RAM mode has been exited
- * or not. If it has been exited, the real memory is being used
- * (resulting in the variable on the stack located below
- * DCACHE_RAM_BASE), use the redirect pointer to find out where the
- * actual console buffer is.
- */
- if ((uintptr_t)&cursor < (uintptr_t)&car_cbmem_console)
- cbm_cons_p = CBMEM_CONSOLE_REDIRECT;
-#endif
+
if (!cbm_cons_p)
return;
@@ -119,14 +144,17 @@ static void copy_console_buffer(struct cbmem_console *new_cons_p)
{
u32 copy_size;
u32 cursor = new_cons_p->buffer_cursor;
- int overflow = cbmem_console_p->buffer_cursor >
- cbmem_console_p->buffer_size;
+ struct cbmem_console *old_cons_p;
+ int overflow;
+
+ old_cons_p = current_console();
+
+ overflow = old_cons_p->buffer_cursor > old_cons_p->buffer_size;
copy_size = overflow ?
- cbmem_console_p->buffer_size : cbmem_console_p->buffer_cursor;
+ old_cons_p->buffer_size : old_cons_p->buffer_cursor;
- memcpy(new_cons_p->buffer_body + cursor,
- cbmem_console_p->buffer_body,
+ memcpy(new_cons_p->buffer_body + cursor, old_cons_p->buffer_body,
copy_size);
cursor += copy_size;
@@ -134,7 +162,7 @@ static void copy_console_buffer(struct cbmem_console *new_cons_p)
if (overflow) {
const char loss_str1[] = "\n\n*** Log truncated, ";
const char loss_str2[] = " characters dropped. ***\n\n";
- u32 dropped_chars = cbmem_console_p->buffer_cursor - copy_size;
+ u32 dropped_chars = old_cons_p->buffer_cursor - copy_size;
/*
* When running from ROM sprintf is not available, a simple
@@ -173,7 +201,7 @@ void cbmemc_reinit(void)
cbm_cons_p = cbmem_add(CBMEM_ID_CONSOLE,
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE);
if (!cbm_cons_p) {
- CBMEM_CONSOLE_REDIRECT = NULL;
+ current_console_set(NULL);
return;
}
@@ -181,18 +209,17 @@ void cbmemc_reinit(void)
sizeof(struct cbmem_console);
cbm_cons_p->buffer_cursor = 0;
-
- copy_console_buffer(cbm_cons_p);
-
- CBMEM_CONSOLE_REDIRECT = cbm_cons_p;
#else
cbm_cons_p = cbmem_find(CBMEM_ID_CONSOLE);
if (!cbm_cons_p)
return;
+#endif
copy_console_buffer(cbm_cons_p);
- cbmem_console_p = cbm_cons_p;
-#endif
+ current_console_set(cbm_cons_p);
}
+
+/* Call cbmemc_reinit() at CAR migration time. */
+CAR_MIGRATE(cbmemc_reinit)
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3234
-gerrit
commit 0f7c19066ffff2cceec3e25b4ab669b84a077762
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri May 10 00:42:14 2013 -0500
chromeos: use cache-as-ram migration API for vbnv
It's possible that the vbnv global variables may be accessed
in romstage after cache-as-ram is torn down. Therefore use
the cache-as-ram migration API. Wrappers were written to
wrap the API to keep the existing code as close as possible.
Change-Id: Ia1d8932f98e00def0a44444a1ead0018a59d3d98
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/vendorcode/google/chromeos/vbnv.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/vendorcode/google/chromeos/vbnv.c b/src/vendorcode/google/chromeos/vbnv.c
index 2a2faf9..d94203a 100644
--- a/src/vendorcode/google/chromeos/vbnv.c
+++ b/src/vendorcode/google/chromeos/vbnv.c
@@ -53,7 +53,25 @@
#define CRC_OFFSET 15
static int vbnv_initialized CAR_GLOBAL;
-uint8_t vbnv[CONFIG_VBNV_SIZE] CAR_GLOBAL;
+static uint8_t vbnv[CONFIG_VBNV_SIZE] CAR_GLOBAL;
+
+/* Wrappers for accessing the variables marked as CAR_GLOBAL. */
+static inline int is_vbnv_initialized(void)
+{
+ return car_get_var(vbnv_initialized);
+}
+
+static inline uint8_t *vbnv_data_addr(int index)
+{
+ uint8_t *vbnv_arr = car_get_var_ptr(vbnv);
+
+ return &vbnv_arr[index];
+}
+
+static inline uint8_t vbnv_data(int index)
+{
+ return *vbnv_data_addr(index);
+}
/* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A
* table-based algorithm would be faster, but for only 15 bytes isn't
@@ -109,20 +127,20 @@ void save_vbnv(const uint8_t *vbnv_copy)
static void vbnv_setup(void)
{
- read_vbnv(vbnv);
- vbnv_initialized = 1;
+ read_vbnv(vbnv_data_addr(0));
+ car_set_var(vbnv_initialized, 1);
}
int get_recovery_mode_from_vbnv(void)
{
- if (!vbnv_initialized)
+ if (!is_vbnv_initialized())
vbnv_setup();
- return vbnv[RECOVERY_OFFSET];
+ return vbnv_data(RECOVERY_OFFSET);
}
int vboot_wants_oprom(void)
{
- if (!vbnv_initialized)
+ if (!is_vbnv_initialized())
vbnv_setup();
/* FIXME(crosbug.com/p/8789). The following commented-out line does the
@@ -130,6 +148,6 @@ int vboot_wants_oprom(void)
* rebooted if it finds that it's needed but not loaded. At the moment,
* it doesn't yet do that, so we must always say we want it. */
- /* return (vbnv[BOOT_OFFSET] & BOOT_OPROM_NEEDED) ? 1 : 0; */
+ /* return (vbnv_data(BOOT_OFFSET) & BOOT_OPROM_NEEDED) ? 1 : 0; */
return 1;
}
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3233
-gerrit
commit a3f42dd864a9ec942f992cc0121ae2889fd3cdac
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri May 10 00:40:56 2013 -0500
pc80/tpm: allow for cache-as-ram migration
As the TPM driver can be accessed in romstage after
cache-as-ram is torn down use the cache-as-ram migration
API to dynamically determine the global variable address.
Change-Id: I149d7c130bc3677ed52282095670c07a76c34439
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/drivers/pc80/tpm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/drivers/pc80/tpm.c b/src/drivers/pc80/tpm.c
index c7b5081..9a4fc09 100644
--- a/src/drivers/pc80/tpm.c
+++ b/src/drivers/pc80/tpm.c
@@ -278,7 +278,7 @@ static u32 tis_probe(void)
u16 vid, did;
int i;
- if (vendor_dev_id)
+ if (car_get_var(vendor_dev_id))
return 0; /* Already probed. */
didvid = tpm_read(0, TIS_REG_DID_VID);
@@ -287,7 +287,7 @@ static u32 tis_probe(void)
return TPM_DRIVER_ERR;
}
- vendor_dev_id = didvid;
+ car_set_var(vendor_dev_id, didvid);
vid = didvid & 0xffff;
did = (didvid >> 16) & 0xffff;
Aaron Durbin (adurbin(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3232
-gerrit
commit 96da0bb72368480415b57a4e2fd92d216edfe6e8
Author: Aaron Durbin <adurbin(a)chromium.org>
Date: Fri May 10 00:33:32 2013 -0500
x86: add cache-as-ram migration option
There are some boards that do a significant amount of
work after cache-as-ram is torn down but before ramstage
is loaded. For example, using vboot to verify the ramstage
is one such operation. However, there are pieces of code
that are executed that referecne global variables that
are linked in the cache-as-ram region. If those variables
are referenced after cache-as-ram is torn down then the
values observed will most likely be incorrect.
Therefore provide a Kconfig option to select cache-as-ram
migration to memory using cbmem. This option is named
CAR_MIGRATION. When enabled, the address of cache-as-ram
variables may be obtained dynamically. Additionally,
whe cache-as-ram migration occurs the cache-as-ram
data region for global variables is copied into cbmem.
There are also automatic callbacks for other modules
to perform their own migration, if necessary.
Change-Id: I2e77219647c2bd2b1aa845b262be3b2543f1fcb7
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/arch/x86/init/romstage.ld | 12 +++++
src/cpu/Makefile.inc | 1 +
src/cpu/x86/Kconfig | 9 ++++
src/cpu/x86/Makefile.inc | 1 +
src/cpu/x86/car.c | 102 ++++++++++++++++++++++++++++++++++++++++++
src/include/cbmem.h | 1 +
src/include/cpu/x86/car.h | 29 ++++++++++++
src/lib/cbmem.c | 4 ++
src/lib/cbmem_info.c | 1 +
src/lib/dynamic_cbmem.c | 9 ++++
10 files changed, 169 insertions(+)
diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld
index 88c5657..bb6259f 100644
--- a/src/arch/x86/init/romstage.ld
+++ b/src/arch/x86/init/romstage.ld
@@ -35,6 +35,10 @@ SECTIONS
*(.rodata.*);
*(.rom.data.*);
. = ALIGN(16);
+ _car_migrate_start = .;
+ *(.car.migrate);
+ _car_migrate_end = .;
+ . = ALIGN(16);
_erom = .;
}
@@ -48,8 +52,16 @@ SECTIONS
. = CONFIG_DCACHE_RAM_BASE;
.car.data . (NOLOAD) : {
+ _car_data_start = .;
*(.car.global_data);
+ /* The cbmem_console section comes last to take advantage of
+ * a zero-sized array to hold the memconsole contents that
+ * grows to a bound of CONFIG_CONSOLE_CAR_BUFFER_SIZE. However,
+ * collisions within the cache-as-ram region cannot be
+ * statically checked becuase the cache-as-ram region usage is
+ * cpu/chipset dependent. */
*(.car.cbmem_console);
+ _car_data_end = .;
}
_bogus = ASSERT((SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
diff --git a/src/cpu/Makefile.inc b/src/cpu/Makefile.inc
index b48a803..8d93756 100644
--- a/src/cpu/Makefile.inc
+++ b/src/cpu/Makefile.inc
@@ -6,6 +6,7 @@ subdirs-y += armltd
subdirs-y += intel
subdirs-y += samsung
subdirs-y += via
+subdirs-y += x86
################################################################################
## Rules for building the microcode blob in CBFS
diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig
index c64a8e4..5687a7a 100644
--- a/src/cpu/x86/Kconfig
+++ b/src/cpu/x86/Kconfig
@@ -115,3 +115,12 @@ config X86_AMD_FIXED_MTRRS
help
This option informs the MTRR code to use the RdMem and WrMem fields
in the fixed MTRR MSRs.
+
+config CAR_MIGRATION
+ def_bool n
+ depends on DYNAMIC_CBMEM || EARLY_CBMEM_INIT
+ help
+ Migrate the cache-as-ram variables to cbmem once cbmem is set up
+ in romstage. This option is only needed if one will be doing more
+ work in romstage after the cache-as-ram is torn down aside from
+ loading ramstage.
diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc
new file mode 100644
index 0000000..fe8648c
--- /dev/null
+++ b/src/cpu/x86/Makefile.inc
@@ -0,0 +1 @@
+romstage-$(CONFIG_CAR_MIGRATION) += car.c
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
new file mode 100644
index 0000000..5a2de02
--- /dev/null
+++ b/src/cpu/x86/car.c
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ *
+ * 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
+ */
+
+#include <string.h>
+#include <console/console.h>
+#include <cbmem.h>
+#include <cpu/x86/car.h>
+
+typedef void (* const car_migration_func_t)(void);
+
+extern car_migration_func_t _car_migrate_start;
+extern car_migration_func_t _car_migrate_end;
+
+extern char _car_data_start[];
+extern char _car_data_end[];
+
+
+
+/*
+ * The car_migrated global variable determines if the cache-as-ram space has
+ * been migrated to real RAM. It does this by asumming the following things:
+ * 1. cache-as-ram space is zero'd out once it is set up.
+ * 2. Either the cache-as-ram space is memory-backed after getting torn down
+ * or the space returns 0xff's for each byte read.
+ * Based on these 2 attributes there is the ability to tell when the
+ * cache-as-ram region has been migrated.
+ */
+static int car_migrated CAR_GLOBAL;
+
+
+void *car_get_var_ptr(void *var)
+{
+ char *migrated_base;
+ int offset;
+ void * _car_start = &_car_data_start;
+ void * _car_end = &_car_data_end;
+
+ /* If the cache-as-ram has not been migrated return the pointer
+ * passed in. */
+ if (!car_migrated)
+ return var;
+
+ if (var < _car_start || var >= _car_end) {
+ printk(BIOS_ERR,
+ "Requesting CAR variable outside of CAR region: %p\n",
+ var);
+ return var;
+ }
+
+ migrated_base = cbmem_find(CBMEM_ID_CAR_GLOBALS);
+
+ if (migrated_base == NULL) {
+ printk(BIOS_ERR, "CAR: Could not find migration base!\n");
+ return var;
+ }
+
+ offset = (char *)var - (char *)_car_start;
+
+ return &migrated_base[offset];
+}
+
+void car_migrate_variables(void)
+{
+ void *migrated_base;
+ car_migration_func_t *migrate_func;
+ int car_data_size = &_car_data_end[0] - &_car_data_start[0];
+
+ migrated_base = cbmem_add(CBMEM_ID_CAR_GLOBALS, car_data_size);
+
+ if (migrated_base == NULL) {
+ printk(BIOS_ERR, "Could not migrate CAR data!\n");
+ return;
+ }
+
+ memcpy(migrated_base, &_car_data_start[0], car_data_size);
+
+ /* Mark that the data has bee moved. */
+ car_migrated = ~0;
+
+ /* Call all the migration functions. */
+ migrate_func = &_car_migrate_start;
+ while (migrate_func != &_car_migrate_end) {
+ (*migrate_func)();
+ migrate_func++;
+ }
+}
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 67cb1cb..baec780 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -69,6 +69,7 @@
#define CBMEM_ID_RAMSTAGE_CACHE 0x9a3ca54e
#define CBMEM_ID_ROOT 0xff4007ff
#define CBMEM_ID_VBOOT_HANDOFF 0x780074f0
+#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3
#define CBMEM_ID_NONE 0x00000000
#ifndef __ASSEMBLER__
diff --git a/src/include/cpu/x86/car.h b/src/include/cpu/x86/car.h
index 2d2af03..b57620d 100644
--- a/src/include/cpu/x86/car.h
+++ b/src/include/cpu/x86/car.h
@@ -28,4 +28,33 @@
#define CAR_CBMEM
#endif
+#if CONFIG_CAR_MIGRATION && defined(__PRE_RAM__)
+#define CAR_MIGRATE_ATTR __attribute__ ((used,section (".car.migrate")))
+
+/* Call migrate_fn_() when CAR globals are migrated. */
+#define CAR_MIGRATE(migrate_fn_) \
+ static void (* const migrate_fn_ ## _ptr)(void) CAR_MIGRATE_ATTR = \
+ migrate_fn_;
+
+/* Get the correct pointer for the CAR global variable. */
+void *car_get_var_ptr(void *var);
+
+/* Get and set a primitive type global varible. */
+#define car_get_var(var) \
+ *(typeof(var) *)car_get_var_ptr(&(var))
+#define car_set_var(var, val) \
+ do { car_get_var(var) = (val); } while(0)
+
+/* Migrate the CAR variables to memory. */
+void car_migrate_variables(void);
+
+#else
+#define CAR_MIGRATE(migrate_fn_)
+static inline void *car_get_var_ptr(void *var) { return var; }
+#define car_get_var(var) (var)
+#define car_set_var(var, val) do { (var) = (val); } while (0)
+static inline void car_migrate_variables(void) { }
+#endif
+
+
#endif
diff --git a/src/lib/cbmem.c b/src/lib/cbmem.c
index e8200b6..3702da1 100644
--- a/src/lib/cbmem.c
+++ b/src/lib/cbmem.c
@@ -22,6 +22,7 @@
#include <bootstate.h>
#include <cbmem.h>
#include <console/console.h>
+#include <cpu/x86/car.h>
#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
#include <arch/acpi.h>
#endif
@@ -228,6 +229,9 @@ int cbmem_initialize(void)
#ifndef __PRE_RAM__
cbmem_arch_init();
#endif
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
+
return rv;
}
#endif
diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c
index ad8c890..7031a70 100644
--- a/src/lib/cbmem_info.c
+++ b/src/lib/cbmem_info.c
@@ -46,6 +46,7 @@ static struct cbmem_id_to_name {
{ CBMEM_ID_RAMSTAGE_CACHE, "RAMSTAGE $ " },
{ CBMEM_ID_ROOT, "CBMEM ROOT " },
{ CBMEM_ID_VBOOT_HANDOFF, "VBOOT " },
+ { CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" },
};
void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
diff --git a/src/lib/dynamic_cbmem.c b/src/lib/dynamic_cbmem.c
index 5c269a0..ba7760d 100644
--- a/src/lib/dynamic_cbmem.c
+++ b/src/lib/dynamic_cbmem.c
@@ -23,6 +23,7 @@
#include <cbmem.h>
#include <string.h>
#include <stdlib.h>
+#include <cpu/x86/car.h>
#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
#include <arch/acpi.h>
#endif
@@ -182,12 +183,17 @@ void cbmem_initialize_empty(void)
root, root->max_entries);
cbmem_arch_init();
+
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
}
static inline int cbmem_fail_recovery(void)
{
cbmem_initialize_empty();
cbmem_handle_acpi_resume();
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
return 1;
}
@@ -256,6 +262,9 @@ int cbmem_initialize(void)
cbmem_arch_init();
+ /* Migrate cache-as-ram variables. */
+ car_migrate_variables();
+
/* Recovery successful. */
return 0;
}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3188
-gerrit
commit 61b11c2db1586a40877aa09321e3c0f79530c8f6
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Fri May 3 18:25:27 2013 +0200
Get rid of MAXIMUM_CONSOLE_LOGLEVEL; compile all messages into the coreboot binary
This option has never had much if any use. It solved a problem over 10
years ago that resulted from an argument over the value or lack thereof
of including all the debug strings in a coreboot image. The answer is
in: it's a good idea to maintain the capability to print all messages,
for many reasons.
This option is also misleading people, as in a recent discussion, to
believe that log messges are controlled at build time in a way they are
not. For the record, from this day forward, we can print messages at all
log levels and the default log level is set at boot time, as directed by
DEFAULT_CONSOLE_LOGLEVEL. You can set the default to 0 at build time and
if you are having trouble override it in CMOS and get more messages.
Besides, a quick glance shows it's always set to max (9 in this case) in
the very few cases (1) in which it is set.
Change-Id: I60c4cdaf4dcd318b841a6d6c70546417c5626f21
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
documentation/LinuxBIOS-AMD64.tex | 5 ---
src/console/Kconfig | 79 ----------------------------------
src/include/console/console.h | 32 +-------------
src/mainboard/msi/ms9652_fam10/Kconfig | 4 --
util/abuild/abuild | 2 -
5 files changed, 1 insertion(+), 121 deletions(-)
diff --git a/documentation/LinuxBIOS-AMD64.tex b/documentation/LinuxBIOS-AMD64.tex
index 19a6f59..5847dab 100644
--- a/documentation/LinuxBIOS-AMD64.tex
+++ b/documentation/LinuxBIOS-AMD64.tex
@@ -408,11 +408,6 @@ machine.
Use new \textit{chip\_configure} method for configuring (nonpci)
devices. Set to \texttt{1} for all AMD64 mainboards.
-\item \begin{verbatim}CONFIG_MAXIMUM_CONSOLE_LOGLEVEL\end{verbatim}
-
-Errors or log messages up to this level can be printed. Default is
-\texttt{8}, minimum is \texttt{0}, maximum is \texttt{10}.
-
\item \begin{verbatim}CONFIG_DEFAULT_CONSOLE_LOGLEVEL\end{verbatim}
Console will log at this level unless changed. Default is \texttt{7},
diff --git a/src/console/Kconfig b/src/console/Kconfig
index 6251589..a613477 100644
--- a/src/console/Kconfig
+++ b/src/console/Kconfig
@@ -250,119 +250,40 @@ config CONSOLE_CAR_BUFFER_SIZE
in the DCACHE based RAM to keep console output before it can be
saved in a CBMEM buffer. 3K bytes should be enough even for the
BIOS_SPEW level.
-
-
-choice
- prompt "Maximum console log level"
- default MAXIMUM_CONSOLE_LOGLEVEL_8
-
-config MAXIMUM_CONSOLE_LOGLEVEL_8
- bool "8: SPEW"
- help
- Way too many details.
-config MAXIMUM_CONSOLE_LOGLEVEL_7
- bool "7: DEBUG"
- help
- Debug-level messages.
-config MAXIMUM_CONSOLE_LOGLEVEL_6
- bool "6: INFO"
- help
- Informational messages.
-config MAXIMUM_CONSOLE_LOGLEVEL_5
- bool "5: NOTICE"
- help
- Normal but significant conditions.
-config MAXIMUM_CONSOLE_LOGLEVEL_4
- bool "4: WARNING"
- help
- Warning conditions.
-config MAXIMUM_CONSOLE_LOGLEVEL_3
- bool "3: ERR"
- help
- Error conditions.
-config MAXIMUM_CONSOLE_LOGLEVEL_2
- bool "2: CRIT"
- help
- Critical conditions.
-config MAXIMUM_CONSOLE_LOGLEVEL_1
- bool "1: ALERT"
- help
- Action must be taken immediately.
-config MAXIMUM_CONSOLE_LOGLEVEL_0
- bool "0: EMERG"
- help
- System is unusable.
-
-endchoice
-
-config MAXIMUM_CONSOLE_LOGLEVEL
- int
- default 0 if MAXIMUM_CONSOLE_LOGLEVEL_0
- default 1 if MAXIMUM_CONSOLE_LOGLEVEL_1
- default 2 if MAXIMUM_CONSOLE_LOGLEVEL_2
- default 3 if MAXIMUM_CONSOLE_LOGLEVEL_3
- default 4 if MAXIMUM_CONSOLE_LOGLEVEL_4
- default 5 if MAXIMUM_CONSOLE_LOGLEVEL_5
- default 6 if MAXIMUM_CONSOLE_LOGLEVEL_6
- default 7 if MAXIMUM_CONSOLE_LOGLEVEL_7
- default 8 if MAXIMUM_CONSOLE_LOGLEVEL_8
- help
- Map the log level config names to an integer.
-
choice
prompt "Default console log level"
default DEFAULT_CONSOLE_LOGLEVEL_8
config DEFAULT_CONSOLE_LOGLEVEL_8
bool "8: SPEW"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8)
help
Way too many details.
config DEFAULT_CONSOLE_LOGLEVEL_7
bool "7: DEBUG"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7)
help
Debug-level messages.
config DEFAULT_CONSOLE_LOGLEVEL_6
bool "6: INFO"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6)
help
Informational messages.
config DEFAULT_CONSOLE_LOGLEVEL_5
bool "5: NOTICE"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6 || MAXIMUM_CONSOLE_LOGLEVEL_5)
help
Normal but significant conditions.
config DEFAULT_CONSOLE_LOGLEVEL_4
bool "4: WARNING"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6 || MAXIMUM_CONSOLE_LOGLEVEL_5 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_4)
help
Warning conditions.
config DEFAULT_CONSOLE_LOGLEVEL_3
bool "3: ERR"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6 || MAXIMUM_CONSOLE_LOGLEVEL_5 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_4 || MAXIMUM_CONSOLE_LOGLEVEL_3)
help
Error conditions.
config DEFAULT_CONSOLE_LOGLEVEL_2
bool "2: CRIT"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6 || MAXIMUM_CONSOLE_LOGLEVEL_5 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_4 || MAXIMUM_CONSOLE_LOGLEVEL_3 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_2)
help
Critical conditions.
config DEFAULT_CONSOLE_LOGLEVEL_1
bool "1: ALERT"
- depends on (MAXIMUM_CONSOLE_LOGLEVEL_8 || MAXIMUM_CONSOLE_LOGLEVEL_7 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_6 || MAXIMUM_CONSOLE_LOGLEVEL_5 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_4 || MAXIMUM_CONSOLE_LOGLEVEL_3 ||\
- MAXIMUM_CONSOLE_LOGLEVEL_2 || MAXIMUM_CONSOLE_LOGLEVEL_1)
help
Action must be taken immediately.
config DEFAULT_CONSOLE_LOGLEVEL_0
diff --git a/src/include/console/console.h b/src/include/console/console.h
index d320093..9112f35 100644
--- a/src/include/console/console.h
+++ b/src/include/console/console.h
@@ -86,41 +86,11 @@ static inline void printk(int LEVEL, const char *fmt, ...) {
#else /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */
-#undef WE_CLEANED_UP_ALL_SIDE_EFFECTS
-/* We saw some strange effects in the past like coreboot crashing while
- * disabling cache as ram for a maximum console log level of 6 and above while
- * it worked fine without. In order to catch such issues reliably we are
- * always doing a function call to do_printk with the full number of arguments.
- * Our favorite reason to do it this way was:
- * disable_car();
- * printk(BIOS_DEBUG, "CAR disabled\n"); // oops, garbage stack pointer
- * move_stack();
- * This slightly increases the code size and some unprinted strings will end
- * up in the final coreboot binary (most of them compressed). If you want to
- * avoid this, do a
- * #define WE_CLEANED_UP_ALL_SIDE_EFFECTS
- */
-#ifdef WE_CLEANED_UP_ALL_SIDE_EFFECTS
-
#define printk(LEVEL, fmt, args...) \
do { \
- if (CONFIG_MAXIMUM_CONSOLE_LOGLEVEL >= LEVEL) { \
- do_printk(LEVEL, fmt, ##args); \
- } \
+ do_printk(LEVEL, fmt, ##args); \
} while(0)
-#else
-
-#define printk(LEVEL, fmt, args...) \
- do { \
- if (CONFIG_MAXIMUM_CONSOLE_LOGLEVEL >= LEVEL) { \
- do_printk(LEVEL, fmt, ##args); \
- } else { \
- do_printk(BIOS_NEVER, fmt, ##args); \
- } \
- } while(0)
-#endif
-
#endif /* defined(__PRE_RAM__) && !CONFIG_EARLY_CONSOLE */
#define print_emerg(STR) printk(BIOS_EMERG, "%s", (STR))
diff --git a/src/mainboard/msi/ms9652_fam10/Kconfig b/src/mainboard/msi/ms9652_fam10/Kconfig
index e3de52f..b6baac3 100644
--- a/src/mainboard/msi/ms9652_fam10/Kconfig
+++ b/src/mainboard/msi/ms9652_fam10/Kconfig
@@ -93,10 +93,6 @@ config DEFAULT_CONSOLE_LOGLEVEL
int
default 9
-config MAXIMUM_CONSOLE_LOGLEVEL
- int
- default 9
-
config MAINBOARD_POWER_ON_AFTER_POWER_FAIL
bool
default y
diff --git a/util/abuild/abuild b/util/abuild/abuild
index 1c69eec..aad066c 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -596,8 +596,6 @@ while true ; do
-C|--config) shift; configureonly=1;;
-l|--loglevel) shift
customizing="${customizing}, loglevel $1"
- configoptions="${configoptions}CONFIG_MAXIMUM_CONSOLE_LOGLEVEL_$1=y\n"
- configoptions="${configoptions}CONFIG_MAXIMUM_CONSOLE_LOGLEVEL=$1\n"
configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$1=y\n"
configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$1\n"
shift;;
the following patch was just integrated into master:
commit bed88d65b2a142be1a0f278eef8dfbb64859077e
Author: Paul Menzel <paulepanter(a)users.sourceforge.net>
Date: Wed May 8 15:09:45 2013 +0200
northbridge/intel/i5000/udelay.c: Remove unused header `console.h`
Nothing from the header `console.h` is needed in `udelay.c`, so do
not include it.
This header was included since commit
»Add Intel i5000 Memory Controller Hub« (17670866) [1].
[1] http://review.coreboot.org/491
Change-Id: Ie136a1b862b55c9471f9293ed616ce27a1d01a50
Signed-off-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/3218
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
See http://review.coreboot.org/3218 for details.
-gerrit
the following patch was just integrated into master:
commit 3f5f6d8368031710d4f5847ff285812fcde54009
Author: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Date: Tue May 7 20:35:29 2013 +0200
Drop prototype guarding for romcc
Commit "romcc: Don't fail on function prototypes" (11a7db3b) [1]
made romcc not choke on function prototypes anymore. This
allows us to get rid of a lot of ifdefs guarding __ROMCC__ .
[1] http://review.coreboot.org/2424
Change-Id: Ib1be3b294e5b49f5101f2e02ee1473809109c8ac
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
Reviewed-on: http://review.coreboot.org/3216
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
See http://review.coreboot.org/3216 for details.
-gerrit