Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2006-02-07 21:44:54 +0300
committerJeff Johnston <jjohnstn@redhat.com>2006-02-07 21:44:54 +0300
commit9bbe6d5d283de104216238d684e0a46506326706 (patch)
treebe201e8f20488b3c81392d55d2337acd4948b25f /newlib/libc/sys
parent03a49a00ab2239e769c61592ea946d151ea95114 (diff)
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.
Diffstat (limited to 'newlib/libc/sys')
-rw-r--r--newlib/libc/sys/arm/crt0.S38
-rw-r--r--newlib/libc/sys/arm/libcfunc.c2
-rw-r--r--newlib/libc/sys/arm/swi.h8
-rw-r--r--newlib/libc/sys/arm/syscalls.c2
-rw-r--r--newlib/libc/sys/arm/trap.S2
5 files changed, 39 insertions, 13 deletions
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index 8a8372a88..c750ca819 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -18,15 +18,26 @@
/* .text is used instead of .section .text so it works with arm-aout too. */
.text
+#if defined(__thumb2__)
+ .syntax unified
+ .thumb
+.macro FUNC_START name
+ .global \name
+ .thumb_func
+\name:
+.endm
+#else
.code 32
+.macro FUNC_START name
+ .global \name
+\name:
+.endm
+#endif
.align 0
- .global _mainCRTStartup
- .global _start
- .global start
-start:
-_start:
-_mainCRTStartup:
+ FUNC_START _mainCRTStartup
+ FUNC_START _start
+ FUNC_START start
#if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__)
/* Annotation for EABI unwinding tables. */
.fnstart
@@ -45,7 +56,12 @@ _mainCRTStartup:
/* Issue Angel SWI to read stack info */
mov r0, #AngelSWI_Reason_HeapInfo
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 sp, [r0, #8]
ldr sl, [r0, #12]
@@ -75,8 +91,8 @@ _mainCRTStartup:
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 */
bx a4 /* Go there and start Thumb decoding */
@@ -100,7 +116,7 @@ __change_mode:
#else
mov r0, #AngelSWI_Reason_GetCmdLine
adr r1, .LC30 /* Space for command line */
- swi AngelSWI
+ AngelSWIAsm AngelSWI
ldr r1, .LC30
#endif
/* Parse string at r1 */
@@ -222,7 +238,7 @@ __change_mode:
bl FUNCTION (exit) /* Should not return. */
-#ifdef __thumb__
+#if defined(__thumb__) && !defined(__thumb2__)
/* Come out of Thumb mode. This code should be redundant. */
mov a4, pc
diff --git a/newlib/libc/sys/arm/libcfunc.c b/newlib/libc/sys/arm/libcfunc.c
index ddc611f34..3bf0a56f4 100644
--- a/newlib/libc/sys/arm/libcfunc.c
+++ b/newlib/libc/sys/arm/libcfunc.c
@@ -13,7 +13,7 @@ static inline int
do_AngelSWI (int reason, void * arg)
{
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" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
: "r0", "r1", "lr"
diff --git a/newlib/libc/sys/arm/swi.h b/newlib/libc/sys/arm/swi.h
index 15c3866a1..f5c910313 100644
--- a/newlib/libc/sys/arm/swi.h
+++ b/newlib/libc/sys/arm/swi.h
@@ -33,6 +33,14 @@
#else
#define AngelSWI AngelSWI_ARM
#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: */
#define AngelSWI_Reason_Open 0x01
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index e89022806..529309930 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -98,7 +98,7 @@ static inline int
do_AngelSWI (int reason, void * arg)
{
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" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
: "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
diff --git a/newlib/libc/sys/arm/trap.S b/newlib/libc/sys/arm/trap.S
index 328fabca5..21b6937f9 100644
--- a/newlib/libc/sys/arm/trap.S
+++ b/newlib/libc/sys/arm/trap.S
@@ -1,4 +1,5 @@
/* Run-time exception support */
+#if !defined(__thumb2__)
#include "swi.h"
/* .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.
@ Terminate the program for the moment:
swi SWI_Exit
+#endif