This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
[ECOS] PowerPC HAL fix for copying exception vectors
- From: Shaun Louie <sal at microplex dot com>
- To: ecos-patches <ecos-patches at sources dot redhat dot com>
- Date: Tue, 23 Sep 2008 17:22:58 -0700
- Subject: [ECOS] PowerPC HAL fix for copying exception vectors
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.
Shaun
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 17:56:36.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)
+#if !defined(CYGSEM_HAL_USE_ROM_MONITOR) && defined(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