Changeset 27037 in vbox for trunk/src/VBox
- Timestamp:
- Mar 4, 2010 2:43:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
r27009 r27037 312 312 { 313 313 PRTR0MEMOBJSOLARIS pMemSolaris; 314 void *pv;315 316 /* Create the object. */317 pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);318 if (!pMemSolaris)319 return VERR_NO_MEMORY;320 314 321 315 /* 322 316 * Use xalloc. 323 317 */ 324 pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/,318 void *pv = vmem_xalloc(heap_arena, cb, uAlignment, 0 /*phase*/, 0 /*nocross*/, 325 319 NULL /*minaddr*/, NULL /*maxaddr*/, VM_SLEEP); 326 320 if (RT_UNLIKELY(!pv)) 327 { 328 rtR0MemObjDelete(&pMemSolaris->Core); 321 return VERR_NO_MEMORY; 322 323 /* Create the object. */ 324 pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_RES_VIRT, pv, cb); 325 if (!pMemSolaris) 326 { 327 LogRel(("rtR0MemObjNativeReserveKernel failed to alloc memory object.\n")); 328 vmem_xfree(heap_arena, pv, cb); 329 329 return VERR_NO_MEMORY; 330 330 } … … 357 357 358 358 PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap; 359 size_t size = pMemToMapSolaris->Core.cb; 360 void *pv = pMemToMapSolaris->Core.pv; 361 pgcnt_t cPages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 362 pgcnt_t iPage; 363 uint64_t *paddrs; 364 caddr_t addr; 365 int rc; 359 size_t cb = pMemToMapSolaris->Core.cb; 360 void *pv = pMemToMapSolaris->Core.pv; 361 pgcnt_t cPages = (cb + PAGE_SIZE - 1) >> PAGE_SHIFT; 366 362 367 363 /* Create the mapping object */ 368 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);369 if (!pMemSolaris) 370 return VERR_NO_MEMORY; 371 372 paddrs = kmem_zalloc(sizeof(uint64_t) * cPages, KM_SLEEP);373 for ( iPage = 0; iPage < cPages; iPage++)374 { 375 pa ddrs[iPage] = vbi_va_to_pa(pv);376 if ( paddrs[iPage] == -(uint64_t)1)364 PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, cb); 365 if (!pMemSolaris) 366 return VERR_NO_MEMORY; 367 368 uint64_t *paPhysAddrs = kmem_zalloc(sizeof(uint64_t) * cPages, KM_SLEEP); 369 for (pgcnt_t iPage = 0; iPage < cPages; iPage++) 370 { 371 paPhysAddrs[iPage] = vbi_va_to_pa(pv); 372 if (RT_UNLIKELY(paPhysAddrs[iPage] == -(uint64_t)1)) 377 373 { 378 374 LogRel(("rtR0MemObjNativeMapUser: no page to map.\n")); 379 kmem_free(pa ddrs, sizeof(uint64_t) * cPages);375 kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages); 380 376 rtR0MemObjDelete(&pMemSolaris->Core); 381 377 return VERR_MAP_FAILED; … … 384 380 } 385 381 386 rc = vbi_user_map(&addr, fProt, paddrs, size); 382 caddr_t virtAddr = NULL; 383 int rc = vbi_user_map(&virtAddr, fProt, paPhysAddrs, cb); 387 384 if (rc != 0) 388 385 { 389 386 LogRel(("rtR0MemObjNativeMapUser: vbi mapping failure.\n")); 390 kmem_free(pa ddrs, sizeof(uint64_t) * cPages);387 kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages); 391 388 rtR0MemObjDelete(&pMemSolaris->Core); 392 389 return VERR_MAP_FAILED; … … 396 393 397 394 pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)vbi_proc(); 398 pMemSolaris->Core.pv = addr;399 *ppMem = &pMemSolaris->Core; 400 kmem_free(pa ddrs, sizeof(uint64_t) * cPages);395 pMemSolaris->Core.pv = virtAddr; 396 *ppMem = &pMemSolaris->Core; 397 kmem_free(paPhysAddrs, sizeof(uint64_t) * cPages); 401 398 return rc; 402 399 }
Note:
See TracChangeset
for help on using the changeset viewer.