This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Am Mon, 22 Jan 2001 schrieben Sie: > Hallo, > > > I have tested the code on the eb01. After swi the proc is in SV. Sorry, I wanted to say: I have tested it on both the sim and the aeb and it worked on the aeb but not on the sim. > > 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! Me too! :-) I will try it! Jens-Christian > > Yves. -- Jens-Christian Lache Technische Universitaet Hamburg-Harburg www.tu-harburg.de/~sejl1601 Mail: lache@tu-harburg.de lache@ngi.de Tel.: +0491759610756 ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |