[rtems commit] bsps/powerpc: Use interrupt stack for init stack

Sebastian Huber sebh at rtems.org
Mon Nov 19 06:20:45 UTC 2018


Module:    rtems
Branch:    master
Commit:    84e59b7c04e47c3ec7aa95f53509fd812eee725e
Changeset: http://git.rtems.org/rtems/commit/?id=84e59b7c04e47c3ec7aa95f53509fd812eee725e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Nov 15 20:47:22 2018 +0100

bsps/powerpc: Use interrupt stack for init stack

Move start.o to separate file.

Update #3459.

---

 bsps/powerpc/gen5200/start/start.S                 | 16 ++++++++-----
 bsps/powerpc/gen83xx/start/start.S                 | 11 +++++----
 bsps/powerpc/haleakala/start/linkcmds              |  1 +
 .../powerpc/haleakala/start/{dlentry.S => start.S} |  0
 bsps/powerpc/mpc8260ads/start/start.S              | 17 ++++++++------
 bsps/powerpc/mvme3100/start/start.S                | 19 ++++++++-------
 bsps/powerpc/mvme5500/start/start.S                | 25 +++++++-------------
 bsps/powerpc/shared/start/linkcmds.share           |  3 ---
 bsps/powerpc/shared/start/start.S                  | 27 ++++++++--------------
 bsps/powerpc/ss555/start/linkcmds                  |  1 +
 bsps/powerpc/virtex/start/start.S                  | 16 ++++++-------
 bsps/powerpc/virtex4/start/linkcmds                |  1 +
 bsps/powerpc/virtex5/start/linkcmds                |  1 +
 c/src/lib/libbsp/powerpc/haleakala/Makefile.am     |  9 ++++----
 c/src/lib/libbsp/powerpc/ss555/Makefile.am         |  7 +++---
 c/src/lib/libbsp/powerpc/virtex/configure.ac       |  6 -----
 c/src/lib/libbsp/powerpc/virtex4/Makefile.am       |  7 +++++-
 c/src/lib/libbsp/powerpc/virtex5/Makefile.am       |  7 +++++-
 18 files changed, 84 insertions(+), 90 deletions(-)

diff --git a/bsps/powerpc/gen5200/start/start.S b/bsps/powerpc/gen5200/start/start.S
index 0c2dfd5..9e9e504 100644
--- a/bsps/powerpc/gen5200/start/start.S
+++ b/bsps/powerpc/gen5200/start/start.S
@@ -90,7 +90,9 @@
 /*                                                                     */
 /***********************************************************************/
 
+#include <rtems/asm.h>
 #include <rtems/powerpc/cache.h>
+#include <libcpu/powerpc-utility.h>
 
 #include <bsp.h>
 #include <bsp/mpc5200.h>
@@ -470,12 +472,14 @@ skip_ROM_start:
 	bl	bsp_uboot_copy_board_info
 #endif /* HAS_UBOOT */
 
-/* set stack pointer (common for RAM/ROM startup) */
-	LA	r1, bsp_section_text_start
-	addi    r1, r1, -0x10			/* Set up stack pointer = beginning of text section - 0x10 */
-	/* tag TOS with a NULL pointer (termination mark for stack dump) */
-	li  r0, 0
-	stw r0, 0(r1)
+	/*
+	 * Initialize start stack (common for RAM/ROM startup).  The stacks are
+	 * statically allocated and properly aligned.
+	 */
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	li	r0, 0
+	stw	r0, 0(r1)
 
 	bl	__eabi				/* Set up EABI and SYSV environment */
 
diff --git a/bsps/powerpc/gen83xx/start/start.S b/bsps/powerpc/gen83xx/start/start.S
index 532210e..943ced4 100644
--- a/bsps/powerpc/gen83xx/start/start.S
+++ b/bsps/powerpc/gen83xx/start/start.S
@@ -413,13 +413,16 @@ start_code_in_ram:
 	/* Read-write small data */
 	LA r13, _SDA_BASE_
 
-        /* Clear cmdline */
+	/* Clear cmdline */
 	li	r3, 0
 
-	/* Set start stack pointer */
+	/*
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
+	 */
 	LA	r1, _ISR_Stack_area_end
-	stwu	r3, -4(r1)
-	stwu	r3, -4(r1)
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	stw	r3, 0(r1)
 
 	/* Call the first C routine */
         bl      SYM (boot_card)
diff --git a/bsps/powerpc/haleakala/start/linkcmds b/bsps/powerpc/haleakala/start/linkcmds
index 3bccc97..7cd993c 100644
--- a/bsps/powerpc/haleakala/start/linkcmds
+++ b/bsps/powerpc/haleakala/start/linkcmds
@@ -11,6 +11,7 @@
 
 OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 OUTPUT_ARCH(powerpc)
+STARTUP(start.o)
 ENTRY(download_entry)
 EXTERN(__vectors)
 
diff --git a/bsps/powerpc/haleakala/start/dlentry.S b/bsps/powerpc/haleakala/start/start.S
similarity index 100%
rename from bsps/powerpc/haleakala/start/dlentry.S
rename to bsps/powerpc/haleakala/start/start.S
diff --git a/bsps/powerpc/mpc8260ads/start/start.S b/bsps/powerpc/mpc8260ads/start/start.S
index 4fdc21c..0537bbf 100644
--- a/bsps/powerpc/mpc8260ads/start/start.S
+++ b/bsps/powerpc/mpc8260ads/start/start.S
@@ -30,11 +30,9 @@
  */
 
 #include <rtems/asm.h>
+#include <libcpu/powerpc-utility.h>
 
 /*
- *  The initial stack is set to run BELOW the code base address.
- *  (between the vectors and text sections)
- *
  *  The entry veneer has to clear the BSS and copy the read only
  *  version of the data segment to the correct location.
  */
@@ -134,11 +132,16 @@ text_length:
         /* set toc */
         lwz r2, toc_pointer-base_addr(r1)
 
-        /* Set up stack pointer = beginning of text section - 56 */
-        addi    r1, r1, -56-4
+	/* Clear cmdline */
+	li	r3, 0
 
-        /* Clear cmdline */
-        xor r3, r3, r3
+	/*
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
+	 */
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	stw	r3, 0(r1)
 
         .extern SYM (boot_card)
         bl       SYM (boot_card)	/* call the first C routine */
diff --git a/bsps/powerpc/mvme3100/start/start.S b/bsps/powerpc/mvme3100/start/start.S
index 493720e..ade890a 100644
--- a/bsps/powerpc/mvme3100/start/start.S
+++ b/bsps/powerpc/mvme3100/start/start.S
@@ -12,8 +12,7 @@
  */
 
 #include <rtems/asm.h>
-#include <rtems/score/cpu.h>
-#include <rtems/powerpc/powerpc.h>
+#include <libcpu/powerpc-utility.h>
 
 #include <bspopts.h>
 
@@ -71,15 +70,15 @@ __rtems_entry_point:
 	mr	r6,r28
 	mr	r7,r27
 	bl	save_boot_params
-	addis	r9,r0, (__stack-PPC_MINIMUM_STACK_FRAME_SIZE)@ha
-	addi	r9,r9, (__stack-PPC_MINIMUM_STACK_FRAME_SIZE)@l
-	/* align down to 16-bytes */
-	li  r5, (CPU_STACK_ALIGNMENT - 1)
-	andc r1, r9, r5
 
-	/* NULL ptr to back chain */
-	li  r0, 0
-	stw r0, 0(r1)
+	/*
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
+	 */
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	li	r0, 0
+	stw	r0, 0(r1)
 
 	/*
 	 * We are now in a environment that is totally independent from
diff --git a/bsps/powerpc/mvme5500/start/start.S b/bsps/powerpc/mvme5500/start/start.S
index 5990c7e..c948c9c 100644
--- a/bsps/powerpc/mvme5500/start/start.S
+++ b/bsps/powerpc/mvme5500/start/start.S
@@ -13,8 +13,7 @@
  */
 
 #include <rtems/asm.h>
-#include <rtems/score/cpu.h>
-#include <rtems/powerpc/powerpc.h>
+#include <libcpu/powerpc-utility.h>
 
 #include <libcpu/io.h>
 #include <libcpu/bat.h>
@@ -134,23 +133,15 @@ enter_C_code:
 	mr	r6,r28
 	mr	r7,r27
 	bl	save_boot_params
+
 	/*
-	 * stack = &__rtems_end + 4096
-	 */
-	addis	r9,r0, __stack-PPC_MINIMUM_STACK_FRAME_SIZE at ha
-	addi	r9,r9, __stack-PPC_MINIMUM_STACK_FRAME_SIZE at l
-	/*
-	 * align initial stack
-	 * (we hope that the bootloader stack was 16-byte aligned
-	 * or we haven't used altivec yet...)
-	 */
-	li   r0, (CPU_STACK_ALIGNMENT-1)
-	andc r1, r9, r0
-	/*
-	 * NULL ptr to back chain
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
 	 */
-	li   r0, 0
-	stw  r0, 0(r1)
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	li	r0, 0
+	stw	r0, 0(r1)
 
 	/*
 	 * We are now in a environment that is totally independent from
diff --git a/bsps/powerpc/shared/start/linkcmds.share b/bsps/powerpc/shared/start/linkcmds.share
index e2a3a16..2fc6601 100644
--- a/bsps/powerpc/shared/start/linkcmds.share
+++ b/bsps/powerpc/shared/start/linkcmds.share
@@ -3,7 +3,6 @@ OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
 OUTPUT_ARCH(powerpc)
 /* Do we need any of these for elf?
    __DYNAMIC = 0;    */
-PROVIDE (__stack = 0);
 MEMORY {
 	VECTORS	: ORIGIN = 0x0 ,  LENGTH = 0x3000
 	CODE : ORIGIN = 0x3000 , LENGTH = 32M - 0x3000
@@ -247,8 +246,6 @@ SECTIONS
    PROVIDE (__bss_end = .);
   } > CODE
   . = ALIGN(16);
-  . += 0x1000;
-  __stack = .;
   _end = . ;
   __rtems_end = . ;
   PROVIDE (end = .);
diff --git a/bsps/powerpc/shared/start/start.S b/bsps/powerpc/shared/start/start.S
index 354b9a9..faffaf9 100644
--- a/bsps/powerpc/shared/start/start.S
+++ b/bsps/powerpc/shared/start/start.S
@@ -10,8 +10,7 @@
  */
 
 #include <rtems/asm.h>
-#include <rtems/score/cpu.h>
-#include <rtems/powerpc/powerpc.h>
+#include <libcpu/powerpc-utility.h>
 
 #include <libcpu/io.h>
 #include <libcpu/bat.h>
@@ -133,24 +132,16 @@ enter_C_code:
 	mr	r6,r28
 	mr	r7,r27
 	bl	save_boot_params
+
 	/*
-	 * stack = &__rtems_end + 4096
-	 */
-	addis	r9,r0, __stack-PPC_MINIMUM_STACK_FRAME_SIZE at ha
-	addi	r9,r9, __stack-PPC_MINIMUM_STACK_FRAME_SIZE at l
-	/*
-	 * align initial stack
-	 * (we hope that the bootloader stack was 16-byte aligned
-	 * or we haven't used altivec yet...)
-	 */
-	li   r0, (CPU_STACK_ALIGNMENT-1)
-	andc r1, r9, r0
-	/*
-	 * Tag TOS with a NULL (terminator for stack dump)
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
 	 */
-	li   r0, 0
-	stw  r0, 0(r1)
-	
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	li	r0, 0
+	stw	r0, 0(r1)
+
 	/*
 	 * We are now in a environment that is totally independent from
 	 * bootloader setup.
diff --git a/bsps/powerpc/ss555/start/linkcmds b/bsps/powerpc/ss555/start/linkcmds
index f3a41dd..e8df31e 100644
--- a/bsps/powerpc/ss555/start/linkcmds
+++ b/bsps/powerpc/ss555/start/linkcmds
@@ -16,6 +16,7 @@
 
 OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 OUTPUT_ARCH(powerpc) 
+STARTUP(start.o)
 ENTRY(start)
 EXTERN(_vectors)
 
diff --git a/bsps/powerpc/virtex/start/start.S b/bsps/powerpc/virtex/start/start.S
index 725b099..3c9cd22 100644
--- a/bsps/powerpc/virtex/start/start.S
+++ b/bsps/powerpc/virtex/start/start.S
@@ -47,11 +47,6 @@ virtex_exc_vector_base:
 	b	twiddle
 .endr
 
-	/* Start stack area */
-.rept BSP_START_STACK_SIZE / 4
-	b	twiddle
-.endr
-
 _start:
 
 	/* Reset time base */
@@ -59,10 +54,13 @@ _start:
 	mtspr	TBWU, r0
 	mtspr	TBWL, r0
 
-	/* Initialize start stack */
-	LWI	r1, _start
-	stwu	r0, -4(r1)
-	stwu	r0, -4(r1)
+	/*
+	 * Initialize start stack.  The stacks are statically allocated and
+	 * properly aligned.
+	 */
+	LA	r1, _ISR_Stack_area_end
+	subi	r1, r1, PPC_DEFAULT_CACHE_LINE_SIZE
+	stw	r0, 0(r1)
 
 	/* Copy fast text */
 	LWI	r3, bsp_section_fast_text_begin
diff --git a/bsps/powerpc/virtex4/start/linkcmds b/bsps/powerpc/virtex4/start/linkcmds
index 6670516..46e5111 100644
--- a/bsps/powerpc/virtex4/start/linkcmds
+++ b/bsps/powerpc/virtex4/start/linkcmds
@@ -8,6 +8,7 @@
 OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 OUTPUT_ARCH(powerpc)
 
+STARTUP(start.o)
 ENTRY(download_entry)
 EXTERN(download_entry)
 EXTERN(__vectors)
diff --git a/bsps/powerpc/virtex5/start/linkcmds b/bsps/powerpc/virtex5/start/linkcmds
index 0cb4b4e..32425f4 100644
--- a/bsps/powerpc/virtex5/start/linkcmds
+++ b/bsps/powerpc/virtex5/start/linkcmds
@@ -8,6 +8,7 @@
 OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 OUTPUT_ARCH(powerpc)
 
+STARTUP(start.o)
 ENTRY(download_entry)
 EXTERN(download_entry)
 EXTERN(__vectors)
diff --git a/c/src/lib/libbsp/powerpc/haleakala/Makefile.am b/c/src/lib/libbsp/powerpc/haleakala/Makefile.am
index 89594c8..e58a42a 100644
--- a/c/src/lib/libbsp/powerpc/haleakala/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/haleakala/Makefile.am
@@ -5,11 +5,13 @@ include $(top_srcdir)/../../bsp.am
 
 dist_project_lib_DATA = ../../../../../../bsps/powerpc/haleakala/start/bsp_specs
 
-
+start.$(OBJEXT): ../../../../../../bsps/powerpc/haleakala/start/start.S
+	$(CPPASCOMPILE) -o $@ -c $<
+project_lib_DATA = start.$(OBJEXT)
 
 rtems_crti.$(OBJEXT): ../../../../../../bsps/powerpc/shared/start/rtems_crti.S
 	$(CPPASCOMPILE) -o $@ -c $<
-project_lib_DATA = rtems_crti.$(OBJEXT)
+project_lib_DATA += rtems_crti.$(OBJEXT)
 
 project_lib_DATA += linkcmds
 
@@ -26,9 +28,6 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/haleakala/start/mmu_405.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/haleakala/start/mmu_405asm.S 
 
-# dlentry
-librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/haleakala/start/dlentry.S
-
 # console
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/shared/console/uart.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/shared/console/console.c
diff --git a/c/src/lib/libbsp/powerpc/ss555/Makefile.am b/c/src/lib/libbsp/powerpc/ss555/Makefile.am
index 51ea721..c6276e1 100644
--- a/c/src/lib/libbsp/powerpc/ss555/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/ss555/Makefile.am
@@ -5,11 +5,13 @@ include $(top_srcdir)/../../bsp.am
 
 dist_project_lib_DATA = ../../../../../../bsps/powerpc/ss555/start/bsp_specs
 
-
+start.$(OBJEXT): ../../../../../../bsps/powerpc/ss555/start/start.S
+	$(CPPASCOMPILE) -o $@ -c $<
+project_lib_DATA = start.$(OBJEXT)
 
 rtems_crti.$(OBJEXT): ../../../../../../bsps/powerpc/shared/start/rtems_crti.S
 	$(CPPASCOMPILE) -o $@ -c $<
-project_lib_DATA = rtems_crti.$(OBJEXT)
+project_lib_DATA += rtems_crti.$(OBJEXT)
 
 project_lib_DATA += linkcmds
 
@@ -26,7 +28,6 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/bspstart.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/iss555.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/getentropy/getentropy-cpucounter.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c
-librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/start.S
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-default.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspreset-empty.c
 # tm27supp
diff --git a/c/src/lib/libbsp/powerpc/virtex/configure.ac b/c/src/lib/libbsp/powerpc/virtex/configure.ac
index b70adf1..19ecf51 100644
--- a/c/src/lib/libbsp/powerpc/virtex/configure.ac
+++ b/c/src/lib/libbsp/powerpc/virtex/configure.ac
@@ -10,12 +10,6 @@ RTEMS_CANONICAL_TARGET_CPU
 AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
 RTEMS_BSP_CONFIGURE
 
-
-
-
-RTEMS_BSPOPTS_SET([BSP_START_STACK_SIZE],[*],[4096])
-RTEMS_BSPOPTS_HELP([BSP_START_STACK_SIZE],[size of low-level start stack])
-
 RTEMS_BSPOPTS_SET([RTEMS_XPARAMETERS_H],[*],[\<xparameters_dflt.h\>])
 RTEMS_BSPOPTS_HELP([RTEMS_XPARAMETERS_H],
 [This defines the location of the hardware specific "xparameters.h" file.
diff --git a/c/src/lib/libbsp/powerpc/virtex4/Makefile.am b/c/src/lib/libbsp/powerpc/virtex4/Makefile.am
index 62ca072..56845f9 100644
--- a/c/src/lib/libbsp/powerpc/virtex4/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/virtex4/Makefile.am
@@ -9,9 +9,14 @@ dist_project_lib_DATA = ../../../../../../bsps/powerpc/virtex4/start/bsp_specs
 # include
 
 # start
+
+start.$(OBJEXT): ../../../../../../bsps/powerpc/virtex4/start/start.S
+	$(CPPASCOMPILE) -o $@ -c $<
+project_lib_DATA = start.$(OBJEXT)
+
 rtems_crti.$(OBJEXT): ../../../../../../bsps/powerpc/shared/start/rtems_crti.S
 	$(CPPASCOMPILE) -o $@ -c $<
-project_lib_DATA = rtems_crti.$(OBJEXT)
+project_lib_DATA += rtems_crti.$(OBJEXT)
 
 project_lib_DATA += linkcmds
 
diff --git a/c/src/lib/libbsp/powerpc/virtex5/Makefile.am b/c/src/lib/libbsp/powerpc/virtex5/Makefile.am
index 2dd664d..fae04ed 100644
--- a/c/src/lib/libbsp/powerpc/virtex5/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/virtex5/Makefile.am
@@ -8,9 +8,14 @@ dist_project_lib_DATA = ../../../../../../bsps/powerpc/virtex5/start/bsp_specs
 # include
 
 # start
+
+start.$(OBJEXT): ../../../../../../bsps/powerpc/virtex5/start/start.S
+	$(CPPASCOMPILE) -o $@ -c $<
+project_lib_DATA = start.$(OBJEXT)
+
 rtems_crti.$(OBJEXT): ../../../../../../bsps/powerpc/shared/start/rtems_crti.S
 	$(CPPASCOMPILE) -o $@ -c $<
-project_lib_DATA = rtems_crti.$(OBJEXT)
+project_lib_DATA += rtems_crti.$(OBJEXT)
 
 project_lib_DATA += linkcmds
 




More information about the vc mailing list