Commit Graph

6 Commits

Author SHA1 Message Date
Matthew Malcomson 6dbd190111 Enable return code with semi-hosting SYS_EXIT_EXTENDED
The _exit function currently passes -1 as a "sig" to the _kill function as an
invalid signal number so that _kill can distinguish between an abort and a
standard exit.

For boards using the SYS_EXIT_EXTENDED semi-hosting operation to return a
status code, this means that the "status" paramter to _exit is ignored and the
return code is always -1.
https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit_extended-0x20

This patch puts shared code between _kill and _exit into a new function
_kill_shared that takes the semi-hosting "reason" to use (if semi-hosting is
available) as an argument.

For semi-hosting _kill_shared provides that "reason".

Without the "sig" argument being used to distinguish between a normal and
abnormal exit, the _exit function can provide the return code to be used if the
SYS_EXIT_EXTENDED operation is available.

Hence the exit code can be returned.
2018-11-19 13:46:19 +01:00
Christophe Lyon 8a7536e91d [ARM] Make _kill() a noreturn function.
AngelSWI_Reason_ReportException does not return accoring to the ARM
documentation, so it is valid to mark _kill() as noreturn.  This way,
the compiler does not warn about _exit() returning a value despite
being noreturn.

2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

	* libgloss/arm/_exit.c (_exit): Declare _kill() as noreturn.
	* libgloss/arm/_exit.c (_kill): Likewise. Remove the return
	statements.
	* newlib/libc/sys/arm/syscalls.c (_kill): Likewise..
2018-10-08 14:35:43 +01:00
Tamar Christina 430b529111 Fix AArch32 semihosting SYS_EXIT call on semihosting v1.
The current SYS_EXIT has a bug that when making the call it always uses
the v2 calling convention.  This is undefined behavior according to the
semihosting specification:
https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit-0x18

This patch fixes it by making sure v1 passes the argument directly in the register instead
of in a block. And for v2 it does the same if the v2 extension isn't supported.

The sequence generated now is

   12424:       ebfffecd        bl      11f60 <_has_ext_exit_extended>
   12428:       e3500000        cmp     r0, #0
   1242c:       11a0500d        movne   r5, sp
   12430:       059d5000        ldreq   r5, [sp]
   12434:       e1a00004        mov     r0, r4
   12438:       e1a01005        mov     r1, r5
   1243c:       ef00f000        svc     0x0000f000

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2018-07-11 17:18:04 +02:00
Yaakov Selkowitz eea249da3b ansification: remove _PARAMS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:13 -06:00
Tamar Christina d7d6ad7b6b Add support for Semihosting v2 support for ARM in libgloss.
Semihosting v2 changes are documented here:
https://developer.arm.com/docs/100863/latest/

The biggest change is the addition of an extensions mechanism
to add more extensions in the future.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-05 14:41:27 +02:00
Jeff Johnston 4d95d0e99a 2006-01-03 Kazu Hirata <kazu@codesourcery.com>
* arm/Makefile (RDPMON_OBJS): Add _exit.o and _kill.o.
        (RDIMON_OBJS): Define in terms of RDPMON_OBJS.
        (rdimon-_exit.o, rdimon-_kill.o): New.
        * arm/_exit.c, arm/_kill.c: New.
        * arm/syscalls.c (_exit, _kill): Remove.
2007-01-03 16:55:25 +00:00