Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 May 2014 11:27:37 +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: r266301 - in head/sys: arm/allwinner arm/arm arm/broadcom/bcm2835 arm/conf arm/freescale/imx arm/freescale/vybrid arm/include arm/lpc arm/mv arm/rockchip arm/samsung/exynos arm/tegra ar...
Message-ID:  <201405171127.s4HBRbc3035247@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sat May 17 11:27:36 2014
New Revision: 266301
URL: http://svnweb.freebsd.org/changeset/base/266301

Log:
  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@

Added:
  head/sys/arm/arm/platform.c   (contents, props changed)
  head/sys/arm/arm/platform_if.m   (contents, props changed)
  head/sys/arm/include/platform.h   (contents, props changed)
  head/sys/arm/include/platformvar.h   (contents, props changed)
  head/sys/dev/fdt/fdt_arm_platform.c   (contents, props changed)
Modified:
  head/sys/arm/allwinner/a10_machdep.c
  head/sys/arm/arm/machdep.c
  head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  head/sys/arm/conf/RPI-B
  head/sys/arm/freescale/imx/imx51_machdep.c
  head/sys/arm/freescale/imx/imx53_machdep.c
  head/sys/arm/freescale/imx/imx6_machdep.c
  head/sys/arm/freescale/vybrid/vf_machdep.c
  head/sys/arm/include/machdep.h
  head/sys/arm/lpc/lpc_machdep.c
  head/sys/arm/mv/mv_machdep.c
  head/sys/arm/rockchip/rk30xx_machdep.c
  head/sys/arm/samsung/exynos/exynos5_machdep.c
  head/sys/arm/tegra/tegra2_machdep.c
  head/sys/arm/ti/ti_machdep.c
  head/sys/arm/versatile/versatile_machdep.c
  head/sys/arm/xilinx/zy7_machdep.c
  head/sys/conf/files.arm
  head/sys/conf/options.arm

Modified: head/sys/arm/allwinner/a10_machdep.c
==============================================================================
--- head/sys/arm/allwinner/a10_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/allwinner/a10_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -45,30 +45,31 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <dev/fdt/fdt_common.h>
 
 #include <arm/allwinner/a10_wdog.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 }
 
@@ -83,7 +84,7 @@ initarm_late_init(void)
  * perhaps a 1MB block would be more appropriate.
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 
 	arm_devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */

Modified: head/sys/arm/arm/machdep.c
==============================================================================
--- head/sys/arm/arm/machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/arm/machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -98,6 +98,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/metadata.h>
 #include <machine/pcb.h>
 #include <machine/physmem.h>
+#include <machine/platform.h>
 #include <machine/reg.h>
 #include <machine/trap.h>
 #include <machine/undefined.h>
@@ -1091,7 +1092,7 @@ initarm(struct arm_boot_params *abp)
 		    EXFLAG_NODUMP | EXFLAG_NOALLOC);
 
 	/* Platform-specific initialisation */
-	initarm_early_init();
+	platform_probe_and_attach();
 
 	pcpu0_init();
 
@@ -1207,9 +1208,9 @@ initarm(struct arm_boot_params *abp)
 	    VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE, PTE_CACHE);
 
 	/* Establish static device mappings. */
-	err_devmap = initarm_devmap_init();
+	err_devmap = platform_devmap_init();
 	arm_devmap_bootstrap(l1pagetable, NULL);
-	vm_max_kernel_address = initarm_lastaddr();
+	vm_max_kernel_address = platform_lastaddr();
 
 	cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT);
 	pmap_pa = kernel_l1pt.pv_pa;
@@ -1229,7 +1230,7 @@ initarm(struct arm_boot_params *abp)
 	 */
 	OF_interpret("perform-fixup", 0);
 
-	initarm_gpio_init();
+	platform_gpio_init();
 
 	cninit();
 
@@ -1247,7 +1248,7 @@ initarm(struct arm_boot_params *abp)
 		printf("WARNING: could not fully configure devmap, error=%d\n",
 		    err_devmap);
 
-	initarm_late_init();
+	platform_late_init();
 
 	/*
 	 * Pages were allocated during the secondary bootstrap for the

Added: head/sys/arm/arm/platform.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/arm/platform.c	Sat May 17 11:27:36 2014	(r266301)
@@ -0,0 +1,179 @@
+/*-
+ * Copyright (c) 2005 Peter Grehan
+ * Copyright (c) 2009 Nathan Whitehorn
+ * 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$");
+
+/*
+ * Dispatch platform calls to the appropriate platform implementation
+ * through a previously registered kernel object.
+ */
+
+#define	_ARM32_BUS_DMA_PRIVATE
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/ktr.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+#include <sys/systm.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+
+#include <vm/vm.h>
+#include <vm/vm_page.h>
+
+#include <machine/bus_dma.h>
+#include <machine/cpu.h>
+#include <machine/intr.h>
+#include <machine/md_var.h>
+#include <machine/platform.h>
+#include <machine/platformvar.h>
+#include <machine/smp.h>
+
+#include "platform_if.h"
+
+static platform_def_t	*plat_def_impl;
+static platform_t	plat_obj;
+static struct kobj_ops	plat_kernel_kops;
+static struct platform_kobj	plat_kernel_obj;
+
+static char plat_name[64] = "";
+SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN, plat_name, 0,
+    "Platform currently in use");
+
+/*
+ * Platform install routines. Highest priority wins, using the same
+ * algorithm as bus attachment.
+ */
+SET_DECLARE(platform_set, platform_def_t);
+
+void
+platform_probe_and_attach(void)
+{
+	platform_def_t	**platpp, *platp;
+	int		prio, best_prio;
+
+	plat_obj = &plat_kernel_obj;
+	best_prio = 0;
+
+	/*
+	 * We are unable to use TUNABLE_STR as the read will happen
+	 * well after this function has returned.
+	 */
+	TUNABLE_STR_FETCH("hw.platform", plat_name, sizeof(plat_name));
+
+	/*
+	 * Try to locate the best platform kobj
+	 */
+	SET_FOREACH(platpp, platform_set) {
+		platp = *platpp;
+
+		/*
+		 * Take care of compiling the selected class, and
+		 * then statically initialise the MMU object
+		 */
+		kobj_class_compile_static(platp, &plat_kernel_kops);
+		kobj_init_static((kobj_t)plat_obj, platp);
+
+		plat_obj->cls = platp;
+
+		prio = PLATFORM_PROBE(plat_obj);
+
+		/* Check for errors */
+		if (prio > 0)
+			continue;
+
+		/*
+		 * Check if this module was specifically requested through
+		 * the loader tunable we provide.
+		 */
+		if (strcmp(platp->name,plat_name) == 0) {
+			plat_def_impl = platp;
+			break;
+		}
+
+		/* Otherwise, see if it is better than our current best */
+		if (plat_def_impl == NULL || prio > best_prio) {
+			best_prio = prio;
+			plat_def_impl = platp;
+		}
+
+		/*
+		 * We can't free the KOBJ, since it is static. Reset the ops
+		 * member of this class so that we can come back later.
+		 */
+		platp->ops = NULL;
+	}
+
+	if (plat_def_impl == NULL)
+		panic("No platform module found!");
+
+	/*
+	 * Recompile to make sure we ended with the
+	 * correct one, and then attach.
+	 */
+
+	kobj_class_compile_static(plat_def_impl, &plat_kernel_kops);
+	kobj_init_static((kobj_t)plat_obj, plat_def_impl);
+
+	strlcpy(plat_name,plat_def_impl->name,sizeof(plat_name));
+
+	PLATFORM_ATTACH(plat_obj);
+}
+
+int
+platform_devmap_init(void)
+{
+
+	return PLATFORM_DEVMAP_INIT(plat_obj);
+}
+
+vm_offset_t
+platform_lastaddr(void)
+{
+
+	return PLATFORM_LASTADDR(plat_obj);
+}
+
+void
+platform_gpio_init(void)
+{
+
+	PLATFORM_GPIO_INIT(plat_obj);
+}
+
+void
+platform_late_init(void)
+{
+
+	PLATFORM_LATE_INIT(plat_obj);
+}
+

Added: head/sys/arm/arm/platform_if.m
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/arm/platform_if.m	Sat May 17 11:27:36 2014	(r266301)
@@ -0,0 +1,116 @@
+#-
+# Copyright (c) 2009 Nathan Whitehorn
+# 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.
+#
+# $FreeBSD$
+#
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/systm.h>
+#include <sys/smp.h>
+
+#include <machine/machdep.h>
+#include <machine/platform.h>
+#include <machine/platformvar.h>
+#include <machine/smp.h>
+#include <machine/vmparam.h>
+
+/**
+ * @defgroup PLATFORM platform - KObj methods for ARM platform
+ * implementations
+ * @brief A set of methods required by all platform implementations.
+ * These are used to bring up secondary CPUs, supply the physical memory
+ * map, etc.
+ *@{
+ */
+
+INTERFACE platform;
+
+#
+# Default implementations
+#
+CODE {
+	static void platform_null_attach(platform_t plat)
+	{
+		return;
+	}
+};
+
+/**
+ * @brief Probe for whether we are on this platform, returning the standard
+ * newbus probe codes. If we have Open Firmware or a flattened device tree,
+ * it is guaranteed to be available at this point.
+ */
+METHOD int probe {
+	platform_t	_plat;
+};
+
+/**
+ * @brief Attach this platform module. This happens before the MMU is online,
+ * so the platform module can install its own high-priority MMU module at
+ * this point.
+ */
+METHOD int attach {
+	platform_t	_plat;
+} DEFAULT platform_null_attach;
+
+/**
+ * @brief Called as one of the last steps of early virtual memory
+ * initialization, shortly before the new page tables are installed.
+ */
+METHOD int devmap_init {
+	platform_t	_plat;
+};
+
+/**
+ * @brief Called after devmap_init(), and must return the address of the
+ * first byte of unusable KVA space.  This allows a platform to carve out
+ * of the top of the KVA space whatever reserves it needs for things like
+ * static device mapping, and this is called to get the value before
+ * calling pmap_bootstrap() which uses the value to size the available KVA.
+ */
+METHOD vm_offset_t lastaddr {
+	platform_t	_plat;
+};
+
+/**
+ * @brief Called after the static device mappings are established and just
+ * before cninit(). The intention is that the routine can do any hardware
+ * setup (such as gpio or pinmux) necessary to make the console functional.
+ */
+METHOD void gpio_init {
+	platform_t	_plat;
+};
+
+/**
+ * @brief Called just after cninit(). This is the first of the init
+ * routines that can use printf() and expect the output to appear on
+ * a standard console.
+ */
+METHOD void late_init {
+	platform_t	_plat;
+};
+

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -54,31 +54,24 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h>
+#include <machine/platformvar.h>
 
 #include <dev/fdt/fdt_common.h>
 
 #include <arm/broadcom/bcm2835/bcm2835_wdog.h>
 
-vm_offset_t
-initarm_lastaddr(void)
-{
-
-	return (arm_devmap_lastaddr());
-}
+#include "platform_if.h"
 
-void
-initarm_early_init(void)
+static vm_offset_t
+bcm2835_lastaddr(platform_t plat)
 {
 
+	return (arm_devmap_lastaddr());
 }
 
-void
-initarm_gpio_init(void)
-{
-}
-
-void
-initarm_late_init(void)
+static void
+bcm2835_late_init(platform_t plat)
 {
 	phandle_t system;
 	pcell_t cells[2];
@@ -101,8 +94,8 @@ initarm_late_init(void)
  * All on-chip peripherals exist in a 16MB range starting at 0x20000000.
  * Map the entire range using 1MB section mappings.
  */
-int
-initarm_devmap_init(void)
+static int
+bcm2835_devmap_init(platform_t plat)
 {
 
 	arm_devmap_add_entry(0x20000000, 0x01000000);
@@ -129,4 +122,13 @@ cpu_reset()
 	bcmwd_watchdog_reset();
 	while (1);
 }
+static platform_method_t bcm2835_methods[] = {
+	PLATFORMMETHOD(platform_devmap_init,	bcm2835_devmap_init),
+	PLATFORMMETHOD(platform_lastaddr,	bcm2835_lastaddr),
+	PLATFORMMETHOD(platform_late_init,	bcm2835_late_init),
+
+	PLATFORMMETHOD_END,
+};
+
+FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b");
 

Modified: head/sys/arm/conf/RPI-B
==============================================================================
--- head/sys/arm/conf/RPI-B	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/conf/RPI-B	Sat May 17 11:27:36 2014	(r266301)
@@ -59,6 +59,7 @@ options 	KBD_INSTALL_CDEV	# install a CD
 #options         ROOTDEVNAME=\"ufs:mmcsd0s2\"
 
 options 	PREEMPTION
+options 	PLATFORM
 
 device		bpf
 device		loop

Modified: head/sys/arm/freescale/imx/imx51_machdep.c
==============================================================================
--- head/sys/arm/freescale/imx/imx51_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/freescale/imx/imx51_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -39,18 +39,19 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <arm/freescale/imx/imx_machdep.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 	/* XXX - Get rid of this stuff soon. */
@@ -59,13 +60,13 @@ initarm_early_init(void)
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 
 }
@@ -78,7 +79,7 @@ initarm_late_init(void)
  * Notably missing are entries for GPU, IPU, in general anything video related.
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 
 	arm_devmap_add_entry(0x70000000, 0x00100000);

Modified: head/sys/arm/freescale/imx/imx53_machdep.c
==============================================================================
--- head/sys/arm/freescale/imx/imx53_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/freescale/imx/imx53_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -39,17 +39,19 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
+
 #include <arm/freescale/imx/imx_machdep.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 	/* XXX - Get rid of this stuff soon. */
@@ -58,13 +60,13 @@ initarm_early_init(void)
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 
 }
@@ -77,7 +79,7 @@ initarm_late_init(void)
  * Notably missing are entries for GPU, IPU, in general anything video related.
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 
 	arm_devmap_add_entry(0x50000000, 0x00100000);

Modified: head/sys/arm/freescale/imx/imx6_machdep.c
==============================================================================
--- head/sys/arm/freescale/imx/imx6_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/freescale/imx/imx6_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <arm/arm/mpcore_timervar.h>
 #include <arm/freescale/imx/imx6_anatopreg.h>
@@ -46,14 +47,14 @@ __FBSDID("$FreeBSD$");
 #include <arm/freescale/imx/imx_machdep.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 	/* Inform the MPCore timer driver that its clock is variable. */
@@ -61,13 +62,13 @@ initarm_early_init(void)
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 
 }
@@ -89,7 +90,7 @@ initarm_late_init(void)
  * as OCRAM that probably shouldn't be mapped as PTE_DEVICE memory.
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 	const uint32_t IMX6_ARMMP_PHYS = 0x00a00000;
 	const uint32_t IMX6_ARMMP_SIZE = 0x00100000;

Modified: head/sys/arm/freescale/vybrid/vf_machdep.c
==============================================================================
--- head/sys/arm/freescale/vybrid/vf_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/freescale/vybrid/vf_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -41,36 +41,37 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <dev/fdt/fdt_common.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 
 }
 
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 
 	arm_devmap_add_entry(0x40000000, 0x100000);

Modified: head/sys/arm/include/machdep.h
==============================================================================
--- head/sys/arm/include/machdep.h	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/include/machdep.h	Sat May 17 11:27:36 2014	(r266301)
@@ -34,40 +34,6 @@ vm_offset_t fake_preload_metadata(struct
 vm_offset_t parse_boot_param(struct arm_boot_params *abp);
 void arm_generic_initclocks(void);
 
-/*
- * Initialization functions called by the common initarm() function in
- * arm/machdep.c (but not necessarily from the custom initarm() functions of
- * older code).
- *
- *  - initarm_early_init() is called very early, after parsing the boot params
- *    and after physical memory has been located and sized.
- *
- *  - initarm_devmap_init() is called as one of the last steps of early virtual
- *    memory initialization, shortly before the new page tables are installed.
- *
- *  - initarm_lastaddr() is called after initarm_devmap_init(), and must return
- *    the address of the first byte of unusable KVA space.  This allows a
- *    platform to carve out of the top of the KVA space whatever reserves it
- *    needs for things like static device mapping, and this is called to get the
- *    value before calling pmap_bootstrap() which uses the value to size the
- *    available KVA.
- *
- *  - initarm_gpio_init() is called after the static device mappings are
- *    established and just before cninit().  The intention is that the routine
- *    can do any hardware setup (such as gpio or pinmux) necessary to make the
- *    console functional.
- *
- *  - initarm_late_init() is called just after cninit().  This is the first of
- *    the init routines that can use printf() and expect the output to appear on
- *    a standard console.
- *
- */
-void initarm_early_init(void);
-int initarm_devmap_init(void);
-vm_offset_t initarm_lastaddr(void);
-void initarm_gpio_init(void);
-void initarm_late_init(void);
-
 /* Board-specific attributes */
 void board_set_serial(uint64_t);
 void board_set_revision(uint32_t);

Added: head/sys/arm/include/platform.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/include/platform.h	Sat May 17 11:27:36 2014	(r266301)
@@ -0,0 +1,38 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_MACHINE_PLATFORM_H_
+#define	_MACHINE_PLATFORM_H_
+
+void platform_probe_and_attach(void);
+int platform_devmap_init(void);
+vm_offset_t platform_lastaddr(void);
+void platform_gpio_init(void);
+void platform_late_init(void);
+
+#endif	/* _MACHINE_PLATFORM_H_ */

Added: head/sys/arm/include/platformvar.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/include/platformvar.h	Sat May 17 11:27:36 2014	(r266301)
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2005 Peter Grehan
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_PLATFORMVAR_H_
+#define _MACHINE_PLATFORMVAR_H_
+
+/*
+ * An ARM platform implementation is declared with a kernel object and
+ * an associated method table, similar to a device driver.
+ *
+ * e.g.
+ *
+ * static platform_method_t bcm2835_methods[] = {
+ *	PLATFORMMETHOD(platform_probe,		bcm2835_probe),
+ *  ...
+ *	PLATFORMMETHOD_END
+ * };
+ *
+ * static platform_def_t bcm3835_platform = {
+ * 	"bcm2835",
+ *	bcm2835_methods,
+ *	sizeof(bcm2835_platform_softc),	// or 0 if no softc
+ * };
+ *
+ * PLATFORM_DEF(bcm2835_platform);
+ */
+
+#include <sys/kobj.h>
+#include <sys/linker_set.h>
+
+struct platform_kobj {
+	/*
+	 * A platform instance is a kernel object
+	 */
+	KOBJ_FIELDS;
+
+	/* Platform class, for access to class specific data */
+	struct kobj_class *cls;
+};
+
+typedef struct platform_kobj	*platform_t;
+typedef struct kobj_class	platform_def_t;
+#define platform_method_t	kobj_method_t
+
+#define PLATFORMMETHOD		KOBJMETHOD
+#define	PLATFORMMETHOD_END	KOBJMETHOD_END
+
+#define PLATFORM_DEF(name)	DATA_SET(platform_set, name)
+
+#ifdef FDT
+struct fdt_platform_class {
+	KOBJ_CLASS_FIELDS;
+
+	const char *fdt_compatible;
+};
+
+typedef struct fdt_platform_class fdt_platform_def_t;
+
+extern platform_method_t fdt_platform_methods[];
+
+#define FDT_PLATFORM_DEF(NAME, NAME_STR, size, compatible)	\
+static fdt_platform_def_t NAME ## _fdt_platform = {		\
+	.name = NAME_STR,					\
+	.methods = fdt_platform_methods,			\
+	.fdt_compatible = compatible,				\
+};								\
+static kobj_class_t NAME ## _baseclasses[] =			\
+	{ (kobj_class_t)&NAME ## _fdt_platform, NULL };		\
+static platform_def_t NAME ## _platform = {			\
+	NAME_STR,						\
+	NAME ## _methods,					\
+	size,							\
+	NAME ## _baseclasses,					\
+};								\
+DATA_SET(platform_set, NAME ## _platform)
+
+#endif
+
+#endif /* _MACHINE_PLATFORMVAR_H_ */

Modified: head/sys/arm/lpc/lpc_machdep.c
==============================================================================
--- head/sys/arm/lpc/lpc_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/lpc/lpc_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/fdt.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <arm/lpc/lpcreg.h>
 #include <arm/lpc/lpcvar.h>
@@ -60,19 +61,19 @@ __FBSDID("$FreeBSD$");
 #include <dev/fdt/fdt_common.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 	/*
@@ -82,7 +83,7 @@ initarm_gpio_init(void)
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 }
 
@@ -92,7 +93,7 @@ initarm_late_init(void)
  * dts file when this code was converted to arm_devmap_add_entry().
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 
 	arm_devmap_add_entry(LPC_DEV_PHYS_BASE, LPC_DEV_SIZE);

Modified: head/sys/arm/mv/mv_machdep.c
==============================================================================
--- head/sys/arm/mv/mv_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/mv/mv_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/devmap.h>
 #include <machine/fdt.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <arm/mv/mvreg.h>	/* XXX */
 #include <arm/mv/mvvar.h>	/* XXX eventually this should be eliminated */
@@ -201,14 +202,14 @@ moveon:
 }
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (fdt_immr_va);
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 	if (fdt_immr_addr(MV_BASE) != 0)
@@ -216,7 +217,7 @@ initarm_early_init(void)
 }
 
 void
-initarm_gpio_init(void)
+platform_gpio_init(void)
 {
 
 	/*
@@ -228,7 +229,7 @@ initarm_gpio_init(void)
 }
 
 void
-initarm_late_init(void)
+platform_late_init(void)
 {
 	/*
 	 * Re-initialise decode windows
@@ -297,7 +298,7 @@ out:
  * Supply a default do-nothing implementation of mv_pci_devmap() via a weak
  * alias.  Many Marvell platforms don't support a PCI interface, but to support
  * those that do, we end up with a reference to this function below, in
- * initarm_devmap_init().  If "device pci" appears in the kernel config, the
+ * platform_devmap_init().  If "device pci" appears in the kernel config, the
  * real implementation of this function in arm/mv/mv_pci.c overrides the weak
  * alias defined here.
  */
@@ -321,7 +322,7 @@ __weak_reference(mv_default_fdt_pci_devm
  * Construct pmap_devmap[] with DT-derived config data.
  */
 int
-initarm_devmap_init(void)
+platform_devmap_init(void)
 {
 	phandle_t root, child;
 	pcell_t bank_count;

Modified: head/sys/arm/rockchip/rk30xx_machdep.c
==============================================================================
--- head/sys/arm/rockchip/rk30xx_machdep.c	Sat May 17 11:26:54 2014	(r266300)
+++ head/sys/arm/rockchip/rk30xx_machdep.c	Sat May 17 11:27:36 2014	(r266301)
@@ -46,31 +46,32 @@ __FBSDID("$FreeBSD$");
 #include <machine/bus.h>
 #include <machine/devmap.h>
 #include <machine/machdep.h>
+#include <machine/platform.h> 
 
 #include <dev/fdt/fdt_common.h>
 
 #include <arm/rockchip/rk30xx_wdog.h>
 
 vm_offset_t
-initarm_lastaddr(void)
+platform_lastaddr(void)
 {
 
 	return (arm_devmap_lastaddr());
 }
 
 void
-initarm_early_init(void)
+platform_probe_and_attach(void)
 {
 
 }

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



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