diff options
Diffstat (limited to 'libgloss/arm')
-rw-r--r-- | libgloss/arm/configure | 31 | ||||
-rw-r--r-- | libgloss/arm/configure.in | 9 | ||||
-rw-r--r-- | libgloss/arm/crt0.S | 45 | ||||
-rw-r--r-- | libgloss/arm/elf-redboot.ld | 1 | ||||
-rw-r--r-- | libgloss/arm/libcfunc.c | 60 | ||||
-rw-r--r-- | libgloss/arm/redboot-crt0.S | 28 | ||||
-rw-r--r-- | libgloss/arm/swi.h | 8 | ||||
-rw-r--r-- | libgloss/arm/syscalls.c | 137 | ||||
-rw-r--r-- | libgloss/arm/trap.S | 2 |
9 files changed, 88 insertions, 233 deletions
diff --git a/libgloss/arm/configure b/libgloss/arm/configure index 47d91ec30..2103e319a 100644 --- a/libgloss/arm/configure +++ b/libgloss/arm/configure @@ -537,16 +537,13 @@ else fi if test "x$newlib_may_supply_syscalls" = "xyes"; then - BUILD_CRT0_TRUE='#' - BUILD_CRT0_FALSE= -else BUILD_CRT0_TRUE= BUILD_CRT0_FALSE='#' +else + BUILD_CRT0_TRUE='#' + BUILD_CRT0_FALSE= fi - - - if test "$srcdir" = "." ; then if test "${with_target_subdir}" != "." ; then libgloss_topdir="${srcdir}/${with_multisrctop}../../.." @@ -604,7 +601,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:608: checking host system type" >&5 +echo "configure:605: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -625,7 +622,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:629: checking target system type" >&5 +echo "configure:626: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -643,7 +640,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:647: checking build system type" >&5 +echo "configure:644: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -697,7 +694,7 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x," # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:701: checking for a BSD compatible install" >&5 +echo "configure:698: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -761,7 +758,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:765: checking for $ac_word" >&5 +echo "configure:762: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -791,7 +788,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:795: checking for $ac_word" >&5 +echo "configure:792: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -840,7 +837,7 @@ fi fi echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:844: checking whether we are using GNU C" >&5 +echo "configure:841: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -849,7 +846,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:850: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -864,7 +861,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:868: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:865: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -900,7 +897,7 @@ LD=${LD-ld} # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:904: checking for $ac_word" >&5 +echo "configure:901: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1090,8 +1087,6 @@ s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g -s%@BUILD_CRT0_TRUE@%$BUILD_CRT0_TRUE%g -s%@BUILD_CRT0_FALSE@%$BUILD_CRT0_FALSE%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g diff --git a/libgloss/arm/configure.in b/libgloss/arm/configure.in index 71595998a..d334288c4 100644 --- a/libgloss/arm/configure.in +++ b/libgloss/arm/configure.in @@ -12,16 +12,13 @@ AC_ARG_ENABLE(newlib-supplied-syscalls, esac], [newlib_may_supply_syscalls=yes])dnl if test "x$newlib_may_supply_syscalls" = "xyes"; then - BUILD_CRT0_TRUE='#' - BUILD_CRT0_FALSE= -else BUILD_CRT0_TRUE= BUILD_CRT0_FALSE='#' +else + BUILD_CRT0_TRUE='#' + BUILD_CRT0_FALSE= fi -AC_SUBST(BUILD_CRT0_TRUE) -AC_SUBST(BUILD_CRT0_FALSE) - if test "$srcdir" = "." ; then if test "${with_target_subdir}" != "." ; then libgloss_topdir="${srcdir}/${with_multisrctop}../../.." diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S index 823f409a4..33bcc3a4b 100644 --- a/libgloss/arm/crt0.S +++ b/libgloss/arm/crt0.S @@ -18,26 +18,15 @@ /* .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 - FUNC_START _mainCRTStartup - FUNC_START _start - FUNC_START start + .global _mainCRTStartup + .global _start + .global start +start: +_start: +_mainCRTStartup: #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) /* Annotation for EABI unwinding tables. */ .fnstart @@ -56,12 +45,7 @@ /* Issue Angel SWI to read stack info */ mov r0, #AngelSWI_Reason_HeapInfo adr r1, .LC0 /* point at ptr to 4 words to receive data */ -#if defined(__thumb2__) - bkpt AngelSWI -#else - /* We are always in ARM mode for startup */ - AngelSWIAsm AngelSWI_ARM -#endif + swi AngelSWI_ARM /* We are always in ARM mode for startup */ ldr r0, .LC0 /* point at values read */ ldr sp, [r0, #8] ldr sl, [r0, #12] @@ -140,8 +124,8 @@ sub a3, a3, a1 /* Third arg: length of block */ -#if defined(__thumb__) && !defined(__thumb2__) - /* Enter Thumb mode.... */ +#ifdef __thumb__ /* Enter Thumb mode.... */ + add a4, pc, #1 /* Get the address of the Thumb block */ bx a4 /* Go there and start Thumb decoding */ @@ -181,7 +165,7 @@ __change_mode: #else mov r0, #AngelSWI_Reason_GetCmdLine adr r1, .LC30 /* Space for command line */ - AngelSWIAsm AngelSWI + swi AngelSWI ldr r1, .LC30 #endif /* Parse string at r1 */ @@ -267,11 +251,6 @@ __change_mode: add r3, #4 b .LC15 .LC14: - /* Ensure doubleword stack alignment. */ - mov r4, sp - mov r5, #7 - bic r4, r5 - mov sp, r4 #else add r2, sp, r0, LSL #2 /* End of args */ mov r3, sp /* Start of args */ @@ -281,8 +260,6 @@ __change_mode: strhi r5, [r2, #-4]! strhi r4, [r3], #4 bhi .LC13 - /* Ensure doubleword stack alignment. */ - bic sp, sp, #7 #endif #endif @@ -303,7 +280,7 @@ __change_mode: bl FUNCTION (exit) /* Should not return. */ -#if defined(__thumb__) && !defined(__thumb2__) +#ifdef __thumb__ /* Come out of Thumb mode. This code should be redundant. */ mov a4, pc diff --git a/libgloss/arm/elf-redboot.ld b/libgloss/arm/elf-redboot.ld index 3d1f8d806..be3865430 100644 --- a/libgloss/arm/elf-redboot.ld +++ b/libgloss/arm/elf-redboot.ld @@ -209,7 +209,6 @@ SECTIONS .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } - .debug_ranges 0 : { *(.debug_ranges) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } diff --git a/libgloss/arm/libcfunc.c b/libgloss/arm/libcfunc.c index 4f131939a..ddc611f34 100644 --- a/libgloss/arm/libcfunc.c +++ b/libgloss/arm/libcfunc.c @@ -5,17 +5,15 @@ Note: These functions are in a seperate file so that OS providers can overrride the system call stubs (defined in syscalls.c) without having to provide libc funcitons as well. */ - #include "swi.h" -#include <errno.h> -#include <unistd.h> #ifdef ARM_RDI_MONITOR + static inline int do_AngelSWI (int reason, void * arg) { int value; - asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0" + asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0" : "=r" (value) /* Outputs */ : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ : "r0", "r1", "lr" @@ -24,65 +22,19 @@ do_AngelSWI (int reason, void * arg) } #endif /* ARM_RDI_MONITOR */ + void abort (void) { - extern void _exit (int n); #ifdef ARM_RDI_MONITOR do_AngelSWI (AngelSWI_Reason_ReportException, (void *) ADP_Stopped_RunTimeError); #else - _exit(17); + asm ("mov r0,#17\nswi %a0" :: "i" (SWI_Exit)); #endif } -unsigned __attribute__((weak)) -alarm (unsigned seconds) -{ - (void)seconds; - return 0; -} - -clock_t _clock(void); -clock_t __attribute__((weak)) -clock(void) -{ - return _clock(); -} - -int _isatty(int fildes); -int __attribute__((weak)) -isatty(int fildes) -{ - return _isatty(fildes); -} - -int __attribute__((weak)) -pause(void) -{ - errno = ENOSYS; - return -1; -} - -#include <sys/types.h> -#include <time.h> - -unsigned __attribute__((weak)) -sleep(unsigned seconds) -{ - clock_t t0 = _clock(); - clock_t dt = seconds * CLOCKS_PER_SEC; - - while (_clock() - t0 < dt); - return 0; -} - -int __attribute__((weak)) -usleep(useconds_t useconds) +void +alarm (void) { - clock_t t0 = _clock(); - clock_t dt = useconds / (1000000/CLOCKS_PER_SEC); - - while (_clock() - t0 < dt); - return 0; } diff --git a/libgloss/arm/redboot-crt0.S b/libgloss/arm/redboot-crt0.S index 2499ac091..f2963eeb4 100644 --- a/libgloss/arm/redboot-crt0.S +++ b/libgloss/arm/redboot-crt0.S @@ -12,34 +12,18 @@ .text /* Setup the assembly entry point. */ -#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) + .code 32 + .globl SYM_NAME(start) + .globl SYM_NAME(_start) +SYM_NAME(start): +SYM_NAME(_start): mov fp, #0 /* Null frame pointer. */ mov r7, #0 /* Null frame pointer for Thumb. */ /* Enable interrupts for gdb debugging. */ -#ifdef __thumb2__ - cpsie if -#else mrs r0, cpsr bic r0, r0, #0xC0 msr cpsr, r0 -#endif mov a2, #0 /* Second arg: fill value. */ ldr a1, .LC1 /* First arg: start of memory block. */ @@ -62,7 +46,7 @@ /* Nothing to left to clear. */ #endif -#if defined(__thumb__) && !defined(__thumb2__) /* Enter Thumb mode. */ +#ifdef __thumb__ /* Enter Thumb mode. */ add a4, pc, #1 /* Get the address of the Thumb block. */ bx a4 /* Go there and start Thumb decoding. */ diff --git a/libgloss/arm/swi.h b/libgloss/arm/swi.h index f5c910313..15c3866a1 100644 --- a/libgloss/arm/swi.h +++ b/libgloss/arm/swi.h @@ -33,14 +33,6 @@ #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/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index a6d2f747e..a215d7a50 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -7,7 +7,6 @@ #include <sys/stat.h> #include <sys/fcntl.h> #include <stdio.h> -#include <string.h> #include <time.h> #include <sys/time.h> #include <sys/times.h> @@ -19,10 +18,11 @@ /* Forward prototypes. */ int _system _PARAMS ((const char *)); int _rename _PARAMS ((const char *, const char *)); -int _isatty _PARAMS ((int)); +int isatty _PARAMS ((int)); clock_t _times _PARAMS ((struct tms *)); int _gettimeofday _PARAMS ((struct timeval *, struct timezone *)); -int _unlink _PARAMS ((const char *)); +void _raise _PARAMS ((void)); +int _unlink _PARAMS ((void)); int _link _PARAMS ((void)); int _stat _PARAMS ((const char *, struct stat *)); int _fstat _PARAMS ((int, struct stat *)); @@ -31,7 +31,6 @@ int _getpid _PARAMS ((int)); int _kill _PARAMS ((int, int)); void _exit _PARAMS ((int)); int _close _PARAMS ((int)); -clock_t _clock _PARAMS ((void)); int _swiclose _PARAMS ((int)); int _open _PARAMS ((const char *, int, ...)); int _swiopen _PARAMS ((const char *, int)); @@ -99,7 +98,7 @@ static inline int do_AngelSWI (int reason, void * arg) { int value; - asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0" + asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0" : "=r" (value) /* Outputs */ : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" @@ -134,16 +133,6 @@ initialise_monitor_handles (void) { int i; - /* Open the standard file descriptors by opening the special - * teletype device, ":tt", read-only to obtain a descritpor for - * standard input and write-only to obtain a descriptor for standard - * output. Finally, open ":tt" in append mode to obtain a descriptor - * for standard error. Since this is a write mode, most kernels will - * probably return the same value as for standard output, but the - * kernel can differentiate the two using the mode flag and return a - * different descriptor for standard error. - */ - #ifdef ARM_RDI_MONITOR int volatile block[3]; @@ -155,12 +144,7 @@ initialise_monitor_handles (void) block[0] = (int) ":tt"; block[2] = 3; /* length of filename */ block[1] = 4; /* mode "w" */ - monitor_stdout = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); - - block[0] = (int) ":tt"; - block[2] = 3; /* length of filename */ - block[1] = 8; /* mode "a" */ - monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); + monitor_stdout = monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); #else int fh; const char * name; @@ -177,14 +161,7 @@ initialise_monitor_handles (void) : "=r"(fh) : "i" (SWI_Open),"r"(name) : "r0","r1"); - monitor_stdout = fh; - - name = ":tt"; - asm ("mov r0,%2; mov r1, #8; swi %a1; mov %0, r0" - : "=r"(fh) - : "i" (SWI_Open),"r"(name) - : "r0","r1"); - monitor_stderr = fh; + monitor_stdout = monitor_stderr = fh; #endif for (i = 0; i < MAX_OPEN_FILES; i ++) @@ -194,8 +171,6 @@ initialise_monitor_handles (void) openfiles[0].pos = 0; openfiles[1].handle = monitor_stdout; openfiles[1].pos = 0; - openfiles[2].handle = monitor_stderr; - openfiles[2].pos = 0; } static int @@ -205,7 +180,7 @@ get_errno (void) return do_AngelSWI (AngelSWI_Reason_Errno, NULL); #else register r0 asm("r0"); - asm ("swi %a1" : "=r"(r0) : "i" (SWI_GetErrno)); + asm ("swi %a1" : "=3Dr"(r0) : "i" (SWI_GetErrno)); return r0; #endif } @@ -370,6 +345,8 @@ _write (int file, return len - x; } +extern int strlen (const char *); + int _swiopen (const char * path, int flags) @@ -458,31 +435,33 @@ _close (int file) return wrap (_swiclose (file)); } +void +_exit (int n) +{ + /* FIXME: return code is thrown away. */ + +#ifdef ARM_RDI_MONITOR + do_AngelSWI (AngelSWI_Reason_ReportException, + (void *) ADP_Stopped_ApplicationExit); +#else + asm ("swi %a0" :: "i" (SWI_Exit)); +#endif + n = n; +} + int -_kill (int pid, int sig) +_kill (int n, int m) { - (void)pid; (void)sig; #ifdef ARM_RDI_MONITOR - /* Note: Both arguments are thrown away. */ return do_AngelSWI (AngelSWI_Reason_ReportException, (void *) ADP_Stopped_ApplicationExit); #else asm ("swi %a0" :: "i" (SWI_Exit)); #endif + n = n; m = m; } -void -_exit (int status) -{ - /* There is only one SWI for both _exit and _kill. For _exit, call - the SWI with the second argument set to -1, an invalid value for - signum, so that the SWI handler can distinguish the two calls. - Note: The RDI implementation of _kill throws away both its - arguments. */ - _kill(status, -1); -} - -int __attribute__((weak)) +int _getpid (int n) { return 1; @@ -522,7 +501,9 @@ _sbrk (int incr) return (caddr_t) prev_heap_end; } -int __attribute__((weak)) +extern void memset (struct stat *, int, unsigned int); + +int _fstat (int file, struct stat * st) { memset (st, 0, sizeof (* st)); @@ -532,8 +513,7 @@ _fstat (int file, struct stat * st) file = file; } -int __attribute__((weak)) -_stat (const char *fname, struct stat *st) +int _stat (const char *fname, struct stat *st) { int file; @@ -549,22 +529,22 @@ _stat (const char *fname, struct stat *st) return 0; } -int __attribute__((weak)) +int _link (void) { - errno = ENOSYS; return -1; } int -_unlink (const char *path) +_unlink (void) { -#ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_Remove, &path); -#else - (void)path; - asm ("swi %a0" :: "i" (SWI_Remove)); -#endif + return -1; +} + +void +_raise (void) +{ + return; } int @@ -598,7 +578,7 @@ _gettimeofday (struct timeval * tp, struct timezone * tzp) /* Return a clock that ticks at 100Hz. */ clock_t -_clock (void) +_times (struct tms * tp) { clock_t timeval; @@ -607,14 +587,6 @@ _clock (void) #else asm ("swi %a1; mov %0, r0" : "=r" (timeval): "i" (SWI_Clock) : "r0"); #endif - return timeval; -} - -/* Return a clock that ticks at 100Hz. */ -clock_t -_times (struct tms * tp) -{ - clock_t timeval = _clock(); if (tp) { @@ -629,35 +601,24 @@ _times (struct tms * tp) int -_isatty (int fd) +isatty (int fd) { -#ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_IsTTY, &fd); -#else - (void)fd; - asm ("swi %a0" :: "i" (SWI_IsTTY)); -#endif + return 1; + fd = fd; } int _system (const char *s) { -#ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_System, &s); -#else - (void)s; - asm ("swi %a0" :: "i" (SWI_CLI)); -#endif + if (s == NULL) + return 0; + errno = ENOSYS; + return -1; } int _rename (const char * oldpath, const char * newpath) { -#ifdef ARM_RDI_MONITOR - const char *block[2] = {oldpath, newpath}; - return do_AngelSWI (AngelSWI_Reason_Rename, block); -#else - (void)oldpath; (void)newpath; - asm ("swi %a0" :: "i" (SWI_Rename)); -#endif + errno = ENOSYS; + return -1; } diff --git a/libgloss/arm/trap.S b/libgloss/arm/trap.S index 21b6937f9..328fabca5 100644 --- a/libgloss/arm/trap.S +++ b/libgloss/arm/trap.S @@ -1,5 +1,4 @@ /* Run-time exception support */ -#if !defined(__thumb2__) #include "swi.h" /* .text is used instead of .section .text so it works with arm-aout too. */ @@ -92,4 +91,3 @@ __rt_stkovf_split_big: @ We now know how much extra stack the function requires. @ Terminate the program for the moment: swi SWI_Exit -#endif |