public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] ecos newbie question: the stack for interrupt_end()
@ 2004-04-09 22:18 wyb
  2004-04-11 11:59 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: wyb @ 2004-04-09 22:18 UTC (permalink / raw)
  To: ecos-discuss

In arm HAL, the following code said that interrupt_end() should be called on
the thread stack.

=========================================
spurious_IRQ:
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
        // If we are returning from the last nested interrupt, move back
        // to the thread stack. interrupt_end() must be called on the
        // thread stack since it potentially causes a context switch.
        ldr     r2,.irq_level
        ldr     r3,[r2]
        subs    r1,r3,#1
        str     r1,[r2]
        ldreq   sp,[sp]         // This should be the saved stack pointer
#endif
==========================================

But if the thread was in user mode, the "ldreq sp, [sp]" still loaded SP
with svc_sp,not usr_sp. because the sp saved in interrupt_stack was svc_sp.
The "ldreq sp, .__interrupt_stack" in following code saved the svc_sp. Mybe
i'm false, can anyone help me.

#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
        // Switch to interrupt stack
        ldr     r2,.irq_level           // current number of nested
interrupts
        ldr     r0,[r2]
        add     r1,r0,#1
        str     r1,[r2]                 // if was zero, switch stacks
        cmp     r0,#0
        moveq   r1,sp                   // save old stack pointer
        ldreq   sp,.__interrupt_stack
        stmeqfd sp!,{r1}
10:
#endif


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] ecos newbie question: the stack for interrupt_end()
  2004-04-09 22:18 [ECOS] ecos newbie question: the stack for interrupt_end() wyb
@ 2004-04-11 11:59 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2004-04-11 11:59 UTC (permalink / raw)
  To: wyb; +Cc: ecos-discuss

On Fri, Apr 09, 2004 at 02:51:12PM +0800, wyb wrote:
> In arm HAL, the following code said that interrupt_end() should be called on
> the thread stack.
> 
> =========================================
> spurious_IRQ:
> #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
>         // If we are returning from the last nested interrupt, move back
>         // to the thread stack. interrupt_end() must be called on the
>         // thread stack since it potentially causes a context switch.
>         ldr     r2,.irq_level
>         ldr     r3,[r2]
>         subs    r1,r3,#1
>         str     r1,[r2]
>         ldreq   sp,[sp]         // This should be the saved stack pointer
> #endif
> ==========================================
> 
> But if the thread was in user mode, the "ldreq sp, [sp]" still loaded SP
> with svc_sp,not usr_sp.

The thread should not be in user mode. eCos runs everything in
supervisor mode.

           Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-11 11:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-09 22:18 [ECOS] ecos newbie question: the stack for interrupt_end() wyb
2004-04-11 11:59 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).