Commit Graph

23 Commits

Author SHA1 Message Date
Alexander Fedotov 942f60d714 Stack Pointer and Stack Limit initialization refactored.
SP initialization changes:
  1. set default value in semihosting case as well
  2. moved existing SP & SL init code for processor modes in separate routine and made it as "hook"
  3. init SP for processor modes in Thumb mode as well

Add new macro FN_RETURN, FN_EH_START and FN_EH_END.
2019-07-23 10:00:06 +02:00
Alexander Fedotov a0b0a4a018 Align comments and spaces in libgloss/arm/crt0.S and newlib/libc/sys/arm/crt0.S to ease further code alignment. 2019-04-12 14:34:47 +01:00
Tamar Christina 6d6a623e7d AArch32: Add support for HLT to Mixed Mode models
The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction
when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to
be done for Armv7-a and earlier architectures.

The HLT instruction is defined in the undefined encoding space for older
architectures but simulators such as QEMU already trap on it [1] for all
architectures and is a requirement for semihosting v2 [2].

Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to
use the instruction encodings we want directly in crt0.

This patch does this, I have not updated newlib/libc/* as that is quite out of
date already.  A proper sync is needed in order to get things back in sync.

A different patch for this would be best.

[1] 19a6e31c9d
[2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface
2019-02-08 12:37:16 +01:00
Laurent ALFONSI 9b1167219a ARM/AArch64: Fix GetCmdLine semihosting directives
When simulating arm code, the target program startup code (crt0) uses
semihosting invocations to get the command line from the simulator. The
simulator returns the command line and its size into the area passed in
parameter. (ARM 32-bit specifications :
http://infocenter.arm.com/help/topic/com.arm.doc.dui0058d/DUI0058.pdf
chapter "5.4.19 SYS_GET_CMDLINE").

The memory area pointed by the semihosting register argument is located
in .text section (usually not writtable (RX)).

If we run this code on a simulator that respects this rights properties
(qemu user-mode for instance), the command line will not be written to
the .text program memory, in particular the length of the string. The
program runs with an empty command line. This problem hasn't been seen
earlier probably because qemu user-mode is not so much used, but this can
happen with another simulator that refuse to write in a read-only segment.

With this modification, the command line can be correctly passed to the
target program.

Changes:
- libgloss/arm/crt0.S : Arguments passed to the AngelSWI_Reason_GetCmdLine
  semihosting invocation are placed into .data section instead of .text
- libgloss/aarch64/crt0.S : Idem for aarch64 AngelSVC_Reason_GetCmdLine
  semihosting.
2017-05-19 15:45:58 -04:00
David Hoover 5c9403eaf4 Fixed semihosting for ARM when heapinfo not provided by debugger. 2016-04-21 09:51:08 +02:00
Thomas Preud'homme 69f4c40291 Make macro checks ARMv8-M baseline proof
libgloss:

        * arm/Makefile.in: Add newlib/libc/machine/arm to the include path if
        newlib is present.
        * arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macros __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * arm/crt0.S: Use THUMB1_ONLY rather than __ARM_ARCH_6M__,
        !__ARM_ARCH_ISA_ARM rather than THUMB_V7M_V6M for fp enabling, and
        PREFER_THUMB rather than THUMB_V7_V6M.  Rename other occurences of
        THUMB_V7M_V6M to THUMB_VXM.
        * arm/linux-crt0.c: Likewise.
        * arm/redboot-crt0.S: Likewise.
        * arm/swi.h: Likewise.
        * arm/trap.S: Likewise.

newlib:

        * libc/machine/arm/memcpy-stub.c: Use ACLE macros __ARM_ARCH_ISA_THUMB
        and __ARM_ARCH_ISA_ARM to check for Thumb-2 only targets rather than
        __ARM_ARCH and __ARM_ARCH_PROFILE.
        * libc/machine/arm/memcpy.S: Likewise.
        * libc/machine/arm/setjmp.S: Likewise for Thumb-1 only target and
        include acle-compat.h.
        * libc/machine/arm/strcmp.S: Likewise for Thumb-1 and Thumb-2 only
        target and include acle-compat.h.
        * libc/sys/arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macro __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * libc/sys/arm/crt0.S: Use PREFER_THUMB rather than THUMB_V7_V6M and
        rename THUMB_V7M_V6M into THUMB_VXM.
        * libc/sys/arm/swi.h: Likewise.
2016-01-28 11:26:37 +01:00
Corinna Vinschen 8d98f956cc * arm/crt0.S: Initialise __heap_limit when ARM_RDI_MONITOR is defined.
* arm/syscalls.c: define __heap_limit global symbol.
	* arm/syscalls.c (_sbrk): Honour __heap_limit.
2015-02-17 09:30:52 +00:00
Richard Earnshaw 639951dda7 2013-10-14 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
* arm/cpu-init/rdimon-aem.S: Disable for M class cores.
	* arm/crt0.S: Don't call _rdimon_hw_init_hook for non-A class cores.
	* arm/cpu-init/Makefile.in (CPU_INIT_OBJS): Use CFLAGS.
2013-10-14 15:15:12 +00:00
Richard Earnshaw 99be2bc4ff 2013-09-20 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
	    Greta Yorsh  <greta.yorsh@arm.com>

	* arm/Makefile.in: Add support for cpu-init directory and add
	elf-aprofile-ve.specs.
	* arm/configure.in: Likewise.
	* arm/configure: Regenerate.
	* arm/cpu-init: New directory.
	* arm/cpu-init/Makefile.in: New file.
	* arm/cpu-init/rdimon-aem.S: Likewise.
	* arm/crt0.S: Call _rdimon_init_hook
	* arm/elf-aprofile-ve.specs: New file.
2013-09-20 14:23:41 +00:00
Corinna Vinschen 387b584725 * aarch64/crt0.S: Remove 'start'.
* arm/crt0.S: Ditto.
	* arm/redboot-crt0.S: Ditto.
2013-08-12 11:27:37 +00:00
Jeff Johnston 2404223df6 2013-07-02 Joey Ye <joey.ye@arm.com>
* arm/crt0.S (_mainCRTStartup): Weak reference to atexit and _fini
        when lite exit is enabled.
2013-07-02 21:34:35 +00:00
Jeff Johnston 50e970d1b1 2011-12-13 Richard Earnshaw <rearnsha@arm.com>
Thomas Klein  <th.r.klein@web.de>

        * arm/crt0.S: Manually set the target architecture
        when compiling for Thumb1 on EABI targets.
        Avoid v6-only Thumb-1 MOV instruction.
2011-12-13 22:45:12 +00:00
Nick Clifton 5b495afe51 * arm/crt0.s: Support 0 heap base response from HeapInfo syscall. 2011-09-29 11:23:29 +00:00
Nick Clifton 29deef8805 * arm/arm.h (HAVE_CALL_INDIRECT): Define.
* arm/crt0.S (indirect_call): New macro.  Encodes indirect
	function calls.  Does not use blx for pre-armv5 targets.
2011-09-29 11:06:49 +00:00
Nick Clifton 415e1ecce4 * arm/crt0.S: Support armv6-m processors in libgloss.
* arm/swi.h: Likewise.
	* arm/trap.S: Likewise.
	* arm/redboot-crt0.S: Likewise.
	* arm/linux-crt0.c: Likewise.
	* arm/arm.h: New.
2011-07-13 15:06:21 +00:00
Jeff Johnston 455e95b5bd 2008-10-06 Bill Tompkins <bill+newlib@key-square.com>
* arm/crt0.S: Fix calling hardware_init_hook() or software_init_hook()
        under thumb and thumb2.
2008-10-06 20:55:19 +00:00
Nick Clifton 026f9d290f * libc/machine/arm/setjmp.S: Fix thumb2 support.
* arm/crt0.S: Allow assembly under ARMv7 ISA.  Support for
            initializing stack pointers for interrupt modes is still pending.
2008-04-25 09:02:40 +00:00
Jeff Johnston a9a6f94229 2007-08-13 Carlos O'Donell <carlos@codesourcery.com>
* arm/crt0.S: Remove '.set' for __stack, hardware_init_hook,
	and software_init_hook.
2007-08-13 18:13:39 +00:00
Jeff Johnston f9fa511d46 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-02-07 18:46:23 +00:00
Jeff Johnston fd745b00ed 2005-07-19 Paul Brook <paul@codesourcery.com>
* arm/crt0.S: Ensure doubleword stack alignment.
2005-07-19 15:15:25 +00:00
Jeff Johnston 35310094a1 2005-01-07 Paul Brook <paul@codesourcery.com>
* arm/crt0.S: Call __libc_{init,fini}_array instead of
        _init/_fini if they exist.
2005-01-07 18:01:26 +00:00
Jeff Johnston 60e4d52a55 2004-11-26 Paul Brook <paul@codesourcery.com>
* arm/crt0.S (_start): Add .cantunwind annotation.
2004-11-26 16:43:35 +00:00
Jeff Johnston a7364adeb9 2004-06-09 Toralf Lund <toralf@procaptura.com>
* arm/crt0.S: Copied from newlib and it now also sets up stacks for
        FIQ and IRQ mode, plus calls hardware_init_hook() and
        software_init_hook() if present.
        * arm/libcfunc.c, arm/swi.h, arm/syscalls.c: Copied
        from newlib.
        * arm/Makefile.in: Build crt0.o, rdpmon-crt0.o, rdimon-crt0.o,
        librdpmon.a, librdimon.a - support file for "bare" setup, as well
        as "RDP" and "RDI" monitors.
        * arm/coff-rdpmon.specs, arm/elf-rdpmon.specs,
        arm/coff-rdimon.specs, arm/elf-rdimon.specs: gcc specs files to go
        with above mentioned support libs and startfiles.
2004-06-09 19:06:50 +00:00