[rtems commit] bsps/powerpc: ppc_exc_initialize_interrupt_stack()

Sebastian Huber sebh at rtems.org
Fri Jan 9 13:09:38 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec 23 09:53:43 2014 +0100

bsps/powerpc: ppc_exc_initialize_interrupt_stack()

---

 .../new-exceptions/bspsupport/ppc_exc_initialize.c    | 12 +-----------
 .../powerpc/new-exceptions/bspsupport/vectors.h       | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_initialize.c b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_initialize.c
index f830bad..ef978f8 100644
--- a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_initialize.c
+++ b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_initialize.c
@@ -156,8 +156,6 @@ void ppc_exc_initialize_with_vector_base(
 {
   rtems_status_code sc = RTEMS_SUCCESSFUL;
   const ppc_exc_categories *const categories = ppc_exc_current_categories();
-  uintptr_t const interrupt_stack_end = interrupt_stack_begin + interrupt_stack_size;
-  uintptr_t interrupt_stack_pointer = interrupt_stack_end - PPC_MINIMUM_STACK_FRAME_SIZE;
   unsigned vector = 0;
   uint32_t sda_base = 0;
   uint32_t r13 = 0;
@@ -180,15 +178,7 @@ void ppc_exc_initialize_with_vector_base(
     ppc_exc_fatal_error();
   }
 
-  /* Ensure proper interrupt stack alignment */
-  interrupt_stack_pointer &= ~((uintptr_t) CPU_STACK_ALIGNMENT - 1);
-
-  /* Tag interrupt stack bottom */
-  *(uint32_t *) interrupt_stack_pointer = 0;
-
-  /* Move interrupt stack values to special purpose registers */
-  PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG1, interrupt_stack_pointer);
-  PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG2, interrupt_stack_begin);
+  ppc_exc_initialize_interrupt_stack(interrupt_stack_begin, interrupt_stack_size);
 
 #ifndef PPC_EXC_CONFIG_BOOKE_ONLY
 
diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors.h b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors.h
index 9e5f466..bf13c75 100644
--- a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors.h
+++ b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors.h
@@ -355,6 +355,25 @@ rtems_status_code ppc_exc_make_prologue(
   size_t *prologue_size
 );
 
+static inline void ppc_exc_initialize_interrupt_stack(
+  uintptr_t stack_begin,
+  uintptr_t stack_size
+)
+{
+  uintptr_t stack_end = stack_begin + stack_size;
+  uintptr_t stack_pointer = stack_end - PPC_MINIMUM_STACK_FRAME_SIZE;
+
+  /* Ensure proper interrupt stack alignment */
+  stack_pointer &= ~((uintptr_t) CPU_STACK_ALIGNMENT - 1);
+
+  /* Tag interrupt stack bottom */
+  *(uint32_t *) stack_pointer = 0;
+
+  /* Move interrupt stack values to special purpose registers */
+  PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG1, stack_pointer);
+  PPC_SET_SPECIAL_PURPOSE_REGISTER(SPRG2, stack_begin);
+}
+
 /**
  * @brief Initializes the exception handling.
  *




More information about the vc mailing list