Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15463
-gerrit
commit b54476d6efd82f3a5ad62f8354dbb4eb2b9013bd
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Jun 27 14:50:27 2016 +0300
intel post-car: Consolidate choose_top_of_stack()
Change-Id: I2c49d68ea9a8f52737b6064bc4fa703bdb1af1df
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/cpu/intel/haswell/romstage.c | 16 +---------
src/drivers/intel/fsp1_1/Kconfig | 4 ---
src/drivers/intel/fsp1_1/stack.c | 23 ++------------
src/include/program_loading.h | 6 ++++
src/lib/Makefile.inc | 1 +
src/lib/romstage_stack.c | 48 ++++++++++++++++++++++++++++++
src/soc/intel/baytrail/romstage/romstage.c | 16 +---------
src/soc/intel/broadwell/romstage/stack.c | 17 ++---------
8 files changed, 62 insertions(+), 69 deletions(-)
diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c
index cde9441..9154316 100644
--- a/src/cpu/intel/haswell/romstage.c
+++ b/src/cpu/intel/haswell/romstage.c
@@ -65,20 +65,6 @@ static inline u32 *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-#define ROMSTAGE_RAM_STACK_SIZE 0x5000
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- ROMSTAGE_RAM_STACK_SIZE);
- stack_top += ROMSTAGE_RAM_STACK_SIZE;
- return stack_top;
-}
-
/* setup_romstage_stack_after_car() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
static void *setup_romstage_stack_after_car(void)
@@ -90,7 +76,7 @@ static void *setup_romstage_stack_after_car(void)
u32 top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack_top() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
diff --git a/src/drivers/intel/fsp1_1/Kconfig b/src/drivers/intel/fsp1_1/Kconfig
index 86f6c7b..59b4797 100644
--- a/src/drivers/intel/fsp1_1/Kconfig
+++ b/src/drivers/intel/fsp1_1/Kconfig
@@ -99,10 +99,6 @@ config GOP_SUPPORT
bool "Enable GOP support"
default n
-config ROMSTAGE_RAM_STACK_SIZE
- hex "Size of the romstage RAM stack in bytes"
- default 0x5000
-
config USE_GENERIC_FSP_CAR_INC
bool
default n
diff --git a/src/drivers/intel/fsp1_1/stack.c b/src/drivers/intel/fsp1_1/stack.c
index 65ba235..8d0759a 100644
--- a/src/drivers/intel/fsp1_1/stack.c
+++ b/src/drivers/intel/fsp1_1/stack.c
@@ -21,23 +21,7 @@
#include <fsp/romstage.h>
#include <fsp/stack.h>
#include <stdlib.h>
-
-const unsigned long romstage_ram_stack_size = CONFIG_ROMSTAGE_RAM_STACK_SIZE;
-
-/*
- * Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage.
- */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
+#include <program_loading.h>
/*
* setup_stack_and_mtrrs() determines the stack to use after
@@ -57,7 +41,7 @@ void *setup_stack_and_mtrrs(void)
soc_display_mtrrs();
/* Top of stack needs to be aligned to a 8-byte boundary. */
- top_of_stack = choose_top_of_stack();
+ top_of_stack = romstage_ram_stack_top();
slot = (void *)top_of_stack;
num_mtrrs = 0;
max_mtrrs = soc_get_variable_mtrr_count(NULL);
@@ -68,8 +52,7 @@ void *setup_stack_and_mtrrs(void)
*/
mtrr_mask_upper = (1 << ((cpuid_eax(0x80000008) & 0xff) - 32)) - 1;
alignment = mmap_region_granularity();
- aligned_ram = ALIGN_DOWN(top_of_stack - romstage_ram_stack_size,
- alignment);
+ aligned_ram = ALIGN_DOWN(romstage_ram_stack_bottom(), alignment);
/*
* The order for each MTRR is value then base with upper 32-bits of
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 42addb8..e265b18 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -170,6 +170,12 @@ void run_ramstage(void);
/* Called when the stage cache couldn't load ramstage on resume. */
void ramstage_cache_invalid(void);
+/* Determine where stack for ramstage loader is located. */
+enum { ROMSTAGE_STACK_CBMEM, ROMSTAGE_STACK_LOW_MEM };
+uintptr_t romstage_ram_stack_base(size_t size, int src);
+uintptr_t romstage_ram_stack_top(void);
+uintptr_t romstage_ram_stack_bottom(void);
+
/***********************
* PAYLOAD LOADING *
***********************/
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 1028917..0c34b75 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -78,6 +78,7 @@ romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
+romstage-y += romstage_stack.c
romstage-y += stack.c
ramstage-y += rtc.c
diff --git a/src/lib/romstage_stack.c b/src/lib/romstage_stack.c
new file mode 100644
index 0000000..fde9d1b
--- /dev/null
+++ b/src/lib/romstage_stack.c
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google Inc.
+ * Copyright (C) 2015-2016 Intel Corp.
+ *
+ * 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.
+ */
+
+#include <program_loading.h>
+#include <cbmem.h>
+
+/*
+ * Romstage needs quite a bit of stack for decompressing images since the lzma
+ * lib keeps its state on the stack during romstage.
+ */
+#define ROMSTAGE_RAM_STACK_SIZE 0x5000
+
+uintptr_t romstage_ram_stack_base(size_t size, int src)
+{
+ /* cbmem_add() does a find() before add(). */
+ if (src == ROMSTAGE_STACK_CBMEM)
+ return (uintptr_t)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, size);
+ if (src == ROMSTAGE_STACK_LOW_MEM)
+ return CONFIG_RAMTOP - size;
+ return 0;
+}
+
+uintptr_t romstage_ram_stack_bottom(void)
+{
+ return romstage_ram_stack_base(ROMSTAGE_RAM_STACK_SIZE,
+ ROMSTAGE_STACK_CBMEM);
+}
+
+uintptr_t romstage_ram_stack_top(void)
+{
+ uintptr_t stack_top = romstage_ram_stack_base(ROMSTAGE_RAM_STACK_SIZE,
+ ROMSTAGE_STACK_CBMEM);
+ stack_top += ROMSTAGE_RAM_STACK_SIZE;
+ return stack_top;
+}
diff --git a/src/soc/intel/baytrail/romstage/romstage.c b/src/soc/intel/baytrail/romstage/romstage.c
index a167c90..d7e8b17 100644
--- a/src/soc/intel/baytrail/romstage/romstage.c
+++ b/src/soc/intel/baytrail/romstage/romstage.c
@@ -258,20 +258,6 @@ static inline uint32_t *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
- const unsigned long romstage_ram_stack_size = 0x5000;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
-
/* setup_stack_and_mttrs() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
static void *setup_stack_and_mttrs(void)
@@ -283,7 +269,7 @@ static void *setup_stack_and_mttrs(void)
uint32_t top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack_top() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
diff --git a/src/soc/intel/broadwell/romstage/stack.c b/src/soc/intel/broadwell/romstage/stack.c
index 6c602a8..76307cf 100644
--- a/src/soc/intel/broadwell/romstage/stack.c
+++ b/src/soc/intel/broadwell/romstage/stack.c
@@ -21,6 +21,7 @@
#include <cbmem.h>
#include <cpu/x86/mtrr.h>
#include <soc/romstage.h>
+#include <program_loading.h>
static inline uint32_t *stack_push(u32 *stack, u32 value)
{
@@ -29,20 +30,6 @@ static inline uint32_t *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
- const unsigned long romstage_ram_stack_size = 0x5000;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
-
/* setup_stack_and_mttrs() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
void *setup_stack_and_mttrs(void)
@@ -54,7 +41,7 @@ void *setup_stack_and_mttrs(void)
uint32_t top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack_top() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15468
-gerrit
commit 76c3ba129bab9cb0c61cce50a15677f0e64fa0bb
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Jun 27 13:24:11 2016 +0300
intel post-car: Separate romstage ramstack (WIP)
TODO: Need to fix MTRRs before placing stack high.
TODO: Case LATE_CBMEM_INIT
Change-Id: I221e207bcd0031048876f29100a1770a444d435b
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/cpu/intel/car/romstage.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/cpu/intel/car/romstage.c b/src/cpu/intel/car/romstage.c
index c6df446..215a6a2 100644
--- a/src/cpu/intel/car/romstage.c
+++ b/src/cpu/intel/car/romstage.c
@@ -1,7 +1,25 @@
+/*
+ * 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.
+ */
+
#include <cpu/intel/romstage.h>
+#include <program_loading.h>
void * asmlinkage romstage_main(unsigned long bist)
{
mainboard_romstage_entry(bist);
- return (void*)CONFIG_RAMTOP;
+
+ if (IS_ENABLED(CONFIG_LATE_CBMEM_INIT))
+ return (void*)CONFIG_RAMTOP;
+
+ return (void*)romstage_ram_stack_top();
}
Jonathan Neuschäfer (j.neuschaefer(a)gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15284
-gerrit
commit 9824e6b7f65ff62bff12b4c28da49b3a895a303b
Author: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Date: Thu Jul 7 20:53:29 2016 +0200
arch/riscv: Move CBMEM into RAM
CBMEM should be placed at the top of RAM, which can be found by parsing
the configuration string. Configuration string parsing isn't yet
implemented, so I'll hard-code the CBMEM location for now.
Change-Id: If4092d094a856f6783887c062d6682dd13a73b8f
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
---
src/soc/ucb/riscv/cbmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/soc/ucb/riscv/cbmem.c b/src/soc/ucb/riscv/cbmem.c
index 3aabf19..a013e01 100644
--- a/src/soc/ucb/riscv/cbmem.c
+++ b/src/soc/ucb/riscv/cbmem.c
@@ -16,5 +16,5 @@
void *cbmem_top(void)
{
// TODO: find out how RISCV stores this.
- return (void *)0x1fff000;
+ return (void *)0xc0000000;
}
Jonathan Neuschäfer (j.neuschaefer(a)gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15285
-gerrit
commit 5420eed91c53fdfd363e9bdd739a93f1a241c937
Author: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Date: Thu Jul 7 20:53:28 2016 +0200
spike-riscv: Look for the CBFS in RAM
Change-Id: I98927a70adc45d9aca916bd985932b94287921de
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
---
src/arch/riscv/Makefile.inc | 3 ---
src/arch/riscv/rom_media.c | 26 --------------------
src/mainboard/emulation/qemu-riscv/Makefile.inc | 3 +++
src/mainboard/emulation/qemu-riscv/rom_media.c | 26 ++++++++++++++++++++
src/mainboard/emulation/spike-riscv/Makefile.inc | 3 +++
src/mainboard/emulation/spike-riscv/rom_media.c | 30 ++++++++++++++++++++++++
6 files changed, 62 insertions(+), 29 deletions(-)
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index 243fa53..c1c62ef 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -33,7 +33,6 @@ bootblock-y += trap_util.S
bootblock-y += trap_handler.c
bootblock-y += virtual_memory.c
bootblock-y += boot.c
-bootblock-y += rom_media.c
bootblock-y += misc.c
bootblock-y += \
$(top)/src/lib/memchr.c \
@@ -60,7 +59,6 @@ ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)
romstage-y += boot.c
romstage-y += stages.c
-romstage-y += rom_media.c
romstage-y += misc.c
romstage-y += \
$(top)/src/lib/memchr.c \
@@ -90,7 +88,6 @@ ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y)
ramstage-y =
ramstage-y += trap_handler.c
ramstage-y += virtual_memory.c
-ramstage-y += rom_media.c
ramstage-y += stages.c
ramstage-y += misc.c
ramstage-y += boot.c
diff --git a/src/arch/riscv/rom_media.c b/src/arch/riscv/rom_media.c
deleted file mode 100644
index c171307..0000000
--- a/src/arch/riscv/rom_media.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2015 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.
- */
-#include <boot_device.h>
-
-/* This assumes that the CBFS resides at 0x0, which is true for the default
- * configuration. */
-static const struct mem_region_device boot_dev =
- MEM_REGION_DEV_RO_INIT(NULL, CONFIG_ROM_SIZE);
-
-const struct region_device *boot_device_ro(void)
-{
- return &boot_dev.rdev;
-}
diff --git a/src/mainboard/emulation/qemu-riscv/Makefile.inc b/src/mainboard/emulation/qemu-riscv/Makefile.inc
index 87bc39a..b8a62f7 100644
--- a/src/mainboard/emulation/qemu-riscv/Makefile.inc
+++ b/src/mainboard/emulation/qemu-riscv/Makefile.inc
@@ -15,11 +15,14 @@
bootblock-y += bootblock.c
bootblock-y += uart.c
bootblock-y += qemu_util.c
+bootblock-y += rom_media.c
romstage-y += romstage.c
romstage-y += qemu_util.c
romstage-y += uart.c
+romstage-y += rom_media.c
ramstage-y += uart.c
ramstage-y += qemu_util.c
+ramstage-y += rom_media.c
bootblock-y += memlayout.ld
romstage-y += memlayout.ld
diff --git a/src/mainboard/emulation/qemu-riscv/rom_media.c b/src/mainboard/emulation/qemu-riscv/rom_media.c
new file mode 100644
index 0000000..c171307
--- /dev/null
+++ b/src/mainboard/emulation/qemu-riscv/rom_media.c
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 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.
+ */
+#include <boot_device.h>
+
+/* This assumes that the CBFS resides at 0x0, which is true for the default
+ * configuration. */
+static const struct mem_region_device boot_dev =
+ MEM_REGION_DEV_RO_INIT(NULL, CONFIG_ROM_SIZE);
+
+const struct region_device *boot_device_ro(void)
+{
+ return &boot_dev.rdev;
+}
diff --git a/src/mainboard/emulation/spike-riscv/Makefile.inc b/src/mainboard/emulation/spike-riscv/Makefile.inc
index dff4758..91c1369 100644
--- a/src/mainboard/emulation/spike-riscv/Makefile.inc
+++ b/src/mainboard/emulation/spike-riscv/Makefile.inc
@@ -15,11 +15,14 @@
bootblock-y += bootblock.c
bootblock-y += uart.c
bootblock-y += spike_util.c
+bootblock-y += rom_media.c
romstage-y += romstage.c
romstage-y += uart.c
romstage-y += spike_util.c
+romstage-y += rom_media.c
ramstage-y += uart.c
ramstage-y += spike_util.c
+ramstage-y += rom_media.c
bootblock-y += memlayout.ld
romstage-y += memlayout.ld
diff --git a/src/mainboard/emulation/spike-riscv/rom_media.c b/src/mainboard/emulation/spike-riscv/rom_media.c
new file mode 100644
index 0000000..10952a3
--- /dev/null
+++ b/src/mainboard/emulation/spike-riscv/rom_media.c
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ * Copyright 2016 Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
+ *
+ * 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.
+ */
+#include <boot_device.h>
+
+/*
+ * 0x80000000 is this start of RAM. We currently need to load coreboot.rom into
+ * RAM on SPIKE, because SPIKE doesn't support loading custom code into the
+ * boot ROM.
+ */
+static const struct mem_region_device boot_dev =
+ MEM_REGION_DEV_RO_INIT(0x80000000, CONFIG_ROM_SIZE);
+
+const struct region_device *boot_device_ro(void)
+{
+ return &boot_dev.rdev;
+}
Jonathan Neuschäfer (j.neuschaefer(a)gmx.net) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15288
-gerrit
commit 573669dca9b36ff0dda3e5d08df0b1a815b191d2
Author: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
Date: Thu Jul 7 20:53:28 2016 +0200
util/riscvtools: Provide a tohost/fromhost symbols so Spike doesn't hang
See https://github.com/riscv/riscv-isa-sim/issues/54 for more
information.
Change-Id: I8cda8dc07866d395eb3ce5d94df8232840fa8b82
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer(a)gmx.net>
---
util/riscvtools/spike-elf.ld | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util/riscvtools/spike-elf.ld b/util/riscvtools/spike-elf.ld
index 341a16f..44114f7 100644
--- a/util/riscvtools/spike-elf.ld
+++ b/util/riscvtools/spike-elf.ld
@@ -8,4 +8,8 @@ SECTIONS
.data : {
*(.data)
}
+
+ tohost = .;
+ . = . + 8;
+ fromhost = .;
}