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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2006 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 51extern "C" { 52#endif 53 54extern 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 71extern 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 99extern char *prom_strcpy(char *s1, char *s2); 100extern char *prom_strncpy(char *s1, char *s2, size_t n); 101extern int prom_strcmp(char *s1, char *s2); 102extern int prom_strncmp(char *s1, char *s2, size_t n); 103extern int prom_strlen(char *s); 104extern char *prom_strrchr(char *s1, char c); 105extern char *prom_strcat(char *s1, char *s2); 106extern char *prom_strchr(const char *, int); 107 108/* 109 * IEEE 1275 Routines defined by each platform using IEEE 1275: 110 */ 111 112extern void *p1275_cif_init(void *); 113extern 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 */ 121extern void *promplat_alloc(size_t); 122extern void promplat_free(void *, size_t); 123extern void promplat_bcopy(const void *s1, void *s2, size_t n); 124#endif 125 126/* 127 * More private globals 128 */ 129extern int prom_aligned_allocator; 130extern void *p1275cif; /* P1275 client interface cookie */ 131 132/* 133 * When this is non-NULL, the PROM output functions will attempt 134 * to redirect any thing directed to the PROM's stdout, which has 135 * been prequalified as being the console framebuffer. 136 */ 137extern promif_redir_arg_t promif_redirect_arg; 138extern promif_redir_t promif_redirect; 139 140/* 141 * Every call into the prom is wrappered with these calls so that 142 * the caller can ensure that e.g. pre-emption is disabled 143 * while we're in the firmware. See 1109602. 144 */ 145extern void promif_preprom(void); 146extern void promif_postprom(void); 147 148extern void (*promif_setprop_preprom)(void); 149extern void (*promif_setprop_postprom)(void); 150 151extern void (*promif_nextprop_preprom)(void); 152extern void (*promif_nextprop_postprom)(void); 153 154/* 155 * Some calls into the prom (those expected to generate output on the console) 156 * are wrappered with these calls so that the caller can ensure that 157 * the console framebuffer will be brought to full power before entering the 158 * firmware. 159 */ 160extern promif_owrap_t *promif_preout(void); 161extern void promif_postout(promif_owrap_t *); 162 163/* 164 * The default allocator used in IEEE 1275 mode: 165 */ 166extern caddr_t (*promif_allocator)(caddr_t, uint_t, uint_t); 167 168/* 169 * The prom interface uses this string internally for prefixing error 170 * messages so that the "client" of the given instance of 171 * promif can be identified e.g. "boot", "kmdb" or "kernel". 172 * 173 * It is passed into the library via prom_init(). 174 */ 175extern char promif_clntname[]; 176 177/* 178 * The routine called when all else fails (and there may be no firmware 179 * interface at all!) 180 */ 181extern void prom_fatal_error(const char *); 182 183/* 184 * These functions are used by prom_prop.c for serializing i2c 185 * controller access on some platforms. 186 */ 187extern void (*prom_setprop_enter)(void); 188extern void (*prom_setprop_exit)(void); 189 190#ifdef __cplusplus 191} 192#endif 193 194#endif /* !_SYS_PROMIMPL_H */ 195