[coreboot] r933 - in coreboot-v3: arch/x86 include/arch/x86

svn at coreboot.org svn at coreboot.org
Thu Oct 16 05:03:34 CEST 2008


Author: hailfinger
Date: 2008-10-16 05:03:33 +0200 (Thu, 16 Oct 2008)
New Revision: 933

Modified:
   coreboot-v3/arch/x86/stage1.c
   coreboot-v3/include/arch/x86/cpu.h
Log:
We need a way to find out where our stack and our global variables are
at any given moment. The code is generic enough to handle this in a
processor-specific way behind the scenes if needed.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: Ronald G. Minnich <rminnich at gmail.com>


Modified: coreboot-v3/arch/x86/stage1.c
===================================================================
--- coreboot-v3/arch/x86/stage1.c	2008-10-16 03:00:28 UTC (rev 932)
+++ coreboot-v3/arch/x86/stage1.c	2008-10-16 03:03:33 UTC (rev 933)
@@ -71,11 +71,21 @@
 /*
  * The name is slightly misleading because this is the initial stack pointer,
  * not the address of the first element on the stack.
+ * NOTE: This function is very processor specific.
  */
 void *bottom_of_stack(void)
 {
-	/* -4 because CONFIG_CARBASE + CONFIG_CARSIZE - 4 is initial %esp */
-	return (void *)(CONFIG_CARBASE + CONFIG_CARSIZE - 4);
+	u32 onstack = (u32)&onstack;
+
+	/* Check whether the variable onstack is inside the CAR stack area.
+	 * If it is, assume we're still in CAR or the stack has not moved.
+	 * Otherwise return initial %esp for the RAM-based stack location.
+	 */
+	if ((onstack >= CAR_STACK_BASE - CAR_STACK_SIZE) &&
+	    (onstack < CAR_STACK_BASE))
+		return (void *)CAR_STACK_BASE;
+	/* OK, so current %esp is not inside the CAR stack area. */
+	return (void *)RAM_STACK_BASE;
 }
 
 struct global_vars *global_vars(void)

Modified: coreboot-v3/include/arch/x86/cpu.h
===================================================================
--- coreboot-v3/include/arch/x86/cpu.h	2008-10-16 03:00:28 UTC (rev 932)
+++ coreboot-v3/include/arch/x86/cpu.h	2008-10-16 03:03:33 UTC (rev 933)
@@ -266,11 +266,17 @@
 struct global_vars * global_vars(void);
 EXPORT_SYMBOL(global_vars);
 
+#define CAR_STACK_BASE (CONFIG_CARBASE + CONFIG_CARSIZE - 4)
+#define RAM_STACK_BASE 0x88ffc
+
 #ifdef CONFIG_CONSOLE_BUFFER
 #define PRINTK_BUF_SIZE_CAR (CONFIG_CARSIZE / 2)
 #define PRINTK_BUF_ADDR_CAR CONFIG_CARBASE
 #define PRINTK_BUF_SIZE_RAM 65536
 #define PRINTK_BUF_ADDR_RAM 0x90000
+#define CAR_STACK_SIZE ((CONFIG_CARSIZE / 2) - 4)
+#else
+#define CAR_STACK_SIZE (CONFIG_CARSIZE - 4)
 #endif
 
 /* resource maps. These started out as special for the K8 but now have more general usage */





More information about the coreboot mailing list