Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: prom_plat.h | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright (c) 2000, 2003 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | #ifndef _SYS_PROM_PLAT_H | |
50 | #define _SYS_PROM_PLAT_H | |
51 | ||
52 | #pragma ident "@(#)prom_plat.h 1.1 00/08/07 SMI" | |
53 | ||
54 | #ifdef __cplusplus | |
55 | extern "C" { | |
56 | #endif | |
57 | ||
58 | /* | |
59 | * This file contains external sun4u-specific promif interface definitions. | |
60 | */ | |
61 | ||
62 | /* | |
63 | * Memory allocation plus memory/mmu interfaces: | |
64 | * | |
65 | * Routines with fine-grained memory and MMU control are platform-dependent. | |
66 | * | |
67 | * MMU node virtualized "mode" arguments and results: | |
68 | * | |
69 | * The default virtualized "mode" for client program mappings created | |
70 | * by the firmware is as follows: | |
71 | * | |
72 | * G (global) Clear | |
73 | * L (locked) Clear | |
74 | * W (write) Set | |
75 | * R (read - soft) Set (Prom is not required to implement soft bits) | |
76 | * X (exec - soft) Set (Prom is not required to implement soft bits) | |
77 | * CV,CP (Cacheable) Set if memory page, Clear if IO page | |
78 | * E (side effects) Clear if memory page; Set if IO page | |
79 | * IE (Invert endian.) Clear | |
80 | * | |
81 | * The following fields are initialized as follows in the TTE-data for any | |
82 | * mappings created by the firmware on behalf of the client program: | |
83 | * | |
84 | * P (Priviledged) Set | |
85 | * V (Valid) Set | |
86 | * NFO (No Fault Only) Clear | |
87 | * Context 0 | |
88 | * Soft bits < private to the firmware implementation > | |
89 | * | |
90 | * Page size of Prom mappings are typically 8k, "modify" cannot change | |
91 | * page sizes. Mappings created by "map" are 8k pages. | |
92 | * | |
93 | * If the virtualized "mode" is -1, the defaults as shown above are used, | |
94 | * otherwise the virtualized "mode" is set (and returned) based on the | |
95 | * following virtualized "mode" abstractions. The mmu node "translations" | |
96 | * property contains the actual tte-data, not the virtualized "mode". | |
97 | * | |
98 | * Note that client programs may not create locked mappings by setting | |
99 | * the LOCKED bit. There are specific client interfaces to create | |
100 | * and remove locked mappings. (SUNW,{i,d}tlb-load). | |
101 | * The LOCKED bit is defined here since it may be returned by the | |
102 | * "translate" method. | |
103 | * | |
104 | * The PROM is not required to implement the Read and eXecute soft bits, | |
105 | * and is not required to track them for the client program. They may be | |
106 | * set on calls to "map" and "modfify" and may be ignored by the firmware, | |
107 | * and are not necessarily returned from "translate". | |
108 | * | |
109 | * The TTE soft bits are private to the firmware. No assumptions may | |
110 | * be made regarding the contents of the TTE soft bits. | |
111 | * | |
112 | * Changing a mapping from cacheable to non-cacheable implies a flush | |
113 | * or invalidate operation, if necessary. | |
114 | * | |
115 | * The "map" MMU node method should NOT be used to create IO device | |
116 | * mappings. The correct way to do this is to call the device's parent | |
117 | * "map-in" method using the CALL-METHOD client interface service. | |
118 | */ | |
119 | ||
120 | #define PROM_MMU_MODE_DEFAULT ((int)-1) /* Default "mode", see above */ | |
121 | ||
122 | #define PROM_MMU_MODE_WRITE 0x0001 /* Translation is Writable */ | |
123 | #define PROM_MMU_MODE_READ 0x0002 /* Soft: Readable, See above */ | |
124 | #define PROM_MMU_MODE_EXEC 0x0004 /* Soft: eXecutable, See above */ | |
125 | #define PROM_MMU_MODE_RWX_MASK 0x0007 /* Mask for R-W-X bits */ | |
126 | ||
127 | #define PROM_MMU_MODE_LOCKED 0x0010 /* Read-only: Locked; see above */ | |
128 | #define PROM_MMU_MODE_CACHED 0x0020 /* Set means both CV,CP bits */ | |
129 | #define PROM_MMU_MODE_EFFECTS 0x0040 /* side Effects bit in MMU */ | |
130 | #define PROM_MMU_MODE_GLOBAL 0x0080 /* Global bit */ | |
131 | #define PROM_MMU_MODE_INVERT 0x0100 /* Invert Endianness */ | |
132 | ||
133 | /* | |
134 | * prom_alloc is platform dependent and has historical semantics | |
135 | * associated with the align argument and the return value. | |
136 | * prom_malloc is the generic memory allocator. | |
137 | */ | |
138 | extern caddr_t prom_alloc(caddr_t virthint, size_t size, uint_t align); | |
139 | ||
140 | extern caddr_t prom_allocate_virt(uint_t align, size_t size); | |
141 | extern caddr_t prom_claim_virt(size_t size, caddr_t virt); | |
142 | extern void prom_free_virt(size_t size, caddr_t virt); | |
143 | ||
144 | extern int prom_allocate_phys(size_t size, uint_t align, | |
145 | unsigned long long *physaddr); | |
146 | extern int prom_claim_phys(size_t size, | |
147 | unsigned long long physaddr); | |
148 | extern void prom_free_phys(size_t size, | |
149 | unsigned long long physaddr); | |
150 | ||
151 | extern int prom_map_phys(int mode, size_t size, caddr_t virt, | |
152 | unsigned long long physaddr); | |
153 | extern void prom_unmap_phys(size_t size, caddr_t virt); | |
154 | extern void prom_unmap_virt(size_t size, caddr_t virt); | |
155 | ||
156 | /* | |
157 | * prom_retain allocates or returns retained physical memory | |
158 | * identified by the arguments of name string "id", "size" and "align". | |
159 | */ | |
160 | extern int prom_retain(char *id, size_t size, uint_t align, | |
161 | unsigned long long *physaddr); | |
162 | ||
163 | /* | |
164 | * prom_translate_virt returns the physical address and virtualized "mode" | |
165 | * for the given virtual address. After the call, if *valid is non-zero, | |
166 | * a mapping to 'virt' exists and the physical address and virtualized | |
167 | * "mode" were returned to the caller. | |
168 | */ | |
169 | extern int prom_translate_virt(caddr_t virt, int *valid, | |
170 | unsigned long long *physaddr, int *mode); | |
171 | ||
172 | /* | |
173 | * prom_modify_mapping changes the "mode" of an existing mapping or | |
174 | * repeated mappings. virt is the virtual address whose "mode" is to | |
175 | * be changed; size is some multiple of the fundamental pagesize. | |
176 | * This method cannot be used to change the pagesize of an MMU mapping, | |
177 | * nor can it be used to Lock a translation into the i or d tlb. | |
178 | */ | |
179 | extern int prom_modify_mapping(caddr_t virt, size_t size, int mode); | |
180 | ||
181 | /* | |
182 | * Client interfaces for managing the {i,d}tlb handoff to client programs. | |
183 | */ | |
184 | extern int prom_itlb_load(int index, | |
185 | unsigned long long tte_data, caddr_t virt); | |
186 | extern int prom_dtlb_load(int index, | |
187 | unsigned long long tte_data, caddr_t virt); | |
188 | ||
189 | /* | |
190 | * Prom heartbeat | |
191 | */ | |
192 | extern int prom_heartbeat(int msecs); | |
193 | ||
194 | /* | |
195 | * CPU Control Group: MP's only. | |
196 | */ | |
197 | extern int prom_startcpu(dnode_t node, caddr_t pc, int arg); | |
198 | extern int prom_stop_self(void); | |
199 | extern int prom_idle_self(void); | |
200 | extern int prom_resumecpu(dnode_t node); | |
201 | ||
202 | /* | |
203 | * Set trap table | |
204 | */ | |
205 | extern void prom_set_traptable(void *tba_addr); | |
206 | ||
207 | /* | |
208 | * Power-off | |
209 | */ | |
210 | extern void prom_power_off(void); | |
211 | ||
212 | /* | |
213 | * The client program implementation is required to provide a wrapper | |
214 | * to the client handler, for the 32 bit client program to 64 bit cell-sized | |
215 | * client interface handler (switch stack, etc.). This function is not | |
216 | * to be used externally! | |
217 | */ | |
218 | extern int client_handler(void *cif_handler, void *arg_array); | |
219 | ||
220 | /* | |
221 | * The 'format' of the "translations" property in the 'mmu' node ... | |
222 | */ | |
223 | struct translation { | |
224 | uint32_t virt_hi; /* upper 32 bits of vaddr */ | |
225 | uint32_t virt_lo; /* lower 32 bits of vaddr */ | |
226 | uint32_t size_hi; /* upper 32 bits of size in bytes */ | |
227 | uint32_t size_lo; /* lower 32 bits of size in bytes */ | |
228 | uint32_t tte_hi; /* higher 32 bites of tte */ | |
229 | uint32_t tte_lo; /* lower 32 bits of tte */ | |
230 | }; | |
231 | ||
232 | #ifdef __cplusplus | |
233 | } | |
234 | #endif | |
235 | ||
236 | #endif /* _SYS_PROM_PLAT_H */ |