summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libcpu
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2008-07-16 23:10:55 +0000
committerTill Straumann <strauman@slac.stanford.edu>2008-07-16 23:10:55 +0000
commit03542996ddab2cb8a74b2c815e2644f9d9c820aa (patch)
treec019c67dc5c14387b0e465b623aa05c41ad4b295 /c/src/lib/libcpu
parent2008-07-16 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-03542996ddab2cb8a74b2c815e2644f9d9c820aa.tar.bz2
2008-07-16 Till Straumann <strauman@slac.stanford.edu>
* new-exceptions/bspsupport/vectors_init.c: must not align start of stack downwards (we don't 'own' memory below start). Instead, use original boundaries but align the stack pointer as required. Added test to verify that R13 was loaded with _SDA_BASE_ during early initialization (low-level assembly code relies on it).
Diffstat (limited to 'c/src/lib/libcpu')
-rw-r--r--c/src/lib/libcpu/powerpc/ChangeLog11
-rw-r--r--c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c28
2 files changed, 35 insertions, 4 deletions
diff --git a/c/src/lib/libcpu/powerpc/ChangeLog b/c/src/lib/libcpu/powerpc/ChangeLog
index 3c53b7e21e..703956afc9 100644
--- a/c/src/lib/libcpu/powerpc/ChangeLog
+++ b/c/src/lib/libcpu/powerpc/ChangeLog
@@ -1,5 +1,16 @@
2008-07-16 Till Straumann <strauman@slac.stanford.edu>
+ * new-exceptions/bspsupport/vectors_init.c: must not
+ align start of stack downwards (we don't 'own' memory
+ below start). Instead, use original boundaries but
+ align the stack pointer as required.
+
+ Added test to verify that R13 was loaded with _SDA_BASE_
+ during early initialization (low-level assembly code
+ relies on it).
+
+2008-07-16 Till Straumann <strauman@slac.stanford.edu>
+
* new-exceptions/cpu.c: propagate R2 to all task contexts
even if the ABI is SVR4. Cannot hurt...
diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c
index 83479775fa..c302db298d 100644
--- a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c
+++ b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/vectors_init.c
@@ -350,14 +350,34 @@ void ppc_exc_initialize(
uint32_t interrupt_stack_end = 0;
uint32_t interrupt_stack_pointer = 0;
uint32_t *p = NULL;
+ uint32_t r13, sda_base;
- /* Ensure proper interrupt stack alignment */
- interrupt_stack_start &= ~(CPU_STACK_ALIGNMENT - 1);
- interrupt_stack_size &= ~(CPU_STACK_ALIGNMENT - 1);
+ /* Assembly code needs SDA_BASE in r13 (SVR4 or EABI). Make sure
+ * early init code put it there.
+ */
+ asm volatile(
+ " lis %0, _SDA_BASE_@h \n"
+ " ori %0, %0, _SDA_BASE_@l \n"
+ " mr %1, 13 \n"
+ :"=r"(sda_base),"=r"(r13)
+ );
+
+ if ( sda_base != r13 ) {
+ printk("ppc_exc_initialize(): INTERNAL ERROR\n");
+ printk(" your BSP seems to not have loaded _SDA_BASE_\n");
+ printk(" into R13 as required by SVR4/EABI. Check early init code...\n");
+ printk(" _SDA_BASE_: 0x%08x, R13: 0x%08x\n", sda_base, r13);
+ while (1)
+ ;
+ }
/* Interrupt stack end and pointer */
interrupt_stack_end = interrupt_stack_start + interrupt_stack_size;
- interrupt_stack_pointer = interrupt_stack_end - PPC_MINIMUM_STACK_FRAME_SIZE;
+
+ interrupt_stack_pointer = interrupt_stack_end - PPC_MINIMUM_STACK_FRAME_SIZE;
+
+ /* Ensure proper interrupt stack alignment */
+ interrupt_stack_pointer &= ~(CPU_STACK_ALIGNMENT - 1);
/* Tag interrupt stack bottom */
p = (uint32_t *) interrupt_stack_pointer;