Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7878
-gerrit
commit c9cdcbc4268f5b0f9e20cb2e13aeea740d3682a1
Author: Julius Werner <jwerner(a)chromium.org>
Date: Mon Dec 1 18:08:03 2014 -0800
cbmem: [NOTFORMERGE] CBMEM_INIT_HOOK() API
Squashed two changes from chromium.git.
cbmem: Unify random on-CBMEM-init tasks under common CBMEM_INIT_HOOK() API
There are several use cases for performing a certain task when CBMEM is
first set up (usually to migrate some data into it that was previously
kept in BSS/SRAM/hammerspace), and unfortunately we handle each of them
differently: timestamp migration is called explicitly from
cbmem_initialize(), certain x86-chipset-specific tasks use the
CAR_MIGRATION() macro to register a hook, and the CBMEM console is
migrated through a direct call from romstage (on non-x86 and SandyBridge
boards).
This patch decouples the CAR_MIGRATION() hook mechanism from
cache-as-RAM and rechristens it to CBMEM_INIT_HOOK(), which is a clearer
description of what it really does. All of the above use cases are
ported to this new, consistent model, allowing us to have one less line
of boilerplate in non-CAR romstages.
BRANCH=None
BUG=None
TEST=Built and booted on Nyan_Blaze and Falco with and without
CONFIG_CBMEM_CONSOLE. Confirmed that 'cbmem -c' shows the full log after
boot (and the resume log after S3 resume on Falco). Compiled for Parrot,
Stout and Lumpy.
Original-Change-Id: I1681b372664f5a1f15c3733cbd32b9b11f55f8ea
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232612
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
cbmem: Extend hooks to ramstage, fix timestamp synching
Commit 7dd5bbd71 (cbmem: Unify random on-CBMEM-init tasks under common
CBMEM_INIT_HOOK() API) inadvertently broke ramstage timestamps since
timestamp_sync() was no longer called there. Oops.
This patch fixes the issue by extending the CBMEM_INIT_HOOK() mechanism
to the cbmem_initialize() call in ramstage. The macro is split into
explicit ROMSTAGE_/RAMSTAGE_ versions to make the behavior as clear as
possible and prevent surprises (although just using a single macro and
relying on the Makefiles to link an object into all appropriate stages
would also work).
This allows us to get rid of the explicit cbmemc_reinit() in ramstage
(which I somehow accounted for in the last patch without realizing that
timestamps work exactly the same way...), and replace the older and less
flexible cbmem_arch_init() mechanism.
Also added a size assertion for the pre-RAM CBMEM console to memlayout
that could prevent a very unlikely buffer overflow I just noticed.
BRANCH=None
BUG=None
TEST=Booted on Pinky and Falco, confirmed that ramstage timestamps once
again show up. Compile-tested for Rambi and Samus.
Original-Change-Id: If907266c3f20dc3d599b5c968ea5b39fe5c00e9c
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233533
Reviewed-by: Aaron Durbin <adurbin(a)chromium.org>
Change-Id: I1be89bafacfe85cba63426e2d91f5d8d4caa1800
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
3rdparty | 2 +-
src/arch/arm/include/arch/early_variables.h | 1 -
src/arch/arm64/include/arch/early_variables.h | 1 -
src/arch/x86/boot/cbmem.c | 7 +-
src/arch/x86/boot/gdt.c | 3 +-
src/arch/x86/include/arch/early_variables.h | 7 --
src/arch/x86/init/romstage.ld | 9 +-
src/cpu/x86/car.c | 12 ---
src/drivers/usb/ehci_debug.c | 2 +-
src/include/cbmem.h | 19 +++-
src/include/cpu/x86/gdt.h | 3 -
src/lib/Makefile.inc | 3 +-
src/lib/cbmem_common.c | 59 +++++++++++++
src/lib/cbmem_console.c | 4 +-
src/lib/cbmem_info.c | 45 ----------
src/lib/ramstage.ld | 117 +++++++++++++++++++++++++
src/lib/rmodule.ld | 3 +
src/lib/romstage.ld | 62 +++++++++++++
src/lib/timestamp.c | 2 +-
src/soc/intel/baytrail/romstage/romstage.c | 2 +-
src/soc/intel/broadwell/romstage/power_state.c | 2 +-
21 files changed, 275 insertions(+), 90 deletions(-)
diff --git a/3rdparty b/3rdparty
index 9f68e20..a8b0c52 160000
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit 9f68e20e5ef4b6681fb18bdb4022471bc6810788
+Subproject commit a8b0c52850495c30dfa1cd8cc2c679a6ba4e18ac
diff --git a/src/arch/arm/include/arch/early_variables.h b/src/arch/arm/include/arch/early_variables.h
index 539b572..6145703 100644
--- a/src/arch/arm/include/arch/early_variables.h
+++ b/src/arch/arm/include/arch/early_variables.h
@@ -22,7 +22,6 @@
#define CAR_GLOBAL
-#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)
diff --git a/src/arch/arm64/include/arch/early_variables.h b/src/arch/arm64/include/arch/early_variables.h
index 539b572..6145703 100644
--- a/src/arch/arm64/include/arch/early_variables.h
+++ b/src/arch/arm64/include/arch/early_variables.h
@@ -22,7 +22,6 @@
#define CAR_GLOBAL
-#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)
diff --git a/src/arch/x86/boot/cbmem.c b/src/arch/x86/boot/cbmem.c
index 49dd02b..7ff0925 100644
--- a/src/arch/x86/boot/cbmem.c
+++ b/src/arch/x86/boot/cbmem.c
@@ -58,12 +58,7 @@ void cbmem_arch_init(void)
/* Migrate car.global_data. */
car_migrate_variables();
-#if !defined(__PRE_RAM__)
- /* Relocate CBMEM console. */
- cbmemc_reinit();
-
- move_gdt();
-#endif
+ cbmem_run_init_hooks();
}
/* Something went wrong, our high memory area got wiped */
diff --git a/src/arch/x86/boot/gdt.c b/src/arch/x86/boot/gdt.c
index 7b64af7..b4cfbee 100644
--- a/src/arch/x86/boot/gdt.c
+++ b/src/arch/x86/boot/gdt.c
@@ -32,7 +32,7 @@ struct gdtarg {
/* Copy GDT to new location and reload it.
* FIXME: We only do this for BSP CPU.
*/
-void move_gdt(void)
+static void move_gdt(void)
{
void *newgdt;
u16 num_gdt_bytes = (u32)&gdt_end - (u32)&gdt;
@@ -55,3 +55,4 @@ void move_gdt(void)
__asm__ __volatile__ ("lgdt %0\n\t" : : "m" (gdtarg));
printk(BIOS_DEBUG, "ok\n");
}
+RAMSTAGE_CBMEM_INIT_HOOK(move_gdt)
diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h
index f76c048..2685175 100644
--- a/src/arch/x86/include/arch/early_variables.h
+++ b/src/arch/x86/include/arch/early_variables.h
@@ -29,12 +29,6 @@ asm(".previous");
#endif
#if 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);
@@ -46,7 +40,6 @@ void *car_get_var_ptr(void *var);
do { car_get_var(var) = (val); } while(0)
#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)
diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld
index 99bcc8e..3ade87f 100644
--- a/src/arch/x86/init/romstage.ld
+++ b/src/arch/x86/init/romstage.ld
@@ -31,15 +31,14 @@ SECTIONS
_rom = .;
*(.rom.text);
*(.rom.data);
+ . = ALIGN(4);
+ _cbmem_init_hooks = .;
+ KEEP(*(.rodata.cbmem_init_hooks));
+ _ecbmem_init_hooks = .;
*(.rodata);
*(.rodata.*);
*(.rom.data.*);
. = ALIGN(16);
- _car_migrate_start = .;
- *(.car.migrate);
- LONG(0);
- _car_migrate_end = .;
- . = ALIGN(16);
_erom = .;
}
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index c9cc6d6..eb3b5fc 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -23,10 +23,6 @@
#include <cbmem.h>
#include <arch/early_variables.h>
-typedef void (* const car_migration_func_t)(void);
-
-extern car_migration_func_t _car_migrate_start;
-
extern char _car_data_start[];
extern char _car_data_end[];
@@ -76,7 +72,6 @@ void *car_get_var_ptr(void *var)
static void do_car_migrate_variables(void)
{
void *migrated_base;
- car_migration_func_t *migrate_func;
size_t car_data_size = &_car_data_end[0] - &_car_data_start[0];
/* Check if already migrated. */
@@ -94,13 +89,6 @@ static void do_car_migrate_variables(void)
/* Mark that the data has been moved. */
car_migrated = ~0;
-
- /* Call all the migration functions. */
- migrate_func = &_car_migrate_start;
- while (*migrate_func != NULL) {
- (*migrate_func)();
- migrate_func++;
- }
}
void car_migrate_variables(void)
diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c
index 83c23a3..f89ea2f 100644
--- a/src/drivers/usb/ehci_debug.c
+++ b/src/drivers/usb/ehci_debug.c
@@ -683,7 +683,7 @@ static void migrate_ehci_debug(void)
memcpy(dbg_info_cbmem, dbg_info, sizeof(*dbg_info));
car_set_var(glob_dbg_info_p, dbg_info_cbmem);
}
-CAR_MIGRATE(migrate_ehci_debug);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_ehci_debug);
#endif
int dbgp_ep_is_active(struct dbgp_pipe *pipe)
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index ea81fd0..316a780 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -182,13 +182,30 @@ void *cbmem_find(u32 id);
void cbmem_arch_init(void);
void cbmem_fail_resume(void);
+typedef void (* const cbmem_init_hook_t)(void);
+void cbmem_run_init_hooks(void);
+
#ifndef __PRE_RAM__
/* Ramstage only functions. */
/* Add the cbmem memory used to the memory map at boot. */
void cbmem_add_bootmem(void);
void cbmem_list(void);
void cbmem_print_entry(int n, u32 id, u64 start, u64 size);
-#endif /* __PRE_RAM__ */
+#endif
+
+#ifndef __PRE_RAM__
+#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
+ init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
+#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
+ static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
+ section(".rodata.cbmem_init_hooks"))) = init_fn_;
+#else /* __PRE_RAM__ */
+#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
+ static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
+ section(".rodata.cbmem_init_hooks"))) = init_fn_;
+#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
+ init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
+#endif /* !__PRE_RAM__ */
/* These are for compatibility with old boards only. Any new chipset and board
* must implement cbmem_top() for both romstage and ramstage to support
diff --git a/src/include/cpu/x86/gdt.h b/src/include/cpu/x86/gdt.h
index 260b158..43a80fe 100644
--- a/src/include/cpu/x86/gdt.h
+++ b/src/include/cpu/x86/gdt.h
@@ -28,7 +28,4 @@ extern char _secondary_gdt_addr[];
extern char _secondary_start[];
extern char _secondary_start_end[];
-/* Defined in src/arch/x86/boot/gdt.c */
-void move_gdt(void);
-
#endif /* CPU_X86_GDT */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 5a5ccc2..c6a30a3 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -76,7 +76,8 @@ ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
ramstage-y += dynamic_cbmem.c
romstage-y += dynamic_cbmem.c
-ramstage-y += cbmem_info.c
+romstage-y += cbmem_common.c
+ramstage-y += cbmem_common.c
ramstage-y += hexdump.c
romstage-y += hexdump.c
diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c
new file mode 100644
index 0000000..935f759
--- /dev/null
+++ b/src/lib/cbmem_common.c
@@ -0,0 +1,59 @@
+/*
+ * 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 wacbmem_entryanty 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 <console/console.h>
+#include <cbmem.h>
+#include <stdlib.h>
+
+static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
+
+void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
+{
+ int i;
+ const char *name;
+
+ name = NULL;
+ for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
+ if (cbmem_ids[i].id == id) {
+ name = cbmem_ids[i].name;
+ break;
+ }
+ }
+
+ if (name == NULL)
+ printk(BIOS_DEBUG, "%08x ", id);
+ else
+ printk(BIOS_DEBUG, "%s", name);
+ printk(BIOS_DEBUG, "%2d. ", n);
+ printk(BIOS_DEBUG, "%08llx ", base);
+ printk(BIOS_DEBUG, "%08llx\n", size);
+}
+
+#endif /* !__PRE_RAM__ */
+
+extern cbmem_init_hook_t _cbmem_init_hooks;
+extern cbmem_init_hook_t _ecbmem_init_hooks;
+
+void cbmem_run_init_hooks(void)
+{
+ cbmem_init_hook_t *init_hook_ptr = &_cbmem_init_hooks;
+ while (init_hook_ptr != &_ecbmem_init_hooks) {
+ (*init_hook_ptr)();
+ init_hook_ptr++;
+ }
+}
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c
index 3988084..2799895 100644
--- a/src/lib/cbmem_console.c
+++ b/src/lib/cbmem_console.c
@@ -232,5 +232,5 @@ void cbmemc_reinit(void)
init_console_ptr(cbm_cons_p,
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE, flags);
}
-/* Call cbmemc_reinit() at CAR migration time. */
-CAR_MIGRATE(cbmemc_reinit)
+ROMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit)
+RAMSTAGE_CBMEM_INIT_HOOK(cbmemc_reinit)
diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c
deleted file mode 100644
index 7b1168d..0000000
--- a/src/lib/cbmem_info.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 wacbmem_entryanty 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 <console/console.h>
-#include <cbmem.h>
-#include <stdlib.h>
-
-static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
-
-void cbmem_print_entry(int n, u32 id, u64 base, u64 size)
-{
- int i;
- const char *name;
-
- name = NULL;
- for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
- if (cbmem_ids[i].id == id) {
- name = cbmem_ids[i].name;
- break;
- }
- }
-
- if (name == NULL)
- printk(BIOS_DEBUG, "%08x ", id);
- else
- printk(BIOS_DEBUG, "%s", name);
- printk(BIOS_DEBUG, "%2d. ", n);
- printk(BIOS_DEBUG, "%08llx ", base);
- printk(BIOS_DEBUG, "%08llx\n", size);
-}
diff --git a/src/lib/ramstage.ld b/src/lib/ramstage.ld
new file mode 100644
index 0000000..732c8e9
--- /dev/null
+++ b/src/lib/ramstage.ld
@@ -0,0 +1,117 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 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
+ */
+
+/* This file is included inside a SECTIONS block */
+
+/* First we place the code and read only data (typically const declared).
+ * This could theoretically be placed in rom.
+ */
+.text : {
+ _program = .;
+ _ramstage = .;
+ _text = .;
+ *(.text._start);
+ *(.text.stage_entry);
+ *(.text);
+ *(.text.*);
+ . = ALIGN(16);
+ _etext = .;
+} : to_load
+
+#ifdef CONFIG_COVERAGE
+.ctors : {
+ . = ALIGN(0x100);
+ __CTOR_LIST__ = .;
+ KEEP(*(.ctors));
+ LONG(0);
+ LONG(0);
+ __CTOR_END__ = .;
+}
+#endif
+
+/* TODO: align data sections to cache lines? (is that really useful?) */
+.rodata : {
+ _rodata = .;
+ . = ALIGN(8);
+
+ /* If any changes are made to the driver start/symbols or the
+ * section names the equivalent changes need to made to
+ * rmodule.ld. */
+ console_drivers = .;
+ KEEP(*(.rodata.console_drivers));
+ econsole_drivers = . ;
+ . = ALIGN(8);
+ pci_drivers = . ;
+ KEEP(*(.rodata.pci_driver));
+ epci_drivers = . ;
+ cpu_drivers = . ;
+ KEEP(*(.rodata.cpu_driver));
+ ecpu_drivers = . ;
+ _bs_init_begin = .;
+ KEEP(*(.bs_init));
+ _bs_init_end = .;
+ _cbmem_init_hooks = .;
+ KEEP(*(.rodata.cbmem_init_hooks));
+ _ecbmem_init_hooks = .;
+
+ *(.rodata)
+ *(.rodata.*)
+ /* kevinh/Ispiri - Added an align, because the objcopy tool
+ * incorrectly converts sections that are not long word aligned.
+ */
+ . = ALIGN(8);
+
+ _erodata = .;
+}
+
+.data : {
+ /* Move to different cache line to avoid false sharing with .rodata. */
+ . = ALIGN(64); /* May not be actual line size, not that important. */
+ _data = .;
+ *(.data)
+ *(.data.*)
+ _edata = .;
+}
+
+.bss . : {
+ _bss = .;
+ *(.bss)
+ *(.bss.*)
+ *(.sbss)
+ *(.sbss.*)
+ _ebss = .;
+}
+
+.heap . : {
+ _heap = .;
+ /* Reserve CONFIG_HEAP_SIZE bytes for the heap */
+ . += CONFIG_HEAP_SIZE ;
+ . = ALIGN(4);
+ _eheap = .;
+ _eramstage = .;
+ _eprogram = .;
+}
+
+/* Discard the sections we don't need/want */
+
+/DISCARD/ : {
+ *(.comment)
+ *(.note)
+ *(.note.*)
+}
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index f3e7cba..ad2c852 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -48,6 +48,9 @@ SECTIONS
_bs_init_begin = .;
*(.bs_init)
_bs_init_end = .;
+ _cbmem_init_hooks = .;
+ KEEP(*(.rodata.cbmem_init_hooks));
+ _ecbmem_init_hooks = .;
. = ALIGN(8);
diff --git a/src/lib/romstage.ld b/src/lib/romstage.ld
new file mode 100644
index 0000000..bbad333
--- /dev/null
+++ b/src/lib/romstage.ld
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 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
+ */
+
+/* This file is included inside a SECTIONS block */
+
+.text . : {
+ _program = .;
+ _romstage = .;
+ *(.text._start);
+ *(.text.stage_entry);
+ *(.text);
+ *(.text.*);
+} : to_load
+
+.data . : {
+ . = ALIGN(8);
+ _cbmem_init_hooks = .;
+ KEEP(*(.rodata.cbmem_init_hooks));
+ _ecbmem_init_hooks = .;
+ *(.rodata);
+ *(.rodata.*);
+ *(.data);
+ *(.data.*);
+ . = ALIGN(8);
+}
+
+.bss . : {
+ . = ALIGN(8);
+ _bss = .;
+ *(.bss)
+ *(.bss.*)
+ *(.sbss)
+ *(.sbss.*)
+ _ebss = .;
+ _eromstage = .;
+ _eprogram = .;
+}
+
+/* Discard the sections we don't need/want */
+/DISCARD/ : {
+ *(.comment)
+ *(.note)
+ *(.comment.*)
+ *(.note.*)
+ *(.eh_frame);
+}
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index f0ee48d..f757252 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -164,4 +164,4 @@ void timestamp_reinit(void)
}
/* Call timestamp_reinit at CAR migration time. */
-CAR_MIGRATE(timestamp_reinit)
+ROMSTAGE_CBMEM_INIT_HOOK(timestamp_reinit)
diff --git a/src/soc/intel/baytrail/romstage/romstage.c b/src/soc/intel/baytrail/romstage/romstage.c
index b69b532..63e7bf4 100644
--- a/src/soc/intel/baytrail/romstage/romstage.c
+++ b/src/soc/intel/baytrail/romstage/romstage.c
@@ -178,7 +178,7 @@ static void migrate_power_state(void)
}
memcpy(ps_cbmem, ps_car, sizeof(*ps_cbmem));
}
-CAR_MIGRATE(migrate_power_state);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_power_state)
static struct chipset_power_state *fill_power_state(void)
{
diff --git a/src/soc/intel/broadwell/romstage/power_state.c b/src/soc/intel/broadwell/romstage/power_state.c
index 6e333c1..5871ad9 100644
--- a/src/soc/intel/broadwell/romstage/power_state.c
+++ b/src/soc/intel/broadwell/romstage/power_state.c
@@ -50,7 +50,7 @@ static void migrate_power_state(void)
}
memcpy(ps_cbmem, ps_car, sizeof(*ps_cbmem));
}
-CAR_MIGRATE(migrate_power_state);
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_power_state)
/* Return 0, 3, or 5 to indicate the previous sleep state. */
static int prev_sleep_state(struct chipset_power_state *ps)
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7858
-gerrit
commit 93316c2536c6a99af9ec3e5ea30fa440ff13330b
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Thu Dec 18 10:36:33 2014 +0200
arch/x86: Declare GDT symbols and move_gdt()
We relocate GDT to CBMEM, this can be done late in ramstage.
Note: We currently do this for BSP CPU only.
Change-Id: I626faaf22f846433f25ca2253d6a2a5230f50b6b
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/arch/x86/boot/gdt.c | 12 +++++-------
src/arch/x86/boot/tables.c | 2 +-
src/cpu/x86/lapic/lapic_cpu_init.c | 7 +------
src/cpu/x86/mp_init.c | 5 +----
src/include/cpu/x86/gdt.h | 34 ++++++++++++++++++++++++++++++++++
src/include/lib.h | 3 ---
6 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/src/arch/x86/boot/gdt.c b/src/arch/x86/boot/gdt.c
index 7ebf92a..7b64af7 100644
--- a/src/arch/x86/boot/gdt.c
+++ b/src/arch/x86/boot/gdt.c
@@ -20,12 +20,8 @@
#include <types.h>
#include <string.h>
#include <cbmem.h>
-#include <lib.h>
#include <console/console.h>
-
-// Global Descriptor Table, defined in c_start.S
-extern char gdt;
-extern char gdt_end;
+#include <cpu/x86/gdt.h>
/* i386 lgdt argument */
struct gdtarg {
@@ -33,11 +29,13 @@ struct gdtarg {
u32 base;
} __attribute__((packed));
-// Copy GDT to new location and reload it
+/* Copy GDT to new location and reload it.
+ * FIXME: We only do this for BSP CPU.
+ */
void move_gdt(void)
{
void *newgdt;
- u16 num_gdt_bytes = &gdt_end - &gdt;
+ u16 num_gdt_bytes = (u32)&gdt_end - (u32)&gdt;
struct gdtarg gdtarg;
newgdt = cbmem_find(CBMEM_ID_GDT);
diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c
index 9f2afd4..8685ed4 100644
--- a/src/arch/x86/boot/tables.c
+++ b/src/arch/x86/boot/tables.c
@@ -21,6 +21,7 @@
#include <console/console.h>
#include <cpu/cpu.h>
+#include <cpu/x86/gdt.h>
#include <boot/tables.h>
#include <boot/coreboot_tables.h>
#include <arch/pirq_routing.h>
@@ -28,7 +29,6 @@
#include <arch/acpi.h>
#include <string.h>
#include <cbmem.h>
-#include <lib.h>
#include <smbios.h>
diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c
index 61b6bd7..472d6ed 100644
--- a/src/cpu/x86/lapic/lapic_cpu_init.c
+++ b/src/cpu/x86/lapic/lapic_cpu_init.c
@@ -21,6 +21,7 @@
*/
#include <cpu/x86/cr.h>
+#include <cpu/x86/gdt.h>
#include <cpu/x86/lapic.h>
#include <delay.h>
#include <halt.h>
@@ -53,11 +54,6 @@ char *lowmem_backup_ptr;
int lowmem_backup_size;
#endif
-extern char _secondary_start[];
-extern char _secondary_gdt_addr[];
-extern char gdt[];
-extern char gdt_end[];
-
static inline void setup_secondary_gdt(void)
{
u16 *gdt_limit;
@@ -72,7 +68,6 @@ static inline void setup_secondary_gdt(void)
static void copy_secondary_start_to_lowest_1M(void)
{
- extern char _secondary_start_end[];
unsigned long code_size;
/* Fill in secondary_start's local gdt. */
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index a97a4c5..3e293f6 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -26,6 +26,7 @@
#include <cpu/cpu.h>
#include <cpu/intel/microcode.h>
#include <cpu/x86/cache.h>
+#include <cpu/x86/gdt.h>
#include <cpu/x86/lapic.h>
#include <cpu/x86/name.h>
#include <cpu/x86/msr.h>
@@ -67,10 +68,6 @@ struct saved_msr {
/* The sipi vector rmodule is included in the ramstage using 'objdump -B'. */
extern char _binary_sipi_vector_start[];
-/* These symbols are defined in c_start.S. */
-extern char gdt[];
-extern char gdt_end[];
-extern char idtarg[];
/* The SIPI vector is loaded at the SMM_DEFAULT_BASE. The reason is at the
* memory range is already reserved so the OS cannot use it. That region is
diff --git a/src/include/cpu/x86/gdt.h b/src/include/cpu/x86/gdt.h
new file mode 100644
index 0000000..260b158
--- /dev/null
+++ b/src/include/cpu/x86/gdt.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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
+ */
+
+#ifndef CPU_X86_GDT
+#define CPU_X86_GDT
+
+/* These symbols are defined in c_start.S. */
+extern char gdt[];
+extern char gdt_end[];
+extern char idtarg[];
+
+/* These symbols are defined in secondary.S. */
+extern char _secondary_gdt_addr[];
+extern char _secondary_start[];
+extern char _secondary_start_end[];
+
+/* Defined in src/arch/x86/boot/gdt.c */
+void move_gdt(void);
+
+#endif /* CPU_X86_GDT */
diff --git a/src/include/lib.h b/src/include/lib.h
index 8f02004..772a66f 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -33,9 +33,6 @@ unsigned long log2_ceil(unsigned long x);
/* Defined in src/lib/lzma.c */
unsigned long ulzma(unsigned char *src, unsigned char *dst);
-/* Defined in src/arch/x86/boot/gdt.c */
-void move_gdt(void);
-
/* Defined in src/lib/ramtest.c */
void ram_check(unsigned long start, unsigned long stop);
int ram_check_nodie(unsigned long start, unsigned long stop);
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7876
-gerrit
commit 9b8adf1ea1c6c8d3c4df9838939738858d53c12e
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Thu Dec 18 18:30:29 2014 +0200
CBMEM: Implement cbmem_arch_init() for romstage too
Until we completely can unify early_variables, use this to
handle CBMEM update hooks for both romstage and ramstage.
Change-Id: I100ebc0e35e1b7091b4f287ca37f539fd7c9fa7a
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/arch/arm/Makefile.inc | 2 ++
src/arch/arm/cbmem.c | 26 ++++++++++++++++++++++++++
src/arch/arm/tables.c | 8 --------
src/arch/arm64/Makefile.inc | 2 ++
src/arch/arm64/cbmem.c | 8 ++++++++
src/arch/arm64/tables.c | 4 ----
src/arch/riscv/Makefile.inc | 2 ++
src/arch/riscv/cbmem.c | 26 ++++++++++++++++++++++++++
src/arch/riscv/tables.c | 8 --------
src/arch/x86/boot/cbmem.c | 17 +++++++++++------
src/arch/x86/boot/tables.c | 8 --------
src/include/cbmem.h | 8 +++-----
12 files changed, 80 insertions(+), 39 deletions(-)
diff --git a/src/arch/arm/Makefile.inc b/src/arch/arm/Makefile.inc
index 5698f38..fefaeb1 100644
--- a/src/arch/arm/Makefile.inc
+++ b/src/arch/arm/Makefile.inc
@@ -76,6 +76,7 @@ ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y)
romstage-y += stages.c
romstage-y += div0.c
romstage-y += eabi_compat.c
+romstage-y += cbmem.c
romstage-y += memset.S
romstage-y += memcpy.S
romstage-y += memmove.S
@@ -100,6 +101,7 @@ ramstage-y += cpu.c
ramstage-y += eabi_compat.c
ramstage-y += boot.c
ramstage-y += tables.c
+ramstage-y += cbmem.c
ramstage-y += memset.S
ramstage-y += memcpy.S
ramstage-y += memmove.S
diff --git a/src/arch/arm/cbmem.c b/src/arch/arm/cbmem.c
new file mode 100644
index 0000000..339b71e
--- /dev/null
+++ b/src/arch/arm/cbmem.c
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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 <cbmem.h>
+
+void cbmem_arch_init(void)
+{
+}
+
+void cbmem_fail_resume(void)
+{
+}
diff --git a/src/arch/arm/tables.c b/src/arch/arm/tables.c
index 20c5a9f..cdeeb36 100644
--- a/src/arch/arm/tables.c
+++ b/src/arch/arm/tables.c
@@ -38,14 +38,6 @@ void __attribute__((weak)) get_cbmem_table(uint64_t *base, uint64_t *size)
}
#endif
-void cbmem_arch_init(void)
-{
-}
-
-void cbmem_fail_resume(void)
-{
-}
-
void write_tables(void)
{
unsigned long table_pointer, new_table_pointer;
diff --git a/src/arch/arm64/Makefile.inc b/src/arch/arm64/Makefile.inc
index 5bf72b2..b4df4aa 100644
--- a/src/arch/arm64/Makefile.inc
+++ b/src/arch/arm64/Makefile.inc
@@ -74,6 +74,7 @@ romstage-y += stages.c
romstage-y += div0.c
romstage-y += early_console.c
romstage-y += eabi_compat.c
+romstage-y += cbmem.c
romstage-y += memset.S
romstage-y += memcpy.S
romstage-y += memmove.S
@@ -99,6 +100,7 @@ ramstage-y += cpu.c
ramstage-y += eabi_compat.c
ramstage-y += boot.c
ramstage-y += tables.c
+ramstage-y += cbmem.c
ramstage-y += memset.S
ramstage-y += memcpy.S
ramstage-y += memmove.S
diff --git a/src/arch/arm64/cbmem.c b/src/arch/arm64/cbmem.c
index b33e9b8..e333cfc 100644
--- a/src/arch/arm64/cbmem.c
+++ b/src/arch/arm64/cbmem.c
@@ -28,3 +28,11 @@ void *cbmem_top(void)
{
return (void *)get_top_of_ram();
}
+
+void cbmem_arch_init(void)
+{
+}
+
+void cbmem_fail_resume(void)
+{
+}
diff --git a/src/arch/arm64/tables.c b/src/arch/arm64/tables.c
index 49fab9f..825d7a2 100644
--- a/src/arch/arm64/tables.c
+++ b/src/arch/arm64/tables.c
@@ -38,10 +38,6 @@ uint64_t high_tables_base = 0;
uint64_t high_tables_size;
#endif
-void cbmem_arch_init(void)
-{
-}
-
struct lb_memory *write_tables(void)
{
unsigned long table_pointer, new_table_pointer;
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index 242fd40..ab4ecbd 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -54,6 +54,7 @@ ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)
romstage-y += stages.c
romstage-y += rom_media.c
+romstage-y += cbmem.c
romstage-y += \
$(top)/src/lib/memchr.c \
$(top)/src/lib/memcmp.c \
@@ -87,6 +88,7 @@ ramstage-y += rom_media.c
ramstage-y += stages.c
ramstage-y += misc.c
ramstage-y += boot.c
+ramstage-y += cbmem.c
ramstage-y += tables.c
ramstage-y += \
$(top)/src/lib/memchr.c \
diff --git a/src/arch/riscv/cbmem.c b/src/arch/riscv/cbmem.c
new file mode 100644
index 0000000..339b71e
--- /dev/null
+++ b/src/arch/riscv/cbmem.c
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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 <cbmem.h>
+
+void cbmem_arch_init(void)
+{
+}
+
+void cbmem_fail_resume(void)
+{
+}
diff --git a/src/arch/riscv/tables.c b/src/arch/riscv/tables.c
index 6300f7b..124a659 100644
--- a/src/arch/riscv/tables.c
+++ b/src/arch/riscv/tables.c
@@ -29,10 +29,6 @@
#define MAX_COREBOOT_TABLE_SIZE (8 * 1024)
-void cbmem_arch_init(void)
-{
-}
-
// WTF. this does not agre with the prototype!
static struct lb_memory *wtf_write_tables(void)
{
@@ -70,7 +66,3 @@ void write_tables(void)
{
wtf_write_tables();
}
-
-void cbmem_fail_resume(void)
-{
-}
diff --git a/src/arch/x86/boot/cbmem.c b/src/arch/x86/boot/cbmem.c
index 8b2b6da..920ca99 100644
--- a/src/arch/x86/boot/cbmem.c
+++ b/src/arch/x86/boot/cbmem.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <console/console.h>
+#include <cpu/x86/gdt.h>
#include <cbmem.h>
#include <arch/acpi.h>
@@ -69,16 +70,20 @@ void *cbmem_top(void)
#endif /* DYNAMIC_CBMEM */
+void cbmem_arch_init(void)
+{
+
#if !defined(__PRE_RAM__)
+ move_gdt();
+#endif
+}
-/* ACPI resume needs to be cleared in the fail-to-recover case, but that
- * condition is only handled during ramstage. */
+/* Something went wrong, our high memory area got wiped */
void cbmem_fail_resume(void)
{
-#if CONFIG_HAVE_ACPI_RESUME
- /* Something went wrong, our high memory area got wiped */
+#if !defined(__PRE_RAM__) && IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
+ /* ACPI resume needs to be cleared in the fail-to-recover case, but that
+ * condition is only handled during ramstage. */
acpi_fail_wakeup();
#endif
}
-
-#endif /* !__PRE_RAM__ */
diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c
index 8685ed4..c2265ea 100644
--- a/src/arch/x86/boot/tables.c
+++ b/src/arch/x86/boot/tables.c
@@ -21,7 +21,6 @@
#include <console/console.h>
#include <cpu/cpu.h>
-#include <cpu/x86/gdt.h>
#include <boot/tables.h>
#include <boot/coreboot_tables.h>
#include <arch/pirq_routing.h>
@@ -31,13 +30,6 @@
#include <cbmem.h>
#include <smbios.h>
-
-void cbmem_arch_init(void)
-{
- /* defined in gdt.c */
- move_gdt();
-}
-
void write_tables(void)
{
unsigned long low_table_start, low_table_end;
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 7de6e56..a7bd904 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -213,17 +213,15 @@ void *cbmem_add(u32 id, u64 size);
/* Find a cbmem entry of a given id. These return NULL on failure. */
void *cbmem_find(u32 id);
+void cbmem_arch_init(void);
+void cbmem_fail_resume(void);
+
#ifndef __PRE_RAM__
/* Ramstage only functions. */
/* Add the cbmem memory used to the memory map at boot. */
void cbmem_add_bootmem(void);
void cbmem_list(void);
-void cbmem_arch_init(void);
void cbmem_print_entry(int n, u32 id, u64 start, u64 size);
-void cbmem_fail_resume(void);
-#else
-static inline void cbmem_arch_init(void) {}
-static inline void cbmem_fail_resume(void) {}
#endif /* __PRE_RAM__ */
#endif /* __ASSEMBLER__ */
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7469
-gerrit
commit 23591bcc34464832d5ea34f07c3c29b06bcaa69a
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Nov 10 15:08:47 2014 +0200
ARM: Always select DYNAMIC_CBMEM
TODO before merge: proper cbmem_top(), there is now just empty stub.
Change-Id: I6939559c720383978a3afec8b6da789f895c81d2
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/arch/arm/tables.c | 9 ---------
src/arch/arm64/cbmem.c | 12 ------------
src/arch/arm64/tables.c | 17 -----------------
src/cpu/allwinner/a10/Kconfig | 1 +
src/cpu/allwinner/a10/cbmem.c | 4 ----
src/cpu/ti/am335x/Kconfig | 1 +
src/cpu/ti/am335x/Makefile.inc | 2 ++
src/cpu/ti/am335x/cbmem.c | 24 ++++++++++++++++++++++++
src/mainboard/emulation/qemu-armv7/Kconfig | 1 +
src/mainboard/emulation/qemu-armv7/Makefile.inc | 3 +++
src/mainboard/emulation/qemu-armv7/cbmem.c | 24 ++++++++++++++++++++++++
src/soc/qualcomm/ipq806x/Kconfig | 1 +
src/soc/qualcomm/ipq806x/Makefile.inc | 2 ++
src/soc/qualcomm/ipq806x/cbmem.c | 24 ++++++++++++++++++++++++
14 files changed, 83 insertions(+), 42 deletions(-)
diff --git a/src/arch/arm/tables.c b/src/arch/arm/tables.c
index cdeeb36..09385b6 100644
--- a/src/arch/arm/tables.c
+++ b/src/arch/arm/tables.c
@@ -29,15 +29,6 @@
#define MAX_COREBOOT_TABLE_SIZE (8 * 1024)
-#if !CONFIG_DYNAMIC_CBMEM
-void __attribute__((weak)) get_cbmem_table(uint64_t *base, uint64_t *size)
-{
- printk(BIOS_WARNING, "WARNING: you need to define get_cbmem_table for your board\n");
- *base = 0;
- *size = 0;
-}
-#endif
-
void write_tables(void)
{
unsigned long table_pointer, new_table_pointer;
diff --git a/src/arch/arm64/cbmem.c b/src/arch/arm64/cbmem.c
index 10557fb..4fad34f 100644
--- a/src/arch/arm64/cbmem.c
+++ b/src/arch/arm64/cbmem.c
@@ -18,18 +18,6 @@
#include <cbmem.h>
#include <console/cbmem_console.h>
-unsigned long get_top_of_ram(void);
-
-unsigned long get_top_of_ram(void)
-{
- return CONFIG_RAMTOP;
-}
-
-void *cbmem_top(void)
-{
- return (void *)get_top_of_ram();
-}
-
void cbmem_arch_init(void)
{
/* Relocate CBMEM console. */
diff --git a/src/arch/arm64/tables.c b/src/arch/arm64/tables.c
index 825d7a2..f71c215 100644
--- a/src/arch/arm64/tables.c
+++ b/src/arch/arm64/tables.c
@@ -29,27 +29,10 @@
#define MAX_COREBOOT_TABLE_SIZE (8 * 1024)
-#if ! CONFIG_DYNAMIC_CBMEM
-/*
- * TODO: "High" tables are a convention used on x86. Maybe we can
- * clean up that naming at some point.
- */
-uint64_t high_tables_base = 0;
-uint64_t high_tables_size;
-#endif
-
struct lb_memory *write_tables(void)
{
unsigned long table_pointer, new_table_pointer;
-#if ! CONFIG_DYNAMIC_CBMEM
- if (!high_tables_base) {
- printk(BIOS_ERR, "ERROR: high_tables_base is not set.\n");
- }
-
- printk(BIOS_DEBUG, "high_tables_base: %llx.\n", high_tables_base);
-#endif
-
post_code(0x9d);
table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE,
diff --git a/src/cpu/allwinner/a10/Kconfig b/src/cpu/allwinner/a10/Kconfig
index 2bf32ec..b7b435f 100644
--- a/src/cpu/allwinner/a10/Kconfig
+++ b/src/cpu/allwinner/a10/Kconfig
@@ -13,6 +13,7 @@ config CPU_SPECIFIC_OPTIONS
select HAVE_UART_SPECIAL
select BOOTBLOCK_CONSOLE
select CPU_HAS_BOOTBLOCK_INIT
+ select DYNAMIC_CBMEM
# The "eGON.BT0" header takes 32 bytes
config BOOTBLOCK_BASE
diff --git a/src/cpu/allwinner/a10/cbmem.c b/src/cpu/allwinner/a10/cbmem.c
index 84dc2bf..e051f06 100644
--- a/src/cpu/allwinner/a10/cbmem.c
+++ b/src/cpu/allwinner/a10/cbmem.c
@@ -8,11 +8,7 @@
#include "ram_segs.h"
#include <cbmem.h>
-#if IS_ENABLED(CONFIG_DYNAMIC_CBMEM)
-
void *cbmem_top(void)
{
return a1x_get_cbmem_top();
}
-
-#endif
diff --git a/src/cpu/ti/am335x/Kconfig b/src/cpu/ti/am335x/Kconfig
index fae527d..eb60ad1 100644
--- a/src/cpu/ti/am335x/Kconfig
+++ b/src/cpu/ti/am335x/Kconfig
@@ -6,6 +6,7 @@ config CPU_TI_AM335X
select HAVE_UART_SPECIAL
select BOOTBLOCK_CONSOLE
select CPU_HAS_BOOTBLOCK_INIT
+ select DYNAMIC_CBMEM
bool
default n
diff --git a/src/cpu/ti/am335x/Makefile.inc b/src/cpu/ti/am335x/Makefile.inc
index 24d2594..45188ce 100644
--- a/src/cpu/ti/am335x/Makefile.inc
+++ b/src/cpu/ti/am335x/Makefile.inc
@@ -4,11 +4,13 @@ bootblock-y += dmtimer.c
bootblock-y += pinmux.c
romstage-y += nand.c
+romstage-y += cbmem.c
ramstage-y += dmtimer.c
ramstage-y += monotonic_timer.c
ramstage-y += nand.c
ramstage-y += timer.c
+ramstage-y += cbmem.c
ifeq ($(CONFIG_DRIVERS_UART),y)
bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += uart.c
diff --git a/src/cpu/ti/am335x/cbmem.c b/src/cpu/ti/am335x/cbmem.c
new file mode 100644
index 0000000..c104e9c
--- /dev/null
+++ b/src/cpu/ti/am335x/cbmem.c
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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 <stddef.h>
+#include <cbmem.h>
+
+void *cbmem_top(void)
+{
+ return NULL;
+}
diff --git a/src/mainboard/emulation/qemu-armv7/Kconfig b/src/mainboard/emulation/qemu-armv7/Kconfig
index b275e88..7e24a20 100644
--- a/src/mainboard/emulation/qemu-armv7/Kconfig
+++ b/src/mainboard/emulation/qemu-armv7/Kconfig
@@ -32,6 +32,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select ARM_ROMSTAGE_ARMV7
select ARM_RAMSTAGE_ARMV7
select BOARD_ROMSIZE_KB_4096
+ select DYNAMIC_CBMEM
config MAINBOARD_DIR
string
diff --git a/src/mainboard/emulation/qemu-armv7/Makefile.inc b/src/mainboard/emulation/qemu-armv7/Makefile.inc
index e088da6..4119f93 100644
--- a/src/mainboard/emulation/qemu-armv7/Makefile.inc
+++ b/src/mainboard/emulation/qemu-armv7/Makefile.inc
@@ -14,6 +14,9 @@
romstage-y += romstage.c
+romstage-y += cbmem.c
+ramstage-y += cbmem.c
+
bootblock-y += media.c
romstage-y += media.c
ramstage-y += media.c
diff --git a/src/mainboard/emulation/qemu-armv7/cbmem.c b/src/mainboard/emulation/qemu-armv7/cbmem.c
new file mode 100644
index 0000000..c104e9c
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv7/cbmem.c
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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 <stddef.h>
+#include <cbmem.h>
+
+void *cbmem_top(void)
+{
+ return NULL;
+}
diff --git a/src/soc/qualcomm/ipq806x/Kconfig b/src/soc/qualcomm/ipq806x/Kconfig
index 0fb780c..a6ddf81 100644
--- a/src/soc/qualcomm/ipq806x/Kconfig
+++ b/src/soc/qualcomm/ipq806x/Kconfig
@@ -2,6 +2,7 @@ config SOC_QC_IPQ806X
select ARCH_BOOTBLOCK_ARMV4
select ARCH_ROMSTAGE_ARMV7
select ARCH_RAMSTAGE_ARMV7
+ select DYNAMIC_CBMEM
bool
default n
diff --git a/src/soc/qualcomm/ipq806x/Makefile.inc b/src/soc/qualcomm/ipq806x/Makefile.inc
index dfbbf3d..15396f0 100644
--- a/src/soc/qualcomm/ipq806x/Makefile.inc
+++ b/src/soc/qualcomm/ipq806x/Makefile.inc
@@ -24,11 +24,13 @@ bootblock-y += gpio.c
bootblock-y += timer.c
romstage-y += cbfs.c
+romstage-y += cbmem.c
romstage-y += clock.c
romstage-y += gpio.c
romstage-y += timer.c
ramstage-y += cbfs.c
+ramstage-y += cbmem.c
ramstage-y += clock.c
ramstage-y += gpio.c
ramstage-y += timer.c
diff --git a/src/soc/qualcomm/ipq806x/cbmem.c b/src/soc/qualcomm/ipq806x/cbmem.c
new file mode 100644
index 0000000..c104e9c
--- /dev/null
+++ b/src/soc/qualcomm/ipq806x/cbmem.c
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * 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 <stddef.h>
+#include <cbmem.h>
+
+void *cbmem_top(void)
+{
+ return NULL;
+}
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7888
-gerrit
commit 74001b21f24189de964a86d9acc61bbcd8ae245b
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Dec 22 12:28:07 2014 +0200
CBMEM: Do not use get_top_of_ram() with DYNAMIC_CBMEM
The name was always obscure and confusing. Instead define cbmem_top()
directly in the chipset code for x86 like on ARMs.
TODO: Check TSEG alignment, it used for MTRR programming.
Change-Id: Ibbe5f05ab9c7d87d09caa673766cd17d192cd045
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/arch/x86/boot/cbmem.c | 9 ++---
src/cpu/intel/haswell/romstage.c | 4 +-
src/include/cbmem.h | 4 +-
src/mainboard/emulation/qemu-i440fx/memory.c | 4 +-
src/northbridge/intel/fsp_rangeley/raminit.c | 14 ++++---
src/northbridge/intel/fsp_sandybridge/Makefile.inc | 2 +
.../intel/fsp_sandybridge/northbridge.c | 10 -----
src/northbridge/intel/fsp_sandybridge/ram_calc.c | 38 +++++++++++++++++
src/northbridge/intel/fsp_sandybridge/raminit.c | 8 ----
src/northbridge/intel/gm45/ram_calc.c | 7 +++-
src/northbridge/intel/haswell/ram_calc.c | 11 +++--
src/northbridge/intel/i945/ram_calc.c | 11 +++--
src/northbridge/intel/nehalem/ram_calc.c | 11 +++--
src/northbridge/intel/sandybridge/ram_calc.c | 11 +++--
src/soc/intel/baytrail/baytrail/smm.h | 2 +-
src/soc/intel/baytrail/memmap.c | 8 ++--
src/soc/intel/broadwell/memmap.c | 13 ++++--
src/soc/intel/fsp_baytrail/Makefile.inc | 2 -
src/soc/intel/fsp_baytrail/baytrail/smm.h | 2 +-
src/soc/intel/fsp_baytrail/memmap.c | 22 +++++++++-
src/soc/intel/fsp_baytrail/raminit.c | 47 ----------------------
21 files changed, 131 insertions(+), 109 deletions(-)
diff --git a/src/arch/x86/boot/cbmem.c b/src/arch/x86/boot/cbmem.c
index c1c2af7..9401ac8 100644
--- a/src/arch/x86/boot/cbmem.c
+++ b/src/arch/x86/boot/cbmem.c
@@ -54,23 +54,20 @@ void set_top_of_ram(uint64_t ramtop)
}
#endif /* !__PRE_RAM__ */
-#if IS_ENABLED(CONFIG_LATE_CBMEM_INIT)
unsigned long __attribute__((weak)) get_top_of_ram(void)
{
printk(BIOS_WARNING, "WARNING: you need to define get_top_of_ram() for your chipset\n");
return 0;
}
-#endif
-
-#else
+#if IS_ENABLED(CONFIG_DYNAMIC_CBMEM)
void *cbmem_top(void)
{
/* Top of cbmem is at lowest usable DRAM address below 4GiB. */
return (void *)get_top_of_ram();
}
-
-#endif /* DYNAMIC_CBMEM */
+#endif
+#endif /* !DYNAMIC_CBMEM */
void cbmem_arch_init(void)
{
diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c
index bd2513f..1af5259 100644
--- a/src/cpu/intel/haswell/romstage.c
+++ b/src/cpu/intel/haswell/romstage.c
@@ -133,7 +133,7 @@ static void *setup_romstage_stack_after_car(void)
slot = stack_push(slot, 0 | MTRR_TYPE_WRBACK);
num_mtrrs++;
- top_of_ram = get_top_of_ram();
+ top_of_ram = (uint32_t)cbmem_top();
/* Cache 8MiB below the top of ram. On haswell systems the top of
* ram under 4GiB is the start of the TSEG region. It is required to
* be 8MiB aligned. Set this area as cacheable so it can be used later
@@ -318,7 +318,7 @@ struct ramstage_cache *ramstage_cache_location(long *size)
/* The ramstage cache lives in the TSEG region at RESERVED_SMM_OFFSET.
* The top of ram is defined to be the TSEG base address. */
*size = RESERVED_SMM_SIZE;
- return (void *)(get_top_of_ram() + RESERVED_SMM_OFFSET);
+ return (void *)((uint32_t)cbmem_top() + RESERVED_SMM_OFFSET);
}
void ramstage_cache_invalid(struct ramstage_cache *cache)
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index a7bd904..1b7f307 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -190,6 +190,8 @@ void backup_top_of_ram(uint64_t ramtop);
void cbmem_late_set_table(uint64_t base, uint64_t size);
#endif
+unsigned long get_top_of_ram(void);
+
void get_cbmem_table(uint64_t *base, uint64_t *size);
struct cbmem_entry *get_cbmem_toc(void);
@@ -201,8 +203,6 @@ static inline const struct cbmem_entry *cbmem_entry_find(uint32_t id)
/* Common API between cbmem and dynamic cbmem. */
-unsigned long get_top_of_ram(void);
-
/* Returns 0 if old cbmem was recovered. Recovery is only attempted if
* s3resume is non-zero. */
int cbmem_recovery(int s3resume);
diff --git a/src/mainboard/emulation/qemu-i440fx/memory.c b/src/mainboard/emulation/qemu-i440fx/memory.c
index a189d75..d43b4e9 100644
--- a/src/mainboard/emulation/qemu-i440fx/memory.c
+++ b/src/mainboard/emulation/qemu-i440fx/memory.c
@@ -40,7 +40,7 @@ static unsigned long qemu_get_memory_size(void)
return tomk;
}
-unsigned long get_top_of_ram(void)
+void *cbmem_top(void)
{
- return qemu_get_memory_size() * 1024;
+ return (void *) (qemu_get_memory_size() * 1024);
}
diff --git a/src/northbridge/intel/fsp_rangeley/raminit.c b/src/northbridge/intel/fsp_rangeley/raminit.c
index 3513c0f..ea750e7 100644
--- a/src/northbridge/intel/fsp_rangeley/raminit.c
+++ b/src/northbridge/intel/fsp_rangeley/raminit.c
@@ -26,19 +26,23 @@
#include "northbridge.h"
#include <drivers/intel/fsp/fsp_util.h>
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
/*
* Calculate the top of usable (low) DRAM.
* The FSP's reserved memory sits just below the SMM region,
* allowing calculation of the top of usable memory.
*/
- u32 tom = sideband_read(B_UNIT, BMBOUND);
- u32 bsmmrrl = sideband_read(B_UNIT, BSMMRRL) << 20;
+ uintptr_t tom = sideband_read(B_UNIT, BMBOUND);
+ uintptr_t bsmmrrl = sideband_read(B_UNIT, BSMMRRL) << 20;
if (bsmmrrl) {
tom = bsmmrrl;
}
- tom -= FSP_RESERVE_MEMORY_SIZE;
- return (unsigned long) tom;
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start() - FSP_RESERVE_MEMORY_SIZE;
}
diff --git a/src/northbridge/intel/fsp_sandybridge/Makefile.inc b/src/northbridge/intel/fsp_sandybridge/Makefile.inc
index 080a7f4..ca6f345 100644
--- a/src/northbridge/intel/fsp_sandybridge/Makefile.inc
+++ b/src/northbridge/intel/fsp_sandybridge/Makefile.inc
@@ -20,11 +20,13 @@
subdirs-y += fsp
ramstage-y += northbridge.c
+ramstage-y += ram_calc.c
ramstage-y += gma.c
ramstage-y += acpi.c
romstage-y += raminit.c
+romstage-y += ram_calc.c
romstage-y += early_init.c
romstage-y += report_platform.c
romstage-y += ../../../arch/x86/lib/walkcbfs.S
diff --git a/src/northbridge/intel/fsp_sandybridge/northbridge.c b/src/northbridge/intel/fsp_sandybridge/northbridge.c
index a95d736..b39f4c9 100644
--- a/src/northbridge/intel/fsp_sandybridge/northbridge.c
+++ b/src/northbridge/intel/fsp_sandybridge/northbridge.c
@@ -245,16 +245,6 @@ static void pci_domain_set_resources(device_t dev)
assign_resources(dev->link_list);
}
-unsigned long get_top_of_ram(void)
-{
- struct device *dev = dev_find_slot(0, PCI_DEVFN(0, 0));
-
- /* Base of TSEG is top of usable DRAM */
- u32 tom = pci_read_config32(dev, TSEG) & ~(1UL << 0);
- tom -= 0x200000; /* 2MB for FSP HOB */
- return (unsigned long) tom;
-}
-
/* TODO We could determine how many PCIe busses we need in
* the bar. For now that number is hardcoded to a max of 64.
* See e7525/northbridge.c for an example.
diff --git a/src/northbridge/intel/fsp_sandybridge/ram_calc.c b/src/northbridge/intel/fsp_sandybridge/ram_calc.c
new file mode 100644
index 0000000..bbfc874
--- /dev/null
+++ b/src/northbridge/intel/fsp_sandybridge/ram_calc.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 Google Inc.
+ * Copyright (C) 2013 Sage Electronic Engineering, LLC.
+ *
+ * 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
+ */
+
+#define __SIMPLE_DEVICE__
+
+#include <arch/io.h>
+#include <cbmem.h>
+#include <fsp_util.h>
+#include "northbridge.h"
+
+static uintptr_t smm_region_start(void)
+{
+ /* Base of TSEG is top of usable DRAM */
+ uintptr_t tom = pci_read_config32(PCI_DEV(0,0,0), TSEG) & ~(1UL << 0);
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start() - FSP_RESERVE_MEMORY_SIZE;
+}
diff --git a/src/northbridge/intel/fsp_sandybridge/raminit.c b/src/northbridge/intel/fsp_sandybridge/raminit.c
index 19b48ca..8689274 100644
--- a/src/northbridge/intel/fsp_sandybridge/raminit.c
+++ b/src/northbridge/intel/fsp_sandybridge/raminit.c
@@ -74,11 +74,3 @@ void report_memory_config(void)
((ch_conf >> 16) & 1) ? ", selected" : "");
}
}
-
-unsigned long get_top_of_ram(void)
-{
- /* Base of TSEG is top of usable DRAM */
- u32 tom = pci_read_config32(PCI_DEV(0,0,0), TSEG) & ~(1UL << 0);
- tom -= 0x200000; /* 2MB for FSP HOB */
- return (unsigned long) tom;
-}
diff --git a/src/northbridge/intel/gm45/ram_calc.c b/src/northbridge/intel/gm45/ram_calc.c
index c8c15d3..d9d3357 100644
--- a/src/northbridge/intel/gm45/ram_calc.c
+++ b/src/northbridge/intel/gm45/ram_calc.c
@@ -86,7 +86,7 @@ u32 decode_igd_gtt_size(const u32 gsm)
}
}
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
const pci_devfn_t dev = PCI_DEV(0, 0, 0);
@@ -105,3 +105,8 @@ unsigned long get_top_of_ram(void)
}
return tor;
}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start();
+}
diff --git a/src/northbridge/intel/haswell/ram_calc.c b/src/northbridge/intel/haswell/ram_calc.c
index 99e7d67..01ad50d 100644
--- a/src/northbridge/intel/haswell/ram_calc.c
+++ b/src/northbridge/intel/haswell/ram_calc.c
@@ -24,12 +24,17 @@
#include <cbmem.h>
#include "haswell.h"
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
/*
* Base of TSEG is top of usable DRAM below 4GiB. The register has
* 1 MiB alignement.
*/
- u32 tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
- return (unsigned long) tom & ~((1 << 20) - 1);
+ uintptr_t tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
+ return tom & ~((1 << 20) - 1);
+}
+
+void *cbmem_top(void)
+{
+ return (void *)smm_region_start();
}
diff --git a/src/northbridge/intel/i945/ram_calc.c b/src/northbridge/intel/i945/ram_calc.c
index d09b2e1..4b7d895 100644
--- a/src/northbridge/intel/i945/ram_calc.c
+++ b/src/northbridge/intel/i945/ram_calc.c
@@ -24,9 +24,9 @@
#include <cbmem.h>
#include "i945.h"
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
- u32 tom;
+ uintptr_t tom;
if (pci_read_config8(PCI_DEV(0, 0x0, 0), DEVEN) & (DEVEN_D2F0 | DEVEN_D2F1)) {
/* IGD enabled, get top of Memory from BSM register */
@@ -53,5 +53,10 @@ unsigned long get_top_of_ram(void)
/* TSEG either disabled or invalid */
break;
}
- return (unsigned long) tom;
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start();
}
diff --git a/src/northbridge/intel/nehalem/ram_calc.c b/src/northbridge/intel/nehalem/ram_calc.c
index db57a3d..d36684e 100644
--- a/src/northbridge/intel/nehalem/ram_calc.c
+++ b/src/northbridge/intel/nehalem/ram_calc.c
@@ -23,9 +23,14 @@
#include <cbmem.h>
#include "nehalem.h"
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
/* Base of TSEG is top of usable DRAM */
- u32 tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
- return (unsigned long) tom;
+ uintptr_t tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start();
}
diff --git a/src/northbridge/intel/sandybridge/ram_calc.c b/src/northbridge/intel/sandybridge/ram_calc.c
index 3693a07..e147909 100644
--- a/src/northbridge/intel/sandybridge/ram_calc.c
+++ b/src/northbridge/intel/sandybridge/ram_calc.c
@@ -23,9 +23,14 @@
#include <cbmem.h>
#include "sandybridge.h"
-unsigned long get_top_of_ram(void)
+static uintptr_t smm_region_start(void)
{
/* Base of TSEG is top of usable DRAM */
- u32 tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
- return (unsigned long) tom;
+ uintptr_t tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) smm_region_start();
}
diff --git a/src/soc/intel/baytrail/baytrail/smm.h b/src/soc/intel/baytrail/baytrail/smm.h
index 5ead89f..0d920fb 100644
--- a/src/soc/intel/baytrail/baytrail/smm.h
+++ b/src/soc/intel/baytrail/baytrail/smm.h
@@ -31,7 +31,7 @@ static inline int smm_region_size(void)
return CONFIG_SMM_TSEG_SIZE;
}
-void *smm_region_start(void);
+uintptr_t smm_region_start(void);
#if !defined(__PRE_RAM__) && !defined(__SMM___)
#include <stdint.h>
diff --git a/src/soc/intel/baytrail/memmap.c b/src/soc/intel/baytrail/memmap.c
index f383d82..f2e14b3 100644
--- a/src/soc/intel/baytrail/memmap.c
+++ b/src/soc/intel/baytrail/memmap.c
@@ -22,12 +22,12 @@
#include <baytrail/iosf.h>
#include <baytrail/smm.h>
-void *smm_region_start(void)
+uintptr_t smm_region_start(void)
{
- return (void *)(iosf_bunit_read(BUNIT_SMRRL) << 20);
+ return (iosf_bunit_read(BUNIT_SMRRL) << 20);
}
-unsigned long get_top_of_ram(void)
+void *cbmem_top(void)
{
- return (unsigned long)smm_region_start();
+ return (void *) smm_region_start();
}
diff --git a/src/soc/intel/broadwell/memmap.c b/src/soc/intel/broadwell/memmap.c
index 046cc1d..28f4062 100644
--- a/src/soc/intel/broadwell/memmap.c
+++ b/src/soc/intel/broadwell/memmap.c
@@ -23,19 +23,24 @@
#include <broadwell/pci_devs.h>
#include <broadwell/systemagent.h>
-unsigned long get_top_of_ram(void)
+static uintptr_t dpr_region_start(void)
{
/*
* Base of DPR is top of usable DRAM below 4GiB. The register has
* 1 MiB alignment and reports the TOP of the range, the base
* must be calculated from the size in MiB in bits 11:4.
*/
- u32 dpr = pci_read_config32(SA_DEV_ROOT, DPR);
- u32 tom = dpr & ~((1 << 20) - 1);
+ uintptr_t dpr = pci_read_config32(SA_DEV_ROOT, DPR);
+ uintptr_t tom = dpr & ~((1 << 20) - 1);
/* Subtract DMA Protected Range size if enabled */
if (dpr & DPR_EPM)
tom -= (dpr & DPR_SIZE_MASK) << 16;
- return (unsigned long)tom;
+ return tom;
+}
+
+void *cbmem_top(void)
+{
+ return (void *) dpr_region_start();
}
diff --git a/src/soc/intel/fsp_baytrail/Makefile.inc b/src/soc/intel/fsp_baytrail/Makefile.inc
index fcbe6e7..3896e85 100644
--- a/src/soc/intel/fsp_baytrail/Makefile.inc
+++ b/src/soc/intel/fsp_baytrail/Makefile.inc
@@ -44,8 +44,6 @@ ramstage-y += ramstage.c
ramstage-y += gpio.c
romstage-y += gpio.c
ramstage-y += pmutil.c
-romstage-y += raminit.c
-ramstage-y += raminit.c
ramstage-y += southcluster.c
romstage-y += reset.c
ramstage-y += reset.c
diff --git a/src/soc/intel/fsp_baytrail/baytrail/smm.h b/src/soc/intel/fsp_baytrail/baytrail/smm.h
index 0208c9f..136c2ca 100644
--- a/src/soc/intel/fsp_baytrail/baytrail/smm.h
+++ b/src/soc/intel/fsp_baytrail/baytrail/smm.h
@@ -36,7 +36,7 @@ static inline int smm_region_size(void)
return CONFIG_SMM_TSEG_SIZE;
}
-void *smm_region_start(void);
+uintptr_t smm_region_start(void);
#if !defined(__PRE_RAM__) && !defined(__SMM___)
#include <stdint.h>
diff --git a/src/soc/intel/fsp_baytrail/memmap.c b/src/soc/intel/fsp_baytrail/memmap.c
index 83858b8..615916b 100644
--- a/src/soc/intel/fsp_baytrail/memmap.c
+++ b/src/soc/intel/fsp_baytrail/memmap.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2013 Google, Inc.
+ * Copyright (C) 2014 Sage Electronic Engineering, LLC.
*
* 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
@@ -21,8 +22,25 @@
#include <cbmem.h>
#include <baytrail/iosf.h>
#include <baytrail/smm.h>
+#include <drivers/intel/fsp/fsp_util.h>
-void *smm_region_start(void)
+uintptr_t smm_region_start(void)
{
- return (void *)(iosf_bunit_read(BUNIT_SMRRL) << 20);
+ return (iosf_bunit_read(BUNIT_SMRRL) << 20);
+}
+
+/*
+ * Calculate the top of usable (low) DRAM.
+ * The FSP's reserved memory sits just below the SMM region,
+ * allowing calculation of the top of usable memory.
+ *
+ * The entire memory map is shown in northcluster.c
+ */
+
+void *cbmem_top(void)
+{
+ uintptr_t tom = smm_region_start();
+ if (!tom)
+ tom = iosf_bunit_read(BUNIT_BMBOUND);
+ return (void *) tom - FSP_RESERVE_MEMORY_SIZE;
}
diff --git a/src/soc/intel/fsp_baytrail/raminit.c b/src/soc/intel/fsp_baytrail/raminit.c
deleted file mode 100644
index 55692d2..0000000
--- a/src/soc/intel/fsp_baytrail/raminit.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2011 Google Inc.
- * Copyright (C) 2014 Sage Electronic Engineering, LLC.
- *
- * 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 <console/console.h>
-#include <arch/io.h>
-#include <cbmem.h>
-#include <device/device.h>
-#include <baytrail/baytrail.h>
-#include <baytrail/iosf.h>
-#include <cpu/x86/msr.h>
-#include <drivers/intel/fsp/fsp_util.h>
-
-unsigned long get_top_of_ram(void)
-{
- /*
- * Calculate the top of usable (low) DRAM.
- * The FSP's reserved memory sits just below the SMM region,
- * allowing calculation of the top of usable memory.
- *
- * The entire memory map is shown in northcluster.c
- */
- u32 tom = iosf_bunit_read(BUNIT_BMBOUND);
- u32 bsmmrrl = iosf_bunit_read(BUNIT_SMRRL) << 20;
- if (bsmmrrl) {
- tom = bsmmrrl;
- }
- tom -= FSP_RESERVE_MEMORY_SIZE;
-
- return (unsigned long) tom;
-}
the following patch was just integrated into master:
commit f17680b23c3b334bfbe81a03e08d05e04cc0334e
Author: Vadim Bendebury <vbendeb(a)chromium.org>
Date: Wed Apr 23 14:00:59 2014 -0700
ipq8064: prepare uart driver for use in coreboot
The IO accessor wrappers are used to allow integer register addresses.
A structure defining UART interface configuration is declared and
defined. A few long lines are wrapped. Interface functions are renamed
to match the wrapper API.
cdp.c is edited to fit into coreboot compilation environment, and the
only function required by the UART driver if exposed, the rest are
compiled out for now.
BUG=chrome-os-partner:27784
TEST=after all patches are applied the serial console on AP148 becomes
operational.
Original-Change-Id: I80c824d085036c0f90c52aad77843e87976dbe49
Original-Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/196662
Original-Reviewed-by: Stefan Reinauer <reinauer(a)chromium.org>
(cherry picked from commit 5e9af53a069cd048334a3a28f0a4ce9df7c96992)
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
Change-Id: I80c824d085036c0f90c52aad77843e87976dbe49
Reviewed-on: http://review.coreboot.org/7874
Tested-by: build bot (Jenkins)
Reviewed-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
See http://review.coreboot.org/7874 for details.
-gerrit