xref: /freebsd/sys/powerpc/include/platformvar.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1b40ce02aSNathan Whitehorn /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
371e3c308SPedro F. Giffuni  *
4b40ce02aSNathan Whitehorn  * Copyright (c) 2005 Peter Grehan
5b40ce02aSNathan Whitehorn  * All rights reserved.
6b40ce02aSNathan Whitehorn  *
7b40ce02aSNathan Whitehorn  * Redistribution and use in source and binary forms, with or without
8b40ce02aSNathan Whitehorn  * modification, are permitted provided that the following conditions
9b40ce02aSNathan Whitehorn  * are met:
10b40ce02aSNathan Whitehorn  * 1. Redistributions of source code must retain the above copyright
11b40ce02aSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer.
12b40ce02aSNathan Whitehorn  * 2. Redistributions in binary form must reproduce the above copyright
13b40ce02aSNathan Whitehorn  *    notice, this list of conditions and the following disclaimer in the
14b40ce02aSNathan Whitehorn  *    documentation and/or other materials provided with the distribution.
15b40ce02aSNathan Whitehorn  *
16b40ce02aSNathan Whitehorn  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17b40ce02aSNathan Whitehorn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18b40ce02aSNathan Whitehorn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19b40ce02aSNathan Whitehorn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20b40ce02aSNathan Whitehorn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21b40ce02aSNathan Whitehorn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22b40ce02aSNathan Whitehorn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23b40ce02aSNathan Whitehorn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24b40ce02aSNathan Whitehorn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25b40ce02aSNathan Whitehorn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26b40ce02aSNathan Whitehorn  * SUCH DAMAGE.
27b40ce02aSNathan Whitehorn  */
28b40ce02aSNathan Whitehorn 
29b40ce02aSNathan Whitehorn #ifndef _MACHINE_PLATFORMVAR_H_
30b40ce02aSNathan Whitehorn #define _MACHINE_PLATFORMVAR_H_
31b40ce02aSNathan Whitehorn 
32b40ce02aSNathan Whitehorn /*
33b40ce02aSNathan Whitehorn  * A PowerPC platform implementation is declared with a kernel object and
34b40ce02aSNathan Whitehorn  * an associated method table, similar to a device driver.
35b40ce02aSNathan Whitehorn  *
36b40ce02aSNathan Whitehorn  * e.g.
37b40ce02aSNathan Whitehorn  *
38b40ce02aSNathan Whitehorn  * static platform_method_t chrp_methods[] = {
39b40ce02aSNathan Whitehorn  *	PLATFORMMETHOD(platform_probe,		chrp_probe),
40b40ce02aSNathan Whitehorn  *	PLATFORMMETHOD(platform_mem_regions,	ofw_mem_regions),
41b40ce02aSNathan Whitehorn  *  ...
42b40ce02aSNathan Whitehorn  *	PLATFORMMETHOD(platform_smp_first_cpu,	chrp_smp_first_cpu),
43b40ce02aSNathan Whitehorn  *	{ 0, 0 }
44b40ce02aSNathan Whitehorn  * };
45b40ce02aSNathan Whitehorn  *
46b40ce02aSNathan Whitehorn  * static platform_def_t chrp_platform = {
47b40ce02aSNathan Whitehorn  * 	"chrp",
48b40ce02aSNathan Whitehorn  *	chrp_methods,
49b40ce02aSNathan Whitehorn  *	sizeof(chrp_platform_softc),	// or 0 if no softc
50b40ce02aSNathan Whitehorn  * };
51b40ce02aSNathan Whitehorn  *
52b40ce02aSNathan Whitehorn  * PLATFORM_DEF(chrp_platform);
53b40ce02aSNathan Whitehorn  */
54b40ce02aSNathan Whitehorn 
55b40ce02aSNathan Whitehorn #include <sys/kobj.h>
56b40ce02aSNathan Whitehorn 
57b40ce02aSNathan Whitehorn struct platform_kobj {
58b40ce02aSNathan Whitehorn 	/*
59b40ce02aSNathan Whitehorn 	 * A platform instance is a kernel object
60b40ce02aSNathan Whitehorn 	 */
61b40ce02aSNathan Whitehorn 	KOBJ_FIELDS;
62b40ce02aSNathan Whitehorn 
63b40ce02aSNathan Whitehorn 	/*
64b40ce02aSNathan Whitehorn 	 * Utility elements that an instance may use
65b40ce02aSNathan Whitehorn 	 */
66b40ce02aSNathan Whitehorn 	struct mtx	platform_mtx;	/* available for instance use */
67b40ce02aSNathan Whitehorn 	void		*platform_iptr;	/* instance data pointer */
68b40ce02aSNathan Whitehorn 
69b40ce02aSNathan Whitehorn 	/*
70b40ce02aSNathan Whitehorn 	 * Opaque data that can be overlaid with an instance-private
71b40ce02aSNathan Whitehorn 	 * structure. Platform code can test that this is large enough at
72b40ce02aSNathan Whitehorn 	 * compile time with a sizeof() test againt it's softc. There
73b40ce02aSNathan Whitehorn 	 * is also a run-time test when the platform kernel object is
74b40ce02aSNathan Whitehorn 	 * registered.
75b40ce02aSNathan Whitehorn 	 */
76b40ce02aSNathan Whitehorn #define PLATFORM_OPAQUESZ	64
77b40ce02aSNathan Whitehorn 	u_int		platform_opaque[PLATFORM_OPAQUESZ];
78b40ce02aSNathan Whitehorn };
79b40ce02aSNathan Whitehorn 
80b40ce02aSNathan Whitehorn typedef struct platform_kobj	*platform_t;
81b40ce02aSNathan Whitehorn typedef struct kobj_class	platform_def_t;
82b40ce02aSNathan Whitehorn #define platform_method_t	kobj_method_t
83b40ce02aSNathan Whitehorn 
84b40ce02aSNathan Whitehorn #define PLATFORMMETHOD		KOBJMETHOD
85eaba9848SRui Paulo #define	PLATFORMMETHOD_END	KOBJMETHOD_END
86b40ce02aSNathan Whitehorn 
87b40ce02aSNathan Whitehorn #define PLATFORM_DEF(name)	DATA_SET(platform_set, name)
88b40ce02aSNathan Whitehorn 
89b40ce02aSNathan Whitehorn #endif /* _MACHINE_PLATFORMVAR_H_ */
90