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

* arm/crt0.S: Add Thumb-2 startup code.
        * arm/redboot-crt0.S: Ditto.
        * arm/libcfunc.c (do_AngelSWI): Use AngelSWIInsn.
        * arm/swi.h (AngelSWIInsn, AngelSWIAsm): Define.
        * arm/trap.S: Disable for Thumb-2.
This commit is contained in:
Jeff Johnston 2006-02-07 18:46:23 +00:00
parent 9bbe6d5d28
commit f9fa511d46
7 changed files with 65 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2006-02-07 Paul Brook <paul@codesourcery.com>
* arm/crt0.S: Add Thumb-2 startup code.
* arm/redboot-crt0.S: Ditto.
* arm/libcfunc.c (do_AngelSWI): Use AngelSWIInsn.
* arm/swi.h (AngelSWIInsn, AngelSWIAsm): Define.
* arm/trap.S: Disable for Thumb-2.
2006-01-18 Nathan Sidwell <nathan@codesourcery.com>
* mt/ms2.ld (.sram): Correct typo in section names.

View File

@ -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]
@ -124,8 +140,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 */
@ -165,7 +181,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 */
@ -287,7 +303,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

View File

@ -15,7 +15,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"

View File

@ -12,11 +12,23 @@
.text
/* Setup the assembly entry point. */
.code 32
.globl SYM_NAME(start)
.globl SYM_NAME(_start)
SYM_NAME(start):
SYM_NAME(_start):
#ifdef __thumb2__
.macro FUNC_START name
.global \name
.thumb_func
\name:
.endm
.syntax unified
.thumb
#else
.macro FUNC_START name
.global \name
\name:
.endm
.code 32
#endif
FUNC_START SYM_NAME(start)
FUNC_START SYM_NAME(_start)
mov fp, #0 /* Null frame pointer. */
mov r7, #0 /* Null frame pointer for Thumb. */
@ -46,7 +58,7 @@ SYM_NAME(_start):
/* Nothing to left to clear. */
#endif
#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. */

View File

@ -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

View File

@ -99,7 +99,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"

View File

@ -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