115885Sjulian/*- 215885Sjulian * SPDX-License-Identifier: BSD-2-Clause 315885Sjulian * 415885Sjulian * Copyright (c) 2005 Peter Grehan 515885Sjulian * Copyright (c) 2008 Nathan Whitehorn 615885Sjulian * All rights reserved. 715885Sjulian * 815885Sjulian * Redistribution and use in source and binary forms, with or without 915885Sjulian * modification, are permitted provided that the following conditions 1015885Sjulian * are met: 1115885Sjulian * 1. Redistributions of source code must retain the above copyright 1215885Sjulian * notice, this list of conditions and the following disclaimer. 1315885Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1415885Sjulian * notice, this list of conditions and the following disclaimer in the 1515885Sjulian * documentation and/or other materials provided with the distribution. 1615885Sjulian * 1715885Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1815885Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1915885Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2015885Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2115885Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2215885Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2315885Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2415885Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2515885Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2615885Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2715885Sjulian * SUCH DAMAGE. 2815885Sjulian */ 2915885Sjulian 3015885Sjulian#ifndef _DEV_OFW_OFWVAR_H_ 3115885Sjulian#define _DEV_OFW_OFWVAR_H_ 3215885Sjulian 3315885Sjulian/* 3415885Sjulian * An Open Firmware client implementation is declared with a kernel object and 3515885Sjulian * an associated method table, similar to a device driver. 3615885Sjulian * 3715885Sjulian * e.g. 3815885Sjulian * 3915885Sjulian * static ofw_method_t fdt_methods[] = { 4015885Sjulian * OFWMETHOD(ofw_init, fdt_init), 4115885Sjulian * OFWMETHOD(ofw_finddevice, fdt_finddevice), 4215885Sjulian * ... 4315885Sjulian * OFWMETHOD(ofw_nextprop, fdt_nextprop), 4415885Sjulian * { 0, 0 } 4515885Sjulian * }; 4615885Sjulian * 4715885Sjulian * static ofw_def_t ofw_fdt = { 4815885Sjulian * "ofw_fdt", 4915885Sjulian * fdt_methods, 5015885Sjulian * sizeof(fdt_softc), // or 0 if no softc 5115885Sjulian * }; 5215885Sjulian * 5315885Sjulian * OFW_DEF(ofw_fdt); 5415885Sjulian */ 5515885Sjulian 5615885Sjulian#include <sys/kobj.h> 5715885Sjulian 5815885Sjulianstruct ofw_kobj { 5915885Sjulian /* 6015885Sjulian * An OFW instance is a kernel object. 6115885Sjulian */ 6215885Sjulian KOBJ_FIELDS; 63 64 /* 65 * Utility elements that an instance may use 66 */ 67 struct mtx ofw_mtx; /* available for instance use */ 68 void *ofw_iptr; /* instance data pointer */ 69 70 /* 71 * Opaque data that can be overlaid with an instance-private 72 * structure. OFW code can test that this is large enough at 73 * compile time with a sizeof() test againt it's softc. There 74 * is also a run-time test when the MMU kernel object is 75 * registered. 76 */ 77#define OFW_OPAQUESZ 64 78 u_int ofw_opaque[OFW_OPAQUESZ]; 79}; 80 81typedef struct ofw_kobj *ofw_t; 82typedef struct kobj_class ofw_def_t; 83 84#define ofw_method_t kobj_method_t 85#define OFWMETHOD KOBJMETHOD 86 87#define OFW_DEF(name) DATA_SET(ofw_set, name) 88 89#endif /* _DEV_OFW_OFWVAR_H_ */ 90