From: Yves Rutschle <y.rutschle@indigovision.com>
To: 'Jens-Christian Lache' <lache@tu-harburg.de>
Cc: "'crossgcc@sources.redhat.com'" <crossgcc@sources.redhat.com>
Subject: RE: gcc compile
Date: Sun, 01 Apr 2001 00:00:00 -0000 [thread overview]
Message-ID: <c=US%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-010122122135Z-632@crianlarich.indigo-avs.com> (raw)
Message-ID: <20010401000000.S3DcE-nkd4kRcVPOikbBli6fDiI6suqC_nrGESZU5ac@z> (raw)
Hallo,
> I have tested the code on the eb01. After swi the proc is in SV.
Therefore it's not because of the simulator :)
> 0x2018d28 <swi_handler__Fi>: mov r12, sp
> 0x2018d2c <swi_handler__Fi+4>: stmdb sp!, {r11, r12, lr, pc}
> 0x2018d30 <swi_handler__Fi+8>: sub r11, r12, #4 ; 0x4
> 0x2018d34 <swi_handler__Fi+12>: sub sp, sp, #12 ; 0xc
[snipped swi routine]
> 0x2018d98 <swi_handler__Fi+112>: ldmdb r11, {r11, sp, pc}
This code won't set CPSR back to SPSR; Try to add a hat
at the end of the return instruction:
ldmdb r11, {r11, sp, pc}^
(the hat activates the copy of SPSR to CPSR same as movs pc,lr)
>Don?t know what I am doing wrong. This does also not work:
>void swi_handler(int reason) {
> switch(reason) {
> case REASON_CHANGE_TO_SV :
> asm volatile ("mrs r0,cpsr": : :"r0");
> asm volatile ("orr r0, r0, #192": : :"r0");
> asm volatile ("msr cpsr, r0");
> default :
> break;
> }
> asm volatile("movs pc, lr");
>}
Huh. What do you think happens to the stack when you leave
like that? :-) (hint: you pushed 4 registers when entering
the routine...)
I don't think you can create a whole swi handler in C (unless
gcc has extensions I don't know about. the arm C doesn't
anyway).
I'd advise you to use an assembly top-level handler such
as:
stmdf sp!, {r0-r3, lr}
ldr r0, [lr,#-4]
bic r0, r0, #0xff000000
mov r1, sp ; r1 = SWI number
mrs r2, spsr
stmfd sp!, {r2} ; keep spsr in case of nested swi's
bl C_Handler
ldmfd sp!, {r2}
msr spsr, r2 ; restore spsr
ldmfd sp!, {r0-r3, pc}^ ; return, restore cpsr from spsr
(this is straight from ADS' developer guide, by the way)
Then your C handler looks like:
void C_Handler( int swi_number, unsigned int * stack )
{
printf( "got swi %d\n", swi_number );
}
Hope that helps!
Yves.
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
next reply other threads:[~2001-04-01 0:00 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-22 4:27 Yves Rutschle [this message]
2001-01-22 4:41 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-22 13:38 ` Philip Blundell
2001-01-23 2:18 ` Richard Earnshaw
2001-01-23 2:26 ` Philip Blundell
2001-04-01 0:00 ` Philip Blundell
2001-04-01 0:00 ` Richard Earnshaw
2001-04-01 0:00 ` Philip Blundell
2001-04-01 0:00 ` Yves Rutschle
-- strict thread matches above, loose matches on Subject: below --
2001-01-23 9:21 Jens-Christian Lache
2001-01-23 9:29 ` Philip Blundell
2001-04-01 0:00 ` Philip Blundell
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-22 7:08 Yves Rutschle
2001-04-01 0:00 ` Yves Rutschle
2001-01-22 3:45 Yves Rutschle
2001-01-22 3:58 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-22 4:07 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-22 4:37 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-04-01 0:00 ` Yves Rutschle
[not found] <718D38CAB6E0D011B2C90060970C28A56425F0@EXCHANGESERVER>
2001-01-19 2:49 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-19 2:29 David Korn
2001-01-20 9:51 ` Philip Blundell
2001-01-20 17:15 ` David Feustel
2001-01-21 1:51 ` Philip Blundell
2001-04-01 0:00 ` Philip Blundell
2001-04-01 0:00 ` David Feustel
2001-01-22 2:53 ` Jens-Christian Lache
2001-01-22 3:08 ` Philip Blundell
2001-01-22 7:00 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-04-01 0:00 ` Philip Blundell
2001-01-22 3:22 ` Richard Earnshaw
2001-04-01 0:00 ` Richard Earnshaw
2001-04-01 0:00 ` Jens-Christian Lache
2001-04-01 0:00 ` Philip Blundell
2001-04-01 0:00 ` David Korn
2001-01-19 2:21 Jens-Christian Lache
2001-01-19 2:58 ` Pierre Saucourt-Harmel (r54698)
2001-04-01 0:00 ` Pierre Saucourt-Harmel (r54698)
2001-04-01 0:00 ` Jens-Christian Lache
2001-01-19 1:56 David Korn
2001-04-01 0:00 ` David Korn
2001-01-18 15:43 Hua Ji
2001-01-18 22:35 ` Helmut Kolb
2001-01-19 3:13 ` Kai Ruottu
2001-04-01 0:00 ` Kai Ruottu
2001-04-01 0:00 ` Helmut Kolb
2001-04-01 0:00 ` Hua Ji
2001-01-18 9:27 Sascha Andres
2001-01-18 13:39 ` Jonathan Larmour
2001-04-01 0:00 ` Jonathan Larmour
2001-01-18 15:23 ` Gerrit Peter Haase
2001-01-22 0:19 ` Sascha Andres
2001-01-22 2:43 ` Jens-Christian Lache
2001-04-01 0:00 ` Jens-Christian Lache
2001-04-01 0:00 ` Sascha Andres
2001-04-01 0:00 ` Gerrit Peter Haase
2001-04-01 0:00 ` Sascha Andres
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='c=US%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-010122122135Z-632@crianlarich.indigo-avs.com' \
--to=y.rutschle@indigovision.com \
--cc=crossgcc@sources.redhat.com \
--cc=lache@tu-harburg.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).