- dataP->v = (void *) startUpl;
-
- do {
- upl_t iopl;
- int upl_flags = UPL_SET_INTERNAL | UPL_SET_LITE
- | UPL_SET_IO_WIRE | UPL_COPYOUT_FROM;
- vm_size_t iopl_size = size;
-
- kr = vm_map_get_upl(kernel_map,
- (vm_map_offset_t)startUpl,
- &iopl_size,
- &iopl,
- 0,
- 0,
- &upl_flags,
- 0);
- if (kr) {
- panic("IOMapper:vm_map_get_upl returned 0x%x\n");
- goto bail;
- }
-
- if (!ret->appendBytes(&iopl, sizeof(upl_t)))
- goto bail;
-
- startUpl += iopl_size;
- size -= iopl_size;
- } while(size);
-
- // Need to re-establish the dataP as the OSData may have grown.
- dataP = getARTDataP(ret);
-
- // Now grab the page entry of the first page and get its phys addr
- pl = UPL_GET_INTERNAL_PAGE_LIST(dataP->u[0]);
- *physAddrP = pl->phys_addr;
- *virtAddrP = dataP->v;
-
- return ret;
-
-bail:
- FreeARTTable(ret, size);
- return 0;
+ ppnum_t pagenum = pmap_find_phys(kernel_pmap, (addr64_t) address);
+ if (pagenum)
+ *physAddrP = pagenum;
+ else {
+ FreeARTTable((OSData *) address, size);
+ address = 0;
+ }
+
+ *virtAddrP = (void *) address;
+
+ return (OSData *) address;