- if (hasMapper)
- IOMapper::gSystem = (IOMapper *) kHasMapper;
- else {
- sMapperLock.lock();
- IOMapper::gSystem = (IOMapper *) kNoMapper;
- sMapperLock.unlock();
- sMapperLock.wakeup(&IOMapper::gSystem);
- }
-}
-
-void IOMapper::waitForSystemMapper()
-{
- sMapperLock.lock();
- while ((vm_address_t) IOMapper::gSystem & kWaitMask)
- sMapperLock.sleep(&IOMapper::gSystem);
- sMapperLock.unlock();
-}
-
-void IOMapper::iovmInsert(ppnum_t addr, IOItemCount offset,
- ppnum_t *pageList, IOItemCount pageCount)
-{
- while (pageCount--)
- iovmInsert(addr, offset++, *pageList++);
-}
-
-void IOMapper::iovmInsert(ppnum_t addr, IOItemCount offset,
- upl_page_info_t *pageList, IOItemCount pageCount)
-{
- for (IOItemCount i = 0; i < pageCount; i++)
- iovmInsert(addr, offset + i, pageList[i].phys_addr);
-}
-
-OSData * IOMapper::
-NewARTTable(IOByteCount size, void ** virtAddrP, ppnum_t *physAddrP)
-{
- if (!virtAddrP || !physAddrP)
- return 0;
-
- kern_return_t kr;
- vm_address_t address;
-
- size = round_page_32(size);
- kr = kmem_alloc_contig(kernel_map, &address, size, PAGE_MASK, 0);
- if (kr)
- 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;