Index: sys/arm/allwinner/a10_machdep.c =================================================================== --- sys/arm/allwinner/a10_machdep.c (revision 265871) +++ sys/arm/allwinner/a10_machdep.c (working copy) @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -51,7 +52,7 @@ #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -58,17 +59,17 @@ } 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 @@ * perhaps a 1MB block would be more appropriate. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { arm_devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */ Index: sys/arm/arm/machdep.c =================================================================== --- sys/arm/arm/machdep.c (revision 265871) +++ sys/arm/arm/machdep.c (working copy) @@ -98,6 +98,7 @@ #include #include #include +#include #include #include #include @@ -1095,7 +1096,7 @@ EXFLAG_NODUMP | EXFLAG_NOALLOC); /* Platform-specific initialisation */ - initarm_early_init(); + platform_probe_and_attach(); pcpu0_init(); @@ -1211,9 +1212,9 @@ 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; @@ -1233,7 +1234,7 @@ */ OF_interpret("perform-fixup", 0); - initarm_gpio_init(); + platform_gpio_init(); cninit(); @@ -1251,7 +1252,7 @@ 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 Index: sys/arm/arm/platform.c =================================================================== --- sys/arm/arm/platform.c (revision 0) +++ sys/arm/arm/platform.c (working copy) @@ -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 +__FBSDID("$FreeBSD$"); + +/* + * Dispatch platform calls to the appropriate platform implementation + * through a previously registered kernel object. + */ + +#define _ARM32_BUS_DMA_PRIVATE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#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); +} + Property changes on: sys/arm/arm/platform.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/arm/arm/platform_if.m =================================================================== --- sys/arm/arm/platform_if.m (revision 0) +++ sys/arm/arm/platform_if.m (working copy) @@ -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: projects/specific_leg/sys/powerpc/powerpc/platform_if.m 255417 2013-09-09 12:49:19Z nwhitehorn $ +# + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/** + * @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; +}; + Index: sys/arm/broadcom/bcm2835/bcm2835_machdep.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_machdep.c (revision 265871) +++ sys/arm/broadcom/bcm2835/bcm2835_machdep.c (working copy) @@ -54,32 +54,25 @@ #include #include #include +#include +#include #include #include -vm_offset_t -initarm_lastaddr(void) +#include "platform_if.h" + +static vm_offset_t +bcm2835_lastaddr(platform_t plat) { return (arm_devmap_lastaddr()); } -void -initarm_early_init(void) +static void +bcm2835_late_init(platform_t plat) { - -} - -void -initarm_gpio_init(void) -{ -} - -void -initarm_late_init(void) -{ phandle_t system; pcell_t cells[2]; int len; @@ -101,8 +94,8 @@ * 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 @@ 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"); + Index: sys/arm/conf/RPI-B =================================================================== --- sys/arm/conf/RPI-B (revision 265871) +++ sys/arm/conf/RPI-B (working copy) @@ -59,6 +59,7 @@ #options ROOTDEVNAME=\"ufs:mmcsd0s2\" options PREEMPTION +options PLATFORM device bpf device loop Index: sys/arm/freescale/imx/imx51_machdep.c =================================================================== --- sys/arm/freescale/imx/imx51_machdep.c (revision 265871) +++ sys/arm/freescale/imx/imx51_machdep.c (working copy) @@ -39,11 +39,12 @@ #include #include #include +#include #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -50,7 +51,7 @@ } void -initarm_early_init(void) +platform_probe_and_attach(void) { /* XXX - Get rid of this stuff soon. */ @@ -59,13 +60,13 @@ } void -initarm_gpio_init(void) +platform_gpio_init(void) { } void -initarm_late_init(void) +platform_late_init(void) { } @@ -78,7 +79,7 @@ * 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); Index: sys/arm/freescale/imx/imx53_machdep.c =================================================================== --- sys/arm/freescale/imx/imx53_machdep.c (revision 265871) +++ sys/arm/freescale/imx/imx53_machdep.c (working copy) @@ -39,10 +39,12 @@ #include #include #include +#include + #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -49,7 +51,7 @@ } void -initarm_early_init(void) +platform_probe_and_attach(void) { /* XXX - Get rid of this stuff soon. */ @@ -58,13 +60,13 @@ } void -initarm_gpio_init(void) +platform_gpio_init(void) { } void -initarm_late_init(void) +platform_late_init(void) { } @@ -77,7 +79,7 @@ * 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); Index: sys/arm/freescale/imx/imx6_machdep.c =================================================================== --- sys/arm/freescale/imx/imx6_machdep.c (revision 265871) +++ sys/arm/freescale/imx/imx6_machdep.c (working copy) @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -53,7 +54,7 @@ } void -initarm_early_init(void) +platform_probe_and_attach(void) { /* Inform the MPCore timer driver that its clock is variable. */ @@ -61,13 +62,13 @@ } void -initarm_gpio_init(void) +platform_gpio_init(void) { } void -initarm_late_init(void) +platform_late_init(void) { } @@ -89,7 +90,7 @@ * 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; Index: sys/arm/freescale/vybrid/vf_machdep.c =================================================================== --- sys/arm/freescale/vybrid/vf_machdep.c (revision 265871) +++ sys/arm/freescale/vybrid/vf_machdep.c (working copy) @@ -41,11 +41,12 @@ #include #include #include +#include #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -52,25 +53,25 @@ } 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); Index: sys/arm/include/machdep.h =================================================================== --- sys/arm/include/machdep.h (revision 265871) +++ sys/arm/include/machdep.h (working copy) @@ -34,40 +34,6 @@ 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); Index: sys/arm/include/platform.h =================================================================== --- sys/arm/include/platform.h (revision 0) +++ sys/arm/include/platform.h (working copy) @@ -0,0 +1,37 @@ +/*- + * 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. + * + */ + +#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_ */ Property changes on: sys/arm/include/platform.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/arm/include/platformvar.h =================================================================== --- sys/arm/include/platformvar.h (revision 0) +++ sys/arm/include/platformvar.h (working copy) @@ -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 +#include + +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_ */ Property changes on: sys/arm/include/platformvar.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: sys/arm/lpc/lpc_machdep.c =================================================================== --- sys/arm/lpc/lpc_machdep.c (revision 265871) +++ sys/arm/lpc/lpc_machdep.c (working copy) @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,7 @@ #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -67,12 +68,12 @@ } void -initarm_early_init(void) +platform_probe_and_attach(void) { } void -initarm_gpio_init(void) +platform_gpio_init(void) { /* @@ -82,7 +83,7 @@ } void -initarm_late_init(void) +platform_late_init(void) { } @@ -92,7 +93,7 @@ * 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); Index: sys/arm/mv/mv_machdep.c =================================================================== --- sys/arm/mv/mv_machdep.c (revision 265871) +++ sys/arm/mv/mv_machdep.c (working copy) @@ -53,6 +53,7 @@ #include #include #include +#include #include /* XXX */ #include /* XXX eventually this should be eliminated */ @@ -201,7 +202,7 @@ } vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (fdt_immr_va); @@ -208,7 +209,7 @@ } void -initarm_early_init(void) +platform_probe_and_attach(void) { if (fdt_immr_addr(MV_BASE) != 0) @@ -216,7 +217,7 @@ } void -initarm_gpio_init(void) +platform_gpio_init(void) { /* @@ -228,7 +229,7 @@ } void -initarm_late_init(void) +platform_late_init(void) { /* * Re-initialise decode windows @@ -297,7 +298,7 @@ * 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 @@ * 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; Index: sys/arm/rockchip/rk30xx_machdep.c =================================================================== --- sys/arm/rockchip/rk30xx_machdep.c (revision 265871) +++ sys/arm/rockchip/rk30xx_machdep.c (working copy) @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -52,7 +53,7 @@ #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -59,18 +60,18 @@ } 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) { /* Enable cache */ @@ -82,7 +83,7 @@ * Set up static device mappings. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { arm_devmap_add_entry(0x10000000, 0x00200000); Index: sys/arm/samsung/exynos/exynos5_machdep.c =================================================================== --- sys/arm/samsung/exynos/exynos5_machdep.c (revision 265871) +++ sys/arm/samsung/exynos/exynos5_machdep.c (working copy) @@ -41,11 +41,12 @@ #include #include #include +#include #include vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -52,25 +53,25 @@ } 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) { /* UART */ Index: sys/arm/tegra/tegra2_machdep.c =================================================================== --- sys/arm/tegra/tegra2_machdep.c (revision 265871) +++ sys/arm/tegra/tegra2_machdep.c (working copy) @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -99,7 +100,7 @@ #endif vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -106,17 +107,17 @@ } 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) { } @@ -126,7 +127,7 @@ * before conversion to the newer arm_devmap_add_entry() routine. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { arm_devmap_add_entry(0x70000000, 0x00100000); Index: sys/arm/ti/ti_machdep.c =================================================================== --- sys/arm/ti/ti_machdep.c (revision 265871) +++ sys/arm/ti/ti_machdep.c (working copy) @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -57,7 +58,7 @@ void (*ti_cpu_reset)(void) = NULL; vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -64,17 +65,17 @@ } 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 @@ * peripherals using 1mb section mappings. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { #if defined(SOC_OMAP4) arm_devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ Index: sys/arm/versatile/versatile_machdep.c =================================================================== --- sys/arm/versatile/versatile_machdep.c (revision 265871) +++ sys/arm/versatile/versatile_machdep.c (working copy) @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -58,7 +59,7 @@ #define DEVMAP_BOOTSTRAP_MAP_START 0xE0000000 vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (DEVMAP_BOOTSTRAP_MAP_START); @@ -65,18 +66,18 @@ } 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) { } @@ -91,7 +92,7 @@ * Construct pmap_devmap[] with DT-derived config data. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { int i = 0; fdt_devmap[i].pd_va = 0xf0100000; Index: sys/arm/xilinx/zy7_machdep.c =================================================================== --- sys/arm/xilinx/zy7_machdep.c (revision 265871) +++ sys/arm/xilinx/zy7_machdep.c (working copy) @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -57,7 +58,7 @@ void (*zynq7_cpu_reset)(void); vm_offset_t -initarm_lastaddr(void) +platform_lastaddr(void) { return (arm_devmap_lastaddr()); @@ -64,18 +65,18 @@ } 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) { } @@ -85,7 +86,7 @@ * nice efficient 1MB section mappings. */ int -initarm_devmap_init(void) +platform_devmap_init(void) { arm_devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE); Index: sys/conf/files.arm =================================================================== --- sys/conf/files.arm (revision 265871) +++ sys/conf/files.arm (working copy) @@ -36,6 +36,8 @@ arm/arm/physmem.c standard arm/arm/pl190.c optional pl190 arm/arm/pl310.c optional pl310 +arm/arm/platform.c optional platform +arm/arm/platform_if.m optional platform arm/arm/pmap.c optional cpu_arm9 | cpu_arm9e | cpu_fa526 | cpu_xscale_80219 | cpu_xscale_80321 | cpu_xscale_81342 | cpu_xscale_ixp425 | cpu_xscale_ixp435 | cpu_xscale_pxa2x0 arm/arm/pmap-v6.c optional cpu_arm1136 | cpu_arm1176 | cpu_cortexa | cpu_mv_pj4b | cpu_krait arm/arm/sc_machdep.c optional sc @@ -61,6 +63,7 @@ crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/fb/fb.c optional sc +dev/fdt/fdt_arm_platform.c optional platform fdt dev/hwpmc/hwpmc_arm.c optional hwpmc dev/kbd/kbd.c optional sc | vt dev/syscons/scgfbrndr.c optional sc Index: sys/conf/options.arm =================================================================== --- sys/conf/options.arm (revision 265871) +++ sys/conf/options.arm (working copy) @@ -31,6 +31,7 @@ LINUX_BOOT_ABI opt_global.h LOADERRAMADDR opt_global.h PHYSADDR opt_global.h +PLATFORM opt_global.h SOCDEV_PA opt_global.h SOCDEV_VA opt_global.h PV_STATS opt_pmap.h Index: sys/dev/fdt/fdt_arm_platform.c =================================================================== --- sys/dev/fdt/fdt_arm_platform.c (revision 0) +++ sys/dev/fdt/fdt_arm_platform.c (working copy) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2013 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 + +#include +#include + +#include +#include + +#include "platform_if.h" + +#define FDT_PLATFORM(plat) \ + ((fdt_platform_def_t *)(plat)->cls->baseclasses[0]) + +static int +fdt_platform_probe(platform_t plat) +{ + const char *compat; + phandle_t root; + + /* + * TODO: Make these KASSERTs, we should only be here if we + * are using the FDT platform magic. + */ + if (plat->cls == NULL || FDT_PLATFORM(plat) == NULL) + return 1; + + /* Is the device is compatible? */ + root = OF_finddevice("/"); + compat = FDT_PLATFORM(plat)->fdt_compatible; + if (fdt_is_compatible(root, compat) != 0) + return 0; + + /* Not compatible, return an error */ + return 1; +} + +platform_method_t fdt_platform_methods[] = { + PLATFORMMETHOD(platform_probe, fdt_platform_probe), + PLATFORMMETHOD_END +}; + Property changes on: sys/dev/fdt/fdt_arm_platform.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property