Re: What is the preferred way of doing a context switch on the ARM?
- From: Michael <MichaelDMcDonnell@xxxxxxxxx>
- Date: Fri, 29 Aug 2008 07:29:48 -0700 (PDT)
On Aug 29, 7:15 am, "Boudewijn Dijkstra" <boudew...@xxxxxxxxx> wrote:
Op Fri, 29 Aug 2008 15:39:06 +0200 schreef Michael
<MichaelDMcDonn...@xxxxxxxxx>:
On Aug 29, 1:05 am, "Boudewijn Dijkstra" <boudew...@xxxxxxxxx> wrote:
Op Fri, 29 Aug 2008 07:45:34 +0200 schreef Michael
<MichaelDMcDonn...@xxxxxxxxx>:
I’m asking, because I see no clean way to do it. On stack based
machines you simply “pushall” onto the active task’s stack, switch
stacks, and do a “popall”. The ARM makes this difficult because when
it switches to a privileged mode, the active task’s stack becomes
“invisible”, and the CPSR gets saved into the SPSR (as opposed to
being pushed onto the stack). Thanks!
User-defined task code is only run in User or System mode, which both
use the 'unaliased' registers. On an exception, the processor starts
using alternative registers, but you can go to System mode to access
those unaliased registers and push them (and the SPSR as well, of
course).
Yes, but I was looking for a clean way to do it (no mode changing).
This is the clean way, because it's the only right way. ;)
I believe it was designed this way to allow for short & fast ASM-only
exception
handlers. Only if you need more registers, then some PSR-switching is
required.
Also there's the question of what register to use for the STM / LDM
instructions. Evidently you need to push a register onto the privilege
mode's stack.
That's why they have a stack, and that's what this stack is for. And if
you
intend to call a function from the IRQ exception (such as an interrupt
process
function), then you need to push R14 anyway.
I would think that there would be a cleaner way...
But there isn't. Welcome to the dirty realm of possibilities! :)
--
Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/- Hide quoted text -
- Show quoted text -
Thanks for your help. I'm surprised that the ARM architects didn't
provide for this (easy context switching).
.
- Follow-Ups:
- Re: What is the preferred way of doing a context switch on the ARM?
- From: FreeRTOS.org
- Re: What is the preferred way of doing a context switch on the ARM?
- References:
- What is the preferred way of doing a context switch on the ARM?
- From: Michael
- Re: What is the preferred way of doing a context switch on the ARM?
- From: Boudewijn Dijkstra
- Re: What is the preferred way of doing a context switch on the ARM?
- From: Michael
- Re: What is the preferred way of doing a context switch on the ARM?
- From: Boudewijn Dijkstra
- What is the preferred way of doing a context switch on the ARM?
- Prev by Date: spam
- Next by Date: Re: What is the preferred way of doing a context switch on the ARM?
- Previous by thread: Re: What is the preferred way of doing a context switch on the ARM?
- Next by thread: Re: What is the preferred way of doing a context switch on the ARM?
- Index(es):
Relevant Pages
|