xref: /illumos-gate/usr/src/uts/sun/sys/promimpl.h (revision fea9cb91)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*fea9cb91Slq150181  * Common Development and Distribution License (the "License").
6*fea9cb91Slq150181  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*fea9cb91Slq150181 
227c478bd9Sstevel@tonic-gate /*
23*fea9cb91Slq150181  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_PROMIMPL_H
287c478bd9Sstevel@tonic-gate #define	_SYS_PROMIMPL_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * promif implementation header file; private to promif implementation.
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * These interfaces are not 'exported' in the same sense as
367c478bd9Sstevel@tonic-gate  * those described in promif.h
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * Used so that the kernel and other stand-alones (eg boot)
397c478bd9Sstevel@tonic-gate  * don't have to directly reference the prom (of which there
407c478bd9Sstevel@tonic-gate  * are now several completely different variants).
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #include <sys/types.h>
447c478bd9Sstevel@tonic-gate #include <sys/promif.h>
457c478bd9Sstevel@tonic-gate #include <sys/prom_isa.h>
467c478bd9Sstevel@tonic-gate #if defined(_MACHDEP)
477c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h>
487c478bd9Sstevel@tonic-gate #endif
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
517c478bd9Sstevel@tonic-gate extern "C" {
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate extern int obp_romvec_version;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * XXX for chatty stuff in prom_stdinpath/prom_stdoutpath until proposed
587c478bd9Sstevel@tonic-gate  * changes from romvec pathnames to root node properties for stdin/stdout
597c478bd9Sstevel@tonic-gate  * pathnames.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /* #define	PROM_DEBUG_STDPATH	1 */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Debugging macros for the promif functions.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	PROMIF_DMSG_VERBOSE		2
697c478bd9Sstevel@tonic-gate #define	PROMIF_DMSG_NORMAL		1
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate extern int promif_debug;		/* externally patchable */
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	PROMIF_DEBUG			/* define this to enable debugging */
747c478bd9Sstevel@tonic-gate #define	PROMIF_DEBUG_P1275		/* Debug 1275 client interface calls */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #ifdef PROMIF_DEBUG
777c478bd9Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)				\
787c478bd9Sstevel@tonic-gate 	if (promif_debug) { 				\
797c478bd9Sstevel@tonic-gate 		if (promif_debug == PROMIF_DMSG_VERBOSE)	\
807c478bd9Sstevel@tonic-gate 			prom_printf("file %s line %d: ", __FILE__, __LINE__); \
817c478bd9Sstevel@tonic-gate 		prom_printf args;			\
827c478bd9Sstevel@tonic-gate 	}
837c478bd9Sstevel@tonic-gate #else
847c478bd9Sstevel@tonic-gate #define	PROMIF_DPRINTF(args)
857c478bd9Sstevel@tonic-gate #endif /* PROMIF_DEBUG */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	prom_decode_int(v)	(v)
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * minimum alignment required by prom
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate #define	PROMIF_MIN_ALIGN	1
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Private utility routines (not exported as part of the interface)
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate extern	char		*prom_strcpy(char *s1, char *s2);
1007c478bd9Sstevel@tonic-gate extern	char		*prom_strncpy(char *s1, char *s2, size_t n);
1017c478bd9Sstevel@tonic-gate extern	int		prom_strcmp(char *s1, char *s2);
1027c478bd9Sstevel@tonic-gate extern	int		prom_strncmp(char *s1, char *s2, size_t n);
1037c478bd9Sstevel@tonic-gate extern	int		prom_strlen(char *s);
1047c478bd9Sstevel@tonic-gate extern	char		*prom_strrchr(char *s1, char c);
1057c478bd9Sstevel@tonic-gate extern	char		*prom_strcat(char *s1, char *s2);
1067c478bd9Sstevel@tonic-gate extern	char		*prom_strchr(const char *, int);
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * IEEE 1275 Routines defined by each platform using IEEE 1275:
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate extern	void		*p1275_cif_init(void *);
1137c478bd9Sstevel@tonic-gate extern	int		p1275_cif_call(void *);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #if defined(PROM_32BIT_ADDRS)
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate  * Client programs defining PROM_32BIT_ADDRS need to provide two
1187c478bd9Sstevel@tonic-gate  * callbacks to allow the promif routines to allocate and free memory
1197c478bd9Sstevel@tonic-gate  * allocated from the bottom 32-bits of the 64-bit address space.
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate extern void		*promplat_alloc(size_t);
1227c478bd9Sstevel@tonic-gate extern void		promplat_free(void *, size_t);
1237c478bd9Sstevel@tonic-gate extern void		promplat_bcopy(const void *s1, void *s2, size_t n);
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * More private globals
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate extern	int		prom_aligned_allocator;
1307c478bd9Sstevel@tonic-gate extern	void		*p1275cif;	/* P1275 client interface cookie */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
133*fea9cb91Slq150181  * When this is non-NULL, the PROM output functions will attempt
134*fea9cb91Slq150181  * to redirect any thing directed to the PROM's stdout, which has
135*fea9cb91Slq150181  * been prequalified as being the console framebuffer.
136*fea9cb91Slq150181  */
137*fea9cb91Slq150181 extern  promif_redir_arg_t promif_redirect_arg;
138*fea9cb91Slq150181 extern  promif_redir_t	promif_redirect;
139*fea9cb91Slq150181 
140*fea9cb91Slq150181 /*
1417c478bd9Sstevel@tonic-gate  * Every call into the prom is wrappered with these calls so that
1427c478bd9Sstevel@tonic-gate  * the caller can ensure that e.g. pre-emption is disabled
1437c478bd9Sstevel@tonic-gate  * while we're in the firmware.  See 1109602.
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate extern	void		promif_preprom(void);
1467c478bd9Sstevel@tonic-gate extern	void		promif_postprom(void);
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate extern	void		(*promif_setprop_preprom)(void);
1497c478bd9Sstevel@tonic-gate extern	void		(*promif_setprop_postprom)(void);
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate extern	void		(*promif_nextprop_preprom)(void);
1527c478bd9Sstevel@tonic-gate extern	void		(*promif_nextprop_postprom)(void);
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * Some calls into the prom (those expected to generate output on the console)
1567c478bd9Sstevel@tonic-gate  * are wrappered with these calls so that the caller can ensure that
1577c478bd9Sstevel@tonic-gate  * the console framebuffer will be brought to full power before entering the
1587c478bd9Sstevel@tonic-gate  * firmware.
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate extern	promif_owrap_t	*promif_preout(void);
1617c478bd9Sstevel@tonic-gate extern	void		promif_postout(promif_owrap_t *);
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * The default allocator used in IEEE 1275 mode:
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate extern	caddr_t		(*promif_allocator)(caddr_t, uint_t, uint_t);
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * The prom interface uses this string internally for prefixing error
1707c478bd9Sstevel@tonic-gate  * messages so that the "client" of the given instance of
1717c478bd9Sstevel@tonic-gate  * promif can be identified e.g. "boot", "kmdb" or "kernel".
1727c478bd9Sstevel@tonic-gate  *
1737c478bd9Sstevel@tonic-gate  * It is passed into the library via prom_init().
1747c478bd9Sstevel@tonic-gate  */
1757c478bd9Sstevel@tonic-gate extern	char		promif_clntname[];
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * The routine called when all else fails (and there may be no firmware
1797c478bd9Sstevel@tonic-gate  * interface at all!)
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate extern	void		prom_fatal_error(const char *);
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * These functions are used by prom_prop.c for serializing i2c
1857c478bd9Sstevel@tonic-gate  * controller access on some platforms.
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate extern void (*prom_setprop_enter)(void);
1887c478bd9Sstevel@tonic-gate extern void (*prom_setprop_exit)(void);
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate #endif
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #endif /* !_SYS_PROMIMPL_H */
195