Commit Graph

541 Commits

Author SHA1 Message Date
Ed Maste
688fd61ae8 Use canonical __PIC__ flag
It is automatically set when -fPIC is passed to the compiler.

Reviewed by:	dim, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1179
2014-11-21 02:05:48 +00:00
Warner Losh
40e6bdaf1e opt_global.h is included automatically in the build. No need to
explicitly include it in these places.

Sponsored by: Netflix
2014-11-18 17:06:56 +00:00
Konstantin Belousov
4f3dc90023 Add fueword(9) and casueword(9) functions. They are like fuword(9)
and casuword(9), but do not mix value read and indication of fault.

I know (or remember) enough assembly to handle x86 and powerpc.  For
arm, mips and sparc64, implement fueword() and casueword() as wrappers
around fuword() and casuword(), which means that the functions cannot
distinguish between -1 and fault.

On architectures where fueword() and casueword() are native, implement
fuword() and casuword() using fueword() and casuword(), to reduce
assembly code duplication.

Sponsored by:	The FreeBSD Foundation
Tested by:	pho
MFC after:	2 weeks (ia64 needs treating)
2014-10-28 15:22:13 +00:00
Andrew Turner
5c8f95d56d Add an elf not so kgdb detects the kernel as a FreeBSD elf file. The
ELFNOTE macro is based on one from the FreeBSD/ARM Xen tree [1].

Obtained from:	Julien Grall <julien.grall AT linaro.org> [1]
2014-10-18 13:38:04 +00:00
Mark Johnston
5eaae1411f Pass up the error status of minidumpsys() to its callers.
PR:		193761
Submitted by:	Conrad Meyer <conrad.meyer@isilon.com>
Sponsored by:	EMC / Isilon Storage Division
2014-10-08 20:25:21 +00:00
Andrew Turner
3a08e1e31c Make sure __ARM_ARCH is defined in sysreg.h by including acle-compat.h 2014-09-30 13:32:45 +00:00
Andrew Turner
1af789ed11 Add machine/sysreg.h to simplify accessing the system control coprocessor
registers and use it in the ARMv7 CPU functions.

The sysreg.h file has been checked by hand, however it may contain errors
with the comments on when a register was first introduced. The ARMv7 cpu
functions have been checked by compiling both the previous and this version
and comparing the md5 of the object files.

Submitted by:	Svatopluk Kraus <onwahe at gmail.com>
Submitted by:	Michal Meloun <meloun at miracle.cz>
Reviewed by:	ian, rpaulo
Differential Revision: https://reviews.freebsd.org/D795
2014-09-27 09:57:34 +00:00
Ian Lepore
0e390441a7 Add a common routine for parsing FDT data describing an ARM GIC interrupt.
In the fdt data we've written for ourselves, the interrupt properties
for GIC interrupts have just been a bare interrupt number.  In standard
data that conforms to the published bindings, GIC interrupt properties
contain 3-tuples that describe the interrupt as shared vs private, the
interrupt number within the shared/private address space, and configuration
info such as level vs edge triggered.

The new gic_decode_fdt() function parses both types of data, based on the
#interrupt-cells property.  Previously, each platform implemented a decode
routine and put a pointer to it into fdt_pic_table.  Now they can just
list this function in their table instead if they use arm/gic.c.
2014-09-14 21:21:03 +00:00
Andrew Turner
fad7eeb196 Rename pmap_kenter_temp to pmap_kenter_temporary to be consistent with the
other architectures with this function.

Submitted by:	Svatopluk Kraus <onwahe at gmail.com>
Submitted by:	Michal Meloun <meloun at miracle.cz>
2014-09-11 10:53:57 +00:00
Andrew Turner
b8fd1e31d9 Unify interrupts bit definition and usage. While here remove PSR_C_bit.
Submitted by:	Svatopluk Kraus <onwahe at gmail.com>,
		Michal Meloun <meloun at miracle.cz>
Differential Revision: https://reviews.freebsd.org/D754
2014-09-10 15:25:15 +00:00
Andrew Turner
d7f129a3cb Add more register values to armreg.h and remove CPU_CONTROL_32BP_ENABLE
from asm.h as they were already defined in armreg.h.

Submitted by:	Michal Meloun <meloun at miracle.cz>
2014-09-10 13:38:52 +00:00
Ian Lepore
05e3ac86bf Rename new to newval in inline asm code, to avoid clashes with C++ new.
Also rename cmp to cmpval just to keep the asm variable names similar to
the C variable names.
2014-09-09 13:50:21 +00:00
Ian Lepore
156688371b Do not generate unwind info in asm functions if _STANDALONE is defined.
The .fnend op causes the assembler to emit RELOC references to unwind
support functions that don't exist in libstand.
2014-09-01 14:57:04 +00:00
Ruslan Bukin
99d7e0a9a8 GIC (Cortex A's interrupt controller) supports up to 1020 IRQs. 2014-08-31 17:40:19 +00:00
Ian Lepore
46dd56e781 The Marvell PJ4B cpu family is armv7, not armv6. 2014-08-31 15:23:49 +00:00
Warner Losh
817dc00433 Expand the elf brandelf infrastructure to give access to the whole ELF
header (Elf_Ehdr) to determine if a particular interpretor wants to
accept it or not. Use this mechanism to filter EABI arm on OABI arm
kernels, and vice versa. This method could also be used to implement
OABI on EABI arm kernels, if desired, or to allow a single mips kernel
to run o32, n32 and n64 binaries.

Differential Revision: https://reviews.freebsd.org/D609
2014-08-18 02:44:56 +00:00
Ian Lepore
6a3fc532ab When the initarm_* routines were renamed to platform_* and moved to their
own header file, the lovely block of comments explaining what the generic
init code expects of the soc implementations got lost, restore it.
2014-08-17 02:56:58 +00:00
Warner Losh
161fedb9cc From https://sourceware.org/ml/newlib/2014/msg00113.html
By Richard Earnshaw at ARM
>
>GCC has for a number of years provides a set of pre-defined macros for
>use with determining the ISA and features of the target during
>pre-processing.  However, the design was always somewhat cumbersome in
>that each new architecture revision created a new define and then
>removed the previous one.  This meant that it was necessary to keep
>updating the support code simply to recognise a new architecture being
>added.
>
>The ACLE specification (ARM C Language Extentions)
>(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.set.swdev/index.html)
>provides a much more suitable interface and GCC has supported this
>since gcc-4.8.
>
>This patch makes use of the ACLE pre-defines to map to the internal
>feature definitions.  To support older versions of GCC a compatibility
>header is provided that maps the traditional pre-defines onto the new
>ACLE ones.

Stop using __FreeBSD_ARCH_armv6__ and switch to __ARM_ARCH >= 6 in the
couple of places in tree. clang already implements ACLE. Add a define
that says we implement version 1.1, even though the implementation
isn't quite complete.
2014-08-14 04:20:13 +00:00
Ian Lepore
59866d11b5 Set the pl310 L2 cache driver to attach during the middle of BUS_PASS_CPU.
Because that's earlier than interrupts are available, set up deferred
configuration of interrupts (which are used only for debugging).
2014-08-05 17:39:58 +00:00
Gleb Smirnoff
c8d2ffd6a7 Merge all MD sf_buf allocators into one MI, residing in kern/subr_sfbuf.c
The MD allocators were very common, however there were some minor
differencies. These differencies were all consolidated in the MI allocator,
under ifdefs. The defines from machine/vmparam.h turn on features required
for a particular machine. For details look in the comment in sys/sf_buf.h.

As result no MD code left in sys/*/*/vm_machdep.c. Some arches still have
machine/sf_buf.h, which is usually quite small.

Tested by:	glebius (i386), tuexen (arm32), kevlo (arm32)
Reviewed by:	kib
Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2014-08-05 09:44:10 +00:00
Ian Lepore
c311f7078c When arm 64-bit atomic ops are available, define ARM_HAVE_ATOMIC64. Use
that symbol (which will be correct in both kernel and userland contexts)
rather than just __arm__ to decide whether to use a local implementation.
2014-08-02 03:44:27 +00:00
Ian Lepore
eaa4e27642 Use atomic_load/store_64() in the arm implementation of counter(9), and
remove the XXX comments about non-atomic access to the counters.
2014-08-01 23:06:38 +00:00
Ian Lepore
9d203d4512 Add 64-bit atomic ops for armv4, only for kernel code, mostly so that we
don't need any #ifdef stuff to use atomic_load/store_64() elsewhere in
the kernel.  For armv4 the atomics are trivial to implement for kernel
code (just disable interrupts), less so for user mode, so this only has
the kernel mode implementations for now.
2014-08-01 22:56:41 +00:00
Ian Lepore
59561ab3e1 Add 64-bit atomic ops for armv6. The only safe way to access a 64-bit
value shared across multiple cores is with atomic_load_64() and
atomic_store_64(), because the normal 64-bit load/store instructions
are not atomic on 32-bit arm.  Luckily the ldrexd/strexd instructions
that are atomic are fairly cheap on armv6.  Because it's fairly simple
to do, this implements all the ops for 64-bit, not just load/store.

Reviewed by:	andrew, cognet
2014-08-01 22:28:36 +00:00
Ian Lepore
25166187e3 Fix unwind-info errors in our hand-written arm assembler code.
We have functions nested within functions, and places where we start a
function then never end it, we just jump to the middle of something else.
We tried to express this with nested ENTRY()/END() macros (which result
in .fnstart and .fnend directives), but it turns out there's no way to
express that nesting in ARM EHABI unwind info, and newer tools treat
multiple .fnstart directives without an intervening .fnend as an error.

These changes introduce two new macros, EENTRY() and EEND().  EENTRY()
creates a global label you can call/jump to just like ENTRY(), but it
doesn't emit a .fnstart.  EEND() is a no-op that just documents the
conceptual endpoint that matches up with the same-named EENTRY().

This is based on patches submitted by Stepan Dyatkovskiy, but I made some
changes and added the EEND() stuff, so blame any problems on me.

Submitted by:	Stepan Dyatkovskiy <stpworld@narod.ru>
2014-08-01 18:24:44 +00:00
Ian Lepore
677a88cec2 Add dl_unwind_find_exidx() for ARM EABI, required for C++ exception
handling.  For statically linked apps this uses the __exidx_start/end
symbols set up by the linker.  For dynamically linked apps it finds the
shared object that contains the given address and returns the location and
size of the exidx section in that shared object.

The dl_unwind_find_exidx() name is used by other BSD projects and Android,
and is mentioned in clang 3.5 comments as "the BSD interface" for finding
exidx data.  GCC (in libgcc_s) expects the exact same API and functionality
to be provided by a function named __gnu_Unwind_Find_exidx(), so we provide
that with an alias ("strong reference").

Reviewed by:	kib@
MFC after:	1 week
2014-07-19 22:13:27 +00:00
Michael Tuexen
2ff25a8b1c Different versions of the ARM processor use different registers.
Fix the code used on a Raspberry Pi.

Reviewed by: markm@
2014-06-17 21:48:04 +00:00
Zbigniew Bodek
1e17cf74b6 Delete obsolete and unused PJ4B CPU functions
Since PJ4Bv7 uses armv7_ CPU functions only pj4b_config
function is necessary. Remove obsolete routines.
2014-05-25 19:19:41 +00:00
Ian Lepore
11d47032ee Eliminate one of the causes of spurious interrupts on armv6. The arm weak
memory ordering model allows writes to different devices to complete out
of order, leading to a situation where the write that clears an interrupt
source at a device can complete after a write that unmasks and EOIs the
interrupt at the interrupt controller, leading to a spurious re-interrupt.

This adds a generic barrier function specific to the needs of interrupt
controllers, and calls that function from the GIC and TI AINTC controllers.
There may still be other soc-specific controllers that need to make the call.

Reviewed by:	cognet, Svatopluk Kraus <onwahe@gmail.com>
MFC after:	3 days
2014-05-24 16:21:16 +00:00
Warner Losh
32d5c97723 Remove NetBSD implementation details not relevant to FreeBSD. 2014-05-23 00:21:02 +00:00
Andrew Turner
87ff982083 Add FDT_PLATFORM_DEF2 for when there are multiple platforms needing to use
the same platform methods.
2014-05-17 18:02:46 +00:00
Andrew Turner
92e7f50a4e Fix a comment s/initarm_/platform_/ 2014-05-17 11:29:44 +00:00
Andrew Turner
27521ff8e4 Add the start of the ARM platform code. This is based on the PowerPC
platform code, it is expected these will be merged in the future when the
ARM code is more complete.

Until more boards can be tested only use this with the Raspberry Pi and
rrename the functions on the other SoCs.

Reviewed by:	ian@
2014-05-17 11:27:36 +00:00
Mark Murray
7ff2eaaad3 Give suitably-endowed ARMs a register similar to the x86 TSC register.
Here, "suitably endowed" means that the System Control Coprocessor
(#15) has Performance Monitoring Registers, including a CCNT (Cycle
Count) register.

The CCNT register is used in a way similar to the TSC register in
x86 processors by the get_cyclecount(9) function. The entropy-harvesting
thread is a heavy user of this function, and will benefit from not
having to call binuptime(9) instead.

One problem with the CCNT register is that it is 32-bit only, so
the upper 32-bits of the returned number are always 0. The entropy
harvester does not care, but in case any one else does, follow-up
work may include an interrup trap to increment an upper-32-bit
counter on CCNT overflow.

Another problem is that the CCNT register is not readable in user-mode
code; in can be made readable by userland, but then it is also
writable, and so is a good chunk of the PMU system. For that reason,
the CCNT is not enabled for user-mode access in this commit.

Like the x86, there is one CCNT per core, so they don't all run in
perfect sync.

Reviewed by:	ian@ (an earlier version)
Tested by:	ian@ (same earlier version)
Committed from:	WANDBOARD-QUAD
2014-05-14 19:11:15 +00:00
Ian Lepore
b07d0cbce3 Add cpu_l2cache_drain_writebuf(), use it to implement generic_bs_barrier().
On modern ARM SoCs the L2 cache controller sits between the CPU and the
AXI bus, and most on-chip memory-mapped devices are on the AXI bus.  We
map the device registers using the 'Device' memory attribute, which means
the memory is not cached, but writes to it are buffered.  Ensuring that a
write has made it all the way to a device may require that the L2
controller take some action.

There is currently only one implementation of the new function, for the
PL310 cache controller.  It invokes a function that the controller
manual calls "cache sync" but it actually has nothing to do with cache at
all, it triggers a drain of all pending store buffer writes and it blocks
until they complete.

The sheeva and xscale L2 controllers (which predate the concept of Device
memory) don't seem to have a corresponding function.  It appears that the
standard armv5 drain_writebuf function includes draining all the way
through the L2 controller.
2014-05-11 04:24:57 +00:00
Ian Lepore
6af0d51bce Make the hardware memory and instruction barrier functions work on armv4
and armv5 as well.
2014-05-11 00:43:06 +00:00
Ian Lepore
334b9c79c3 Add a public routine to set the L2 cache ram latencies. This can be
called by platform init routines to fine-tune cache performance.
2014-05-06 14:19:54 +00:00
Ian Lepore
7b41388248 Add defines for the bits in the PL310 debug control register.
This should have been part of r265444.
2014-05-06 14:08:42 +00:00
Ian Lepore
457e64a02f Make this declaration into a proper function prototype. 2014-04-29 23:29:28 +00:00
Ian Lepore
88b3694bd9 Move duplicated code to print l2 cache config into the common code. 2014-04-27 23:47:38 +00:00
Ian Lepore
824e4131a0 There is no difference between IPI_STOP and IPI_STOP_HARD on ARM, so
map them both to the same interrupt number like other arches do.
2014-04-27 20:01:59 +00:00
Ian Lepore
edecf7f6c1 Remove cpu_idcache_wbinv_all() from kdb_cpu_trap(), it's no longer needed.
This was added ca. 2004 for the purpose of ensuring the caches were in the
right state after the debugger set a breakpoint.  kdb_cpu_sync_icache()
was added in 2007 to handle that situation, and now the wbinv_all is
actually harmful because the operation isn't broadcast to other cores.
2014-04-27 18:12:55 +00:00
Ian Lepore
91c650065a Provide a proper armv7 implementation of icache_sync_all rather than
using armv7_idcache_wbinv_all, because wbinv_all doesn't broadcast the
operation to other cores.  In elf_cpu_load_file() use icache_sync_all()
and explain why it's needed (and why other sync operations aren't).

As part of doing this, all callers of cpu_icache_sync_all() were
inspected to ensure they weren't relying on the old side effect of
doing a wbinv_all along with the icache work.
2014-04-27 00:46:01 +00:00
Ian Lepore
75c95895f5 Call cpu_icache_sync_range() rather than sync_all since we know the range
and flushing the entire icache is needlessly expensive.
2014-04-26 23:09:01 +00:00
Ian Lepore
0b7d5b8f89 Tell VM we now have ARM platforms with physically discontiguous memory. 2014-04-06 21:40:39 +00:00
Ian Lepore
e69ba7c708 We don't support any ARM systems with an ISA bus and don't need a freelist
of memory to support ISA addressing limitations.
2014-04-04 19:35:38 +00:00
Tijl Coosemans
0a4c54d606 Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4
-fms-extensions.

MFC after:	2 weeks
2014-04-01 14:46:11 +00:00
Ruslan Bukin
66e227bf1e Add Cortex-A15 cpu id revisions. 2014-04-01 04:56:40 +00:00
Andrew Turner
d4f9011c2e VFP fixes/cleanups for ARM11:
* Save the required VFP registers on context switch. If the exception bit
   is set we need to save and restore the FPINST register, and if the fp2v
   bit is also set we need to save and restore FPINST2.
 * Move saving and restoring the floating point control registers to C.
 * Clear the fpexc exception and fp2v flags on a floating-point exception.
 * Signal a SIGFPE if the fpexc exception flag is set on an undefined
   instruction. This is how the ARM core signals to software there is a
   floating-point exception.
2014-03-29 14:35:36 +00:00
Andrew Turner
4797432ff7 Add more flags for the fpexc register from the ARM1176JZF-S Manual 2014-03-29 10:11:19 +00:00