summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2016-06-27 14:50:27 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2016-07-10 11:16:07 +0200
commite5c00a5d2c71cc7689e783f26a6031997857d661 (patch)
treebca1e3ede5790272720190ed0f77d4e6c571e7a8 /src/lib
parent70cd54310b98f422b7d66a0e0932d53edec40bb7 (diff)
intel post-car: Consolidate choose_top_of_stack()
Change-Id: I2c49d68ea9a8f52737b6064bc4fa703bdb1af1df Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/15463 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Makefile.inc1
-rw-r--r--src/lib/romstage_stack.c48
2 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 10289176fb..0c34b7535d 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 0000000000..fde9d1b9b2
--- /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;
+}