[U-Boot] [PATCH v0 2/7] sc520: Create arch asm-offsets

Graeme Russ graeme.russ at gmail.com
Sat Nov 5 03:21:46 CET 2011


Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
---
 arch/x86/cpu/sc520/asm-offsets.c        |   45 +++++++++++++++++++++++++++++++
 arch/x86/cpu/sc520/sc520_car.S          |    3 +-
 arch/x86/cpu/start.S                    |    3 +-
 arch/x86/include/asm/arch-sc520/sc520.h |   26 ------------------
 arch/x86/include/asm/global_data.h      |   19 -------------
 board/eNET/eNET_start16.S               |    5 ++-
 6 files changed, 52 insertions(+), 49 deletions(-)
 create mode 100644 arch/x86/cpu/sc520/asm-offsets.c

diff --git a/arch/x86/cpu/sc520/asm-offsets.c b/arch/x86/cpu/sc520/asm-offsets.c
new file mode 100644
index 0000000..794f00c
--- /dev/null
+++ b/arch/x86/cpu/sc520/asm-offsets.c
@@ -0,0 +1,45 @@
+/*
+ * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
+ *
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ *
+ * We use the technique used in the OSF Mach kernel code:
+ * generate asm statements containing #defines,
+ * compile this file to assembler, and then extract the
+ * #defines from the assembly-language output.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <asm/arch/sc520.h>
+
+#include <linux/kbuild.h>
+
+int main(void)
+{
+	DEFINE(GENERATED_GD_RELOC_OFF, offsetof(gd_t, reloc_off));
+
+	DEFINE(GENERATED_SC520_PAR0, offsetof(struct sc520_mmcr, par[0]));
+	DEFINE(GENERATED_SC520_PAR1, offsetof(struct sc520_mmcr, par[1]));
+	DEFINE(GENERATED_SC520_PAR2, offsetof(struct sc520_mmcr, par[2]));
+	DEFINE(GENERATED_SC520_PAR3, offsetof(struct sc520_mmcr, par[3]));
+	DEFINE(GENERATED_SC520_PAR4, offsetof(struct sc520_mmcr, par[4]));
+	DEFINE(GENERATED_SC520_PAR5, offsetof(struct sc520_mmcr, par[5]));
+	DEFINE(GENERATED_SC520_PAR6, offsetof(struct sc520_mmcr, par[6]));
+	DEFINE(GENERATED_SC520_PAR7, offsetof(struct sc520_mmcr, par[7]));
+	DEFINE(GENERATED_SC520_PAR8, offsetof(struct sc520_mmcr, par[8]));
+	DEFINE(GENERATED_SC520_PAR9, offsetof(struct sc520_mmcr, par[9]));
+	DEFINE(GENERATED_SC520_PAR10, offsetof(struct sc520_mmcr, par[10]));
+	DEFINE(GENERATED_SC520_PAR11, offsetof(struct sc520_mmcr, par[11]));
+	DEFINE(GENERATED_SC520_PAR12, offsetof(struct sc520_mmcr, par[12]));
+	DEFINE(GENERATED_SC520_PAR13, offsetof(struct sc520_mmcr, par[13]));
+	DEFINE(GENERATED_SC520_PAR14, offsetof(struct sc520_mmcr, par[14]));
+	DEFINE(GENERATED_SC520_PAR15, offsetof(struct sc520_mmcr, par[15]));
+
+	return 0;
+}
diff --git a/arch/x86/cpu/sc520/sc520_car.S b/arch/x86/cpu/sc520/sc520_car.S
index 7cac4d1..c04cc1f 100644
--- a/arch/x86/cpu/sc520/sc520_car.S
+++ b/arch/x86/cpu/sc520/sc520_car.S
@@ -24,6 +24,7 @@
 #include <config.h>
 #include <asm/processor-flags.h>
 #include <asm/arch/sc520.h>
+#include <generated/asm-offsets.h>
 
 .section .text
 
@@ -55,7 +56,7 @@ car_init:
 
 	/* Configure Cache-As-RAM PAR */
 	movl	$CONFIG_SYS_SC520_CAR_PAR, %eax
-	movl	$SC520_PAR2, %edi
+	movl	$(SC520_MMCR_BASE + GENERATED_SC520_PAR2), %edi
 	movl	%eax, (%edi)
 
 	/* Trash the cache then turn it on */
diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S
index 1634eb1..5adb387 100644
--- a/arch/x86/cpu/start.S
+++ b/arch/x86/cpu/start.S
@@ -30,6 +30,7 @@
 #include <version.h>
 #include <asm/global_data.h>
 #include <asm/processor-flags.h>
+#include <generated/asm-offsets.h>
 
 .section .text
 .code32
@@ -112,7 +113,7 @@ relocate_code:
 
 	/* Setup call address of in-RAM copy of board_init_r() */
 	movl	$board_init_r, %ebp
-	addl	(GD_RELOC_OFF * 4)(%edx), %ebp
+	addl	(GENERATED_GD_RELOC_OFF)(%edx), %ebp
 
 	/* Setup parameters to board_init_r() */
 	movl	%edx, %eax
diff --git a/arch/x86/include/asm/arch-sc520/sc520.h b/arch/x86/include/asm/arch-sc520/sc520.h
index 5ac9bb8..9dc29d3 100644
--- a/arch/x86/include/asm/arch-sc520/sc520.h
+++ b/arch/x86/include/asm/arch-sc520/sc520.h
@@ -259,32 +259,6 @@ extern sc520_mmcr_t *sc520_mmcr;
 /* Memory Mapped Control Registers (MMCR) Base Address */
 #define SC520_MMCR_BASE		0xfffef000
 
-/* MMCR Addresses (required for assembler code) */
-#define SC520_DRCCTL		(SC520_MMCR_BASE + 0x010)
-#define SC520_DRCTMCTL		(SC520_MMCR_BASE + 0x012)
-#define SC520_DRCCFG		(SC520_MMCR_BASE + 0x014)
-#define SC520_DRCBENDADR	(SC520_MMCR_BASE + 0x018)
-#define SC520_ECCCTL		(SC520_MMCR_BASE + 0x020)
-#define SC520_DBCTL		(SC520_MMCR_BASE + 0x040)
-#define SC520_ECCINT		(SC520_MMCR_BASE + 0xd18)
-
-#define SC520_PAR0		(SC520_MMCR_BASE + 0x088)
-#define SC520_PAR1		(SC520_PAR0 + (0x04 * 1))
-#define SC520_PAR2		(SC520_PAR0 + (0x04 * 2))
-#define SC520_PAR3		(SC520_PAR0 + (0x04 * 3))
-#define SC520_PAR4		(SC520_PAR0 + (0x04 * 4))
-#define SC520_PAR5		(SC520_PAR0 + (0x04 * 5))
-#define SC520_PAR6		(SC520_PAR0 + (0x04 * 6))
-#define SC520_PAR7		(SC520_PAR0 + (0x04 * 7))
-#define SC520_PAR8		(SC520_PAR0 + (0x04 * 8))
-#define SC520_PAR9		(SC520_PAR0 + (0x04 * 9))
-#define SC520_PAR10		(SC520_PAR0 + (0x04 * 10))
-#define SC520_PAR11		(SC520_PAR0 + (0x04 * 11))
-#define SC520_PAR12		(SC520_PAR0 + (0x04 * 12))
-#define SC520_PAR13		(SC520_PAR0 + (0x04 * 13))
-#define SC520_PAR14		(SC520_PAR0 + (0x04 * 14))
-#define SC520_PAR15		(SC520_PAR0 + (0x04 * 15))
-
 /*
  * PARs for maximum allowable 256MB of SDRAM @ 0x00000000
  * Two PARs are required due to maximum PAR size of 128MB
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index c736549..05a2139 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -61,25 +61,6 @@ extern gd_t *gd;
 
 #endif
 
-/* Word Offsets into Global Data - MUST match struct gd_t */
-#define GD_BD		0
-#define GD_FLAGS	1
-#define GD_BAUDRATE	2
-#define GD_HAVE_CONSOLE	3
-#define GD_RELOC_OFF	4
-#define GD_LOAD_OFF	5
-#define GD_ENV_ADDR	6
-#define GD_ENV_VALID	7
-#define GD_CPU_CLK	8
-#define GD_BUS_CLK	9
-#define GD_RELOC_ADDR	10
-#define GD_START_ADDR_SP	11
-#define GD_RAM_SIZE	12
-#define GD_RESET_STATUS	13
-#define GD_JT		14
-
-#define GD_SIZE		15
-
 /*
  * Global Data Flags
  */
diff --git a/board/eNET/eNET_start16.S b/board/eNET/eNET_start16.S
index 4241f6e..5e3f44c 100644
--- a/board/eNET/eNET_start16.S
+++ b/board/eNET/eNET_start16.S
@@ -30,6 +30,7 @@
 #include "config.h"
 #include "hardware.h"
 #include <asm/arch/sc520.h>
+#include <generated/asm-offsets.h>
 
 .text
 .section .start16, "ax"
@@ -46,12 +47,12 @@ board_init16:
 	movw	%ax, %ds
 
 	/* Map PAR for Boot Flash (BOOTCS, 512kB @ 0x380000000) */
-	movl    $(SC520_PAR14 - SC520_MMCR_BASE), %edi
+	movl    $GENERATED_SC520_PAR14, %edi
 	movl	$CONFIG_SYS_SC520_BOOTCS_PAR, %eax
 	movl	%eax, (%di)
 
 	/* Map PAR for LED, Hex Switches (GPCS6, 20 Bytes @ 0x1000) */
-	movl    $(SC520_PAR15 - SC520_MMCR_BASE), %edi
+	movl    $GENERATED_SC520_PAR15, %edi
 	movl	$CONFIG_SYS_SC520_LLIO_PAR, %eax
 	movl	%eax, (%di)
 
-- 
1.7.5.2.317.g391b14



More information about the U-Boot mailing list