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