Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Apr 2015 14:43:10 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r281494 - in head/sys: arm64/arm64 arm64/conf arm64/include conf dev/fdt sys
Message-ID:  <201504131443.t3DEhAbi031191@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Mon Apr 13 14:43:10 2015
New Revision: 281494
URL: https://svnweb.freebsd.org/changeset/base/281494

Log:
  Bring in the start of the arm64 kernel.
  
  This is only the minimum set of files needed to boot in qemu. As such it is
  missing a few things.
  
  The bus_dma code is currently only stub functions with a full implementation
  from the development tree to follow.
  
  The gic driver has been copied as the interrupt framework is different. It
  is expected the two drivers will be merged by the arm intrng project,
  however this will need to be imported into the tree and support for arm64
  would need to be added.
  
  This includes code developed by myself, SemiHalf, Ed Maste, and Robin
  Randhawa from ARM. This has been funded by the FreeBSD Foundation, with
  early development by myself in my spare time with assistance from Robin.
  
  Differential Revision:	https://reviews.freebsd.org/D2199
  Reviewed by:	emaste, imp
  Relnotes:	yes
  Sponsored by:	The FreeBSD Foundation

Added:
  head/sys/arm64/arm64/
  head/sys/arm64/arm64/autoconf.c   (contents, props changed)
  head/sys/arm64/arm64/bcopy.c   (contents, props changed)
  head/sys/arm64/arm64/bus_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/bus_space_asm.S   (contents, props changed)
  head/sys/arm64/arm64/busdma_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/clock.c   (contents, props changed)
  head/sys/arm64/arm64/copyinout.S   (contents, props changed)
  head/sys/arm64/arm64/copystr.c   (contents, props changed)
  head/sys/arm64/arm64/cpufunc_asm.S   (contents, props changed)
  head/sys/arm64/arm64/dump_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/elf_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/exception.S   (contents, props changed)
  head/sys/arm64/arm64/genassym.c   (contents, props changed)
  head/sys/arm64/arm64/gic.c   (contents, props changed)
  head/sys/arm64/arm64/identcpu.c   (contents, props changed)
  head/sys/arm64/arm64/in_cksum.c   (contents, props changed)
  head/sys/arm64/arm64/intr_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/locore.S   (contents, props changed)
  head/sys/arm64/arm64/machdep.c   (contents, props changed)
  head/sys/arm64/arm64/mem.c   (contents, props changed)
  head/sys/arm64/arm64/minidump_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/nexus.c   (contents, props changed)
  head/sys/arm64/arm64/pic_if.m   (contents, props changed)
  head/sys/arm64/arm64/pmap.c   (contents, props changed)
  head/sys/arm64/arm64/stack_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/support.S   (contents, props changed)
  head/sys/arm64/arm64/swtch.S   (contents, props changed)
  head/sys/arm64/arm64/sys_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/trap.c   (contents, props changed)
  head/sys/arm64/arm64/uio_machdep.c   (contents, props changed)
  head/sys/arm64/arm64/vfp.c   (contents, props changed)
  head/sys/arm64/arm64/vm_machdep.c   (contents, props changed)
  head/sys/arm64/conf/
  head/sys/arm64/conf/DEFAULTS   (contents, props changed)
  head/sys/arm64/conf/GENERIC   (contents, props changed)
  head/sys/arm64/include/_bus.h   (contents, props changed)
  head/sys/arm64/include/armreg.h   (contents, props changed)
  head/sys/arm64/include/bus.h   (contents, props changed)
  head/sys/arm64/include/bus_dma.h   (contents, props changed)
  head/sys/arm64/include/clock.h   (contents, props changed)
  head/sys/arm64/include/counter.h   (contents, props changed)
  head/sys/arm64/include/db_machdep.h   (contents, props changed)
  head/sys/arm64/include/debug_monitor.h   (contents, props changed)
  head/sys/arm64/include/devmap.h   (contents, props changed)
  head/sys/arm64/include/dump.h   (contents, props changed)
  head/sys/arm64/include/hypervisor.h   (contents, props changed)
  head/sys/arm64/include/in_cksum.h   (contents, props changed)
  head/sys/arm64/include/intr.h   (contents, props changed)
  head/sys/arm64/include/kdb.h   (contents, props changed)
  head/sys/arm64/include/machdep.h   (contents, props changed)
  head/sys/arm64/include/md_var.h   (contents, props changed)
  head/sys/arm64/include/memdev.h   (contents, props changed)
  head/sys/arm64/include/metadata.h   (contents, props changed)
  head/sys/arm64/include/ofw_machdep.h   (contents, props changed)
  head/sys/arm64/include/resource.h   (contents, props changed)
  head/sys/arm64/include/sf_buf.h   (contents, props changed)
  head/sys/arm64/include/smp.h   (contents, props changed)
  head/sys/arm64/include/stack.h   (contents, props changed)
  head/sys/arm64/include/trap.h   (contents, props changed)
  head/sys/arm64/include/vfp.h   (contents, props changed)
  head/sys/conf/Makefile.arm64   (contents, props changed)
  head/sys/conf/files.arm64   (contents, props changed)
  head/sys/conf/ldscript.arm64   (contents, props changed)
  head/sys/conf/options.arm64   (contents, props changed)
  head/sys/dev/fdt/fdt_arm64.c   (contents, props changed)
Modified:
  head/sys/arm64/include/cpufunc.h
  head/sys/arm64/include/pmap.h
  head/sys/sys/kerneldump.h

Added: head/sys/arm64/arm64/autoconf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/autoconf.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Setup the system to run on the current machine.
+ *
+ * Configure() is called at boot time and initializes the vba
+ * device tables and the memory controller monitoring.  Available
+ * devices are determined (from possibilities mentioned in ioconf.c),
+ * and the drivers are initialized.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/cons.h>
+#include <sys/kernel.h>
+
+#include <machine/intr.h>
+
+static void	configure_first(void *);
+static void	configure(void *);
+static void	configure_final(void *);
+
+SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
+/* SI_ORDER_SECOND is hookable */
+SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
+/* SI_ORDER_MIDDLE is hookable */
+SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
+
+/*
+ * Determine i/o configuration for a machine.
+ */
+static void
+configure_first(void *dummy)
+{
+
+	/* nexus0 is the top of the device tree */
+	device_add_child(root_bus, "nexus", 0);
+}
+
+static void
+configure(void *dummy)
+{
+
+	/* initialize new bus architecture */
+	root_bus_configure();
+}
+
+static void
+configure_final(void *dummy)
+{
+	arm_enable_intr();
+	cninit_finish(); 
+
+	if (bootverbose)
+		printf("Device configuration finished.\n");
+
+	cold = 0;
+}

Added: head/sys/arm64/arm64/bcopy.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/bcopy.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,139 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * 
+ * From: sys/powerpc/powerpc/bcopy.c
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+/*
+ * sizeof(word) MUST BE A POWER OF TWO
+ * SO THAT wmask BELOW IS ALL ONES
+ */
+typedef	long	word;		/* "word" used for optimal copy speed */
+
+#define	wsize	sizeof(word)
+#define wmask	(wsize - 1)
+
+/*
+ * Copy a block of memory, handling overlap.
+ * This is the routine that actually implements
+ * (the portable versions of) bcopy, memcpy, and memmove.
+ */
+void *
+memcpy(void *dst0, const void *src0, size_t length)
+{
+	char		*dst;
+	const char	*src;
+	size_t		t;
+
+	dst = dst0;
+	src = src0;
+
+	if (length == 0 || dst == src) {	/* nothing to do */
+		goto done;
+	}
+
+	/*
+	 * Macros: loop-t-times; and loop-t-times, t>0
+	 */
+#define	TLOOP(s) if (t) TLOOP1(s)
+#define	TLOOP1(s) do { s; } while (--t)
+
+	if ((unsigned long)dst < (unsigned long)src) {
+		/*
+		 * Copy forward.
+		 */
+		t = (size_t)src;	/* only need low bits */
+
+		if ((t | (uintptr_t)dst) & wmask) {
+			/*
+			 * Try to align operands.  This cannot be done
+			 * unless the low bits match.
+			 */
+			if ((t ^ (uintptr_t)dst) & wmask || length < wsize) {
+				t = length;
+			} else {
+				t = wsize - (t & wmask);
+			}
+
+			length -= t;
+			TLOOP1(*dst++ = *src++);
+		}
+		/*
+		 * Copy whole words, then mop up any trailing bytes.
+		 */
+		t = length / wsize;
+		TLOOP(*(word *)dst = *(const word *)src; src += wsize;
+		    dst += wsize);
+		t = length & wmask;
+		TLOOP(*dst++ = *src++);
+	} else {
+		/*
+		 * Copy backwards.  Otherwise essentially the same.
+		 * Alignment works as before, except that it takes
+		 * (t&wmask) bytes to align, not wsize-(t&wmask).
+		 */
+		src += length;
+		dst += length;
+		t = (uintptr_t)src;
+
+		if ((t | (uintptr_t)dst) & wmask) {
+			if ((t ^ (uintptr_t)dst) & wmask || length <= wsize) {
+				t = length;
+			} else {
+				t &= wmask;
+			}
+
+			length -= t;
+			TLOOP1(*--dst = *--src);
+		}
+		t = length / wsize;
+		TLOOP(src -= wsize; dst -= wsize;
+		    *(word *)dst = *(const word *)src);
+		t = length & wmask;
+		TLOOP(*--dst = *--src);
+	}
+done:
+	return (dst0);
+}
+
+void
+bcopy(const void *src0, void *dst0, size_t length)
+{
+
+	memcpy(dst0, src0, length);
+}
+

Added: head/sys/arm64/arm64/bus_machdep.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/bus_machdep.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,204 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "opt_platform.h"
+
+#include <sys/param.h>
+__FBSDID("$FreeBSD$");
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+
+uint8_t  generic_bs_r_1(void *, bus_space_handle_t, bus_size_t);
+uint16_t generic_bs_r_2(void *, bus_space_handle_t, bus_size_t);
+uint32_t generic_bs_r_4(void *, bus_space_handle_t, bus_size_t);
+uint64_t generic_bs_r_8(void *, bus_space_handle_t, bus_size_t);
+
+void generic_bs_rm_1(void *, bus_space_handle_t, bus_size_t, uint8_t *,
+    bus_size_t);
+void generic_bs_rm_2(void *, bus_space_handle_t, bus_size_t, uint16_t *,
+    bus_size_t);
+void generic_bs_rm_4(void *, bus_space_handle_t, bus_size_t, uint32_t *,
+    bus_size_t);
+void generic_bs_rm_8(void *, bus_space_handle_t, bus_size_t, uint64_t *,
+    bus_size_t);
+
+void generic_bs_w_1(void *, bus_space_handle_t, bus_size_t, uint8_t);
+void generic_bs_w_2(void *, bus_space_handle_t, bus_size_t, uint16_t);
+void generic_bs_w_4(void *, bus_space_handle_t, bus_size_t, uint32_t);
+void generic_bs_w_8(void *, bus_space_handle_t, bus_size_t, uint64_t);
+
+void generic_bs_wm_1(void *, bus_space_handle_t, bus_size_t, const uint8_t *,
+    bus_size_t);
+void generic_bs_wm_2(void *, bus_space_handle_t, bus_size_t, const uint16_t *,
+    bus_size_t);
+void generic_bs_wm_4(void *, bus_space_handle_t, bus_size_t, const uint32_t *,
+    bus_size_t);
+void generic_bs_wm_8(void *, bus_space_handle_t, bus_size_t, const uint64_t *,
+    bus_size_t);
+
+static int
+generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
+    bus_space_handle_t *bshp)
+{
+	void *va;
+
+	va = pmap_mapdev(bpa, size);
+	if (va == NULL)
+		return (ENOMEM);
+	*bshp = (bus_space_handle_t)va;
+	return (0);
+}
+
+static void
+generic_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
+{
+
+	pmap_unmapdev(bsh, size);
+}
+
+static void
+generic_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
+    bus_size_t size, int flags)
+{
+}
+
+static int
+generic_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
+    bus_size_t size, bus_space_handle_t *nbshp)
+{
+
+	*nbshp = bsh + offset;
+	return (0);
+}
+
+struct bus_space memmap_bus = {
+	/* cookie */
+	.bs_cookie = NULL,
+
+	/* mapping/unmapping */
+	.bs_map = generic_bs_map,
+	.bs_unmap = generic_bs_unmap,
+	.bs_subregion = generic_bs_subregion,
+
+	/* allocation/deallocation */
+	.bs_alloc = NULL,
+	.bs_free = NULL,
+
+	/* barrier */
+	.bs_barrier = generic_bs_barrier,
+
+	/* read single */
+	.bs_r_1 = generic_bs_r_1,
+	.bs_r_2 = generic_bs_r_2,
+	.bs_r_4 = generic_bs_r_4,
+	.bs_r_8 = generic_bs_r_8,
+
+	/* read multiple */
+	.bs_rm_1 = generic_bs_rm_1,
+	.bs_rm_2 = generic_bs_rm_2,
+	.bs_rm_4 = generic_bs_rm_4,
+	.bs_rm_8 = generic_bs_rm_8,
+
+	/* write single */
+	.bs_w_1 = generic_bs_w_1,
+	.bs_w_2 = generic_bs_w_2,
+	.bs_w_4 = generic_bs_w_4,
+	.bs_w_8 = generic_bs_w_8,
+
+	/* write multiple */
+	.bs_wm_1 = generic_bs_wm_1,
+	.bs_wm_2 = generic_bs_wm_2,
+	.bs_wm_4 = generic_bs_wm_4,
+	.bs_wm_8 = generic_bs_wm_8,
+
+	/* write region */
+	.bs_wr_1 = NULL,
+	.bs_wr_2 = NULL,
+	.bs_wr_4 = NULL,
+	.bs_wr_8 = NULL,
+
+	/* set multiple */
+	.bs_sm_1 = NULL,
+	.bs_sm_2 = NULL,
+	.bs_sm_4 = NULL,
+	.bs_sm_8 = NULL,
+
+	/* set region */
+	.bs_sr_1 = NULL,
+	.bs_sr_2 = NULL,
+	.bs_sr_4 = NULL,
+	.bs_sr_8 = NULL,
+
+	/* copy */
+	.bs_c_1 = NULL,
+	.bs_c_2 = NULL,
+	.bs_c_4 = NULL,
+	.bs_c_8 = NULL,
+
+	/* read single stream */
+	.bs_r_1_s = NULL,
+	.bs_r_2_s = NULL,
+	.bs_r_4_s = NULL,
+	.bs_r_8_s = NULL,
+
+	/* read multiple stream */
+	.bs_rm_1_s = NULL,
+	.bs_rm_2_s = NULL,
+	.bs_rm_4_s = NULL,
+	.bs_rm_8_s = NULL,
+
+	/* read region stream */
+	.bs_rr_1_s = NULL,
+	.bs_rr_2_s = NULL,
+	.bs_rr_4_s = NULL,
+	.bs_rr_8_s = NULL,
+
+	/* write single stream */
+	.bs_w_1_s = NULL,
+	.bs_w_2_s = NULL,
+	.bs_w_4_s = NULL,
+	.bs_w_8_s = NULL,
+
+	/* write multiple stream */
+	.bs_wm_1_s = NULL,
+	.bs_wm_2_s = NULL,
+	.bs_wm_4_s = NULL,
+	.bs_wm_8_s = NULL,
+
+	/* write region stream */
+	.bs_wr_1_s = NULL,
+	.bs_wr_2_s = NULL,
+	.bs_wr_4_s = NULL,
+	.bs_wr_8_s = NULL,
+};
+
+#ifdef FDT
+bus_space_tag_t fdtbus_bs_tag = &memmap_bus;
+#endif

Added: head/sys/arm64/arm64/bus_space_asm.S
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/bus_space_asm.S	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,235 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <machine/asm.h>
+
+__FBSDID("$FreeBSD$");
+
+ENTRY(generic_bs_r_1)
+	ldrb	w0, [x1, x2]
+	ret
+END(generic_bs_r_1)
+
+ENTRY(generic_bs_r_2)
+	ldrh	w0, [x1, x2]
+	ret
+END(generic_bs_r_2)
+
+ENTRY(generic_bs_r_4)
+	ldr	w0, [x1, x2]
+	ret
+END(generic_bs_r_4)
+
+ENTRY(generic_bs_r_8)
+	ldr	x0, [x1, x2]
+	ret
+END(generic_bs_r_8)
+
+ENTRY(generic_bs_rm_1)
+	/* If there is anything to read. */
+	cbz	x4, 2f
+
+	/* Calculate the device address. */
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Read the data. */
+1:	ldrb	w1, [x0]
+	strb	w1, [x3], #2
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_rm_1)
+
+ENTRY(generic_bs_rm_2)
+	/* If there is anything to read. */
+	cbz	x4, 2f
+
+	/* Calculate the device address. */
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Read the data. */
+1:	ldrh	w1, [x0]
+	strh	w1, [x3], #2
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_rm_2)
+
+ENTRY(generic_bs_rm_4)
+	/* If there is anything to read. */
+	cbz	x4, 2f
+
+	/* Calculate the device address. */
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Read the data. */
+1:	ldr	w1, [x0]
+	str	w1, [x3], #2
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_rm_4)
+
+ENTRY(generic_bs_rm_8)
+	/* If there is anything to read. */
+	cbz	x4, 2f
+
+	/* Calculate the device address. */
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Read the data. */
+1:	ldr	x1, [x0]
+	str	x1, [x3], #2
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_rm_8)
+
+
+ENTRY(generic_bs_w_1)
+	strb	w3, [x1, x2]
+	ret
+END(generic_bs_w_1)
+
+ENTRY(generic_bs_w_2)
+	strh	w3, [x1, x2]
+	ret
+END(generic_bs_w_2)
+
+ENTRY(generic_bs_w_4)
+	str	w3, [x1, x2]
+	ret
+END(generic_bs_w_4)
+
+ENTRY(generic_bs_w_8)
+	str	x3, [x1, x2]
+	ret
+END(generic_bs_w_8)
+
+ENTRY(generic_bs_wm_1)
+	/* If there is anything to write. */
+	cbz	x4, 2f
+
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Write the data */
+1:	ldrb	w1, [x3], #1
+	strb	w1, [x0]
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_wm_1)
+
+ENTRY(generic_bs_wm_2)
+	/* If there is anything to write. */
+	cbz	x4, 2f
+
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Write the data */
+1:	ldrh	w1, [x3], #2
+	strh	w1, [x0]
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_wm_2)
+
+ENTRY(generic_bs_wm_4)
+	/* If there is anything to write. */
+	cbz	x4, 2f
+
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Write the data */
+1:	ldr	w1, [x3], #4
+	str	w1, [x0]
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_wm_4)
+
+ENTRY(generic_bs_wm_8)
+	/* If there is anything to write. */
+	cbz	x4, 2f
+
+	add	x0, x1, x2
+	/*
+	 * x0 = The device address.
+	 * x3 = The kernel address.
+	 * x4 = Count
+	 */
+
+	/* Write the data */
+1:	ldr	x1, [x3], #8
+	str	x1, [x0]
+	subs	x4, x4, #1
+	b.ne	1b
+
+2:	ret
+END(generic_bs_wm_8)

Added: head/sys/arm64/arm64/busdma_machdep.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/busdma_machdep.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,68 @@
+/* $FreeBSD$ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+
+int
+_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
+    bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp)
+{
+
+	panic("_bus_dmamap_load_phys");
+}
+
+int
+_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
+    bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs,
+    int *segp)
+{
+
+	panic("_bus_dmamap_load_ma");
+}
+
+int
+_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
+    bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs,
+    int *segp)
+{
+
+	panic("_bus_dmamap_load_buffer");
+}
+
+void
+__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+    struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
+{
+
+	panic("__bus_dmamap_waitok");
+}
+
+bus_dma_segment_t *
+_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
+    bus_dma_segment_t *segs, int nsegs, int error)
+{
+
+	panic("_bus_dmamap_complete");
+}
+
+void
+_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+
+	panic("_bus_dmamap_unload");
+}
+
+void
+_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
+{
+
+	panic("_bus_dmamap_sync");
+}

Added: head/sys/arm64/arm64/clock.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/clock.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/systm.h>
+
+void
+cpu_initclocks(void)
+{
+
+	cpu_initclocks_bsp();
+}

Added: head/sys/arm64/arm64/copyinout.S
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/copyinout.S	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,118 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/errno.h>
+
+#include "assym.s"
+
+/*
+ * Fault handler for the copy{in,out} functions below.
+ */
+ENTRY(copyio_fault)
+	SET_FAULT_HANDLER(xzr, x1) /* Clear the handler */
+	mov	x0, #EFAULT
+	ret
+END(copyio_fault)
+
+/*
+ * Copies from a kernel to user address
+ *
+ * int copyout(const void *kaddr, void *udaddr, size_t len)
+ */
+ENTRY(copyout)
+	cbz	x2, 2f		/* If len == 0 then skip loop */
+
+	adr	x6, copyio_fault /* Get the handler address */
+	SET_FAULT_HANDLER(x6, x7) /* Set the handler */
+
+1:	ldrb	w4, [x0], #1	/* Load from kaddr */
+	strb	w4, [x1], #1	/* Store in uaddr */
+	sub	x2, x2, #1	/* len-- */
+	cbnz	x2, 1b
+
+	SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
+
+2:	mov	x0, xzr		/* return 0 */
+	ret
+END(copyout)
+
+/*
+ * Copies from a user to kernel address
+ *
+ * int copyin(const void *uaddr, void *kdaddr, size_t len)
+ */
+ENTRY(copyin)
+	cbz	x2, 2f		/* If len == 0 then skip loop */
+
+	adr	x6, copyio_fault /* Get the handler address */
+	SET_FAULT_HANDLER(x6, x7) /* Set the handler */
+
+1:	ldrb	w4, [x0], #1	/* Load from uaddr */
+	strb	w4, [x1], #1	/* Store in kaddr */
+	sub	x2, x2, #1	/* len-- */
+	cbnz	x2, 1b
+
+	SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
+
+2:	mov	x0, xzr		/* return 0 */
+	ret
+END(copyin)
+
+/*
+ * Copies a string from a user to kernel address
+ *
+ * int copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done)
+ */
+ENTRY(copyinstr)
+	mov	x5, xzr		/* count = 0 */
+	cbz	x2, 3f		/* If len == 0 then skip loop */
+
+	adr	x6, copyio_fault /* Get the handler address */
+	SET_FAULT_HANDLER(x6, x7) /* Set the handler */
+
+1:	ldrb	w4, [x0], #1	/* Load from uaddr */
+	strb	w4, [x1], #1	/* Store in kaddr */
+	cbz	w4, 2f		/* If == 0 then break */
+	sub	x2, x2, #1	/* len-- */
+	add	x5, x5, #1	/* count++ */
+	cbnz	x2, 1b
+
+2:	SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */
+
+3:	cbz	x3, 4f		/* Check if done != NULL */
+	add	x5, x5, #1	/* count++ */
+	str	x5, [x3]	/* done = count */
+
+4:	mov	x0, xzr		/* return 0 */
+	ret
+END(copyinstr)

Added: head/sys/arm64/arm64/copystr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/copystr.c	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+int
+copystr(const void * __restrict kfaddr, void * __restrict kdaddr, size_t len,
+    size_t * __restrict lencopied)
+{
+	const char *src;
+	size_t pos;
+	char *dst;
+	int error;
+
+	error = ENAMETOOLONG;
+	src = kfaddr;
+	dst = kdaddr;
+	for (pos = 0; pos < len; pos++) {
+		dst[pos] = src[pos];
+		if (src[pos] == '\0') {
+			/* Increment pos to hold the number of bytes copied */
+			pos++;
+			error = 0;
+			break;
+		}
+	}
+
+	if (lencopied != NULL)
+		*lencopied = pos;
+
+	return (0);
+}
+

Added: head/sys/arm64/arm64/cpufunc_asm.S
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm64/arm64/cpufunc_asm.S	Mon Apr 13 14:43:10 2015	(r281494)
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 2014 Robin Randhawa
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Andrew Turner
+ * under sponsorship from the FreeBSD Foundation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504131443.t3DEhAbi031191>