From e6d39ddc288febd5434f1d55273e6d82d5c7172d Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Fri, 1 Sep 2006 15:28:54 +0000 Subject: 2006-09-01 Paul Brook libgloss/ * arm/Makefile.in: Include _exit.c in BSPs. Add rdimon-ram.ld. Build linker scripts instead of spec files for rdimon and rdpmon. Pass CRT0 ad BSP to arm.sc. * arm/_exit.c: New file. * arm/arm.sc: Add STARTUP, GROUP and SEARCH_DIR. Remove defaults for ROM and RAM. * arm/crt0.S: Give Thumb-2 symbols function type. Skip generic Arm init code for Thumb-2. Add _nmi_isr and _fault_isr. * arm/libcfunc.c (do_AngelSWI): Remove. * arm/swi.h (do_AngelSWI): New function. * arm/syscalls.c (do_AngelSWI): Remove. (_exit): Remove. (isatty): New function. --- ChangeLog.csl | 18 ++++++++++++++++++ libgloss/arm/Makefile.in | 43 ++++++++++++++++++++++++------------------- libgloss/arm/_exit.c | 18 ++++++++++++++++++ libgloss/arm/arm.sc | 12 ++++++------ libgloss/arm/crt0.S | 19 +++++++++++++++++++ libgloss/arm/libcfunc.c | 14 -------------- libgloss/arm/swi.h | 21 +++++++++++++++++++++ libgloss/arm/syscalls.c | 38 ++++++-------------------------------- 8 files changed, 112 insertions(+), 71 deletions(-) create mode 100644 libgloss/arm/_exit.c diff --git a/ChangeLog.csl b/ChangeLog.csl index 0a2fa70f8..a4d0b962c 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -1,3 +1,21 @@ +2006-09-01 Paul Brook + + libgloss/ + * arm/Makefile.in: Include _exit.c in BSPs. Add rdimon-ram.ld. + Build linker scripts instead of spec files for rdimon and rdpmon. + Pass CRT0 ad BSP to arm.sc. + * arm/_exit.c: New file. + * arm/arm.sc: Add STARTUP, GROUP and SEARCH_DIR. Remove defaults + for ROM and RAM. + * arm/crt0.S: Give Thumb-2 symbols function type. + Skip generic Arm init code for Thumb-2. + Add _nmi_isr and _fault_isr. + * arm/libcfunc.c (do_AngelSWI): Remove. + * arm/swi.h (do_AngelSWI): New function. + * arm/syscalls.c (do_AngelSWI): Remove. + (_exit): Remove. + (isatty): New function. + 2006-08-31 Nathan Sidwell libgloss/ diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in index cee0a6b7b..9106f5bc3 100644 --- a/libgloss/arm/Makefile.in +++ b/libgloss/arm/Makefile.in @@ -58,16 +58,15 @@ REDBOOT_OBJS = redboot-syscalls.o REDBOOT_SCRIPTS = redboot.ld redboot.specs REDBOOT_INSTALL = install-redboot -RDPMON_CRT0 = rdpmon-crt0.o +RDPMON_CRT0 = rdpmon-crt0.o rdpmon-ram.ld RDPMON_BSP = librdpmon.a -RDPMON_OBJS = syscalls.o libcfunc.o trap.o -RDPMON_SCRIPTS = rdpmon.specs +RDPMON_OBJS = syscalls.o libcfunc.o trap.o _exit.o RDPMON_INSTALL = install-rdpmon -RDIMON_CRT0 = rdimon-crt0.o +RDIMON_CRT0 = rdimon-crt0.o rdimon-ram.ld RDIMON_BSP = librdimon.a -RDIMON_OBJS = rdimon-syscalls.o rdimon-libcfunc.o rdimon-trap.o -RDIMON_SCRIPTS = rdimon.specs +RDIMON_OBJS = rdimon-syscalls.o rdimon-libcfunc.o rdimon-trap.o \ + rdimon-_exit.o RDIMON_INSTALL = install-rdimon CFLAGS = -g @@ -79,7 +78,7 @@ PID_INSTALL = install-pid IQ80310_SCRIPTS = iq80310.specs IQ80310_INSTALL = install-iq80310 -ARMV7M_OBJS = armv7m-crt0.o \ +ARMV7M_OBJS = armv7m-crt0.o rdimon-ram.ld \ armv7m-rom.ld lm3s10x-rom.ld lm3s301-rom.ld lm3s31x-rom.ld \ armv7m-ram.ld lm3s10x-ram.ld lm3s301-ram.ld lm3s31x-ram.ld ARMV7M_SPECS = armv7m.specs @@ -117,6 +116,9 @@ rdimon-crt0.o: crt0.S rdimon-trap.o: trap.S $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $< +rdimon-_exit.o: _exit.c + $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $< + rdimon-syscalls.o: syscalls.c $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $< @@ -132,19 +134,24 @@ $(RDIMON_BSP): $(RDIMON_OBJS) ${RANLIB} $@ # Armv7M board files. -# ram rom stack -armv7m= 32M 32M no -lm3s10x= 2k 8k yes -lm3s301= 2k 16k yes -lm3s31x= 4k 16k yes +# ram rom stack crt0 bsp +# position size position size +rdimon= 0 4096M 0 0 no rdimon-crt0.o -lrdimon +rdpmon= 0 4096M 0 0 no rdpmon-crt0.o -lrdpmon +armv7m= 0 32M 0x20000000 32M no armv7m-crt0.o -lrdimon +lm3s10x= 0 2k 0x20000000 8k yes armv7m-crt0.o -lrdimon +lm3s301= 0 2k 0x20000000 16k yes armv7m-crt0.o -lrdimon +lm3s31x= 0 4k 0x20000000 16k yes armv7m-crt0.o -lrdimon %-ram.ld : arm.sc Makefile - RAM_SIZE=$(word 1,$($*)) \ - ${SHELL} $< $(word 3,$($*)) >$@ + RAM=$(word 1,$($*)) RAM_SIZE=$(word 2,$($*)) \ + CRT0=$(word 6,$($*)) BSP=$(word 7,$($*)) \ + ${SHELL} $< $(word 5,$($*)) >$@ %-rom.ld : arm.sc Makefile - RAM_SIZE=$(word 1,$($*)) \ - ROM_SIZE=$(word 2,$($*)) \ - ${SHELL} $< $(word 3,$($*)) >$@ + RAM=$(word 1,$($*)) RAM_SIZE=$(word 2,$($*)) \ + ROM=$(word 3,$($*)) ROM_SIZE=$(word 4,$($*)) \ + CRT0=$(word 6,$($*)) BSP=$(word 7,$($*)) \ + ${SHELL} $< $(word 5,$($*)) >$@ clean mostlyclean: rm -f a.out core *.i *.o *-test *.srec *.dis *.x $(SIM_BSP) $(IQ80310_BSP) @@ -164,11 +171,9 @@ install-redboot: install-rdpmon: set -e; for x in ${RDPMON_CRT0} ${RDPMON_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done - set -e; for x in ${RDPMON_SCRIPTS}; do ${INSTALL_DATA} ${srcdir}/${objtype}$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done install-rdimon: set -e; for x in ${RDIMON_CRT0} ${RDIMON_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done - set -e; for x in ${RDIMON_SCRIPTS}; do ${INSTALL_DATA} ${srcdir}/${objtype}$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done install-pid: diff --git a/libgloss/arm/_exit.c b/libgloss/arm/_exit.c new file mode 100644 index 000000000..409cccc32 --- /dev/null +++ b/libgloss/arm/_exit.c @@ -0,0 +1,18 @@ +#include <_ansi.h> +#include "swi.h" + +void _exit _PARAMS ((int)); + +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; +} diff --git a/libgloss/arm/arm.sc b/libgloss/arm/arm.sc index b6c813a3f..140192148 100644 --- a/libgloss/arm/arm.sc +++ b/libgloss/arm/arm.sc @@ -6,18 +6,16 @@ # $1 whether to set _stack test "x$1" = "xyes" && SETSTACK=1 -test -z "${RAM}" && RAM=0x20000000 -if test -z "${ROM_SIZE:+1}" ; then - NOROM=1 -else - test -z "${ROM}" && ROM=0 -fi +test -z "${ROM_SIZE:+1}" && NOROM=1 cat < #include -#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" - : "=r" (value) /* Outputs */ - : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ - : "r0", "r1", "lr" - /* Clobbers r0 and r1, and lr if in supervisor mode */); - return value; -} -#endif /* ARM_RDI_MONITOR */ - void abort (void) { diff --git a/libgloss/arm/swi.h b/libgloss/arm/swi.h index f5c910313..7638dbe4e 100644 --- a/libgloss/arm/swi.h +++ b/libgloss/arm/swi.h @@ -66,3 +66,24 @@ #define AngelSWI_Reason_ReportException 0x18 #define ADP_Stopped_ApplicationExit ((2 << 16) + 38) #define ADP_Stopped_RunTimeError ((2 << 16) + 35) + +#if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__) + +static inline int +do_AngelSWI (int reason, void * arg) +{ + int value; + 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" + /* Clobbers r0 and r1, and lr if in supervisor mode */); + /* Accordingly to page 13-77 of ARM DUI 0040D other registers + can also be clobbered. Some memory positions may also be + changed by a system call, so they should not be kept in + registers. Note: we are assuming the manual is right and + Angel is respecting the APCS. */ + return value; +} + +#endif diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index 1df75bb90..7c8fd4274 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -20,6 +20,7 @@ /* 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 *)); @@ -30,7 +31,6 @@ int _fstat _PARAMS ((int, struct stat *)); caddr_t _sbrk _PARAMS ((int)); 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)); @@ -84,26 +84,6 @@ findslot (int fh) return i; } -#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" - : "=r" (value) /* Outputs */ - : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */ - : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" - /* Clobbers r0 and r1, and lr if in supervisor mode */); - /* Accordingly to page 13-77 of ARM DUI 0040D other registers - can also be clobbered. Some memory positions may also be - changed by a system call, so they should not be kept in - registers. Note: we are assuming the manual is right and - Angel is respecting the APCS. */ - return value; -} -#endif /* ARM_RDI_MONITOR */ - /* Function to convert std(in|out|err) handles to internal versions. */ static int remap_handle (int fh) @@ -481,17 +461,6 @@ _kill (int pid, int sig) #endif } -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)) _getpid (int n) { @@ -655,6 +624,11 @@ _isatty (int fd) #endif } +int isatty(int fd) +{ + return _isatty(fd); +} + int _system (const char *s) { -- cgit v1.2.3