PhysicalAddressSpace::PhysicalAddressSpace( Device& inUserClient, UserObjectHandle inKernPhysicalAddrSpaceRef, UInt32 inSize, void* inBackingStore, UInt32 inFlags) : IOFireWireIUnknown( reinterpret_cast<const IUnknownVTbl &>( sInterface ) ), mUserClient(inUserClient), mKernPhysicalAddrSpaceRef(inKernPhysicalAddrSpaceRef), mSize(inSize), mBackingStore(inBackingStore), mSegments( NULL ), mSegmentCount(0) { inUserClient.AddRef() ; if (!mKernPhysicalAddrSpaceRef) throw kIOReturnNoMemory ; uint32_t outputCnt = 1; uint64_t outputVal = 0; IOReturn error = IOConnectCallScalarMethod( mUserClient.GetUserClientConnection(), mUserClient.MakeSelectorWithObject( kPhysicalAddrSpace_GetSegmentCount_d, mKernPhysicalAddrSpaceRef ), NULL,0, &outputVal,&outputCnt); mSegmentCount = outputVal & 0xFFFFFFFF; if ( error || mSegmentCount == 0) throw error ; mSegments = new FWPhysicalSegment32[mSegmentCount] ; if (!mSegments) { throw kIOReturnNoMemory ; } outputCnt = 1; outputVal = 0; const uint64_t inputs[3] = {(const uint64_t)mKernPhysicalAddrSpaceRef, mSegmentCount, (const uint64_t)mSegments}; error = IOConnectCallScalarMethod( mUserClient.GetUserClientConnection(), kPhysicalAddrSpace_GetSegments, inputs,3, &outputVal,&outputCnt); mSegmentCount = outputVal & 0xFFFFFFFF; if (error) { throw error ; } #ifndef __LP64__ ROSETTA_ONLY( { UInt32 i; for( i = 0; i < mSegmentCount; i++ ) { mSegments[i].location = OSSwapInt32( mSegments[i].location ); mSegments[i].length = OSSwapInt32( mSegments[i].length ); } } );
Device* DeviceColl::FindDevice(LPCTSTR szStringId) { DeviceVector::const_iterator itr = m_devices.begin(); while (itr != m_devices.end()) { Device* pDevice = *itr; if (0 == lstrcmpi(pDevice->GetStringId(), szStringId)) { pDevice->AddRef(); return pDevice; } ++itr; } return NULL; }
Device* DeviceColl::FindDevice(DWORD slot) { DeviceVector::const_iterator itr = m_devices.begin(); while (itr != m_devices.end()) { Device* pDevice = *itr; if (slot == pDevice->GetSlotNo()) { pDevice->AddRef(); return pDevice; } ++itr; } return NULL; }
PseudoAddressSpace::PseudoAddressSpace( Device& userclient, UserObjectHandle inKernAddrSpaceRef, void* inBuffer, UInt32 inBufferSize, void* inBackingStore, void* inRefCon) : IOFireWireIUnknown( reinterpret_cast<const IUnknownVTbl &>( sInterface ) ), mNotifyIsOn(false), mWriter( nil ), mReader( nil ), mSkippedPacketHandler( nil ), mUserClient(userclient), mKernAddrSpaceRef(inKernAddrSpaceRef), mBuffer((char*)inBuffer), mBufferSize(inBufferSize), mBackingStore(inBackingStore), mRefCon(inRefCon) { userclient.AddRef() ; mPendingLocks = ::CFDictionaryCreateMutable( kCFAllocatorDefault, 0, NULL, NULL ) ; if (!mPendingLocks) throw kIOReturnNoMemory ; AddressSpaceInfo info ; IOReturn error ; uint32_t outputCnt = 0; size_t outputStructSize = sizeof( info ) ; const uint64_t inputs[1]={(const uint64_t)mKernAddrSpaceRef}; error = IOConnectCallMethod(mUserClient.GetUserClientConnection(), kPseudoAddrSpace_GetFWAddrInfo, inputs,1, NULL,0, NULL,&outputCnt, &info,&outputStructSize); if (error) { throw error ; } #ifndef __LP64__ ROSETTA_ONLY( { info.address.nodeID = OSSwapInt16( info.address.nodeID ); info.address.addressHi = OSSwapInt16( info.address.addressHi ); info.address.addressLo = OSSwapInt32( info.address.addressLo ); } );
BOOL CALLBACK DeviceColl::EnumProc( PNDASUSER_DEVICE_ENUM_ENTRY lpEnumEntry, LPVOID lpContext) { DeviceColl* pDeviceColl = reinterpret_cast<DeviceColl*>(lpContext); Device* pDevice = new Device( lpEnumEntry->SlotNo, lpEnumEntry->szDeviceStringId, lpEnumEntry->szDeviceName, lpEnumEntry->GrantedAccess); pDevice->AddRef(); pDeviceColl->m_devices.push_back(pDevice); return TRUE; }