VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c@ 8170

Last change on this file since 8170 was 8170, checked in by vboxsync, 17 years ago

Rebranding: replacing more innotek strings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.8 KB
Line 
1/* $Id: memobj-r0drv-solaris.c 8170 2008-04-18 17:52:25Z vboxsync $ */
2/** @file
3 * Incredibly Portable Runtime - Ring-0 Memory Objects, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "the-solaris-kernel.h"
36
37#include <iprt/memobj.h>
38#include <iprt/mem.h>
39#include <iprt/err.h>
40#include <iprt/assert.h>
41#include <iprt/log.h>
42#include <iprt/param.h>
43#include <iprt/process.h>
44#include "internal/memobj.h"
45
46
47/*******************************************************************************
48* Structures and Typedefs *
49*******************************************************************************/
50/**
51 * The Solaris version of the memory object structure.
52 */
53typedef struct RTR0MEMOBJSOLARIS
54{
55 /** The core structure. */
56 RTR0MEMOBJINTERNAL Core;
57 /** Pointer to kernel memory cookie. */
58 ddi_umem_cookie_t Cookie;
59 /** Shadow locked pages. */
60 page_t **ppShadowPages;
61} RTR0MEMOBJSOLARIS, *PRTR0MEMOBJSOLARIS;
62
63/**
64 * Used for supplying the solaris kernel info. about memory limits
65 * during contiguous allocations (i_ddi_mem_alloc)
66 */
67struct ddi_dma_attr g_SolarisX86PhysMemLimits =
68{
69 DMA_ATTR_V0, /* Version Number */
70 (uint64_t)0, /* lower limit */
71 (uint64_t)0xffffffff, /* high limit (32-bit PA, 4G) */
72 (uint64_t)0xffffffff, /* counter limit */
73 (uint64_t)PAGE_SIZE, /* alignment */
74 (uint64_t)PAGE_SIZE, /* burst size */
75 (uint64_t)PAGE_SIZE, /* effective DMA size */
76 (uint64_t)0xffffffff, /* max DMA xfer size */
77 (uint64_t)0xffffffff, /* segment boundary */
78 1, /* scatter-gather list length (1 for contiguous) */
79 1, /* device granularity */
80 0 /* bus-specific flags */
81};
82
83
84
85static uint64_t rtR0MemObjSolarisVirtToPhys(struct hat* hatSpace, caddr_t virtAddr)
86{
87 /* We could use paddr_t (more solaris-like) rather than uint64_t but paddr_t isn't defined for 64-bit */
88 pfn_t pfn = hat_getpfnum(hatSpace, virtAddr);
89 if (pfn == PFN_INVALID)
90 {
91 AssertMsgFailed(("rtR0MemObjSolarisVirtToPhys: hat_getpfnum for %p failed.\n", virtAddr));
92 return PFN_INVALID;
93 }
94
95 /* Both works, but second will work for non-page aligned virtAddr */
96#if 0
97 uint64_t physAddr = PAGE_SIZE * pfn;
98#else
99 uint64_t physAddr = ((uint64_t)pfn << MMU_PAGESHIFT) | ((uintptr_t)virtAddr & MMU_PAGEOFFSET);
100#endif
101 return physAddr;
102}
103
104
105int rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
106{
107 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)pMem;
108
109 switch (pMemSolaris->Core.enmType)
110 {
111 case RTR0MEMOBJTYPE_CONT:
112 i_ddi_mem_free(pMemSolaris->Core.pv, NULL);
113 break;
114
115 case RTR0MEMOBJTYPE_PAGE:
116 ddi_umem_free(pMemSolaris->Cookie);
117 break;
118
119 case RTR0MEMOBJTYPE_LOCK:
120 {
121 struct as *addrSpace;
122 if (pMemSolaris->Core.u.Lock.R0Process == NIL_RTR0PROCESS)
123 addrSpace = &kas;
124 else
125 addrSpace = ((proc_t *)pMemSolaris->Core.u.Lock.R0Process)->p_as;
126
127 as_pageunlock(addrSpace, pMemSolaris->ppShadowPages, pMemSolaris->Core.pv, pMemSolaris->Core.cb, S_WRITE);
128 break;
129 }
130
131 case RTR0MEMOBJTYPE_MAPPING:
132 {
133 struct hat *hatSpace;
134 struct as *addrSpace;
135 if (pMemSolaris->Core.u.Mapping.R0Process == NIL_RTR0PROCESS)
136 {
137 /* Kernel process*/
138 hatSpace = kas.a_hat;
139 addrSpace = &kas;
140 }
141 else
142 {
143 /* User process */
144 proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Mapping.R0Process;
145 hatSpace = userProc->p_as->a_hat;
146 addrSpace = userProc->p_as;
147 }
148
149 rw_enter(&addrSpace->a_lock, RW_READER);
150 hat_unload(hatSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb, HAT_UNLOAD_UNLOCK);
151 rw_exit(&addrSpace->a_lock);
152 as_unmap(addrSpace, pMemSolaris->Core.pv, pMemSolaris->Core.cb);
153 break;
154 }
155
156 /* unused */
157 case RTR0MEMOBJTYPE_LOW:
158 case RTR0MEMOBJTYPE_PHYS:
159 case RTR0MEMOBJTYPE_RES_VIRT:
160 default:
161 AssertMsgFailed(("enmType=%d\n", pMemSolaris->Core.enmType));
162 return VERR_INTERNAL_ERROR;
163 }
164
165 return VINF_SUCCESS;
166}
167
168
169int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
170{
171 /* Create the object */
172 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PAGE, NULL, cb);
173 if (!pMemSolaris)
174 return VERR_NO_MEMORY;
175
176 void *virtAddr = ddi_umem_alloc(cb, DDI_UMEM_SLEEP, &pMemSolaris->Cookie);
177 if (!virtAddr)
178 {
179 rtR0MemObjDelete(&pMemSolaris->Core);
180 return VERR_NO_PAGE_MEMORY;
181 }
182
183 pMemSolaris->Core.pv = virtAddr;
184 pMemSolaris->ppShadowPages = NULL;
185 *ppMem = &pMemSolaris->Core;
186 return VINF_SUCCESS;
187}
188
189
190int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
191{
192 /* Try page alloc first */
193 int rc = rtR0MemObjNativeAllocPage(ppMem, cb, fExecutable);
194 if (RT_SUCCESS(rc))
195 {
196 size_t iPage = cb >> PAGE_SHIFT;
197 while (iPage-- > 0)
198 if (rtR0MemObjNativeGetPagePhysAddr(*ppMem, iPage) > (_4G - PAGE_SIZE))
199 {
200 /* Failed! Fall back to physical contiguous alloc */
201 RTR0MemObjFree(*ppMem, false);
202 rc = rtR0MemObjNativeAllocCont(ppMem, cb, fExecutable);
203 break;
204 }
205 }
206 return rc;
207}
208
209
210int rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
211{
212 NOREF(fExecutable);
213
214 /* Create the object */
215 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb);
216 if (!pMemSolaris)
217 return VERR_NO_MEMORY;
218
219 /* Allocate physically contiguous page-aligned memory. */
220 caddr_t virtAddr;
221 int rc = i_ddi_mem_alloc(NULL, &g_SolarisX86PhysMemLimits, cb, 1, 0, NULL, &virtAddr, NULL, NULL);
222 if (rc != DDI_SUCCESS)
223 {
224 rtR0MemObjDelete(&pMemSolaris->Core);
225 return VERR_NO_CONT_MEMORY;
226 }
227
228 pMemSolaris->Core.pv = virtAddr;
229 pMemSolaris->Core.u.Cont.Phys = rtR0MemObjSolarisVirtToPhys(kas.a_hat, virtAddr);
230 pMemSolaris->ppShadowPages = NULL;
231 *ppMem = &pMemSolaris->Core;
232 return VINF_SUCCESS;
233}
234
235
236int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
237{
238 /** @todo rtR0MemObjNativeAllocPhysNC / solaris */
239 return VERR_NOT_SUPPORTED; /* see the RTR0MemObjAllocPhysNC specs */
240}
241
242
243int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
244{
245 AssertMsgReturn(PhysHighest >= 16 *_1M, ("PhysHigest=%VHp\n", PhysHighest), VERR_NOT_IMPLEMENTED);
246
247 return rtR0MemObjNativeAllocCont(ppMem, cb, false);
248}
249
250
251int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb)
252{
253 /* Create the object */
254 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS, NULL, cb);
255 if (!pMemSolaris)
256 return VERR_NO_MEMORY;
257
258 /* There is no allocation here, it needs to be mapped somewhere first */
259 pMemSolaris->Core.u.Phys.fAllocated = false;
260 pMemSolaris->Core.u.Phys.PhysBase = Phys;
261 *ppMem = &pMemSolaris->Core;
262 return VINF_SUCCESS;
263}
264
265
266int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process)
267{
268 /* Create the locking object */
269 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
270 if (!pMemSolaris)
271 return VERR_NO_MEMORY;
272
273 proc_t *userproc = curproc;
274 if (R0Process != NIL_RTR0PROCESS)
275 userproc = (proc_t *)R0Process;
276
277 struct as *useras = userproc->p_as;
278 page_t **ppl;
279
280 /* Lock down user pages */
281 int rc = as_pagelock(useras, &ppl, (caddr_t)R3Ptr, cb, S_WRITE);
282 if (rc != 0)
283 {
284 cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: as_pagelock failed rc=%d\n", rc);
285 return VERR_LOCK_FAILED;
286 }
287
288 if (!ppl)
289 {
290 as_pageunlock(useras, ppl, (caddr_t)R3Ptr, cb, S_WRITE);
291 cmn_err(CE_NOTE, "rtR0MemObjNativeLockUser: as_pagelock failed to get shadow pages\n");
292 return VERR_LOCK_FAILED;
293 }
294
295 pMemSolaris->Core.u.Lock.R0Process = (RTR0PROCESS)userproc;
296 pMemSolaris->ppShadowPages = ppl;
297 *ppMem = &pMemSolaris->Core;
298 return VINF_SUCCESS;
299}
300
301
302int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
303{
304 /* Create the locking object */
305 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_LOCK, pv, cb);
306 if (!pMemSolaris)
307 return VERR_NO_MEMORY;
308
309 caddr_t virtAddr = (caddr_t)((uintptr_t)pv & (uintptr_t)PAGEMASK);
310 page_t **ppl;
311
312 /* Lock down kernel pages */
313 int rc = as_pagelock(&kas, &ppl, virtAddr, cb, S_WRITE);
314 if (rc != 0)
315 {
316 cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: as_pagelock failed rc=%d\n", rc);
317 return VERR_LOCK_FAILED;
318 }
319
320 if (!ppl)
321 {
322 as_pageunlock(&kas, ppl, virtAddr, cb, S_WRITE);
323 cmn_err(CE_NOTE, "rtR0MemObjNativeLockKernel: failed to get shadow pages\n");
324 return VERR_LOCK_FAILED;
325 }
326
327 pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS; /* means kernel, see rtR0MemObjNativeFree() */
328 pMemSolaris->ppShadowPages = ppl;
329 *ppMem = &pMemSolaris->Core;
330 return VINF_SUCCESS;
331}
332
333
334int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
335{
336 return VERR_NOT_IMPLEMENTED;
337}
338
339
340int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
341{
342 return VERR_NOT_IMPLEMENTED;
343}
344
345int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
346{
347 PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;
348 size_t size = pMemToMapSolaris->Core.cb;
349 void *pv = pMemToMapSolaris->Core.pv;
350 pgcnt_t cPages = btop(size);
351 pgcnt_t iPage;
352 caddr_t addr;
353 int rc;
354
355 /* Create the mapping object */
356 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
357 if (!pMemSolaris)
358 return VERR_NO_MEMORY;
359
360 as_rangelock(&kas);
361 if (pvFixed != (void *)-1)
362 {
363 /* Use user specified address */
364 addr = (caddr_t)pvFixed;
365
366 /* Blow away any previous mapping */
367 as_unmap(&kas, addr, size);
368 }
369 else
370 {
371 /* Let the system choose an address */
372 map_addr(&addr, size, 0, 1, MAP_SHARED | MAP_ANONYMOUS);
373 if (addr == NULL)
374 {
375 as_rangeunlock(&kas);
376 cmn_err(CE_NOTE, "rtR0MemObjNativeMapKernel: map_addr failed\n");
377 return VERR_NO_MEMORY;
378 }
379
380 /* Check address against alignment, fail if it doesn't match */
381 if ((uintptr_t)addr & (uAlignment - 1))
382 {
383 as_rangeunlock(&kas);
384 cmn_err(CE_NOTE, "rtR0MemObjNativeMapKernel: map_addr alignment(%ld) failed.\n", uAlignment);
385 return VERR_MAP_FAILED;
386 }
387 }
388
389 /* Our protection masks are identical to <sys/mman.h> but we
390 * need to add PROT_USER for the pages to be accessible by user
391 */
392 struct segvn_crargs crArgs = SEGVN_ZFOD_ARGS(fProt | PROT_USER, PROT_ALL);
393 rc = as_map(&kas, addr, size, segvn_create, &crArgs);
394 as_rangeunlock(&kas);
395 if (rc != 0)
396 {
397 cmn_err(CE_NOTE, "rtR0MemObjNativeMapKernel: as_map failure.\n");
398 return VERR_NO_MEMORY;
399 }
400
401 /* Map each page into kernel space */
402 rw_enter(&kas.a_lock, RW_READER);
403 caddr_t kernAddr = pv;
404 caddr_t pageAddr = addr;
405 for (iPage = 0; iPage < cPages; iPage++)
406 {
407 page_t *pp = page_numtopp_nolock(hat_getpfnum(kas.a_hat, kernAddr));
408 hat_memload(kas.a_hat, pageAddr, pp, (fProt | PROT_USER), HAT_LOAD_LOCK);
409 pageAddr += ptob(1);
410 kernAddr += ptob(1);
411 }
412 rw_exit(&kas.a_lock);
413
414 pMemSolaris->Core.u.Mapping.R0Process = NIL_RTR0PROCESS; /* means kernel */
415 pMemSolaris->Core.pv = addr;
416 *ppMem = &pMemSolaris->Core;
417 return VINF_SUCCESS;
418}
419
420
421int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
422{
423 PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap;
424 size_t size = pMemToMapSolaris->Core.cb;
425 proc_t *userproc = (proc_t *)R0Process;
426 struct as *useras = userproc->p_as;
427 void *pv = pMemToMapSolaris->Core.pv;
428 pgcnt_t cPages = btop(size);
429 pgcnt_t iPage;
430 caddr_t addr;
431 int rc;
432
433 /* Create the mapping object */
434 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
435 if (!pMemSolaris)
436 return VERR_NO_MEMORY;
437
438 as_rangelock(useras);
439 if (R3PtrFixed != (RTR3PTR)-1)
440 {
441 /* Use user specified address */
442 addr = (caddr_t)R3PtrFixed;
443
444 /* Verify user address (a bit paranoid) */
445 rc = valid_usr_range(addr, size, fProt, useras, (caddr_t)USERLIMIT32);
446 if (rc != RANGE_OKAY)
447 {
448 as_rangeunlock(useras);
449 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: valid_usr_range failed, returned %d\n", rc);
450 return VERR_INVALID_POINTER;
451 }
452
453 /* Blow away any previous mapping */
454 as_unmap(useras, addr, size);
455 }
456 else
457 {
458 /* Let the system choose an address */
459 map_addr(&addr, size, 0, 1, MAP_SHARED | MAP_ANONYMOUS);
460 if (addr == NULL)
461 {
462 as_rangeunlock(useras);
463 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr failed\n");
464 return VERR_MAP_FAILED;
465 }
466
467 /* Check address against alignment, fail if it doesn't match */
468 if ((uintptr_t)addr & (uAlignment - 1))
469 {
470 as_rangeunlock(useras);
471 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr alignment(%ld) failed.\n", uAlignment);
472 return VERR_MAP_FAILED;
473 }
474 }
475
476 /* Our protection masks are identical to <sys/mman.h> but we
477 * need to add PROT_USER for the pages to be accessible by user
478 */
479 struct segvn_crargs crArgs = SEGVN_ZFOD_ARGS(fProt | PROT_USER, PROT_ALL);
480 rc = as_map(useras, addr, size, segvn_create, &crArgs);
481 as_rangeunlock(useras);
482 if (rc != 0)
483 {
484 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_map failure.\n");
485 return VERR_MAP_FAILED;
486 }
487
488#if 0
489 /* Lock down the pages and get the shadow page list
490 * In this case we must as_pageunlock if(ppShadowPages) exists while freeing CONT, PAGE
491 */
492 rc = as_pagelock(&kas, &pMemToMapSolaris->ppShadowPages, pv, size, S_WRITE);
493 if (rc != 0 || pMemToMapSolaris->ppShadowPages == NULL)
494 {
495 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_pagelock failed\n");
496 as_unmap(useras, addr, size);
497 return VERR_NO_MEMORY;
498 }
499
500 /* Map each page into user space */
501 rw_enter(&useras->a_lock, RW_READER);
502 caddr_t pageAddr = addr;
503 for (iPage = 0; iPage < cPages; iPage++)
504 {
505 hat_memload(useras->a_hat, pageAddr, pMemToMapSolaris->ppShadowPages[iPage], fProt | PROT_USER,
506 HAT_LOAD_NOCONSIST | HAT_STRICTORDER | HAT_LOAD_LOCK);
507 pageAddr += ptob(1);
508 }
509 rw_exit(&useras->a_lock, RW_READER);
510#else
511 /* Map each page into user space */
512 rw_enter(&useras->a_lock, RW_READER);
513 caddr_t kernAddr = pv;
514 caddr_t pageAddr = addr;
515 for (iPage = 0; iPage < cPages; iPage++)
516 {
517 page_t *pp = page_numtopp_nolock(hat_getpfnum(kas.a_hat, kernAddr));
518 hat_memload(useras->a_hat, pageAddr, pp, (fProt | PROT_USER), HAT_LOAD_LOCK);
519 pageAddr += ptob(1);
520 kernAddr += ptob(1);
521 }
522 rw_exit(&useras->a_lock);
523#endif
524
525 pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)userproc;
526 pMemSolaris->Core.pv = addr;
527 *ppMem = &pMemSolaris->Core;
528 return VINF_SUCCESS;
529}
530
531
532RTHCPHYS rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage)
533{
534 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)pMem;
535
536 switch (pMemSolaris->Core.enmType)
537 {
538 case RTR0MEMOBJTYPE_PAGE:
539 case RTR0MEMOBJTYPE_LOW:
540 case RTR0MEMOBJTYPE_MAPPING:
541 {
542 uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
543 return rtR0MemObjSolarisVirtToPhys(kas.a_hat, pb);
544 }
545
546 case RTR0MEMOBJTYPE_LOCK:
547 {
548 struct hat *hatSpace;
549 if (pMemSolaris->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
550 {
551 /* User */
552 proc_t *userProc = (proc_t *)pMemSolaris->Core.u.Lock.R0Process;
553 hatSpace = userProc->p_as->a_hat;
554 }
555 else /* Kernel */
556 hatSpace = kas.a_hat;
557
558 uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
559 return rtR0MemObjSolarisVirtToPhys(hatSpace, pb);
560 }
561
562 case RTR0MEMOBJTYPE_CONT:
563 return pMemSolaris->Core.u.Cont.Phys + (iPage << PAGE_SHIFT);
564
565 case RTR0MEMOBJTYPE_PHYS:
566 return pMemSolaris->Core.u.Phys.PhysBase + (iPage << PAGE_SHIFT);
567
568 case RTR0MEMOBJTYPE_PHYS_NC:
569 AssertFailed(/* not implemented */);
570 case RTR0MEMOBJTYPE_RES_VIRT:
571 default:
572 return NIL_RTHCPHYS;
573 }
574}
575
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette