1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/promif.h>
#include <sys/promimpl.h>
#include <sys/platform_module.h>
int obp_romvec_version = -1; /* -1 rsrvd for non-obp sunromvec */
int prom_aligned_allocator = 0; /* Not needed for 1275 */
void *p1275cif; /* 1275 Client interface handler */
#ifdef PROMIF_DEBUG
int promif_debug = 0;
#endif /* PROMIF_DEBUG */
/*
* This is the string we use to print out "panic" level messages,
* so that it's easier to identify who's doing the complaining.
*/
#define PROMIF_CLNTNAMELEN 16
char promif_clntname[PROMIF_CLNTNAMELEN];
/*
* The plat_setprop_enter() and plat_setprop_exit() routines are actually
* defined as #pragma weak symbols, which confuses lint since it does not grok
* #pragma weak and thus thinks the routines are used but not defined. Until
* lint is enhanced, we workaround this with the following stubs.
*/
#ifdef __lint
void
plat_setprop_enter(void)
{}
void
plat_setprop_exit(void)
{}
#endif
/*
* This 'do-nothing' function is called immediately before and immediately
* after entry to the PROM. Some standalones (e.g. the kernel)
* may replace this routine with their own.
*/
static void
default_prepost_prom(void)
{}
/*
* Every standalone that wants to use this library must call
* prom_init() before any of the other routines can be called.
* The only state it creates is the obp_romvec_version variable,
* and the prom_aligned_allocator variable (plus the default pre-
* and post-prom handlers, and the clientname string)
*
*/
void
prom_init(char *pgmname, void *p1275cookie)
{
/*
* Allow implementation to validate input argument.
*/
p1275cif = p1275_cif_init(p1275cookie);
if ((p1275cif == NULL)) {
prom_fatal_error("promif: No interface!");
/*NOTREACHED*/
}
/*
* Initialize the "clientname" string with the string we've
* been handed by the standalone
*/
(void) prom_strncpy(promif_clntname, pgmname, PROMIF_CLNTNAMELEN - 1);
promif_clntname[PROMIF_CLNTNAMELEN - 1] = '\0';
obp_romvec_version = OBP_PSEUDO_ROMVEC_VERSION;
/*
* Add default pre- and post-prom handlers
* (We add this null handler to avoid the numerous tests
* that would otherwise have to be included around every call)
*/
(void) prom_set_preprom(default_prepost_prom);
(void) prom_set_postprom(default_prepost_prom);
}
/*
* Fatal promif internal error, not an external interface
*/
/*ARGSUSED*/
void
prom_fatal_error(const char *errormsg)
{
volatile int zero = 0;
volatile int i = 1;
/*
* No prom interface, try to cause a trap by
* dividing by zero, leaving the message in %i0.
*/
i = i / zero;
/*NOTREACHED*/
}
|