+IOReturn IOMemoryDescriptor::redirect( task_t safeTask, bool redirect )
+{
+ IOReturn err;
+ _IOMemoryMap * mapping = 0;
+ OSIterator * iter;
+
+ LOCK;
+
+ do {
+ if( (iter = OSCollectionIterator::withCollection( _mappings))) {
+ while( (mapping = (_IOMemoryMap *) iter->getNextObject()))
+ mapping->redirect( safeTask, redirect );
+
+ iter->release();
+ }
+ } while( false );
+
+ UNLOCK;
+
+ // temporary binary compatibility
+ IOSubMemoryDescriptor * subMem;
+ if( (subMem = OSDynamicCast( IOSubMemoryDescriptor, this)))
+ err = subMem->redirect( safeTask, redirect );
+ else
+ err = kIOReturnSuccess;
+
+ return( err );
+}
+
+IOReturn IOSubMemoryDescriptor::redirect( task_t safeTask, bool redirect )
+{
+// temporary binary compatibility IOMemoryDescriptor::redirect( safeTask, redirect );
+ return( _parent->redirect( safeTask, redirect ));
+}
+
+IOReturn _IOMemoryMap::redirect( task_t safeTask, bool redirect )
+{
+ IOReturn err = kIOReturnSuccess;
+
+ if( superMap) {
+// err = ((_IOMemoryMap *)superMap)->redirect( safeTask, redirect );
+ } else {
+
+ LOCK;
+ if( logical && addressMap
+ && (get_task_map( safeTask) != addressMap)
+ && (0 == (options & kIOMapStatic))) {
+
+ IOUnmapPages( addressMap, logical, length );
+ if( !redirect) {
+ err = vm_deallocate( addressMap, logical, length );
+ err = memory->doMap( addressMap, &logical,
+ (options & ~kIOMapAnywhere) /*| kIOMapReserve*/ );
+ } else
+ err = kIOReturnSuccess;
+#ifdef DEBUG
+ IOLog("IOMemoryMap::redirect(%d, %x) %x from %lx\n", redirect, err, logical, addressMap);
+#endif
+ }
+ UNLOCK;
+ }
+
+ return( err );
+}
+