1192067Snwhitehorn/*- 2192067Snwhitehorn * Copyright (c) 2005 Peter Grehan 3192067Snwhitehorn * All rights reserved. 4192067Snwhitehorn * 5192067Snwhitehorn * Redistribution and use in source and binary forms, with or without 6192067Snwhitehorn * modification, are permitted provided that the following conditions 7192067Snwhitehorn * are met: 8192067Snwhitehorn * 1. Redistributions of source code must retain the above copyright 9192067Snwhitehorn * notice, this list of conditions and the following disclaimer. 10192067Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 11192067Snwhitehorn * notice, this list of conditions and the following disclaimer in the 12192067Snwhitehorn * documentation and/or other materials provided with the distribution. 13192067Snwhitehorn * 14192067Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15192067Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16192067Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17192067Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18192067Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19192067Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20192067Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21192067Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22192067Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23192067Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24192067Snwhitehorn * SUCH DAMAGE. 25192067Snwhitehorn * 26192067Snwhitehorn * $FreeBSD: releng/10.3/sys/powerpc/include/platformvar.h 246732 2013-02-13 02:21:45Z rpaulo $ 27192067Snwhitehorn */ 28192067Snwhitehorn 29192067Snwhitehorn#ifndef _MACHINE_PLATFORMVAR_H_ 30192067Snwhitehorn#define _MACHINE_PLATFORMVAR_H_ 31192067Snwhitehorn 32192067Snwhitehorn/* 33192067Snwhitehorn * A PowerPC platform implementation is declared with a kernel object and 34192067Snwhitehorn * an associated method table, similar to a device driver. 35192067Snwhitehorn * 36192067Snwhitehorn * e.g. 37192067Snwhitehorn * 38192067Snwhitehorn * static platform_method_t chrp_methods[] = { 39192067Snwhitehorn * PLATFORMMETHOD(platform_probe, chrp_probe), 40192067Snwhitehorn * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions), 41192067Snwhitehorn * ... 42192067Snwhitehorn * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu), 43192067Snwhitehorn * { 0, 0 } 44192067Snwhitehorn * }; 45192067Snwhitehorn * 46192067Snwhitehorn * static platform_def_t chrp_platform = { 47192067Snwhitehorn * "chrp", 48192067Snwhitehorn * chrp_methods, 49192067Snwhitehorn * sizeof(chrp_platform_softc), // or 0 if no softc 50192067Snwhitehorn * }; 51192067Snwhitehorn * 52192067Snwhitehorn * PLATFORM_DEF(chrp_platform); 53192067Snwhitehorn */ 54192067Snwhitehorn 55192067Snwhitehorn#include <sys/kobj.h> 56192067Snwhitehorn 57192067Snwhitehornstruct platform_kobj { 58192067Snwhitehorn /* 59192067Snwhitehorn * A platform instance is a kernel object 60192067Snwhitehorn */ 61192067Snwhitehorn KOBJ_FIELDS; 62192067Snwhitehorn 63192067Snwhitehorn /* 64192067Snwhitehorn * Utility elements that an instance may use 65192067Snwhitehorn */ 66192067Snwhitehorn struct mtx platform_mtx; /* available for instance use */ 67192067Snwhitehorn void *platform_iptr; /* instance data pointer */ 68192067Snwhitehorn 69192067Snwhitehorn /* 70192067Snwhitehorn * Opaque data that can be overlaid with an instance-private 71192067Snwhitehorn * structure. Platform code can test that this is large enough at 72192067Snwhitehorn * compile time with a sizeof() test againt it's softc. There 73192067Snwhitehorn * is also a run-time test when the platform kernel object is 74192067Snwhitehorn * registered. 75192067Snwhitehorn */ 76192067Snwhitehorn#define PLATFORM_OPAQUESZ 64 77192067Snwhitehorn u_int platform_opaque[PLATFORM_OPAQUESZ]; 78192067Snwhitehorn}; 79192067Snwhitehorn 80192067Snwhitehorntypedef struct platform_kobj *platform_t; 81192067Snwhitehorntypedef struct kobj_class platform_def_t; 82192067Snwhitehorn#define platform_method_t kobj_method_t 83192067Snwhitehorn 84246732Srpaulo#define PLATFORMMETHOD KOBJMETHOD 85246732Srpaulo#define PLATFORMMETHOD_END KOBJMETHOD_END 86192067Snwhitehorn 87192067Snwhitehorn#define PLATFORM_DEF(name) DATA_SET(platform_set, name) 88192067Snwhitehorn 89192067Snwhitehorn#endif /* _MACHINE_PLATFORMVAR_H_ */ 90