xref: /titanic_54/usr/src/uts/sun/sys/promimpl.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_PROMIMPL_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_PROMIMPL_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * promif implementation header file; private to promif implementation.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * These interfaces are not 'exported' in the same sense as
36*7c478bd9Sstevel@tonic-gate  * those described in promif.h
37*7c478bd9Sstevel@tonic-gate  *
38*7c478bd9Sstevel@tonic-gate  * Used so that the kernel and other stand-alones (eg boot)
39*7c478bd9Sstevel@tonic-gate  * don't have to directly reference the prom (of which there
40*7c478bd9Sstevel@tonic-gate  * are now several completely different variants).
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/promif.h>
45*7c478bd9Sstevel@tonic-gate #include <sys/prom_isa.h>
46*7c478bd9Sstevel@tonic-gate #if defined(_MACHDEP)
47*7c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h>
48*7c478bd9Sstevel@tonic-gate #endif
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
51*7c478bd9Sstevel@tonic-gate extern "C" {
52*7c478bd9Sstevel@tonic-gate #endif
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate extern int obp_romvec_version;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate /*
57*7c478bd9Sstevel@tonic-gate  * XXX for chatty stuff in prom_stdinpath/prom_stdoutpath until proposed
58*7c478bd9Sstevel@tonic-gate  * changes from romvec pathnames to root node properties for stdin/stdout
59*7c478bd9Sstevel@tonic-gate  * pathnames.
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate /* #define	PROM_DEBUG_STDPATH	1 */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /*
65*7c478bd9Sstevel@tonic-gate  * Debugging macros for the promif functions.
66*7c478bd9Sstevel@tonic-gate  */
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	PROMIF_DMSG_VERBOSE		2
69*7c478bd9Sstevel@tonic-gate #define	PROMIF_DMSG_NORMAL		1
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate extern int promif_debug;		/* externally patchable */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate #define	PROMIF_DEBUG			/* define this to enable debugging */
74*7c478bd9Sstevel@tonic-gate #define	PROMIF_DEBUG_P1275		/* Debug 1275 client interface calls */
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #ifdef PROMIF_DEBUG
77*7c478bd9Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)				\
78*7c478bd9Sstevel@tonic-gate 	if (promif_debug) { 				\
79*7c478bd9Sstevel@tonic-gate 		if (promif_debug == PROMIF_DMSG_VERBOSE)	\
80*7c478bd9Sstevel@tonic-gate 			prom_printf("file %s line %d: ", __FILE__, __LINE__); \
81*7c478bd9Sstevel@tonic-gate 		prom_printf args;			\
82*7c478bd9Sstevel@tonic-gate 	}
83*7c478bd9Sstevel@tonic-gate #else
84*7c478bd9Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)
85*7c478bd9Sstevel@tonic-gate #endif /* PROMIF_DEBUG */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate #define	prom_decode_int(v)	(v)
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /*
91*7c478bd9Sstevel@tonic-gate  * minimum alignment required by prom
92*7c478bd9Sstevel@tonic-gate  */
93*7c478bd9Sstevel@tonic-gate #define	PROMIF_MIN_ALIGN	1
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * Private utility routines (not exported as part of the interface)
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate extern	char		*prom_strcpy(char *s1, char *s2);
100*7c478bd9Sstevel@tonic-gate extern	char		*prom_strncpy(char *s1, char *s2, size_t n);
101*7c478bd9Sstevel@tonic-gate extern	int		prom_strcmp(char *s1, char *s2);
102*7c478bd9Sstevel@tonic-gate extern	int		prom_strncmp(char *s1, char *s2, size_t n);
103*7c478bd9Sstevel@tonic-gate extern	int		prom_strlen(char *s);
104*7c478bd9Sstevel@tonic-gate extern	char		*prom_strrchr(char *s1, char c);
105*7c478bd9Sstevel@tonic-gate extern	char		*prom_strcat(char *s1, char *s2);
106*7c478bd9Sstevel@tonic-gate extern	char		*prom_strchr(const char *, int);
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate /*
109*7c478bd9Sstevel@tonic-gate  * IEEE 1275 Routines defined by each platform using IEEE 1275:
110*7c478bd9Sstevel@tonic-gate  */
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate extern	void		*p1275_cif_init(void *);
113*7c478bd9Sstevel@tonic-gate extern	int		p1275_cif_call(void *);
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #if defined(PROM_32BIT_ADDRS)
116*7c478bd9Sstevel@tonic-gate /*
117*7c478bd9Sstevel@tonic-gate  * Client programs defining PROM_32BIT_ADDRS need to provide two
118*7c478bd9Sstevel@tonic-gate  * callbacks to allow the promif routines to allocate and free memory
119*7c478bd9Sstevel@tonic-gate  * allocated from the bottom 32-bits of the 64-bit address space.
120*7c478bd9Sstevel@tonic-gate  */
121*7c478bd9Sstevel@tonic-gate extern void		*promplat_alloc(size_t);
122*7c478bd9Sstevel@tonic-gate extern void		promplat_free(void *, size_t);
123*7c478bd9Sstevel@tonic-gate extern void		promplat_bcopy(const void *s1, void *s2, size_t n);
124*7c478bd9Sstevel@tonic-gate #endif
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate /*
127*7c478bd9Sstevel@tonic-gate  * More private globals
128*7c478bd9Sstevel@tonic-gate  */
129*7c478bd9Sstevel@tonic-gate extern	int		prom_aligned_allocator;
130*7c478bd9Sstevel@tonic-gate extern	void		*p1275cif;	/* P1275 client interface cookie */
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * Every call into the prom is wrappered with these calls so that
134*7c478bd9Sstevel@tonic-gate  * the caller can ensure that e.g. pre-emption is disabled
135*7c478bd9Sstevel@tonic-gate  * while we're in the firmware.  See 1109602.
136*7c478bd9Sstevel@tonic-gate  */
137*7c478bd9Sstevel@tonic-gate extern	void		promif_preprom(void);
138*7c478bd9Sstevel@tonic-gate extern	void		promif_postprom(void);
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate extern	void		(*promif_setprop_preprom)(void);
141*7c478bd9Sstevel@tonic-gate extern	void		(*promif_setprop_postprom)(void);
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate extern	void		(*promif_nextprop_preprom)(void);
144*7c478bd9Sstevel@tonic-gate extern	void		(*promif_nextprop_postprom)(void);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate /*
147*7c478bd9Sstevel@tonic-gate  * Some calls into the prom (those expected to generate output on the console)
148*7c478bd9Sstevel@tonic-gate  * are wrappered with these calls so that the caller can ensure that
149*7c478bd9Sstevel@tonic-gate  * the console framebuffer will be brought to full power before entering the
150*7c478bd9Sstevel@tonic-gate  * firmware.
151*7c478bd9Sstevel@tonic-gate  */
152*7c478bd9Sstevel@tonic-gate extern	promif_owrap_t	*promif_preout(void);
153*7c478bd9Sstevel@tonic-gate extern	void		promif_postout(promif_owrap_t *);
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate /*
156*7c478bd9Sstevel@tonic-gate  * The default allocator used in IEEE 1275 mode:
157*7c478bd9Sstevel@tonic-gate  */
158*7c478bd9Sstevel@tonic-gate extern	caddr_t		(*promif_allocator)(caddr_t, uint_t, uint_t);
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate /*
161*7c478bd9Sstevel@tonic-gate  * The prom interface uses this string internally for prefixing error
162*7c478bd9Sstevel@tonic-gate  * messages so that the "client" of the given instance of
163*7c478bd9Sstevel@tonic-gate  * promif can be identified e.g. "boot", "kmdb" or "kernel".
164*7c478bd9Sstevel@tonic-gate  *
165*7c478bd9Sstevel@tonic-gate  * It is passed into the library via prom_init().
166*7c478bd9Sstevel@tonic-gate  */
167*7c478bd9Sstevel@tonic-gate extern	char		promif_clntname[];
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate /*
170*7c478bd9Sstevel@tonic-gate  * The routine called when all else fails (and there may be no firmware
171*7c478bd9Sstevel@tonic-gate  * interface at all!)
172*7c478bd9Sstevel@tonic-gate  */
173*7c478bd9Sstevel@tonic-gate extern	void		prom_fatal_error(const char *);
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate /*
176*7c478bd9Sstevel@tonic-gate  * These functions are used by prom_prop.c for serializing i2c
177*7c478bd9Sstevel@tonic-gate  * controller access on some platforms.
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate extern void (*prom_setprop_enter)(void);
180*7c478bd9Sstevel@tonic-gate extern void (*prom_setprop_exit)(void);
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate #endif
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate #endif /* !_SYS_PROMIMPL_H */
187