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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_PROM_PLAT_H
#define _SYS_PROM_PLAT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/feature_tests.h>
#include <sys/cpuvar.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_LONGLONG_TYPE)
#error "This header won't work without long long support"
#endif
/*
* This file contains external platform-specific promif interface definitions.
* There may be none. This file is included by reference in <sys/promif.h>
*
* This version of the file is for the IEEE 1275-1994 compliant sun4u prom.
*/
/*
* Memory allocation plus memory/mmu interfaces:
*
* Routines with fine-grained memory and MMU control are platform-dependent.
*
* MMU node virtualized "mode" arguments and results for Spitfire MMU:
*
* The default virtualized "mode" for client program mappings created
* by the firmware is as follows:
*
* G (global) Clear
* L (locked) Clear
* W (write) Set
* R (read - soft) Set (Prom is not required to implement soft bits)
* X (exec - soft) Set (Prom is not required to implement soft bits)
* CV,CP (Cacheable) Set if memory page, Clear if IO page
* E (side effects) Clear if memory page; Set if IO page
* IE (Invert endian.) Clear
*
* The following fields are initialized as follows in the TTE-data for any
* mappings created by the firmware on behalf of the client program:
*
* P (Priviledged) Set
* V (Valid) Set
* NFO (No Fault Only) Clear
* Context 0
* Soft bits < private to the firmware implementation >
*
* Page size of Prom mappings are typically 8k, "modify" cannot change
* page sizes. Mappings created by "map" are 8k pages.
*
* If the virtualized "mode" is -1, the defaults as shown above are used,
* otherwise the virtualized "mode" is set (and returned) based on the
* following virtualized "mode" abstractions. The mmu node "translations"
* property contains the actual tte-data, not the virtualized "mode".
*
* Note that client programs may not create locked mappings by setting
* the LOCKED bit. There are Spitfire specific client interfaces to create
* and remove locked mappings. (SUNW,{i,d}tlb-load).
* The LOCKED bit is defined here since it may be returned by the
* "translate" method.
*
* The PROM is not required to implement the Read and eXecute soft bits,
* and is not required to track them for the client program. They may be
* set on calls to "map" and "modfify" and may be ignored by the firmware,
* and are not necessarily returned from "translate".
*
* The TTE soft bits are private to the firmware. No assumptions may
* be made regarding the contents of the TTE soft bits.
*
* Changing a mapping from cacheable to non-cacheable implies a flush
* or invalidate operation, if necessary.
*
* NB: The "map" MMU node method should NOT be used to create IO device
* mappings. The correct way to do this is to call the device's parent
* "map-in" method using the CALL-METHOD client interface service.
*/
#define PROM_MMU_MODE_DEFAULT ((int)-1) /* Default "mode", see above */
/*
* NB: These are not implemented in PROM version P1.0 ...
*/
#define PROM_MMU_MODE_WRITE 0x0001 /* Translation is Writable */
#define PROM_MMU_MODE_READ 0x0002 /* Soft: Readable, See above */
#define PROM_MMU_MODE_EXEC 0x0004 /* Soft: eXecutable, See above */
#define PROM_MMU_MODE_RWX_MASK 0x0007 /* Mask for R-W-X bits */
#define PROM_MMU_MODE_LOCKED 0x0010 /* Read-only: Locked; see above */
#define PROM_MMU_MODE_CACHED 0x0020 /* Set means both CV,CP bits */
#define PROM_MMU_MODE_EFFECTS 0x0040 /* side Effects bit in MMU */
#define PROM_MMU_MODE_GLOBAL 0x0080 /* Global bit */
#define PROM_MMU_MODE_INVERT 0x0100 /* Invert Endianness */
/*
* resource allocation group: OBP only. (mapping functions are platform
* dependent because they use physical address arguments.)
*/
extern caddr_t prom_map(caddr_t virthint,
unsigned long long physaddr, uint_t size);
/*
* prom_alloc is platform dependent and has historical semantics
* associated with the align argument and the return value.
* prom_malloc is the generic memory allocator.
*/
extern caddr_t prom_malloc(caddr_t virt, size_t size, uint_t align);
extern caddr_t prom_allocate_virt(uint_t align, size_t size);
extern caddr_t prom_claim_virt(size_t size, caddr_t virt);
extern void prom_free_virt(size_t size, caddr_t virt);
extern int prom_allocate_phys(size_t size, uint_t align,
unsigned long long *physaddr);
extern int prom_claim_phys(size_t size,
unsigned long long physaddr);
extern void prom_free_phys(size_t size,
unsigned long long physaddr);
extern int prom_map_phys(int mode, size_t size, caddr_t virt,
unsigned long long physaddr);
extern void prom_unmap_phys(size_t size, caddr_t virt);
extern void prom_unmap_virt(size_t size, caddr_t virt);
/*
* prom_retain allocates or returns retained physical memory
* identified by the arguments of name string "id", "size" and "align".
*/
extern int prom_retain(char *id, size_t size, uint_t align,
unsigned long long *physaddr);
/*
* prom_translate_virt returns the physical address and virtualized "mode"
* for the given virtual address. After the call, if *valid is non-zero,
* a mapping to 'virt' exists and the physical address and virtualized
* "mode" were returned to the caller.
*/
extern int prom_translate_virt(caddr_t virt, int *valid,
unsigned long long *physaddr, int *mode);
/*
* prom_modify_mapping changes the "mode" of an existing mapping or
* repeated mappings. virt is the virtual address whose "mode" is to
* be changed; size is some multiple of the fundamental pagesize.
* This method cannot be used to change the pagesize of an MMU mapping,
* nor can it be used to Lock a translation into the i or d tlb.
*/
extern int prom_modify_mapping(caddr_t virt, size_t size, int mode);
/*
* Client interfaces for managing the {i,d}tlb handoff to client programs.
*/
extern int prom_itlb_load(int index,
unsigned long long tte_data, caddr_t virt);
extern int prom_dtlb_load(int index,
unsigned long long tte_data, caddr_t virt);
/*
* Administrative group: OBP only and SMCC platform specific.
* XXX: IDPROM related stuff should be replaced with specific data-oriented
* XXX: functions.
*/
extern int prom_heartbeat(int msecs);
extern int prom_get_unum(int syn_code, unsigned long long physaddr,
char *buf, uint_t buflen, int *ustrlen);
extern int prom_serengeti_get_ecacheunum(int cpuid,
unsigned long long physaddr, char *buf,
uint_t buflen, int *ustrlen);
extern int prom_getidprom(caddr_t addr, int size);
extern int prom_getmacaddr(ihandle_t hd, caddr_t ea);
/*
* CPU Control Group: MP's only.
*/
extern int prom_startcpu(dnode_t node, caddr_t pc, int arg);
extern int prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg);
extern int prom_stopcpu_bycpuid(int);
extern int prom_sunfire_cpu_off(void); /* SunFire only */
extern int prom_wakeupcpu(dnode_t node);
extern int prom_serengeti_wakeupcpu(dnode_t node);
extern int prom_hotaddcpu(int cpuid);
extern int prom_hotremovecpu(int cpuid);
extern void promsafe_pause_cpus(void);
extern void promsafe_xc_attention(cpuset_t cpuset);
extern int prom_serengeti_cpu_off(dnode_t node);
/*
* Set trap table
*/
extern void prom_set_traptable(void *tba_addr);
/*
* Power-off
*/
extern void prom_power_off(void);
/*
* sunfire attach/detach
*/
extern int prom_sunfire_attach_board(uint_t board);
extern int prom_sunfire_detach_board(uint_t board);
/*
* Serengeti console switch
*/
extern char *prom_serengeti_set_console_input(char *new_value);
/*
* Serengeti attach/detach
*/
extern int prom_serengeti_attach_board(uint_t node, uint_t board);
extern int prom_serengeti_detach_board(uint_t node, uint_t board);
extern int prom_serengeti_tunnel_switch(uint_t node, uint_t board);
/*
* Starcat-specific routines
*/
extern int prom_starcat_switch_tunnel(uint_t portid,
uint_t msgtype);
extern int prom_starcat_iosram_read(uint32_t key, uint32_t offset,
uint32_t len, caddr_t buf);
extern int prom_starcat_iosram_write(uint32_t key, uint32_t offset,
uint32_t len, caddr_t buf);
/*
* Starfire-specific routines
*/
extern int prom_starfire_add_brd(uint_t cpuid);
extern int prom_starfire_rm_brd(uint_t brdnum);
extern void prom_starfire_add_cpu(uint_t cpuid);
extern void prom_starfire_rm_cpu(uint_t cpuid);
extern int prom_starfire_move_cpu0(uint_t cpuid);
extern void prom_starfire_init_console(uint_t cpuid);
/*
* The client program implementation is required to provide a wrapper
* to the client handler, for the 32 bit client program to 64 bit cell-sized
* client interface handler (switch stack, etc.). This function is not
* to be used externally!
*/
extern int client_handler(void *cif_handler, void *arg_array);
/*
* The 'format' of the "translations" property in the 'mmu' node ...
*/
struct translation {
uint32_t virt_hi; /* upper 32 bits of vaddr */
uint32_t virt_lo; /* lower 32 bits of vaddr */
uint32_t size_hi; /* upper 32 bits of size in bytes */
uint32_t size_lo; /* lower 32 bits of size in bytes */
uint32_t tte_hi; /* higher 32 bites of tte */
uint32_t tte_lo; /* lower 32 bits of tte */
};
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PROM_PLAT_H */
|