[PATCH 2/9] bsps/powerpc: Use interrupt stack for init stack
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Nov 16 14:45:44 UTC 2018
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(-)
rename bsps/powerpc/haleakala/start/{dlentry.S => start.S} (100%)
diff --git a/bsps/powerpc/gen5200/start/start.S b/bsps/powerpc/gen5200/start/start.S
index 0c2dfd5989..9e9e504861 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 532210e4b9..943ced4d59 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 3bccc97c38..7cd993c0c9 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 4fdc21cea9..0537bbf849 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 493720e0c7..ade890a80b 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 5990c7e2d4..c948c9c1ef 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 e2a3a16fbe..2fc66015cb 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 354b9a967e..faffaf9f31 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 f3a41dd3a9..e8df31e2f0 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 725b09954f..3c9cd229d3 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 66705168ef..46e5111b67 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 0cb4b4e752..32425f4c7f 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 89594c83cf..e58a42a530 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 51ea72166f..c6276e15e9 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 b70adf1af5..19ecf513a3 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 62ca072f94..56845f95de 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 2dd664d0a3..fae04ed02d 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
--
2.16.4
More information about the devel
mailing list