This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: crash in call_pending_DSRs_inner when DSR is called (SA1100)
- To: Andreas B?rgel <ab at genologic dot de>
- Subject: Re: [ECOS] crash in call_pending_DSRs_inner when DSR is called (SA1100)
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- Date: Mon, 8 Oct 2001 12:29:18 +0200
- Cc: ecos-discuss at sources dot redhat dot com
- References: <3BC17D5D.2F0A30C0@genologic.de>
On Mon, Oct 08, 2001 at 12:18:05PM +0200, Andreas B?rgel wrote:
> I'm working on a I2C-chipcard driver for a custom StrongARM 1100
> platform. Every time the card is changed, an interrupt is fired. But
> instead calling my DSR the cpu jumps into nirvana (but without achieving
> salvation ;). I found the point where all ends up in
> Cyg_Interrupt::call_pending_DSRs_inner(void) in the line
>
> intr->dsr( intr->vector, 1, (CYG_ADDRWORD)intr->data );
>
> to be very precise in the following line of assembly code
>
> ldr pc, [r12, #12]
[...]
> int chipcard_initializeInterrupt () {
> cyg_handle_t lIntrHandle;
> cyg_interrupt lIntr;
> cyg_vector_t lIntrVector;
> cyg_priority_t lIntrPriority;
>
> lIntrPriority = 99;
> lIntrVector = CYGNUM_HAL_INTERRUPT_GPIO2;
>
> cyg_interrupt_create ( lIntrVector,
> lIntrPriority,
> (cyg_addrword_t) gCardContentBuffer,
> chipcard_isrCardChange,
> chipcard_dsrCardChange,
> &lIntrHandle,
> &lIntr);
> cyg_interrupt_attach ( lIntrHandle);
> cyg_interrupt_unmask ( lIntrVector);
> }
>
The problem is you have a local variable for lIntr. The state
information for the interrupt is put into lIntr. The variable intr in
Cyg_Interrupt::call_pending_DSRs_inner(void) is actually your
lIntr. But because you have made is a local variable, it was destroyed
as soon as chipcard_initializeInterrupt() exited. The memory on the
stack has then be used by other function so changing its
contents. Making lIntr a static will be your salvation.
Andrew