From owner-svn-src-projects@FreeBSD.ORG Sun Nov 24 12:48:57 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 67E5FE13; Sun, 24 Nov 2013 12:48:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 557342F84; Sun, 24 Nov 2013 12:48:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAOCmvWZ085414; Sun, 24 Nov 2013 12:48:57 GMT (envelope-from andrew@svn.freebsd.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAOCmtDe085398; Sun, 24 Nov 2013 12:48:55 GMT (envelope-from andrew@svn.freebsd.org) Message-Id: <201311241248.rAOCmtDe085398@svn.freebsd.org> From: Andrew Turner Date: Sun, 24 Nov 2013 12:48:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r258525 - in projects/specific_leg/sys: arm/arm arm/broadcom/bcm2835 arm/include conf dev/fdt X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Nov 2013 12:48:57 -0000 Author: andrew Date: Sun Nov 24 12:48:55 2013 New Revision: 258525 URL: http://svnweb.freebsd.org/changeset/base/258525 Log: Add the start of the platform code. This is mostly copied from PowerPC. The machine independent parts will be merged later when these parts have been found. Added: projects/specific_leg/sys/arm/arm/platform.c (contents, props changed) projects/specific_leg/sys/arm/arm/platform_if.m projects/specific_leg/sys/arm/include/platform.h (contents, props changed) projects/specific_leg/sys/arm/include/platformvar.h (contents, props changed) projects/specific_leg/sys/dev/fdt/fdt_platform.c (contents, props changed) Modified: projects/specific_leg/sys/arm/arm/machdep.c projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c projects/specific_leg/sys/arm/include/fdt.h projects/specific_leg/sys/conf/files.arm Modified: projects/specific_leg/sys/arm/arm/machdep.c ============================================================================== --- projects/specific_leg/sys/arm/arm/machdep.c Sun Nov 24 11:55:07 2013 (r258524) +++ projects/specific_leg/sys/arm/arm/machdep.c Sun Nov 24 12:48:55 2013 (r258525) @@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1238,6 +1239,8 @@ initarm(struct arm_boot_params *abp) if (OF_init((void *)dtbp) != 0) while (1); + platform_probe_and_attach(); + /* Grab physical memory regions information from device tree. */ if (fdt_get_mem_regions(memory_regions, &memory_regions_sz, &memsize) != 0) Added: projects/specific_leg/sys/arm/arm/platform.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/specific_leg/sys/arm/arm/platform.c Sun Nov 24 12:48:55 2013 (r258525) @@ -0,0 +1,248 @@ +/*- + * 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. + */ + +#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_RD | CTLFLAG_TUN, + plat_name, 0, "Platform currently in use"); + +static struct mem_region *pregions = NULL; +static struct mem_region *aregions = NULL; +static int npregions, naregions; + +void +mem_regions(struct mem_region **phys, int *physsz, struct mem_region **avail, + int *availsz) +{ + if (pregions == NULL) + PLATFORM_MEM_REGIONS(plat_obj, &pregions, &npregions, + &aregions, &naregions); + + *phys = pregions; + *avail = aregions; + *physsz = npregions; + *availsz = naregions; +} + +#if 0 +int +mem_valid(vm_offset_t addr, int len) +{ + int i; + + if (pregions == NULL) + PLATFORM_MEM_REGIONS(plat_obj, &pregions, &npregions, + &aregions, &naregions); + + for (i = 0; i < npregions; i++) + if ((addr >= pregions[i].mr_start) + && (addr + len <= pregions[i].mr_start + pregions[i].mr_size)) + return (0); + + return (EFAULT); +} +#endif + +vm_offset_t +platform_real_maxaddr(void) +{ + return (PLATFORM_REAL_MAXADDR(plat_obj)); +} + +#if 0 +const char * +installed_platform() +{ + return (plat_def_impl->name); +} + +u_long +platform_timebase_freq(struct cpuref *cpu) +{ + return (PLATFORM_TIMEBASE_FREQ(plat_obj, cpu)); +} + +int +platform_smp_first_cpu(struct cpuref *cpu) +{ + return (PLATFORM_SMP_FIRST_CPU(plat_obj, cpu)); +} + +int +platform_smp_next_cpu(struct cpuref *cpu) +{ + return (PLATFORM_SMP_NEXT_CPU(plat_obj, cpu)); +} + +int +platform_smp_get_bsp(struct cpuref *cpu) +{ + return (PLATFORM_SMP_GET_BSP(plat_obj, cpu)); +} + +int +platform_smp_start_cpu(struct pcpu *cpu) +{ + return (PLATFORM_SMP_START_CPU(plat_obj, cpu)); +} + +void +platform_smp_ap_init() +{ + PLATFORM_SMP_AP_INIT(plat_obj); +} +#endif + +#ifdef SMP +struct cpu_group * +cpu_topo(void) +{ + return (PLATFORM_SMP_TOPO(plat_obj)); +} +#endif + +#if 0 +/* + * Reset back to firmware. + */ +void +cpu_reset() +{ + PLATFORM_RESET(plat_obj); +} +#endif + +/* + * 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; + +printf("platform_probe_and_attach\n"); + /* + * Try to locate the best platform kobj + */ + SET_FOREACH(platpp, platform_set) { + platp = *platpp; +printf("platp = %p %p\n", platp, platp->baseclasses); + + /* + * 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); +} + Added: projects/specific_leg/sys/arm/arm/platform_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/specific_leg/sys/arm/arm/platform_if.m Sun Nov 24 12:48:55 2013 (r258525) @@ -0,0 +1,108 @@ +#- +# 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 + +/** + * @defgroup PLATFORM platform - KObj methods for PowerPC 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; + } +#if 0 + static int platform_null_smp_first_cpu(platform_t plat, + struct cpuref *cpuref) + { + cpuref->cr_hwref = -1; + cpuref->cr_cpuid = 0; + return (0); + } + static int platform_null_smp_next_cpu(platform_t plat, + struct cpuref *_cpuref) + { + return (ENOENT); + } + static struct cpu_group *platform_null_smp_topo(platform_t plat) + { +#ifdef SMP + return (smp_topo_none()); +#else + return (NULL); +#endif + } +#endif + static vm_offset_t platform_null_real_maxaddr(platform_t plat) + { + return (VM_MAX_ADDRESS); + } + static void platform_null_smp_ap_init(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; + Modified: projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Nov 24 11:55:07 2013 (r258524) +++ projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Nov 24 12:48:55 2013 (r258525) @@ -54,11 +54,14 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include "platform_if.h" + /* Start of address space used for bootstrap map */ #define DEVMAP_BOOTSTRAP_MAP_START 0xE0000000 @@ -145,3 +148,9 @@ cpu_reset() while (1); } +static platform_method_t bcm2835_methods[] = { + PLATFORMMETHOD_END, +}; + +FDT_PLATFORM_DEF(bcm2835, "bcm2835", 0, "raspberrypi,model-b"); + Modified: projects/specific_leg/sys/arm/include/fdt.h ============================================================================== --- projects/specific_leg/sys/arm/include/fdt.h Sun Nov 24 11:55:07 2013 (r258524) +++ projects/specific_leg/sys/arm/include/fdt.h Sun Nov 24 12:48:55 2013 (r258525) @@ -39,6 +39,7 @@ #include #include +#include /* Max interrupt number */ #define FDT_INTR_MAX NIRQ @@ -51,11 +52,6 @@ */ extern bus_space_tag_t fdtbus_bs_tag; -struct mem_region { - vm_offset_t mr_start; - vm_size_t mr_size; -}; - struct arm_devmap_entry; int fdt_localbus_devmap(phandle_t, struct arm_devmap_entry *, int, int *); Added: projects/specific_leg/sys/arm/include/platform.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/specific_leg/sys/arm/include/platform.h Sun Nov 24 12:48:55 2013 (r258525) @@ -0,0 +1,59 @@ +/*- + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + * + * $NetBSD: powerpc.h,v 1.3 2000/06/01 00:49:59 matt Exp $ + * $FreeBSD$ + */ + +#ifndef _MACHINE_PLATFORM_H_ +#define _MACHINE_PLATFORM_H_ + +struct mem_region { + vm_offset_t mr_start; + vm_size_t mr_size; +}; + +void mem_regions(struct mem_region **, int *, struct mem_region **, int *); +vm_offset_t platform_real_maxaddr(void); + +#if 0 +u_long platform_timebase_freq(struct cpuref *); + +int platform_smp_first_cpu(struct cpuref *); +int platform_smp_next_cpu(struct cpuref *); +int platform_smp_get_bsp(struct cpuref *); +int platform_smp_start_cpu(struct pcpu *); +void platform_smp_ap_init(void); + +const char *installed_platform(void); +#endif +void platform_probe_and_attach(void); + +#endif /* _MACHINE_PLATFORM_H_ */ Added: projects/specific_leg/sys/arm/include/platformvar.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/specific_leg/sys/arm/include/platformvar.h Sun Nov 24 12:48:55 2013 (r258525) @@ -0,0 +1,124 @@ +/*- + * 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_ + +/* + * A PowerPC platform implementation is declared with a kernel object and + * an associated method table, similar to a device driver. + * + * e.g. + * + * static platform_method_t chrp_methods[] = { + * PLATFORMMETHOD(platform_probe, chrp_probe), + * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions), + * ... + * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu), + * PLATFORMMETHOD_END + * }; + * + * static platform_def_t chrp_platform = { + * "chrp", + * chrp_methods, + * sizeof(chrp_platform_softc), // or 0 if no softc + * }; + * + * PLATFORM_DEF(chrp_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; + +#if 0 + /* + * Utility elements that an instance may use + */ + struct mtx platform_mtx; /* available for instance use */ + void *platform_iptr; /* instance data pointer */ + + /* + * Opaque data that can be overlaid with an instance-private + * structure. Platform code can test that this is large enough at + * compile time with a sizeof() test againt it's softc. There + * is also a run-time test when the platform kernel object is + * registered. + */ +#define PLATFORM_OPAQUESZ 64 + u_int platform_opaque[PLATFORM_OPAQUESZ]; +#endif +}; + +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: projects/specific_leg/sys/conf/files.arm ============================================================================== --- projects/specific_leg/sys/conf/files.arm Sun Nov 24 11:55:07 2013 (r258524) +++ projects/specific_leg/sys/conf/files.arm Sun Nov 24 12:48:55 2013 (r258525) @@ -35,6 +35,8 @@ arm/arm/mp_machdep.c optional smp arm/arm/nexus.c standard arm/arm/pl190.c optional pl190 arm/arm/pl310.c optional pl310 +arm/arm/platform.c standard +arm/arm/platform_if.m standard arm/arm/pmap.c optional cpu_arm9 | cpu_arm9e | cpu_fa526 | cpu_sa1100 | cpu_sa1110 | 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 arm/arm/sc_machdep.c optional sc @@ -61,6 +63,7 @@ cddl/compat/opensolaris/kern/opensolaris 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_platform.c optional fdt dev/hwpmc/hwpmc_arm.c optional hwpmc dev/kbd/kbd.c optional sc dev/syscons/scgfbrndr.c optional sc Added: projects/specific_leg/sys/dev/fdt/fdt_platform.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/specific_leg/sys/dev/fdt/fdt_platform.c Sun Nov 24 12:48:55 2013 (r258525) @@ -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 +}; +