ofwvar.h revision 186347
11558Srgrimes/*-
241061Sbde * Copyright (c) 2005 Peter Grehan
31558Srgrimes * Copyright (c) 2008 Nathan Whitehorn
412481Speter * All rights reserved.
51558Srgrimes *
641061Sbde * Redistribution and use in source and binary forms, with or without
741061Sbde * modification, are permitted provided that the following conditions
839271Sphk * are met:
939255Sgibbs * 1. Redistributions of source code must retain the above copyright
1038653Sgpalmer *    notice, this list of conditions and the following disclaimer.
1138653Sgpalmer * 2. Redistributions in binary form must reproduce the above copyright
1238653Sgpalmer *    notice, this list of conditions and the following disclaimer in the
1338653Sgpalmer *    documentation and/or other materials provided with the distribution.
1438653Sgpalmer *
1538653Sgpalmer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1638653Sgpalmer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1738653Sgpalmer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1838653Sgpalmer * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1938653Sgpalmer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2038653Sgpalmer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2138653Sgpalmer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2238653Sgpalmer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2338653Sgpalmer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2438653Sgpalmer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2538653Sgpalmer * SUCH DAMAGE.
2638653Sgpalmer *
2738653Sgpalmer * $FreeBSD: head/sys/dev/ofw/ofwvar.h 186347 2008-12-20 00:33:10Z nwhitehorn $
2838843Sjb */
2938653Sgpalmer
3038653Sgpalmer#ifndef _OFW_OFWVAR_H_
3138653Sgpalmer#define _OFW_OFWVAR_H_
3238653Sgpalmer
3338653Sgpalmer/*
3438653Sgpalmer * An Open Firmware client implementation is declared with a kernel object and
3538653Sgpalmer * an associated method table, similar to a device driver.
3638653Sgpalmer *
3738653Sgpalmer * e.g.
3838653Sgpalmer *
3938653Sgpalmer * static ofw_method_t fdt_methods[] = {
4038653Sgpalmer *	OFWMETHOD(ofw_init,		fdt_init),
4138653Sgpalmer *	OFWMETHOD(ofw_finddevice,	fdt_finddevice),
4238653Sgpalmer *  ...
4338653Sgpalmer *	OFWMETHOD(ofw_nextprop,		fdt_nextprop),
4438653Sgpalmer *	{ 0, 0 }
4538653Sgpalmer * };
4638653Sgpalmer *
4738653Sgpalmer * static ofw_def_t ofw_fdt = {
4838653Sgpalmer * 	"ofw_fdt",
4938653Sgpalmer *	fdt_methods,
5038653Sgpalmer *	sizeof(fdt_softc),	// or 0 if no softc
5138653Sgpalmer * };
5238653Sgpalmer *
5338653Sgpalmer * OFW_DEF(ofw_fdt);
5438653Sgpalmer */
5538653Sgpalmer
5638653Sgpalmer#include <sys/kobj.h>
5738653Sgpalmer
5841061Sbdestruct ofw_kobj {
5938653Sgpalmer	/*
6038653Sgpalmer	 * An OFW instance is a kernel object.
6138653Sgpalmer	 */
6239707Sgrog	KOBJ_FIELDS;
6339707Sgrog
6410855Sjoerg	/*
6538852Sjb	 * Utility elements that an instance may use
6638852Sjb	 */
6738458Sjb	struct mtx	ofw_mtx;	/* available for instance use */
6838458Sjb	void		*ofw_iptr;	/* instance data pointer */
691558Srgrimes
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 /* _OFW_OFWVAR_H_ */
90