import less(1)
[unleashed/tickless.git] / usr / src / psm / promif / ieee1275 / sun4 / prom_init.c
blob81cdf461a32d4e766d4f62224af1ac95ecf8ecc0
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/promif.h>
29 #include <sys/promimpl.h>
30 #include <sys/platform_module.h>
32 int obp_romvec_version = -1; /* -1 rsrvd for non-obp sunromvec */
33 int prom_aligned_allocator = 0; /* Not needed for 1275 */
34 void *p1275cif; /* 1275 Client interface handler */
36 #ifdef PROMIF_DEBUG
37 int promif_debug = 0;
38 #endif /* PROMIF_DEBUG */
41 * This is the string we use to print out "panic" level messages,
42 * so that it's easier to identify who's doing the complaining.
44 #define PROMIF_CLNTNAMELEN 16
45 char promif_clntname[PROMIF_CLNTNAMELEN];
48 * The plat_setprop_enter() and plat_setprop_exit() routines are actually
49 * defined as #pragma weak symbols, which confuses lint since it does not grok
50 * #pragma weak and thus thinks the routines are used but not defined. Until
51 * lint is enhanced, we workaround this with the following stubs.
55 * This 'do-nothing' function is called immediately before and immediately
56 * after entry to the PROM. Some standalones (e.g. the kernel)
57 * may replace this routine with their own.
59 static void
60 default_prepost_prom(void)
64 * Every standalone that wants to use this library must call
65 * prom_init() before any of the other routines can be called.
66 * The only state it creates is the obp_romvec_version variable,
67 * and the prom_aligned_allocator variable (plus the default pre-
68 * and post-prom handlers, and the clientname string)
71 void
72 prom_init(char *pgmname, void *p1275cookie)
75 * Allow implementation to validate input argument.
77 p1275cif = p1275_cif_init(p1275cookie);
79 if ((p1275cif == NULL)) {
80 prom_fatal_error("promif: No interface!");
81 /*NOTREACHED*/
85 * Initialize the "clientname" string with the string we've
86 * been handed by the standalone
88 (void) prom_strncpy(promif_clntname, pgmname, PROMIF_CLNTNAMELEN - 1);
89 promif_clntname[PROMIF_CLNTNAMELEN - 1] = '\0';
91 obp_romvec_version = OBP_PSEUDO_ROMVEC_VERSION;
94 * Add default pre- and post-prom handlers
95 * (We add this null handler to avoid the numerous tests
96 * that would otherwise have to be included around every call)
98 (void) prom_set_preprom(default_prepost_prom);
99 (void) prom_set_postprom(default_prepost_prom);
103 * Fatal promif internal error, not an external interface
106 /*ARGSUSED*/
107 void
108 prom_fatal_error(const char *errormsg)
111 volatile int zero = 0;
112 volatile int i = 1;
115 * No prom interface, try to cause a trap by
116 * dividing by zero, leaving the message in %i0.
119 i = i / zero;
120 /*NOTREACHED*/