Hello Bill. Thank you for your comments.
At 11:02 18-12-2003, you wrote:
> I downloaded the new release this morning then recompiled my
>operational thumb-interwork(ing) program. A quick look at the return
>code in the ISRs showed they were not returning via the 'bx'
>instruction as required to restore the appropriate ARM/THUMB mode. I
>loaded the code into my eval board via a JTAG interface & gdb
>anyway and it crashed out almost immediately. I reloaded it into the
>simulator in gdb and got the same results. Think I'll hold off until
>the final version of 3.4 is available.
Please, can you send me your compilation options? I *assume* you are
using the "thumb-interwork" switch, aren't you?
BTW, ISRs do not return with the bx instruction. ISRs restore the CPSR
saved in the link register (r14). This will preserve the mode the processor
was in before the interrupt.
For example, here is the listing for a simple program with IRQ and FIQ
calls. Disassembly seems right to me.
---8<---
00000000 <do_it>:
int
do_it() {
0: e1a0c00d mov ip, sp
4: e92dd800 stmdb sp!, {fp, ip, lr, pc}
8: e24cb004 sub fp, ip, #4 ; 0x4
c: e1a00003 mov r0, r3
10: e89d6800 ldmia sp, {fp, sp, lr}
14: e12fff1e bx lr
00000018 <do_irq>:
}
int __attribute__ ((interrupt ("IRQ")))
do_irq() {
18: e52dc004 str ip, [sp, -#4]!
1c: e1a0c00d mov ip, sp
20: e92dd809 stmdb sp!, {r0, r3, fp, ip, lr, pc}
24: e24cb004 sub fp, ip, #4 ; 0x4
28: e1a00003 mov r0, r3
2c: e89d6809 ldmia sp, {r0, r3, fp, sp, lr}
30: e8bd1000 ldmia sp!, {ip}
34: e25ef004 subs pc, lr, #4 ; 0x4
00000038 <do_fiq>:
}
void __attribute__ ((interrupt ("FIQ")))
do_fiq() {
38: e52dc004 str ip, [sp, -#4]!
3c: e1a0c00d mov ip, sp
40: e92dd800 stmdb sp!, {fp, ip, lr, pc}
44: e24cb004 sub fp, ip, #4 ; 0x4
48: e89d6800 ldmia sp, {fp, sp, lr}
4c: e8bd1000 ldmia sp!, {ip}
50: e25ef004 subs pc, lr, #4 ; 0x4
00000054 <main>:
}
int
main(int argc, char **argv) {
54: e1a0c00d mov ip, sp
58: e92dd800 stmdb sp!, {fp, ip, lr, pc}
5c: e24cb004 sub fp, ip, #4 ; 0x4
60: e24dd008 sub sp, sp, #8 ; 0x8
64: e50b0010 str r0, [fp, -#16]
68: e50b1014 str r1, [fp, -#20]
do_it();
6c: ebfffffe bl 0 <do_it>
6c: R_ARM_PC24 do_it
do_irq();
70: ebfffffe bl 0 <do_it>
70: R_ARM_PC24 do_irq
do_fiq();
74: ebfffffe bl 0 <do_it>
74: R_ARM_PC24 do_fiq
return 0;
78: e3a03000 mov r3, #0 ; 0x0
}
7c: e1a00003 mov r0, r3
80: e24bd00c sub sp, fp, #12 ; 0xc
84: e89d6800 ldmia sp, {fp, sp, lr}
88: e12fff1e bx lr
--->8---
> This probably isn't the place to ask seeing as I just complained
>about the compiler but here goes anyway. Would it be possible in
>future releases to include the Insight version of gdb? I realize it
>makes the distribution bigger but I do find the graphical interface
>indespensible. If it is too big to include, could it be made a
>seperate distribution by itself? Thanks.
Insight is planned to go into the distribution. I am having problems
compiling the TCL libraries (it seems the TCL/TK guys made some API changes
to the latest distro that Insight doesn't like). As soon as I resolve these
issues I will include Insight in the toolchain. Please bear with me.
>-Bill Knight
>R O SoftWare
>
>PS - The distributions I use with thumb-interwork always seem to have
>seperate directories for those libraries. I do not see them with this
>distribution. Am I missing something or is it possible the
>thumb-interwork code & libraries are missing? Though I expected the
>compiler to complain if I requested that mode and it wasn't supported.
>It did not.
That is part of the problem ;^)
As I understand it, old GCC ARM interworking code was a mess of a hack.
All libraries were compiled against all possibilities of the
thumb/interwork switches. This added a lot of redundancy and was getting
difficult to maintain. The compilation process was rewritten in the "right
way" in the GCC-3 series and now GCC is "aware" of ARM interworking. Now
there are only two set of libraries, plain ARM and thumb (look under the
lib/gcc/arm-elf/[gcc-version] toolchain subdirectory -- the thumb directory
is there). GCC should be smart enough to generate the correct mode swapping
code (it "should" -- but it is not there yet, some small issues are
remaining but are getting continuously detected and fixed).
Cheers.