Commit Graph

580 Commits

Author SHA1 Message Date
Jim Wilson 7e72be1c39 Add libgloss install-pdf and install-html targets.
The toplevel makefile used by binutils/gcc/newlib/etc has install-pdf and
install-html targets, but they fail because libgloss doesn't support them.
Tested with an arm-eabi combined tree build and install, and verifying that
the install-pdf and install-html targets now work, and that the pdf and html
doc files are now in the install tree.

	libgloss/
	* Makefile.in (install-html, install-pdf): New.
	* doc/Makefile.in (htmldir, pdfdir): New.
	(porting.ps): Delete white space on blank line.
	(install-pdf, install-html): New.
2018-11-20 11:13:34 +01:00
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
Tamar Christina 9a7f131e0e Initialize SVE system registers.
This patch initializes the SVE system registers if available
and initializes the vector length to the maximum supported.

This is done according to the SVE specification [1].

[1] https://developer.arm.com/docs/ddi0584/latest/arm-architecture-reference-manual-supplement-the-scalable-vector-extension-sve-for-armv8-a
2018-10-31 11:14:57 +00:00
Christophe Lyon b6ba19e355 [Aarch64] Syscalls: fix prototypes
This patch is similar the arm one committed recently.

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

	* libgloss/aarch64/syscalls.c (_sbrk): Fix prototype.
	(_getpid, _write, _swiwrite, _lseek, _swilseek, _read, _wriread):
	Likewise.
2018-10-08 14:39:16 +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
Christophe Lyon 9edf0810db [Aarch64] Fix warning in _sbrk
2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

    	* libgloss/aarch64/syscalls.c (_sbrk): Cast "__heap_limit" to
    	"char *".
2018-10-05 13:21:54 +01:00
Hans-Peter Nilsson a6837ca34f Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 1
It's been a while...  I see the CRIS port broke with the
time_t-default-to-64-bit change, observable by a few test-cases in the
gcc fortran(!) tests failing, regressing when trying a recent newlib.

This is a two-part belt-and-suspenders change: adjust the CRIS port
gettimeofday syscall (the only one in newlib/CRIS passing a time_t or
struct timeval) to handle a userspace 64-bit time_t and secondly default
time_t to 32-bit long anyway.  I considered making the local
"kernel_timeval" copy in _gettimeofday conditional on (userspace) time_t
being 64 bits, but thought it not worth bothering with the few move insns.
The effect of a 64-bit time_t is however observable as longer simulation
time when running the gcc testsuite and as bigger binaries without any
actual upside from the larger time_t size, so I thought better make the
default for this port go back to being a "long" again.

Tested by running the gcc testsuite over the three combinations of two
parts of the patch and observing the expected changes.  Committed.

libgloss:
	Adjust for syscall and userspace having different time_t or timeval.
	* cris/linunistd.h (kernel_time_t, kernel_suseconds_t, kernel_timeval):
	New types.
	(gettimeofday): Change the type of the first argument to be a
	pointer to a struct kernel_timeval.
	* cris/gensyscalls (_gettimeofday): Use an intermediate struct
	kernel_timeval for the syscall and initialize the result from
	that.

Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
2018-09-13 17:57:11 +02:00
Denis Ivanov 9e032fd939 RISC-V: Fix _sbrk, it's failed only when return value is -1.
Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
2018-08-29 15:49:00 +02:00
Denis Ivanov 258996b696 RISC-V: Fixed return code in _times syscall.
Upon successful completion, times() shall return the elapsed real time,
in clock ticks, since an arbitrary point in the past (for example,
system start-up time).

Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
2018-08-29 15:49:00 +02:00
Sandra Loosemore fddc74d12b Add BSP and semihosting library for nios2-generic-nommu QEMU emulation. 2018-08-08 10:53:03 +02:00
Jeff Johnston 2ec54fb1d1 Patch from Richard Earnshaw <Richard.Earnshaw@arm.com>
* aarch64/cpu-init/rdimon-aem-el3.S (cpu_init_hook): Simplify
  entry/exit sequences.  Add CFI unwind rules.
2018-08-01 14:02:56 -04:00
Sebastian Huber 6158b30e3e RISC-V: Do not use _init/_fini
Introduce new host configuration variable "have_init_fini" which is set
to "yes" by default.  Override it for RISC-V to "no".

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-07-30 10:47:57 +02: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
Ben Levinsky 28627a5a03 libgloss: microblaze: adjust handlers to be weak.
Previously, hw exception handler stub and interrupt handler stub for microbaze were unable to
be overwritten. Change to weak to fix this.

Signed-off-by: Ben Levinsky <ben.levinsky@xilinx.com>
2018-05-03 15:16:13 -04:00
Jaap de Wolff bc9b30ea77 add forward declaration to main() to prevent warnings 2018-02-16 12:16:08 +01:00
Jaap de Wolff c9d4bac58c adapt prototypes arm/syscalls.c to usual prototypes, and do not rely on implicit conversions 2018-02-16 12:16:07 +01:00
Chih-Mao Chen f2c9e55faf RISC-V: isatty: return 0 on error 2018-01-18 09:21:10 +01:00
Yaakov Selkowitz 7192f84096 ansification: remove _HAVE_STDC
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:30 -06:00
Yaakov Selkowitz 70ee6b17df ansification: remove _EXFUN, _EXFUN_NOTHROW
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:29 -06:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Yaakov Selkowitz 67ee0cac4c ansification: remove _VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:20 -06:00
Yaakov Selkowitz fff27f8429 ansification: remove _DEFUN_VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:19 -06:00
Yaakov Selkowitz eea249da3b ansification: remove _PARAMS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:13 -06:00
Yaakov Selkowitz e13e191b60 ansification: remove _NOARGS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:11 -06:00
Yaakov Selkowitz 6783860a2e ansification: remove _AND
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:05 -06:00
Jim Wilson 9588ff7555 RISC-V: Add gdb sim and newlib nano support. Fix a few misc minor bugs. 2017-12-26 12:31:33 -08:00
Jim Wilson 28d5b98038 RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
Jim Wilson 347b083911 RISC-V: Updated syscall to take 6 arguments 2017-12-26 12:26:19 -08:00
Jim Wilson a6633677b9 RISC-V: Add nanosleep functionality 2017-12-26 12:24:45 -08:00
Jim Wilson e807c51d78 RISC-V: Fix libnosys build. 2017-12-26 12:18:42 -08:00
Alexander Fedotov f6ef29c48f Fixed semihosting for AArch64 when heapinfo parameters are not provided by debugger 2017-10-24 17:27:51 +02:00
Tamar Christina 111b6813fb Fix multido compilation on ARM
The previous multi-build implementation was copying the config.status from the parent
multilib directory when building the different semihosting variants. It did so because
the configuration doesn't change. However when you use a relative path to configure it
turns out that the paths inside the config.status are also relative.

To fix this, the srcdir is adjusted from the initial configuration instead of copying it.

Tested on aarch64-none-elf and arm-none-eabi.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-10-09 19:03:52 +02:00
Alexander Fedotov e7eb978881 adjust libnosys config for aarch64 to avoid linker error when switching from rdimon.specs to nosys.specs 2017-10-09 17:53:41 +02:00
Alexander Fedotov-B55613 3ec9892f5d move ILP32 sanity check on heap base code under ARM_RDI_MONITOR 2017-08-24 14:41:19 +02:00
Kito Cheng 6864c08b94 Change license to FreeBSD License for RISC-V
- For prevent confuse about what BSD license variant we used, 2- or
   3-clause license, we change the license to FreeBSD license to make
   it unambiguously refers to the 2-clause license.
2017-08-21 11:08:54 +02:00
Kito Cheng c496cbb6bd Add RISC-V port for libgloss
Contributor list:
    - Andrew Waterman  <andrew@sifive.com>
    - Palmer Dabbelt  <palmer@dabbelt.com>
    - Kito Cheng  <kito.cheng@gmail.com>
    - Alex Suykov  <alex.suykov@gmail.com>
2017-08-17 14:51:05 -04:00
Szabolcs Nagy cfa64a86d1 Fix crt0 init fini code
__USES_INITFINI__ ifdef was incorrectly copied from arm
(it's an arm backend thing in gcc, not meaningful on aarch64)
2017-08-17 13:45:26 +02:00
Alexander Fedotov-B55613 7e69f983a4 fix typo in AArch64 crt0 2017-08-15 16:19:25 +02:00
Alexander Fedotov-B55613 1f6644876e use stack from linker script when nosys 2017-08-14 10:18:14 +02:00
Yao Qi 32ca315312 Don't fetch command line options without semi-hosting
Nowadays, the code fetching command line options via semi-hosting are
unconditionally pulled in, so that the semi-hosting code is still
there even I compile with option --specs=nosys.specs.

gdb ./aarch64-none-elf/libgloss/aarch64/crt0.o

(gdb) disassemble _start

   0x0000000000000050 <+80>:	ldr	x1, 0x128 <_cpu_init_hook+48>
   0x0000000000000054 <+84>:	mov	w0, #0x15
   0x0000000000000058 <+88>:	hlt	#0xf000

This patch fixes this problem by wrapping the code by ARM_RDI_MONITOR.
When semi-hosting is not used, set command line options to NULL.
2017-08-09 17:43:09 +02:00
Tamar Christina 61ddc7a436 Fix crt0 overwriting.
On AArch64 we currently always link in crt0 regardless of if another
one is being provided by something else, like rdimon.a. This was never
an issue before as nosys was not supported on AArch64.

This updates the specs to supply a different crt0 when a semihosting
call is required.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-08-09 14:50:13 +02:00
Tamar Christina cd26662dc5 Previous patch to support nosys.specs accidentally broke validation specs because ARM_RDI_MONITOR was never passed to the build rule for crt0.
This fixed the compile for nosys and validation specs
but nosys won't run because of existing limitations to
aarch64's syscalls.c, it requires semihosting to get
commandline arguments and heap info without having a
fallback method as ARM does.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-21 10:41:37 +02:00
Tamar Christina bb12a1e587 Support building in a different directory than the default output directory by preserving DESTDIR value in recursive calls.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-17 13:38:42 +02:00
Tamar Christina 13665a7c30 Fix link when nosys.specs is used to link
This patch fixes the issue where nosys.specs is used to link.
e.g. The use of crt0 without any support for semihosting requested.

The AArch64 crt0 was missing an #ifdef for the initialise_monitor_handles
which was causing the link to fail. Sorry for missing this before.
2017-07-14 10:36:32 +02:00
Tamar Christina 9eafa44d23 Replace the perl character classes with POSIX ones to fix the build when sed is a BSD sed instead of GNU.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-06 18:05:56 +02:00
Tamar Christina ddb6f8a02a Add support for Semihosting v2 support for AArch64 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
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
Tamar Christina cc142edbe7 Add the needed build system changes in order to compile and create the new libraries for Semihosting v2 for ARM.
This uses the new recursive build target in multi-build.in

The new spec files are:

For AArch32/ARM (m for mixed mode):
  - rdimon-v2m.specs
  - aprofile-validation-v2m.specs
  - aprofile-ve-v2m.specs

These spec files will be using the new libraries generated
by multi-build.in.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-05 14:41:27 +02:00
Tamar Christina bfa3bbcf33 Adds the needed build system changes in order to compile and create the new libraries for Semihosting v2.
This uses the new recursive build target in multi-build.in

For AArch64 no new spec files are needed but the makefiles
are modified to keep them in sync with the ARM ones.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-05 14:41:27 +02:00
Tamar Christina ebd97f4c00 Create a recursive make target that is modeled after the existing multilib makefile config-ml.in which can be used to build the same files within a target multiple ways.
e.g. from the same source file produce multiple libs by varying the
options passed to the compiler.

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
2017-07-05 14:41:27 +02:00