Skip to contentSkip to conversation

MIPS: initial support for driver model

PATCH Superseded Daniel Schwierzeck 1 participant 3 messages Jan 18, 2015 MIPS

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover MIPS: initial support for driver model

- add support for CONFIG_SYS_INIT_SP_ADDR
- add support for CONFIG_SYS_MALLOC_F_LEN
- implement MIPS specific setup of gd_t structure and malloc area after initial stack area

Daniel Schwierzeck (2):
MIPS: add support for CONFIG_SYS_INIT_SP_ADDR
MIPS: add support for pre-relocation malloc

 arch/mips/cpu/mips32/start.S   | 29 ++++++++++++++++++++++++++++-
 arch/mips/cpu/mips64/start.S   | 29 ++++++++++++++++++++++++++++-
 arch/mips/include/asm/config.h |  2 --
 3 files changed, 56 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/2 MIPS: add support for CONFIG_SYS_INIT_SP_ADDR

Support the existing config option CONFIG_SYS_INIT_SP_ADDR on MIPS. This allows to move the initial stack to other places than the beginning of RAM.

---

 arch/mips/cpu/mips32/start.S | 7 ++++++-
 arch/mips/cpu/mips64/start.S | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
arch/mips/cpu/mips32/start.S +6 -1
index 384ea26..5946859 100644
@@ -15,6 +15,11 @@
 #define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
 #endif
 
+#ifndef CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_SDRAM_BASE + \
+				CONFIG_SYS_INIT_SP_OFFSET)
+#endif
+
 	/*
 	 * For the moment disable interrupts, mark the kernel mode and
 	 * set ST0_KX so that the CPU does not spit fire when using
@@ -135,7 +140,7 @@ reset:
 #endif
 
 	/* Set up temporary stack */
-	li	sp, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_INIT_SP_OFFSET
+	li	sp, CONFIG_SYS_INIT_SP_ADDR
 	move	fp, sp
 
 	la	t9, board_init_f
arch/mips/cpu/mips64/start.S +6 -1
index 6ff714e..81df923 100644
@@ -15,6 +15,11 @@
 #define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
 #endif
 
+#ifndef CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SYS_INIT_SP_ADDR	(CONFIG_SYS_SDRAM_BASE + \
+				CONFIG_SYS_INIT_SP_OFFSET)
+#endif
+
 #ifdef CONFIG_SYS_LITTLE_ENDIAN
 #define MIPS64_R_INFO(ssym, r_type3, r_type2, r_type) \
 	(((r_type) << 24) | ((r_type2) << 16) | ((r_type3) << 8) | (ssym))
@@ -129,7 +134,7 @@ reset:
 #endif
 
 	/* Set up temporary stack */
-	dli	sp, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_INIT_SP_OFFSET
+	dli	sp, CONFIG_SYS_INIT_SP_ADDR
 	move	fp, sp
 
 	dla	t9, board_init_f
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/2 MIPS: add support for pre-relocation malloc

In reply to Daniel Schwierzeck

Implement MIPS specific setup of the gd_t structure to support pre-relocation malloc. If CONFIG_SYS_MALLOC_F_LEN is specified, a memory area will be reserved after the initial stack area and the gd->malloc_base pointer will be initialized.

After this patch the new driver model can be used on MIPS.

---

 arch/mips/cpu/mips32/start.S   | 24 +++++++++++++++++++++++-
 arch/mips/cpu/mips64/start.S   | 24 +++++++++++++++++++++++-
 arch/mips/include/asm/config.h |  2 --
 3 files changed, 46 insertions(+), 4 deletions(-)
arch/mips/cpu/mips32/start.S +23 -1
index 5946859..36b92cc 100644
@@ -140,9 +140,31 @@ reset:
 #endif
 
 	/* Set up temporary stack */
-	li	sp, CONFIG_SYS_INIT_SP_ADDR
+	li	t0, -16
+	li	t1, CONFIG_SYS_INIT_SP_ADDR
+	and	sp, t1, t0		# force 16 byte alignment
+	sub	sp, sp, GD_SIZE		# reserve space for gd
+	and	sp, sp, t0		# force 16 byte alignment
+	move	k0, sp			# save gd pointer
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+	li	t2, CONFIG_SYS_MALLOC_F_LEN
+	sub	sp, sp, t2		# reserve space for early malloc
+	and	sp, sp, t0		# force 16 byte alignment
+#endif
 	move	fp, sp
 
+	/* Clear gd */
+	move	t0, k0
+1:
+	sw	zero, 0(t0)
+	blt	t0, t1, 1b
+	 addi	t0, 4
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+	addu	t0, k0, GD_MALLOC_BASE	# gd->malloc_base offset
+	sw	sp, 0(t0)
+#endif
+
 	la	t9, board_init_f
 	jr	t9
 	 move	ra, zero
arch/mips/cpu/mips64/start.S +23 -1
index 81df923..471bc1e 100644
@@ -134,9 +134,31 @@ reset:
 #endif
 
 	/* Set up temporary stack */
-	dli	sp, CONFIG_SYS_INIT_SP_ADDR
+	dli	t0, -16
+	dli	t1, CONFIG_SYS_INIT_SP_ADDR
+	and	sp, t1, t0		# force 16 byte alignment
+	dsub	sp, sp, GD_SIZE		# reserve space for gd
+	and	sp, sp, t0		# force 16 byte alignment
+	move	k0, sp			# save gd pointer
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+	dli	t2, CONFIG_SYS_MALLOC_F_LEN
+	dsub	sp, sp, t2		# reserve space for early malloc
+	and	sp, sp, t0		# force 16 byte alignment
+#endif
 	move	fp, sp
 
+	/* Clear gd */
+	move	t0, k0
+1:
+	sw	zero, 0(t0)
+	blt	t0, t1, 1b
+	 daddi	t0, 4
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+	daddu	t0, k0, GD_MALLOC_BASE	# gd->malloc_base offset
+	sw	sp, 0(t0)
+#endif
+
 	dla	t9, board_init_f
 	jr	t9
 	 move	ra, zero
arch/mips/include/asm/config.h +0 -2
index 1c8a42b..3a891ba 100644
@@ -7,8 +7,6 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
-#define CONFIG_SYS_GENERIC_GLOBAL_DATA
-
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
Signature · 1 line
2.1.0