This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PPC - better stack sizes


The HAL defines for stack sizes were too small on platforms 
which have an FPU and also did not take stack checking into
account.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
Index: hal/powerpc/arch/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/ChangeLog,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -5 -p -r1.68 -r1.69
--- hal/powerpc/arch/current/ChangeLog	30 Jul 2005 00:36:00 -0000	1.68
+++ hal/powerpc/arch/current/ChangeLog	18 Apr 2006 22:29:39 -0000	1.69
@@ -1,5 +1,10 @@
+2006-04-18  Gary Thomas  <gary@mlbassoc.com>
+
+	* include/hal_arch.h: Adjust stack sizes - they were too small
+	(on machines with FPU) and didn't account for stack checking.
+
 2005-07-29  Gary Thomas  <gary@mlbassoc.com>
 
 	* include/arch.inc: Add one-time-include protection since newer
 	versions of the GNU assembler complain about redefining macros.
 
Index: hal/powerpc/arch/current/include/hal_arch.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/arch/current/include/hal_arch.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -5 -p -r1.15 -r1.16
--- hal/powerpc/arch/current/include/hal_arch.h	29 Apr 2004 03:39:58 -0000	1.15
+++ hal/powerpc/arch/current/include/hal_arch.h	18 Apr 2006 22:29:39 -0000	1.16
@@ -401,45 +401,60 @@ externC void hal_idle_thread_action(cyg_
 // Stack needed for a context switch
 #define CYGNUM_HAL_STACK_CONTEXT_SIZE \
     (38*4 /* offsetof(HAL_SavedRegisters, context_size) */)
 
 // Interrupt + call to ISR, interrupt_end() and the DSR
+#ifdef CYGHWR_HAL_POWERPC_FPU
+#define CYGNUM_HAL_STACK_INTERRUPT_SIZE \
+    (((43*4)+(16*8) /* sizeof(HAL_SavedRegisters) */) + 2 * CYGNUM_HAL_STACK_FRAME_SIZE)
+#else
 #define CYGNUM_HAL_STACK_INTERRUPT_SIZE \
     ((43*4 /* sizeof(HAL_SavedRegisters) */) + 2 * CYGNUM_HAL_STACK_FRAME_SIZE)
+#endif
 
 // We have lots of registers so no particular amount is added in for
 // typical local variable usage.
 
 // We define a minimum stack size as the minimum any thread could ever
 // legitimately get away with. We can throw asserts if users ask for less
 // than this. Allow enough for three interrupt sources - clock, serial and
 // one other
 
+#ifdef CYGFUN_KERNEL_THREADS_STACK_CHECKING
+#define CYGNUM_HAL_STACK_CHECKING_OVERHEAD (2*CYGNUM_KERNEL_THREADS_STACK_CHECK_DATA_SIZE)
+#else
+#define CYGNUM_HAL_STACK_CHECKING_OVERHEAD 0
+#endif
+
 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK 
 
 // An interrupt stack which is large enough for all possible interrupt
 // conditions (and only used for that purpose) exists.  "User" stacks
 // can therefore be much smaller
 
 # define CYGNUM_HAL_STACK_SIZE_MINIMUM \
-         (16*CYGNUM_HAL_STACK_FRAME_SIZE + 2*CYGNUM_HAL_STACK_INTERRUPT_SIZE)
+         (16*CYGNUM_HAL_STACK_FRAME_SIZE + \
+          2*CYGNUM_HAL_STACK_INTERRUPT_SIZE + \
+          CYGNUM_HAL_STACK_CHECKING_OVERHEAD)
 
 #else
 
 // No separate interrupt stack exists.  Make sure all threads contain
 // a stack sufficiently large
 # define CYGNUM_HAL_STACK_SIZE_MINIMUM                  \
         (((2+3)*CYGNUM_HAL_STACK_INTERRUPT_SIZE) +      \
-         (16*CYGNUM_HAL_STACK_FRAME_SIZE))
+         (16*CYGNUM_HAL_STACK_FRAME_SIZE) +             \
+         CYGNUM_HAL_STACK_CHECKING_OVERHEAD)
 #endif
 
 // Now make a reasonable choice for a typical thread size. Pluck figures
 // from thin air and say 30 call frames with an average of 16 words of
 // automatic variables per call frame
 #define CYGNUM_HAL_STACK_SIZE_TYPICAL                \
         (CYGNUM_HAL_STACK_SIZE_MINIMUM +             \
-         30 * (CYGNUM_HAL_STACK_FRAME_SIZE+(16*4)))
+         (30 * (CYGNUM_HAL_STACK_FRAME_SIZE+(16*4))) + \
+         CYGNUM_HAL_STACK_CHECKING_OVERHEAD)
 
 //--------------------------------------------------------------------------
 // Macros for switching context between two eCos instances (jump from
 // code in ROM to code in RAM or vice versa).
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]