Print this page
XXXX remove i86xpv platform code
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86pc/os/mp_implfuncs.c
+++ new/usr/src/uts/i86pc/os/mp_implfuncs.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
25 25 #define PSMI_1_7
26 26
27 27 #include <sys/vmem.h>
28 28 #include <vm/hat.h>
29 29 #include <sys/modctl.h>
30 30 #include <vm/seg_kmem.h>
31 31 #include <sys/psm.h>
32 32 #include <sys/psm_modctl.h>
33 33 #include <sys/smp_impldefs.h>
34 34 #include <sys/reboot.h>
35 -#if defined(__xpv)
36 -#include <sys/hypervisor.h>
37 -#include <vm/kboot_mmu.h>
38 -#include <vm/hat_pte.h>
39 -#endif
40 35
41 36 /*
42 37 * External reference functions
43 38 */
44 39 extern void *get_next_mach(void *, char *);
45 40 extern void close_mach_list(void);
46 41 extern void open_mach_list(void);
47 42
48 43 /*
49 44 * from startup.c - kernel VA range allocator for device mappings
50 45 */
51 46 extern void *device_arena_alloc(size_t size, int vm_flag);
52 47 extern void device_arena_free(void * vaddr, size_t size);
53 48
54 49 void psm_modloadonly(void);
55 50 void psm_install(void);
56 51
57 52 /*
58 53 * Local Function Prototypes
59 54 */
60 55 static struct modlinkage *psm_modlinkage_alloc(struct psm_info *infop);
61 56 static void psm_modlinkage_free(struct modlinkage *mlinkp);
62 57
63 58 static char *psm_get_impl_module(int first);
64 59
65 60 static int mod_installpsm(struct modlpsm *modl, struct modlinkage *modlp);
66 61 static int mod_removepsm(struct modlpsm *modl, struct modlinkage *modlp);
67 62 static int mod_infopsm(struct modlpsm *modl, struct modlinkage *modlp, int *p0);
68 63 struct mod_ops mod_psmops = {
69 64 mod_installpsm, mod_removepsm, mod_infopsm
70 65 };
71 66
72 67 static struct psm_sw psm_swtab = {
73 68 &psm_swtab, &psm_swtab, NULL, NULL
74 69 };
75 70
76 71 kmutex_t psmsw_lock; /* lock accesses to psmsw */
77 72 struct psm_sw *psmsw = &psm_swtab; /* start of all psm_sw */
78 73
79 74 static struct modlinkage *
80 75 psm_modlinkage_alloc(struct psm_info *infop)
81 76 {
82 77 int memsz;
83 78 struct modlinkage *mlinkp;
84 79 struct modlpsm *mlpsmp;
85 80 struct psm_sw *swp;
86 81
87 82 memsz = sizeof (struct modlinkage) + sizeof (struct modlpsm) +
88 83 sizeof (struct psm_sw);
89 84 mlinkp = (struct modlinkage *)kmem_zalloc(memsz, KM_NOSLEEP);
90 85 if (!mlinkp) {
91 86 cmn_err(CE_WARN, "!psm_mod_init: Cannot install %s",
92 87 infop->p_mach_idstring);
93 88 return (NULL);
94 89 }
95 90 mlpsmp = (struct modlpsm *)(mlinkp + 1);
96 91 swp = (struct psm_sw *)(mlpsmp + 1);
97 92
98 93 mlinkp->ml_rev = MODREV_1;
99 94 mlinkp->ml_linkage[0] = (void *)mlpsmp;
100 95 mlinkp->ml_linkage[1] = (void *)NULL;
101 96
102 97 mlpsmp->psm_modops = &mod_psmops;
103 98 mlpsmp->psm_linkinfo = infop->p_mach_desc;
104 99 mlpsmp->psm_swp = swp;
105 100
106 101 swp->psw_infop = infop;
107 102
108 103 return (mlinkp);
109 104 }
110 105
111 106 static void
112 107 psm_modlinkage_free(struct modlinkage *mlinkp)
113 108 {
114 109 if (!mlinkp)
115 110 return;
116 111
117 112 (void) kmem_free(mlinkp, (sizeof (struct modlinkage) +
118 113 sizeof (struct modlpsm) + sizeof (struct psm_sw)));
119 114 }
120 115
121 116 int
122 117 psm_mod_init(void **handlepp, struct psm_info *infop)
123 118 {
124 119 struct modlinkage **modlpp = (struct modlinkage **)handlepp;
125 120 int status;
126 121 struct modlinkage *mlinkp;
127 122
128 123 if (!*modlpp) {
129 124 mlinkp = psm_modlinkage_alloc(infop);
130 125 if (!mlinkp)
131 126 return (ENOSPC);
132 127 } else
133 128 mlinkp = *modlpp;
134 129
135 130 status = mod_install(mlinkp);
136 131 if (status) {
137 132 psm_modlinkage_free(mlinkp);
138 133 *modlpp = NULL;
139 134 } else
140 135 *modlpp = mlinkp;
141 136
142 137 return (status);
143 138 }
144 139
145 140 /*ARGSUSED1*/
146 141 int
147 142 psm_mod_fini(void **handlepp, struct psm_info *infop)
148 143 {
149 144 struct modlinkage **modlpp = (struct modlinkage **)handlepp;
150 145 int status;
151 146
152 147 status = mod_remove(*modlpp);
153 148 if (status == 0) {
154 149 psm_modlinkage_free(*modlpp);
155 150 *modlpp = NULL;
156 151 }
157 152 return (status);
158 153 }
159 154
160 155 int
161 156 psm_mod_info(void **handlepp, struct psm_info *infop, struct modinfo *modinfop)
162 157 {
163 158 struct modlinkage **modlpp = (struct modlinkage **)handlepp;
164 159 int status;
165 160 struct modlinkage *mlinkp;
166 161
167 162 if (!*modlpp) {
168 163 mlinkp = psm_modlinkage_alloc(infop);
169 164 if (!mlinkp)
170 165 return ((int)NULL);
171 166 } else
172 167 mlinkp = *modlpp;
173 168
174 169 status = mod_info(mlinkp, modinfop);
175 170
176 171 if (!status) {
177 172 psm_modlinkage_free(mlinkp);
178 173 *modlpp = NULL;
179 174 } else
180 175 *modlpp = mlinkp;
181 176
182 177 return (status);
183 178 }
184 179
185 180 int
186 181 psm_add_intr(int lvl, avfunc xxintr, char *name, int vect, caddr_t arg)
187 182 {
188 183 return (add_avintr((void *)NULL, lvl, xxintr, name, vect,
189 184 arg, NULL, NULL, NULL));
190 185 }
191 186
192 187 int
193 188 psm_add_nmintr(int lvl, avfunc xxintr, char *name, caddr_t arg)
194 189 {
195 190 return (add_nmintr(lvl, xxintr, name, arg));
196 191 }
197 192
198 193 processorid_t
199 194 psm_get_cpu_id(void)
200 195 {
201 196 return (CPU->cpu_id);
202 197 }
203 198
204 199 caddr_t
205 200 psm_map_phys_new(paddr_t addr, size_t len, int prot)
↓ open down ↓ |
156 lines elided |
↑ open up ↑ |
206 201 {
207 202 uint_t pgoffset;
208 203 paddr_t base;
209 204 pgcnt_t npages;
210 205 caddr_t cvaddr;
211 206
212 207 if (len == 0)
213 208 return (0);
214 209
215 210 pgoffset = addr & MMU_PAGEOFFSET;
216 -#ifdef __xpv
217 - /*
218 - * If we're dom0, we're starting from a MA. translate that to a PA
219 - * XXPV - what about driver domains???
220 - */
221 - if (DOMAIN_IS_INITDOMAIN(xen_info)) {
222 - base = pfn_to_pa(xen_assign_pfn(mmu_btop(addr))) |
223 - (addr & MMU_PAGEOFFSET);
224 - } else {
225 - base = addr;
226 - }
227 -#else
228 211 base = addr;
229 -#endif
230 212 npages = mmu_btopr(len + pgoffset);
231 213 cvaddr = device_arena_alloc(ptob(npages), VM_NOSLEEP);
232 214 if (cvaddr == NULL)
233 215 return (0);
234 216 hat_devload(kas.a_hat, cvaddr, mmu_ptob(npages), mmu_btop(base),
235 217 prot, HAT_LOAD_LOCK);
236 218 return (cvaddr + pgoffset);
237 219 }
238 220
239 221 void
240 222 psm_unmap_phys(caddr_t addr, size_t len)
241 223 {
242 224 uint_t pgoffset;
243 225 caddr_t base;
244 226 pgcnt_t npages;
245 227
246 228 if (len == 0)
247 229 return;
248 230
249 231 pgoffset = (uintptr_t)addr & MMU_PAGEOFFSET;
250 232 base = addr - pgoffset;
251 233 npages = mmu_btopr(len + pgoffset);
252 234 hat_unload(kas.a_hat, base, ptob(npages), HAT_UNLOAD_UNLOCK);
253 235 device_arena_free(base, ptob(npages));
254 236 }
255 237
256 238 caddr_t
257 239 psm_map_new(paddr_t addr, size_t len, int prot)
258 240 {
259 241 int phys_prot = PROT_READ;
260 242
261 243 ASSERT(prot == (prot & (PSM_PROT_WRITE | PSM_PROT_READ)));
262 244 if (prot & PSM_PROT_WRITE)
263 245 phys_prot |= PROT_WRITE;
264 246
265 247 return (psm_map_phys(addr, len, phys_prot));
266 248 }
267 249
268 250 #undef psm_map_phys
269 251 #undef psm_map
270 252
271 253 caddr_t
272 254 psm_map_phys(uint32_t addr, size_t len, int prot)
273 255 {
274 256 return (psm_map_phys_new((paddr_t)(addr & 0xffffffff), len, prot));
275 257 }
276 258
277 259 caddr_t
278 260 psm_map(uint32_t addr, size_t len, int prot)
279 261 {
280 262 return (psm_map_new((paddr_t)(addr & 0xffffffff), len, prot));
281 263 }
282 264
283 265 void
284 266 psm_unmap(caddr_t addr, size_t len)
285 267 {
286 268 uint_t pgoffset;
287 269 caddr_t base;
288 270 pgcnt_t npages;
289 271
290 272 if (len == 0)
291 273 return;
292 274
293 275 pgoffset = (uintptr_t)addr & MMU_PAGEOFFSET;
294 276 base = addr - pgoffset;
295 277 npages = mmu_btopr(len + pgoffset);
296 278 hat_unload(kas.a_hat, base, ptob(npages), HAT_UNLOAD_UNLOCK);
297 279 device_arena_free(base, ptob(npages));
298 280 }
299 281
300 282 /*ARGSUSED1*/
301 283 static int
302 284 mod_installpsm(struct modlpsm *modl, struct modlinkage *modlp)
303 285 {
304 286 struct psm_sw *swp;
305 287
306 288 swp = modl->psm_swp;
307 289 mutex_enter(&psmsw_lock);
308 290 psmsw->psw_back->psw_forw = swp;
309 291 swp->psw_back = psmsw->psw_back;
310 292 swp->psw_forw = psmsw;
311 293 psmsw->psw_back = swp;
312 294 swp->psw_flag |= PSM_MOD_INSTALL;
313 295 mutex_exit(&psmsw_lock);
314 296 return (0);
315 297 }
316 298
317 299 /*ARGSUSED1*/
318 300 static int
319 301 mod_removepsm(struct modlpsm *modl, struct modlinkage *modlp)
320 302 {
321 303 struct psm_sw *swp;
322 304
323 305 swp = modl->psm_swp;
324 306 mutex_enter(&psmsw_lock);
325 307 if (swp->psw_flag & PSM_MOD_IDENTIFY) {
326 308 mutex_exit(&psmsw_lock);
327 309 return (EBUSY);
328 310 }
329 311 if (!(swp->psw_flag & PSM_MOD_INSTALL)) {
330 312 mutex_exit(&psmsw_lock);
331 313 return (0);
332 314 }
333 315
334 316 swp->psw_back->psw_forw = swp->psw_forw;
335 317 swp->psw_forw->psw_back = swp->psw_back;
336 318 mutex_exit(&psmsw_lock);
337 319 return (0);
↓ open down ↓ |
98 lines elided |
↑ open up ↑ |
338 320 }
339 321
340 322 /*ARGSUSED1*/
341 323 static int
342 324 mod_infopsm(struct modlpsm *modl, struct modlinkage *modlp, int *p0)
343 325 {
344 326 *p0 = (int)modl->psm_swp->psw_infop->p_owner;
345 327 return (0);
346 328 }
347 329
348 -#if defined(__xpv)
349 -#define DEFAULT_PSM_MODULE "xpv_uppc"
350 -#else
351 330 #define DEFAULT_PSM_MODULE "uppc"
352 -#endif
353 331
354 332 static char *
355 333 psm_get_impl_module(int first)
356 334 {
357 335 static char **pnamep;
358 336 static char *psm_impl_module_list[] = {
359 337 DEFAULT_PSM_MODULE,
360 338 (char *)0
361 339 };
362 340 static void *mhdl = NULL;
363 341 static char machname[MAXNAMELEN];
364 342
365 343 if (first)
366 344 pnamep = psm_impl_module_list;
367 345
368 346 if (*pnamep != (char *)0)
369 347 return (*pnamep++);
370 348
371 349 mhdl = get_next_mach(mhdl, machname);
372 350 if (mhdl)
373 351 return (machname);
374 352 return ((char *)0);
375 353 }
376 354
377 355 void
378 356 psm_modload(void)
379 357 {
380 358 char *this;
381 359
382 360 mutex_init(&psmsw_lock, NULL, MUTEX_DEFAULT, NULL);
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
383 361 open_mach_list();
384 362
385 363 for (this = psm_get_impl_module(1); this != (char *)NULL;
386 364 this = psm_get_impl_module(0)) {
387 365 if (modload("mach", this) == -1)
388 366 cmn_err(CE_CONT, "!Skipping psm: %s\n", this);
389 367 }
390 368 close_mach_list();
391 369 }
392 370
393 -#if defined(__xpv)
394 -#define NOTSUP_MSG "This version of Solaris xVM does not support this hardware"
395 -#else
396 -#define NOTSUP_MSG "This version of Solaris does not support this hardware"
397 -#endif /* __xpv */
398 -
399 371 void
400 372 psm_install(void)
401 373 {
402 374 struct psm_sw *swp, *cswp;
403 375 struct psm_ops *opsp;
404 376 char machstring[15];
405 377 int err, psmcnt = 0;
406 378
407 379 mutex_enter(&psmsw_lock);
408 380 for (swp = psmsw->psw_forw; swp != psmsw; ) {
409 381 opsp = swp->psw_infop->p_ops;
410 382 if (opsp->psm_probe) {
411 383 if ((*opsp->psm_probe)() == PSM_SUCCESS) {
412 384 psmcnt++;
413 385 swp->psw_flag |= PSM_MOD_IDENTIFY;
414 386 swp = swp->psw_forw;
415 387 continue;
416 388 }
417 389 }
418 390 /* remove the unsuccessful psm modules */
419 391 cswp = swp;
420 392 swp = swp->psw_forw;
421 393
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
422 394 mutex_exit(&psmsw_lock);
423 395 (void) strcpy(&machstring[0], cswp->psw_infop->p_mach_idstring);
424 396 err = mod_remove_by_name(cswp->psw_infop->p_mach_idstring);
425 397 if (err)
426 398 cmn_err(CE_WARN, "!%s: mod_remove_by_name failed %d",
427 399 &machstring[0], err);
428 400 mutex_enter(&psmsw_lock);
429 401 }
430 402 mutex_exit(&psmsw_lock);
431 403 if (psmcnt == 0)
432 - halt(NOTSUP_MSG);
404 + halt("This hardware is not supported by current OS version");
433 405 (*psminitf)();
434 406 }
435 407
436 408 /*
437 409 * Return 1 if kernel debugger is present, and 0 if not.
438 410 */
439 411 int
440 412 psm_debugger(void)
441 413 {
442 414 return ((boothowto & RB_DEBUG) != 0);
443 415 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX