2006-02-07 Paul Brook <paul@codesourcery.com>

* libc/machine/arm/setjmp.S: Add Thumb-2 support.
        * libc/sys/arm/crt0.S: Add Thumb-2 startup code.
        * libc/sys/arm/libcfunc.c (do_AngelSWI): Use AngelSWIInsn.
        * libc/sys/arm/swi.h (AngelSWIInsn, AngelSWIAsm): Define.
        * libc/sys/arm/trap.S: Disable for Thumb-2.
This commit is contained in:
Jeff Johnston 2006-02-07 18:44:54 +00:00
parent 03a49a00ab
commit 9bbe6d5d28
7 changed files with 75 additions and 16 deletions

View File

@ -1,3 +1,11 @@
2006-02-07 Paul Brook <paul@codesourcery.com>
* libc/machine/arm/setjmp.S: Add Thumb-2 support.
* libc/sys/arm/crt0.S: Add Thumb-2 startup code.
* libc/sys/arm/libcfunc.c (do_AngelSWI): Use AngelSWIInsn.
* libc/sys/arm/swi.h (AngelSWIInsn, AngelSWIAsm): Define.
* libc/sys/arm/trap.S: Disable for Thumb-2.
2006-01-31 Leif Ekblad <leif@rdos.net> 2006-01-31 Leif Ekblad <leif@rdos.net>
* configure.host: RDOS support added * configure.host: RDOS support added

View File

@ -51,17 +51,39 @@
Function entry is much simpler. If we are compiling for the Thumb we Function entry is much simpler. If we are compiling for the Thumb we
just switch into ARM mode and then drop through into the rest of the just switch into ARM mode and then drop through into the rest of the
function. The function exit code will take care of the restore to function. The function exit code will take care of the restore to
Thumb mode. */ Thumb mode.
For Thumb-2 do everything in Thumb mode. */
#ifdef __APCS_26__ #ifdef __APCS_26__
#define RET movs pc, lr #define RET movs pc, lr
#elif defined(__thumb2__)
#define RET bx lr
#else #else
#define RET tst lr, #1; \ #define RET tst lr, #1; \
moveq pc, lr ; \ moveq pc, lr ; \
.word 0xe12fff1e /* bx lr */ .word 0xe12fff1e /* bx lr */
#endif #endif
#ifdef __thumb__ #ifdef __thumb2__
.macro COND where when
i\where \when
.endm
#else
.macro COND where when
.endm
#endif
#if defined(__thumb2__)
.syntax unified
.macro MODE
.thumb
.thumb_func
.endm
.macro PROLOGUE name
.endm
#elif defined(__thumb__)
#define MODE .thumb_func #define MODE .thumb_func
.macro PROLOGUE name .macro PROLOGUE name
.code 16 .code 16
@ -70,7 +92,7 @@
.code 32 .code 32
SYM (.arm_start_of.\name): SYM (.arm_start_of.\name):
.endm .endm
#else #else /* Arm */
#define MODE .code 32 #define MODE .code 32
.macro PROLOGUE name .macro PROLOGUE name
.endm .endm
@ -131,6 +153,9 @@ SYM (\name):
/* Put the return value into the integer result register. /* Put the return value into the integer result register.
But if it is zero then return 1 instead. */ But if it is zero then return 1 instead. */
movs a1, a2 movs a1, a2
#ifdef __thumb2__
it eq
#endif
moveq a1, #1 moveq a1, #1
FUNC_END longjmp FUNC_END longjmp

View File

@ -18,15 +18,26 @@
/* .text is used instead of .section .text so it works with arm-aout too. */ /* .text is used instead of .section .text so it works with arm-aout too. */
.text .text
#if defined(__thumb2__)
.syntax unified
.thumb
.macro FUNC_START name
.global \name
.thumb_func
\name:
.endm
#else
.code 32 .code 32
.macro FUNC_START name
.global \name
\name:
.endm
#endif
.align 0 .align 0
.global _mainCRTStartup FUNC_START _mainCRTStartup
.global _start FUNC_START _start
.global start FUNC_START start
start:
_start:
_mainCRTStartup:
#if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__)
/* Annotation for EABI unwinding tables. */ /* Annotation for EABI unwinding tables. */
.fnstart .fnstart
@ -45,7 +56,12 @@ _mainCRTStartup:
/* Issue Angel SWI to read stack info */ /* Issue Angel SWI to read stack info */
mov r0, #AngelSWI_Reason_HeapInfo mov r0, #AngelSWI_Reason_HeapInfo
adr r1, .LC0 /* point at ptr to 4 words to receive data */ adr r1, .LC0 /* point at ptr to 4 words to receive data */
swi AngelSWI_ARM /* We are always in ARM mode for startup */ #if defined(__thumb2__)
bkpt AngelSWI
#else
/* We are always in ARM mode for startup */
AngelSWIAsm AngelSWI_ARM
#endif
ldr r0, .LC0 /* point at values read */ ldr r0, .LC0 /* point at values read */
ldr sp, [r0, #8] ldr sp, [r0, #8]
ldr sl, [r0, #12] ldr sl, [r0, #12]
@ -75,8 +91,8 @@ _mainCRTStartup:
sub a3, a3, a1 /* Third arg: length of block */ sub a3, a3, a1 /* Third arg: length of block */
#ifdef __thumb__ /* Enter Thumb mode.... */ #if defined(__thumb__) && !defined(__thumb2__)
/* Enter Thumb mode.... */
add a4, pc, #1 /* Get the address of the Thumb block */ add a4, pc, #1 /* Get the address of the Thumb block */
bx a4 /* Go there and start Thumb decoding */ bx a4 /* Go there and start Thumb decoding */
@ -100,7 +116,7 @@ __change_mode:
#else #else
mov r0, #AngelSWI_Reason_GetCmdLine mov r0, #AngelSWI_Reason_GetCmdLine
adr r1, .LC30 /* Space for command line */ adr r1, .LC30 /* Space for command line */
swi AngelSWI AngelSWIAsm AngelSWI
ldr r1, .LC30 ldr r1, .LC30
#endif #endif
/* Parse string at r1 */ /* Parse string at r1 */
@ -222,7 +238,7 @@ __change_mode:
bl FUNCTION (exit) /* Should not return. */ bl FUNCTION (exit) /* Should not return. */
#ifdef __thumb__ #if defined(__thumb__) && !defined(__thumb2__)
/* Come out of Thumb mode. This code should be redundant. */ /* Come out of Thumb mode. This code should be redundant. */
mov a4, pc mov a4, pc

View File

@ -13,7 +13,7 @@ static inline int
do_AngelSWI (int reason, void * arg) do_AngelSWI (int reason, void * arg)
{ {
int value; int value;
asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0" asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0"
: "=r" (value) /* Outputs */ : "=r" (value) /* Outputs */
: "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
: "r0", "r1", "lr" : "r0", "r1", "lr"

View File

@ -33,6 +33,14 @@
#else #else
#define AngelSWI AngelSWI_ARM #define AngelSWI AngelSWI_ARM
#endif #endif
/* For Thumb-2 code use the BKPT instruction instead of SWI. */
#ifdef __thumb2__
#define AngelSWIInsn "bkpt"
#define AngelSWIAsm bkpt
#else
#define AngelSWIInsn "swi"
#define AngelSWIAsm swi
#endif
/* The reason codes: */ /* The reason codes: */
#define AngelSWI_Reason_Open 0x01 #define AngelSWI_Reason_Open 0x01

View File

@ -98,7 +98,7 @@ static inline int
do_AngelSWI (int reason, void * arg) do_AngelSWI (int reason, void * arg)
{ {
int value; int value;
asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0" asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0"
: "=r" (value) /* Outputs */ : "=r" (value) /* Outputs */
: "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
: "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"

View File

@ -1,4 +1,5 @@
/* Run-time exception support */ /* Run-time exception support */
#if !defined(__thumb2__)
#include "swi.h" #include "swi.h"
/* .text is used instead of .section .text so it works with arm-aout too. */ /* .text is used instead of .section .text so it works with arm-aout too. */
@ -91,3 +92,4 @@ __rt_stkovf_split_big:
@ We now know how much extra stack the function requires. @ We now know how much extra stack the function requires.
@ Terminate the program for the moment: @ Terminate the program for the moment:
swi SWI_Exit swi SWI_Exit
#endif