Changeset 8527 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- May 2, 2008 7:06:57 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/solaris/memobj-r0drv-solaris.c
r8330 r8527 274 274 275 275 proc_t *userproc = (proc_t *)R0Process; 276 277 276 struct as *useras = userproc->p_as; 278 277 page_t **ppl; … … 295 294 else 296 295 cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: as_pagelock failed rc=%d\n", rc); 297 rtR0MemObjDelete( pMemSolaris);296 rtR0MemObjDelete(&pMemSolaris->Core); 298 297 return VERR_LOCK_FAILED; 299 298 } … … 327 326 else 328 327 cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: as_pagelock failed rc=%d\n", rc); 329 rtR0MemObjDelete( pMemSolaris);328 rtR0MemObjDelete(&pMemSolaris->Core); 330 329 return VERR_LOCK_FAILED; 331 330 } … … 345 344 int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt) 346 345 { 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; 346 /* @todo rtR0MemObjNativeMapKernel / Solaris - Should be fairly simple alloc kernel memory and memload it. */ 347 return VERR_NOT_IMPLEMENTED; 418 348 } 419 349 … … 421 351 int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process) 422 352 { 353 AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED); 354 AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED); 355 423 356 PRTR0MEMOBJSOLARIS pMemToMapSolaris = (PRTR0MEMOBJSOLARIS)pMemToMap; 424 357 size_t size = pMemToMapSolaris->Core.cb; … … 431 364 int rc; 432 365 366 /* Request the system for a mapping address. */ 433 367 as_rangelock(useras); 434 if (R3PtrFixed != (RTR3PTR)-1) 435 { 436 /* Use user specified address */ 437 addr = (caddr_t)R3PtrFixed; 438 439 /* Verify user address (a bit paranoid) */ 440 rc = valid_usr_range(addr, size, fProt, useras, (caddr_t)USERLIMIT32); 441 if (rc != RANGE_OKAY) 442 { 443 as_rangeunlock(useras); 444 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: valid_usr_range failed, returned %d\n", rc); 445 return VERR_INVALID_POINTER; 446 } 447 448 /* Blow away any previous mapping */ 449 as_unmap(useras, addr, size); 450 } 451 else 452 { 453 /* Let the system choose an address */ 454 map_addr(&addr, size, 0, 1, MAP_SHARED | MAP_ANONYMOUS); 455 if (addr == NULL) 456 { 457 as_rangeunlock(useras); 458 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr failed\n"); 459 return VERR_MAP_FAILED; 460 } 461 462 /* Check address against alignment, fail if it doesn't match */ 463 if ((uintptr_t)addr & (uAlignment - 1)) 464 { 465 as_rangeunlock(useras); 466 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr alignment(%ld) failed.\n", uAlignment); 467 return VERR_MAP_FAILED; 468 } 368 map_addr(&addr, size, 0 /* offset */, 1 /* vac-align */, MAP_SHARED | MAP_ANONYMOUS); 369 if (!addr) 370 { 371 as_rangeunlock(useras); 372 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr failed\n"); 373 return VERR_MAP_FAILED; 374 } 375 376 /* Check address against alignment, fail if it doesn't match */ 377 if ((uintptr_t)addr & (uAlignment - 1)) 378 { 379 as_rangeunlock(useras); 380 cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: map_addr alignment(%ld) failed.\n", uAlignment); 381 return VERR_MAP_FAILED; 469 382 } 470 383
Note:
See TracChangeset
for help on using the changeset viewer.