Shaun Louie wrote:
Hi,

This patch fixes a problem I had with getting ROM firmware that uses the kernel to boot properly. The problem was that as soon as interrupts were enabled (first context switch), the exception vectors were not initialized (in my case, RAM is remapped to address 0x0, so needs to maintain the exception vectors even though the code is executing from flash) and the decrementer interrupt caused the cpu to begin executing from this uninitialized memory. The fix is to mirror the compile condition with the condition defined in the hal_powerpc.cdl file, where CYGSEM_HAL_POWERPC_COPY_VECTORS requires ! CYGSEM_HAL_USE_ROM_MONITOR, rather than ! CYG_HAL_STARTUP_ROM. With this fix, the exception vectors are copied to the RAM location, and the interrupts/exceptions execute normally.

This probably hasn't been an issue, because normally either redboot is used (no kernel) or the application executes from RAM, which would satisfy the original compiler condition and copy the exception vectors to RAM, if so chosen.

It might even be sufficient to drop the ! defined(CYGSEM_HAL_USE_ROM_MONITOR), and just have #ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS, since the CDL is already guarding against whether CYGSEM_HAL_USE_ROM_MONITOR is defined or not.
I've attached a new patch that does just what I suggested at the end of my last email. I've also included a ChangeLog entry, which I forgot in the original patch.

Shaun
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' 
ecos.20080311/packages/hal/powerpc/arch/current/ChangeLog 
ecos.20080311.halvectors/packages/hal/powerpc/arch/current/ChangeLog
--- ecos.20080311/packages/hal/powerpc/arch/current/ChangeLog   2007-10-12 
09:30:20.000000000 -0600
+++ ecos.20080311.halvectors/packages/hal/powerpc/arch/current/ChangeLog        
2008-09-23 19:00:59.000000000 -0600
@@ -1,5 +1,10 @@
+2008-09-23  Shaun Louie <[EMAIL PROTECTED]>
+
+    * src/vectors.S: Changed compile condition that determines whether
+      exception vectors should be copied to RAM.
+
 2007-10-12  Gary Thomas  <[EMAIL PROTECTED]>
 
        * src/vectors.S: Optimize system initialization of DATA/BSS/etc.
 
 2006-04-18  Gary Thomas  <[EMAIL PROTECTED]>
diff -r -U 5 -N -x CVS -x '*~' -x '.#~' 
ecos.20080311/packages/hal/powerpc/arch/current/src/vectors.S 
ecos.20080311.halvectors/packages/hal/powerpc/arch/current/src/vectors.S
--- ecos.20080311/packages/hal/powerpc/arch/current/src/vectors.S       
2007-10-12 09:30:20.000000000 -0600
+++ ecos.20080311.halvectors/packages/hal/powerpc/arch/current/src/vectors.S    
2008-09-23 19:00:37.000000000 -0600
@@ -297,11 +297,11 @@
         # safe to access RAM until after this point.
         bl      hal_hardware_init      # this is platform dependent
         .globl  _hal_hardware_init_done
 _hal_hardware_init_done:
 
-#if !defined(CYG_HAL_STARTUP_ROM) && defined(CYGSEM_HAL_POWERPC_COPY_VECTORS)
+#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
         lwi     r3,rom_vectors-4
         lwi     r4,((CYGHWR_HAL_POWERPC_VECTOR_BASE)-4)
         lwi     r5,rom_vectors_end-4
         sub     r5,r5,r3                # compute number of words to copy
         srwi    r5,r5,2

Reply via email to