Changeset 19071 in vbox for trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
- Timestamp:
- Apr 21, 2009 12:34:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
r19005 r19071 593 593 { 594 594 vm_object_t pObjectNew = vm_object_allocate(OBJT_PHYS, pMemToMap->cb >> PAGE_SHIFT); 595 if (pObjectNew) 595 if (!RT_UNLIKELY(pObjectNew)) 596 return VERR_NO_MEMORY; 597 598 /* Insert the object in the map. */ 599 rc = vm_map_find(pProcMap, /* Map to insert the object in */ 600 pObjectNew , /* Object to map */ 601 0, /* Start offset in the object */ 602 &AddrR3, /* Start address IN/OUT */ 603 pMemToMap->cb, /* Size of the mapping */ 604 TRUE, /* Whether a suitable address should be searched for first */ 605 ProtectionFlags, /* protection flags */ 606 VM_PROT_ALL, /* Maximum protection flags */ 607 0); /* Copy on write */ 608 if (rc == KERN_SUCCESS) 596 609 { 597 /* Insert the object in the map. */ 598 rc = vm_map_find(pProcMap, /* Map to insert the object in */ 599 pObjectNew , /* Object to map */ 600 0, /* Start offset in the object */ 601 &AddrR3, /* Start address IN/OUT */ 602 pMemToMap->cb, /* Size of the mapping */ 603 TRUE, /* Whether a suitable address should be searched for first */ 604 ProtectionFlags, /* protection flags */ 605 VM_PROT_ALL, /* Maximum protection flags */ 606 0); /* Copy on write */ 607 if (rc == KERN_SUCCESS) 608 { 609 size_t cLeft = pMemToMap->cb >> PAGE_SHIFT; 610 vm_offset_t AddrToMap = (vm_offset_t)pMemToMap->pv; 611 pmap_t pPhysicalMap = pProcMap->pmap; 612 vm_offset_t AddrR3Dst = AddrR3; 613 614 /* Insert the memory page by page into the mapping. */ 615 while (cLeft-- > 0) 616 { 617 vm_page_t Page = PHYS_TO_VM_PAGE(vtophys(AddrToMap)); 618 619 pmap_enter(pPhysicalMap, AddrR3Dst, Page, ProtectionFlags, TRUE); 620 AddrToMap += PAGE_SIZE; 621 AddrR3Dst += PAGE_SIZE; 622 } 623 pObjectToMap = pObjectNew; 624 } 625 else 626 vm_object_deallocate(pObjectNew); 610 size_t cLeft = pMemToMap->cb >> PAGE_SHIFT; 611 vm_offset_t AddrToMap = (vm_offset_t)pMemToMap->pv; 612 pmap_t pPhysicalMap = pProcMap->pmap; 613 vm_offset_t AddrR3Dst = AddrR3; 614 615 /* Insert the memory page by page into the mapping. */ 616 while (cLeft-- > 0) 617 { 618 vm_page_t Page = PHYS_TO_VM_PAGE(vtophys(AddrToMap)); 619 620 pmap_enter(pPhysicalMap, AddrR3Dst, Page, ProtectionFlags, TRUE); 621 AddrToMap += PAGE_SIZE; 622 AddrR3Dst += PAGE_SIZE; 623 } 624 pObjectToMap = pObjectNew; 627 625 } 628 626 else 629 return VERR_NO_MEMORY;627 vm_object_deallocate(pObjectNew); 630 628 } 631 629 else
Note:
See TracChangeset
for help on using the changeset viewer.