xref: /onnv-gate/usr/src/uts/sun/sys/promimpl.h (revision 1253:0df630a41817)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1253Slq150181  * Common Development and Distribution License (the "License").
6*1253Slq150181  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1253Slq150181 
220Sstevel@tonic-gate /*
23*1253Slq150181  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_PROMIMPL_H
280Sstevel@tonic-gate #define	_SYS_PROMIMPL_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  * promif implementation header file; private to promif implementation.
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * These interfaces are not 'exported' in the same sense as
360Sstevel@tonic-gate  * those described in promif.h
370Sstevel@tonic-gate  *
380Sstevel@tonic-gate  * Used so that the kernel and other stand-alones (eg boot)
390Sstevel@tonic-gate  * don't have to directly reference the prom (of which there
400Sstevel@tonic-gate  * are now several completely different variants).
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #include <sys/types.h>
440Sstevel@tonic-gate #include <sys/promif.h>
450Sstevel@tonic-gate #include <sys/prom_isa.h>
460Sstevel@tonic-gate #if defined(_MACHDEP)
470Sstevel@tonic-gate #include <sys/prom_plat.h>
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #ifdef	__cplusplus
510Sstevel@tonic-gate extern "C" {
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate extern int obp_romvec_version;
550Sstevel@tonic-gate 
560Sstevel@tonic-gate /*
570Sstevel@tonic-gate  * XXX for chatty stuff in prom_stdinpath/prom_stdoutpath until proposed
580Sstevel@tonic-gate  * changes from romvec pathnames to root node properties for stdin/stdout
590Sstevel@tonic-gate  * pathnames.
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate /* #define	PROM_DEBUG_STDPATH	1 */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * Debugging macros for the promif functions.
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	PROMIF_DMSG_VERBOSE		2
690Sstevel@tonic-gate #define	PROMIF_DMSG_NORMAL		1
700Sstevel@tonic-gate 
710Sstevel@tonic-gate extern int promif_debug;		/* externally patchable */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #define	PROMIF_DEBUG			/* define this to enable debugging */
740Sstevel@tonic-gate #define	PROMIF_DEBUG_P1275		/* Debug 1275 client interface calls */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #ifdef PROMIF_DEBUG
770Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)				\
780Sstevel@tonic-gate 	if (promif_debug) { 				\
790Sstevel@tonic-gate 		if (promif_debug == PROMIF_DMSG_VERBOSE)	\
800Sstevel@tonic-gate 			prom_printf("file %s line %d: ", __FILE__, __LINE__); \
810Sstevel@tonic-gate 		prom_printf args;			\
820Sstevel@tonic-gate 	}
830Sstevel@tonic-gate #else
840Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)
850Sstevel@tonic-gate #endif /* PROMIF_DEBUG */
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #define	prom_decode_int(v)	(v)
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * minimum alignment required by prom
920Sstevel@tonic-gate  */
930Sstevel@tonic-gate #define	PROMIF_MIN_ALIGN	1
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /*
960Sstevel@tonic-gate  * Private utility routines (not exported as part of the interface)
970Sstevel@tonic-gate  */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate extern	char		*prom_strcpy(char *s1, char *s2);
1000Sstevel@tonic-gate extern	char		*prom_strncpy(char *s1, char *s2, size_t n);
1010Sstevel@tonic-gate extern	int		prom_strcmp(char *s1, char *s2);
1020Sstevel@tonic-gate extern	int		prom_strncmp(char *s1, char *s2, size_t n);
1030Sstevel@tonic-gate extern	int		prom_strlen(char *s);
1040Sstevel@tonic-gate extern	char		*prom_strrchr(char *s1, char c);
1050Sstevel@tonic-gate extern	char		*prom_strcat(char *s1, char *s2);
1060Sstevel@tonic-gate extern	char		*prom_strchr(const char *, int);
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * IEEE 1275 Routines defined by each platform using IEEE 1275:
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate extern	void		*p1275_cif_init(void *);
1130Sstevel@tonic-gate extern	int		p1275_cif_call(void *);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #if defined(PROM_32BIT_ADDRS)
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate  * Client programs defining PROM_32BIT_ADDRS need to provide two
1180Sstevel@tonic-gate  * callbacks to allow the promif routines to allocate and free memory
1190Sstevel@tonic-gate  * allocated from the bottom 32-bits of the 64-bit address space.
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate extern void		*promplat_alloc(size_t);
1220Sstevel@tonic-gate extern void		promplat_free(void *, size_t);
1230Sstevel@tonic-gate extern void		promplat_bcopy(const void *s1, void *s2, size_t n);
1240Sstevel@tonic-gate #endif
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate /*
1270Sstevel@tonic-gate  * More private globals
1280Sstevel@tonic-gate  */
1290Sstevel@tonic-gate extern	int		prom_aligned_allocator;
1300Sstevel@tonic-gate extern	void		*p1275cif;	/* P1275 client interface cookie */
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate /*
133*1253Slq150181  * When this is non-NULL, the PROM output functions will attempt
134*1253Slq150181  * to redirect any thing directed to the PROM's stdout, which has
135*1253Slq150181  * been prequalified as being the console framebuffer.
136*1253Slq150181  */
137*1253Slq150181 extern  promif_redir_arg_t promif_redirect_arg;
138*1253Slq150181 extern  promif_redir_t	promif_redirect;
139*1253Slq150181 
140*1253Slq150181 /*
1410Sstevel@tonic-gate  * Every call into the prom is wrappered with these calls so that
1420Sstevel@tonic-gate  * the caller can ensure that e.g. pre-emption is disabled
1430Sstevel@tonic-gate  * while we're in the firmware.  See 1109602.
1440Sstevel@tonic-gate  */
1450Sstevel@tonic-gate extern	void		promif_preprom(void);
1460Sstevel@tonic-gate extern	void		promif_postprom(void);
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate extern	void		(*promif_setprop_preprom)(void);
1490Sstevel@tonic-gate extern	void		(*promif_setprop_postprom)(void);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate extern	void		(*promif_nextprop_preprom)(void);
1520Sstevel@tonic-gate extern	void		(*promif_nextprop_postprom)(void);
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate /*
1550Sstevel@tonic-gate  * Some calls into the prom (those expected to generate output on the console)
1560Sstevel@tonic-gate  * are wrappered with these calls so that the caller can ensure that
1570Sstevel@tonic-gate  * the console framebuffer will be brought to full power before entering the
1580Sstevel@tonic-gate  * firmware.
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate extern	promif_owrap_t	*promif_preout(void);
1610Sstevel@tonic-gate extern	void		promif_postout(promif_owrap_t *);
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
1640Sstevel@tonic-gate  * The default allocator used in IEEE 1275 mode:
1650Sstevel@tonic-gate  */
1660Sstevel@tonic-gate extern	caddr_t		(*promif_allocator)(caddr_t, uint_t, uint_t);
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate /*
1690Sstevel@tonic-gate  * The prom interface uses this string internally for prefixing error
1700Sstevel@tonic-gate  * messages so that the "client" of the given instance of
1710Sstevel@tonic-gate  * promif can be identified e.g. "boot", "kmdb" or "kernel".
1720Sstevel@tonic-gate  *
1730Sstevel@tonic-gate  * It is passed into the library via prom_init().
1740Sstevel@tonic-gate  */
1750Sstevel@tonic-gate extern	char		promif_clntname[];
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * The routine called when all else fails (and there may be no firmware
1790Sstevel@tonic-gate  * interface at all!)
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate extern	void		prom_fatal_error(const char *);
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate /*
1840Sstevel@tonic-gate  * These functions are used by prom_prop.c for serializing i2c
1850Sstevel@tonic-gate  * controller access on some platforms.
1860Sstevel@tonic-gate  */
1870Sstevel@tonic-gate extern void (*prom_setprop_enter)(void);
1880Sstevel@tonic-gate extern void (*prom_setprop_exit)(void);
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate #ifdef	__cplusplus
1910Sstevel@tonic-gate }
1920Sstevel@tonic-gate #endif
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate #endif /* !_SYS_PROMIMPL_H */
195