Changeset 18970 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
- Timestamp:
- Apr 16, 2009 11:36:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
r18960 r18970 44 44 #include "internal/memobj.h" 45 45 46 46 47 /******************************************************************************* 47 48 * Structures and Typedefs * … … 152 153 153 154 rc = vm_map_remove(pMap, 154 155 155 (vm_offset_t)pMemFreeBSD->Core.pv, 156 (vm_offset_t)pMemFreeBSD->Core.pv + pMemFreeBSD->Core.cb); 156 157 AssertMsg(rc == KERN_SUCCESS, ("%#x", rc)); 157 158 break; … … 557 558 } 558 559 560 559 561 /* see http://markmail.org/message/udhq33tefgtyfozs */ 560 562 int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process) … … 563 565 AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED); 564 566 565 int rc;566 vm_object_t pObjectToMap = ((PRTR0MEMOBJFREEBSD)pMemToMap)->pObject;567 struct proc *pProc = (struct proc *)R0Process;568 struct vm_map *pProcMap = &pProc->p_vmspace->vm_map;569 vm_offset_t AddrR3 = 0; 570 vm_prot_t ProtectionFlags = 0;571 567 int rc; 568 vm_object_t pObjectToMap = ((PRTR0MEMOBJFREEBSD)pMemToMap)->pObject; 569 struct proc *pProc = (struct proc *)R0Process; 570 struct vm_map *pProcMap = &pProc->p_vmspace->vm_map; 571 572 /* calc protection */ 573 vm_prot_t ProtectionFlags = 0; 572 574 if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE) 573 575 ProtectionFlags = VM_PROT_NONE; … … 579 581 ProtectionFlags |= VM_PROT_EXECUTE; 580 582 583 /* calc mapping address */ 581 584 PROC_LOCK(pProc); 582 AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA));585 vm_offset_t AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA)); 583 586 PROC_UNLOCK(pProc); 584 587 … … 604 607 if (rc == KERN_SUCCESS) 605 608 { 606 int cPages = pMemToMap->cb >> PAGE_SHIFT; 607 int iPage; 608 void *AddrToMap = pMemToMap->pv; 609 size_t cLeft = pMemToMap->cb >> PAGE_SHIFT; 610 vm_offset_t AddrToMap = (vm_offset_t)pMemToMap->pv; 609 611 pmap_t pPhysicalMap = pProcMap->pmap; 610 vm_offset_t AddrR3D est= AddrR3;612 vm_offset_t AddrR3Dst = AddrR3; 611 613 612 614 /* Insert the memory page by page into the mapping. */ 613 for (iPage = 0; iPage < cPages; iPage++)615 while (cLeft-- > 0) 614 616 { 615 617 vm_page_t Page = PHYS_TO_VM_PAGE(vtophys(AddrToMap)); 616 618 617 pmap_enter(pPhysicalMap, AddrR3D est, Page, ProtectionFlags, TRUE);618 AddrToMap = (uint8_t *)AddrToMap +PAGE_SIZE;619 AddrR3D est += PAGE_SIZE;619 pmap_enter(pPhysicalMap, AddrR3Dst, Page, ProtectionFlags, TRUE); 620 AddrToMap += PAGE_SIZE; 621 AddrR3Dst += PAGE_SIZE; 620 622 } 621 623 pObjectToMap = pObjectNew; … … 632 634 else 633 635 { 634 /* 636 /* 635 637 * Reference the object. If this isn't done the object will removed from kernel space 636 638 * if the mapping is destroyed. … … 655 657 */ 656 658 PRTR0MEMOBJFREEBSD pMemFreeBSD = (PRTR0MEMOBJFREEBSD)rtR0MemObjNew(sizeof(RTR0MEMOBJFREEBSD), 657 RTR0MEMOBJTYPE_MAPPING, 659 RTR0MEMOBJTYPE_MAPPING, 658 660 (void *)AddrR3, 659 661 pMemToMap->cb); 660 662 if (pMemFreeBSD) 661 663 { 662 Assert( pMemFreeBSD->Core.pv == (void *)AddrR3);664 Assert((vm_offset_t)pMemFreeBSD->Core.pv == AddrR3); 663 665 pMemFreeBSD->Core.u.Mapping.R0Process = R0Process; 664 666 pMemFreeBSD->pMappingObject = pObjectToMap; … … 685 687 { 686 688 case RTR0MEMOBJTYPE_LOCK: 687 {688 689 if ( pMemFreeBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS 689 690 && pMemFreeBSD->Core.u.Lock.R0Process != (RTR0PROCESS)curproc) … … 692 693 return NIL_RTHCPHYS; 693 694 } 694 }695 /* fall thru*/ 695 696 case RTR0MEMOBJTYPE_PAGE: 696 697 case RTR0MEMOBJTYPE_MAPPING: 697 698 { 698 uint8_t *pb = (uint8_t *)pMemFreeBSD->Core.pv + ( (size_t)iPage << PAGE_SHIFT);699 uint8_t *pb = (uint8_t *)pMemFreeBSD->Core.pv + (iPage << PAGE_SHIFT); 699 700 return vtophys(pb); 700 701 } … … 713 714 } 714 715 } 716
Note:
See TracChangeset
for help on using the changeset viewer.