xtensa: make DoubleExceptionVector literals fit the gap

Manually load references to exc_table from the explicit literal in order
to fit DoubleExceptionVector.literals into the available 16-byte gap
before DoubleExceptionVector.text in the absence of link time
relaxation. Without this fix DoubleExceptionVector.literal section
overlaps DoubleExceptionVector.text section in the linked vmlinux image.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: turn off ld relaxation

Sometimes ld for xtensa fails to link vmlinux with the following
message:

	dangerous relocation: call8: call target out of range

This is believed to be relaxation logic issue. See the following thread
for more details:

http://old.nabble.com/xtensa-fsf-ld%3A-dangerous-relocation%3A-call8%3A-call-target-out-of-range-td34168172.html

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: ISS: fix specific simcalls

Simcalls that take memory buffer definitely need wmb or rmb to make sure
gcc doesn't optimize away code that fills the buffer.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: ISS: fix rs_put_char

ISS serial console prints garbage instead of symbols printed via
rs_put_char. gcc optimizes away putting prined symbol into memory buffer
because there's no evidence that the buffer is used afterwards.

Make rs_put_char and rs_write use simc_write that has explicit wmb.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: fix memmove(), bcopy(), and memcpy().

- fix memmove to correctly handle overlapping src and dst;
- fix memcpy loop ending conditions from signed '<=' to '!=';
- modify bcopy to call memmove;

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: copy_thread with CLONE_VM must not copy live parent AR windows

When doing a fork (new VM), the new task has a mirror image of the
parent's stack, so keeps the same live register windows etc.
However when doing a clone with CLONE_VM, keeping the same VM
(eg. when creating a new thread), the child starts afresh on a new
stack -- it cannot share any part of the parent stack.  It
especially cannot have the same live AR windows as the parent,
otherwise it will overwrite the parent stack on overflow, likely
causing corruption.  (and so it did...)

Effectively, the register windows need to be spilled.
Turns out it's much easier to simply not copy parent register
windows when CLONE_VM is set.

Signed-off-by: Marc Gauthier <marc@tensilica.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: fix missing return in do_page_fault for SIGBUS case

Signed-off-by: Marc Gauthier <marc@tensilica.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: Add config files for Diamond 233L - Rev C processor variant

The Diamond 233L processor is a pre-configured Xtensa processor tailored
for Linux application.

Signed-off-by: Pete Delaney <piet@tensilica.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa WIP: add Three Core HiFi-2 MX Variant.

Signed-off-by: Pete Delaney <piet@tensilica.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa WIP: add support for the LX60 board

The Avnet LX60 board is an FPGA board that can be configured with
an Xtensa processor and an OpenCores Ethernet device.

Signed-off-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add U-Boot image support (uImage).

Signed-off-by: Ross Morley <ross@linux-xtensa.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Ported-from: 47e4a5dfe8f33339cb6aec3efd198c0f8aebf96b
xtensa: fix boot parameters parsing

Boot parameter tags with handlers are ignored like this:

	[    0.000000] Ignoring tag 0x00001003
	[    0.000000] Ignoring tag 0x00001001
	[    0.000000] Ignoring tag 0x00001004

because neither tagtable entries nor tag handlers appear in the vmlinux.

Fix tagtable definition attributes so that tag entries are not dropped.

Fix end of memory bank calculation in parse_tag_mem: it is intended to
round down to page size, but instead did something strange leading to
hang right after boot.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: reorganize SR referencing

- reference SRs by names where possible, not by numbers;
- get rid of __stringify around SR names where possible;
- remove unneeded SR names from asm/regs.h;
- add SREG_ prefix to remaining SR names;

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add device trees support

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: bootup memcpy/memmove test

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>