Add infrastructure for global data in the CAR phase of boot
authorGabe Black <gabeblack@google.com>
Sat, 1 Oct 2011 11:27:32 +0000 (04:27 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Thu, 29 Mar 2012 21:19:13 +0000 (23:19 +0200)
The cbmem console structure and car global data are put in their own section,
with the cbmem console coming after the global data. These areas are linked
to be where CAR is available and at the very bottom of the stack.

There is one shortcoming of this change:
The section created by this change needs to be stripped out by the Makefile
since leaving it in confuses cbfstool when it installs the stage in the image.
I would like to make the tools link those symbols at the right location but
leave allocation of that space out of the ELF.

Change-Id: Iccfb99b128d59c5b7d6164796d21ba46d2a674e0
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: http://review.coreboot.org/727
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
src/arch/x86/Makefile.inc
src/arch/x86/init/bootblock.ld
src/include/cpu/x86/car.h [new file with mode: 0644]
src/lib/cbmem_console.c

index fc3cd14fbad580dd5ae787d105d8e230c27c7eb9..d378a20c14fab9c84c86bd34d841882e9760becc 100755 (executable)
@@ -272,7 +272,7 @@ $(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
        rm -f $@
        cp $(obj)/coreboot.pre1 $@
        $(CBFSTOOL) $@ add-stage $(obj)/romstage.elf \
-            $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
+           $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
 #FIXME: location.txt might require an offset of header size
 
 #######################################################################
index 27d718fcbc8e71ec5c53f53c81a0683a9ba2e010..ca4e82021751b633507d40b774848f226496ceb0 100644 (file)
@@ -46,5 +46,12 @@ SECTIONS
                *(.eh_frame);
        }
 
+       . = CONFIG_DCACHE_RAM_BASE;
+       .car.data . (NOLOAD) : {
+               *(.car.global_data);
+               *(.car.cbmem_console);
+       }
+
+       _bogus = ASSERT((SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full");
        _bogus = ASSERT((SIZEOF(.bss) + SIZEOF(.data)) == 0 || CONFIG_CPU_AMD_AGESA, "Do not use global variables in romstage");
 }
diff --git a/src/include/cpu/x86/car.h b/src/include/cpu/x86/car.h
new file mode 100644 (file)
index 0000000..2d2af03
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2011 The ChromiumOS Authors.  All rights reserved.
+ *
+ * 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_CAR_H
+#define CPU_X86_CAR_H
+
+#ifdef __PRE_RAM__
+#define CAR_GLOBAL __attribute__((section(".car.global_data,\"w\",@nobits#")))
+#define CAR_CBMEM __attribute__((section(".car.cbmem_console,\"w\",@nobits#")))
+#else
+#define CAR_GLOBAL
+#define CAR_CBMEM
+#endif
+
+#endif
index 8cfb33bdf70376ca96a163e4e4deedf55e8aa7ab..2e22decd68a93bfaab3b7d807955cac1ca1fc3a9 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <console/console.h>
 #include <cbmem.h>
+#include <cpu/x86/car.h>
 #include <string.h>
 
 /*
@@ -39,7 +40,9 @@ struct cbmem_console {
  * ram space is used for the console buffer storage. The size and location of
  * the area are defined in the config.
  */
-#define cbmem_console_p ((struct cbmem_console *)CONFIG_DCACHE_RAM_BASE)
+
+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
@@ -92,7 +95,7 @@ void cbmemc_tx_byte(unsigned char data)
         * DCACHE_RAM_BASE), use the redirect pointer to find out where the
         * actual console buffer is.
         */
-       if ((u32)&cursor < (u32)CONFIG_DCACHE_RAM_BASE)
+       if ((uintptr_t)&cursor < (uintptr_t)&car_cbmem_console)
                cbm_cons_p = CBMEM_CONSOLE_REDIRECT;
 #endif
        if (!cbm_cons_p)