1/* 2 * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23// public 24#include <IOKit/firewire/IOFireWireUnit.h> 25#include <IOKit/firewire/IOFireWireDevice.h> 26 27// private 28#include "IOFWSBP2PseudoAddressSpace.h" 29 30OSDefineMetaClassAndStructors(IOFWSBP2PseudoAddressSpace, IOFWPseudoAddressSpace); 31 32OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 0); 33OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 1); 34OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 2); 35OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 3); 36OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 4); 37OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 5); 38OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 6); 39OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 7); 40OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 8); 41OSMetaClassDefineReservedUnused(IOFWSBP2PseudoAddressSpace, 9); 42 43#pragma mark - 44 45// setAddressLo 46// 47// 48 49void IOFWSBP2PseudoAddressSpace::setAddressLo( UInt32 addressLo ) 50{ 51 fBase.addressLo = addressLo; 52} 53 54// simpleRead 55// 56// 57 58IOFWSBP2PseudoAddressSpace * IOFWSBP2PseudoAddressSpace::simpleRead( IOFireWireBus * control, 59 FWAddress * addr, 60 UInt32 len, 61 const void * data) 62{ 63 IOFWSBP2PseudoAddressSpace * me = new IOFWSBP2PseudoAddressSpace; 64 do 65 { 66 if(!me) 67 break; 68 69 if(!me->initAll(control, addr, len, simpleReader, NULL, (void *)me)) 70 { 71 me->release(); 72 me = NULL; 73 break; 74 } 75 76 me->fDesc = IOMemoryDescriptor::withAddress((void *)data, len, kIODirectionOut); 77 if(!me->fDesc) 78 { 79 me->release(); 80 me = NULL; 81 } 82 83 } while(false); 84 85 return me; 86} 87 88// simpleRW 89// 90// 91 92IOFWSBP2PseudoAddressSpace * IOFWSBP2PseudoAddressSpace::simpleRW( IOFireWireBus * control, 93 FWAddress * addr, 94 UInt32 len, 95 void * data ) 96{ 97 IOFWSBP2PseudoAddressSpace * me = new IOFWSBP2PseudoAddressSpace; 98 do 99 { 100 if(!me) 101 break; 102 103 if(!me->initAll(control, addr, len, simpleReader, simpleWriter, (void *)me)) 104 { 105 me->release(); 106 me = NULL; 107 break; 108 } 109 110 me->fDesc = IOMemoryDescriptor::withAddress(data, len, kIODirectionOutIn); 111 if(!me->fDesc) 112 { 113 me->release(); 114 me = NULL; 115 } 116 117 } while(false); 118 119 return me; 120} 121 122// createPseudoAddressSpace 123// 124// 125 126IOFWSBP2PseudoAddressSpace * IOFWSBP2PseudoAddressSpace::createPseudoAddressSpace( IOFireWireBus * control, 127 IOFireWireUnit * unit, 128 FWAddress * addr, 129 UInt32 len, 130 FWReadCallback reader, 131 FWWriteCallback writer, 132 void * refcon ) 133{ 134 135 IOFWSBP2PseudoAddressSpace * space = NULL; 136 IOFireWireDevice * device = NULL; 137 138 space = new IOFWSBP2PseudoAddressSpace; 139 140 if( space != NULL ) 141 { 142 if( !space->initAll( control, addr, len, reader, writer, refcon ) ) 143 { 144 space->release(); 145 space = NULL; 146 } 147 } 148 149 if( space != NULL ) 150 { 151 device = OSDynamicCast( IOFireWireDevice, unit->getProvider() ); 152 if( device == NULL ) 153 { 154 space->release(); 155 space = NULL; 156 } 157 } 158 159 if( space != NULL ) 160 { 161 space->addTrustedNode( device ); 162 } 163 164 return space; 165 166} 167