[LinuxBIOS] r505 - in LinuxBIOSv3: arch/x86 include mainboard/adl/msm800sev mainboard/amd/norwich mainboard/artecgroup/dbe61 mainboard/emulation/qemu-x86

svn at openbios.org svn at openbios.org
Thu Oct 11 18:13:12 CEST 2007


Author: stepan
Date: 2007-10-11 18:13:12 +0200 (Thu, 11 Oct 2007)
New Revision: 505

Added:
   LinuxBIOSv3/include/shared.h
Modified:
   LinuxBIOSv3/arch/x86/Makefile
   LinuxBIOSv3/arch/x86/pci_ops_conf2.c
   LinuxBIOSv3/include/console.h
   LinuxBIOSv3/include/post_code.h
   LinuxBIOSv3/mainboard/adl/msm800sev/Makefile
   LinuxBIOSv3/mainboard/amd/norwich/Makefile
   LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile
   LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile
Log:
Create shared symbols for stage0 functions.
This fixes for example printk calls from initram code.

Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Jordan Crouse <jordan.crouse at amd.com>



Modified: LinuxBIOSv3/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3/arch/x86/Makefile	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/arch/x86/Makefile	2007-10-11 16:13:12 UTC (rev 505)
@@ -148,6 +148,11 @@
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/stage0.o $(obj)/stage0.init
 
+	$(Q)# Do another OBJCOPY to get a copy with renamed symbols 
+	$(Q)# for XIP code.
+	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@)) (prefixing stage0)\n"
+	$(Q)$(OBJCOPY) --prefix-symbols=stage0_ $(obj)/stage0.o $(obj)/stage0-prefixed.o
+
 	$(Q)printf "  TEST    $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)test `wc -c < $(obj)/stage0.init` -gt 16128 && \
 		printf "Error. Bootblock got too big.\n" || true

Modified: LinuxBIOSv3/arch/x86/pci_ops_conf2.c
===================================================================
--- LinuxBIOSv3/arch/x86/pci_ops_conf2.c	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/arch/x86/pci_ops_conf2.c	2007-10-11 16:13:12 UTC (rev 505)
@@ -12,8 +12,8 @@
  */
 
 #define IOADDR(devfn, where)	((0xC000 | ((devfn & 0x78) << 5)) + where)
-#define FUNC(devfn)		(((devfn & 7) << 1) | 0xf0)
-#define SET(bus,devfn)		outb(FUNC(devfn), 0xCF8); outb(bus, 0xCFA);
+#define DEVFUNC(devfn)		(((devfn & 7) << 1) | 0xf0)
+#define SET(bus,devfn)		outb(DEVFUNC(devfn), 0xCF8); outb(bus, 0xCFA);
 
 static u8 pci_conf2_read_config8(struct bus *pbus, int bus, int devfn, int where)
 {
@@ -65,7 +65,7 @@
 
 #undef SET
 #undef IOADDR
-#undef FUNC
+#undef DEVFUNC
 
 struct pci_bus_operations pci_cf8_conf2 =
 {

Modified: LinuxBIOSv3/include/console.h
===================================================================
--- LinuxBIOSv3/include/console.h	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/include/console.h	2007-10-11 16:13:12 UTC (rev 505)
@@ -18,6 +18,7 @@
 #define CONSOLE_H
 
 #include <types.h>
+#include <shared.h> /* We share symbols from stage 0 */
 
 #define BIOS_EMERG      0   /* system is unusable                   */
 #define BIOS_ALERT      1   /* action must be taken immediately     */
@@ -45,8 +46,7 @@
 	int (*tst_byte)(void);
 };
 
-// 
-int printk(int msg_level, const char *fmt, ...) 
-	__attribute__((format (printf, 2, 3)));
+SHARED_WITH_ATTRIBUTES(printk, int, __attribute__((format (printf, 2, 3))),
+					int msg_level, const char *fmt, ...);
 
 #endif /* CONSOLE_H */

Modified: LinuxBIOSv3/include/post_code.h
===================================================================
--- LinuxBIOSv3/include/post_code.h	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/include/post_code.h	2007-10-11 16:13:12 UTC (rev 505)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-void post_code(u8 value);
+#include <shared.h>
 
+SHARED(post_code, void, u8 value);
+
 #define POST_START_OF_MAIN                              0x01
 

Added: LinuxBIOSv3/include/shared.h
===================================================================
--- LinuxBIOSv3/include/shared.h	                        (rev 0)
+++ LinuxBIOSv3/include/shared.h	2007-10-11 16:13:12 UTC (rev 505)
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the LinuxBIOS project
+ *
+ * Copyright(C) 2007 coresystems GmbH
+ * Written by Stefan Reinauer <stepan at coresystems.de>
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * 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 SHARED_H
+#define SHARED_H
+
+#ifdef _SHARED
+/* _SHARED mode enforces some functions to be called with an
+ * absolute address, even in PIE mode. This is required since
+ * the relative distance between XIP code and stage 0 is not known
+ */
+#define FUNC(func, ret, attr, args...)   \
+	ret stage0_##func(args) attr
+#define EXTERN(func, ret, attr, args...) \
+	ret (*func)(args) attr= stage0_##func
+#else
+#define FUNC(func, ret, attr, args...)   \
+	ret func(args) attr
+#define EXTERN(func, ret, attr, args...)
+#endif
+
+/**
+ * Use the SHARED macro to create a universally usable function 
+ * prototype. This will create a function prototype in stage 0 and
+ * a function prototype plus a function pointer for all code compiled
+ * with _SHARED defined (required for XIP code)
+ *
+ * @func   function name
+ * @ret    return value
+ * @args   function arguments
+ */
+
+#define SHARED(func,ret,args...) \
+	FUNC(func,ret,,##args);  \
+	EXTERN(func,ret,,##args)
+
+
+/**
+ * Use the SHARED_WITH_ATTRIBUTES macro to create a universally usable function 
+ * prototype for a function using GCC attributes. 
+ * This macro works identically to SHARED(), but it adds a GCC attribute to the
+ * function. So far we use this to have printk parameters tested with a
+ * "format" attribute.
+ *
+ * @func   function name
+ * @ret    return value
+ * @attr   function attributes
+ * @args   function arguments
+ */
+
+#define SHARED_WITH_ATTRIBUTES(func,ret,attr,args...) \
+	FUNC(func,ret,attr,##args);  \
+	EXTERN(func,ret,attr,##args)
+
+#endif /* SHARED_H */

Modified: LinuxBIOSv3/mainboard/adl/msm800sev/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/adl/msm800sev/Makefile	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/mainboard/adl/msm800sev/Makefile	2007-10-11 16:13:12 UTC (rev 505)
@@ -32,14 +32,21 @@
 		$(obj)/southbridge/amd/cs5536/smbus_initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# These are possibly not permanent
-INITRAM_OBJ += $(obj)/lib/console.o $(obj)/lib/vtxprintf.o $(obj)/lib/uart8250.o $(obj)/arch/x86/post_code.o
+# Next Quest: Make a single rule out of those:
+$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
 
-$(obj)/linuxbios.initram: $(obj)/stage0.init $(obj)/stage0.o $(INITRAM_OBJ) 
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(LD) -Ttext 0x80000 $(INITRAM_OBJ) \
-		--entry=main -o $(obj)/linuxbios.initram.o
+	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram

Modified: LinuxBIOSv3/mainboard/amd/norwich/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/amd/norwich/Makefile	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/mainboard/amd/norwich/Makefile	2007-10-11 16:13:12 UTC (rev 505)
@@ -26,8 +26,15 @@
 		$(obj)/southbridge/amd/cs5536/smbus_initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# These are possibly not permanent
-INITRAM_OBJ += $(obj)/lib/console.o $(obj)/lib/vtxprintf.o $(obj)/lib/uart8250.o $(obj)/arch/x86/post_code.o
+# Next Quest: Make a single rule out of those:
+$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
 
 STAGE2_MAINBOARD_OBJ = 
 
@@ -35,11 +42,11 @@
 	$(Q)printf "  BUILD   DUMMY VPD\n"
 	$(Q)dd if=/dev/zero of=$(obj)/linuxbios.vpd bs=256 count=1 $(SILENT)
 
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(LD) -Ttext 0x80000 $(INITRAM_OBJ) \
-		--entry=main -o $(obj)/linuxbios.initram.o
+	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram

Modified: LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile	2007-10-11 16:13:12 UTC (rev 505)
@@ -30,14 +30,21 @@
 INITRAM_OBJ =   $(obj)/mainboard/$(MAINBOARDDIR)/initram.o \
 		$(obj)/arch/x86/geodelx/geodelx.o
 
-# These are possibly not permanent
-INITRAM_OBJ += $(obj)/lib/console.o $(obj)/lib/vtxprintf.o $(obj)/lib/uart8250.o $(obj)/arch/x86/post_code.o
+# Next Quest: Make a single rule out of those:
+$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/southbridge/amd/cs5536/smbus_initram.o: $(src)/southbridge/amd/cs5536/smbus_initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+$(obj)/arch/x86/geodelx/geodelx.o: $(src)/arch/x86/geodelx/geodelx.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
 
-$(obj)/linuxbios.initram: $(obj)/stage0.init $(obj)/stage0.o $(INITRAM_OBJ)
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(LD) -Ttext 0x80000 $(INITRAM_OBJ) \
-		--entry=main -o $(obj)/linuxbios.initram.o
+	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram

Modified: LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile	2007-10-10 16:55:03 UTC (rev 504)
+++ LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile	2007-10-11 16:13:12 UTC (rev 505)
@@ -41,14 +41,15 @@
 #
 
 INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o
-# These are possibly not permanent
-INITRAM_OBJ += $(obj)/lib/console.o $(obj)/lib/vtxprintf.o $(obj)/lib/uart8250.o $(obj)/arch/x86/post_code.o
 
-$(obj)/linuxbios.initram: $(obj)/stage0.init $(obj)/stage0.o $(INITRAM_OBJ)
+$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c
+	$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@
+
+$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ)
 	$(Q)# initram links against stage0
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(LD)  -Ttext 0x80000 $(INITRAM_OBJ) \
-		--entry=main -o $(obj)/linuxbios.initram.o
+	$(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+		$(INITRAM_OBJ) -o $(obj)/linuxbios.initram.o
 	$(Q)printf "  OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
 	$(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
 		$(obj)/linuxbios.initram





More information about the coreboot mailing list