From 03542996ddab2cb8a74b2c815e2644f9d9c820aa Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Wed, 16 Jul 2008 23:10:55 +0000 Subject: 2008-07-16 Till Straumann * 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). --- c/src/lib/libcpu/powerpc/ChangeLog | 11 +++++++++ .../new-exceptions/bspsupport/vectors_init.c | 28 ++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'c/src/lib/libcpu') 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,3 +1,14 @@ +2008-07-16 Till Straumann + + * 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 * new-exceptions/cpu.c: propagate R2 to all task contexts 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; -- cgit v1.2.3