xref: /titanic_53/usr/src/boot/sys/boot/ofw/libofw/openfirm.h (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1*4a5d661aSToomas Soome /*	$NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $	*/
2*4a5d661aSToomas Soome 
3*4a5d661aSToomas Soome /*-
4*4a5d661aSToomas Soome  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5*4a5d661aSToomas Soome  * Copyright (C) 1995, 1996 TooLs GmbH.
6*4a5d661aSToomas Soome  * All rights reserved.
7*4a5d661aSToomas Soome  *
8*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
9*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
10*4a5d661aSToomas Soome  * are met:
11*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
12*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
13*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
14*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
15*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
16*4a5d661aSToomas Soome  * 3. All advertising materials mentioning features or use of this software
17*4a5d661aSToomas Soome  *    must display the following acknowledgement:
18*4a5d661aSToomas Soome  *	This product includes software developed by TooLs GmbH.
19*4a5d661aSToomas Soome  * 4. The name of TooLs GmbH may not be used to endorse or promote products
20*4a5d661aSToomas Soome  *    derived from this software without specific prior written permission.
21*4a5d661aSToomas Soome  *
22*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23*4a5d661aSToomas Soome  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24*4a5d661aSToomas Soome  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25*4a5d661aSToomas Soome  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26*4a5d661aSToomas Soome  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27*4a5d661aSToomas Soome  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28*4a5d661aSToomas Soome  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29*4a5d661aSToomas Soome  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30*4a5d661aSToomas Soome  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31*4a5d661aSToomas Soome  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*4a5d661aSToomas Soome  */
33*4a5d661aSToomas Soome /*-
34*4a5d661aSToomas Soome  * Copyright (C) 2000 Benno Rice.
35*4a5d661aSToomas Soome  * All rights reserved.
36*4a5d661aSToomas Soome  *
37*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
38*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
39*4a5d661aSToomas Soome  * are met:
40*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
41*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
42*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
43*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
44*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
45*4a5d661aSToomas Soome  *
46*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
47*4a5d661aSToomas Soome  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48*4a5d661aSToomas Soome  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49*4a5d661aSToomas Soome  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50*4a5d661aSToomas Soome  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
51*4a5d661aSToomas Soome  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
52*4a5d661aSToomas Soome  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53*4a5d661aSToomas Soome  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
54*4a5d661aSToomas Soome  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
55*4a5d661aSToomas Soome  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56*4a5d661aSToomas Soome  *
57*4a5d661aSToomas Soome  * $FreeBSD$
58*4a5d661aSToomas Soome  */
59*4a5d661aSToomas Soome #ifndef _OPENFIRM_H_
60*4a5d661aSToomas Soome #define	_OPENFIRM_H_
61*4a5d661aSToomas Soome /*
62*4a5d661aSToomas Soome  * Prototypes for Open Firmware Interface Routines
63*4a5d661aSToomas Soome  */
64*4a5d661aSToomas Soome 
65*4a5d661aSToomas Soome #include <sys/cdefs.h>
66*4a5d661aSToomas Soome #include <sys/types.h>
67*4a5d661aSToomas Soome 
68*4a5d661aSToomas Soome typedef	unsigned int		ihandle_t;
69*4a5d661aSToomas Soome typedef unsigned int		phandle_t;
70*4a5d661aSToomas Soome typedef unsigned long int	cell_t;
71*4a5d661aSToomas Soome 
72*4a5d661aSToomas Soome extern int		(*openfirmware)(void *);
73*4a5d661aSToomas Soome extern phandle_t	chosen;
74*4a5d661aSToomas Soome extern ihandle_t	memory, mmu;
75*4a5d661aSToomas Soome extern int		real_mode;
76*4a5d661aSToomas Soome 
77*4a5d661aSToomas Soome /*
78*4a5d661aSToomas Soome  * This isn't actually an Open Firmware function, but it seemed like the right
79*4a5d661aSToomas Soome  * place for it to go.
80*4a5d661aSToomas Soome  */
81*4a5d661aSToomas Soome void		OF_init(int (*openfirm)(void *));
82*4a5d661aSToomas Soome 
83*4a5d661aSToomas Soome /* Generic functions */
84*4a5d661aSToomas Soome int		OF_test(char *);
85*4a5d661aSToomas Soome void		OF_quiesce(); /* Disable firmware */
86*4a5d661aSToomas Soome 
87*4a5d661aSToomas Soome /* Device tree functions */
88*4a5d661aSToomas Soome phandle_t	OF_peer(phandle_t);
89*4a5d661aSToomas Soome phandle_t	OF_child(phandle_t);
90*4a5d661aSToomas Soome phandle_t	OF_parent(phandle_t);
91*4a5d661aSToomas Soome phandle_t	OF_instance_to_package(ihandle_t);
92*4a5d661aSToomas Soome int		OF_getproplen(phandle_t, char *);
93*4a5d661aSToomas Soome int		OF_getprop(phandle_t, char *, void *, int);
94*4a5d661aSToomas Soome int		OF_nextprop(phandle_t, char *, char *);
95*4a5d661aSToomas Soome int		OF_setprop(phandle_t, char *, void *, int);
96*4a5d661aSToomas Soome int		OF_canon(const char *, char *, int);
97*4a5d661aSToomas Soome phandle_t	OF_finddevice(const char *);
98*4a5d661aSToomas Soome int		OF_instance_to_path(ihandle_t, char *, int);
99*4a5d661aSToomas Soome int		OF_package_to_path(phandle_t, char *, int);
100*4a5d661aSToomas Soome int		OF_call_method(char *, ihandle_t, int, int, ...);
101*4a5d661aSToomas Soome 
102*4a5d661aSToomas Soome /* Device I/O functions */
103*4a5d661aSToomas Soome ihandle_t	OF_open(char *);
104*4a5d661aSToomas Soome void		OF_close(ihandle_t);
105*4a5d661aSToomas Soome int		OF_read(ihandle_t, void *, int);
106*4a5d661aSToomas Soome int		OF_write(ihandle_t, void *, int);
107*4a5d661aSToomas Soome int		OF_seek(ihandle_t, u_quad_t);
108*4a5d661aSToomas Soome 
109*4a5d661aSToomas Soome /* Memory functions */
110*4a5d661aSToomas Soome void 		*OF_claim(void *, u_int, u_int);
111*4a5d661aSToomas Soome void		OF_release(void *, u_int);
112*4a5d661aSToomas Soome 
113*4a5d661aSToomas Soome /* Control transfer functions */
114*4a5d661aSToomas Soome void		OF_boot(char *);
115*4a5d661aSToomas Soome void		OF_enter(void);
116*4a5d661aSToomas Soome void		OF_exit(void) __attribute__((noreturn));
117*4a5d661aSToomas Soome void		OF_chain(void *, u_int, void (*)(), void *, u_int);
118*4a5d661aSToomas Soome 
119*4a5d661aSToomas Soome /* Time function */
120*4a5d661aSToomas Soome int		OF_milliseconds(void);
121*4a5d661aSToomas Soome 
122*4a5d661aSToomas Soome #endif /* _OPENFIRM_H_ */
123