Ejemplo n.º 1
0
SCSIParallelWorkLoop *
SCSIParallelWorkLoop::Create ( const char *	lockGroupName )
{

    SCSIParallelWorkLoop *		workLoop = NULL;

    workLoop = OSTypeAlloc ( SCSIParallelWorkLoop );
    require_nonzero ( workLoop, ErrorExit );

    require ( workLoop->InitWithLockGroupName ( lockGroupName ), ReleaseWorkLoop );

    return workLoop;


ReleaseWorkLoop:


    require_nonzero ( workLoop, ErrorExit );
    workLoop->release ( );
    workLoop = NULL;


ErrorExit:


    return workLoop;

}
SCSIParallelTimer *
SCSIParallelTimer::CreateTimerEventSource ( OSObject * owner, Action action )
{
	
	SCSIParallelTimer *		timer = NULL;
	
	timer = OSTypeAlloc ( SCSIParallelTimer );
	require_nonzero ( timer, ErrorExit );
	
	require ( timer->Init ( owner, action ), FreeTimer );
	
	return timer;
	
	
FreeTimer:
	
	
	require_nonzero ( timer, ErrorExit );
	timer->release ( );
	timer = NULL;
	
	
ErrorExit:
	
	
	return timer;
	
}
IOFWPseudoAddressSpace *IOFWPseudoAddressSpace::simpleRW(IOFireWireBus *control,
                                                         FWAddress *addr, UInt32 len, void *data)
{
    IOFWPseudoAddressSpace * me = OSTypeAlloc( IOFWPseudoAddressSpace );
    do 
	{
        if(!me)
            break;
    
		if(!me->initAll(control, addr, len, simpleReader, simpleWriter, (void *)me)) 
		{
            me->release();
            me = NULL;
            break;
        }
        
		me->fDesc = IOMemoryDescriptor::withAddress(data, len, kIODirectionOutIn);
        if(!me->fDesc) 
		{
            me->release();
            me = NULL;
        }
		
    } while(false);

    return me;
}
AppleSCSIPDT03Emulator *
AppleSCSIPDT03Emulator::Create ( void )
{
	
	AppleSCSIPDT03Emulator *	logicalUnit = NULL;
	bool						result		= false;
	
	STATUS_LOG ( ( "AppleSCSIPDT03Emulator::Create\n" ) );
	
	logicalUnit = OSTypeAlloc ( AppleSCSIPDT03Emulator );
	require_nonzero ( logicalUnit, ErrorExit );
	
	result = logicalUnit->init ( );
	require ( result, ReleaseLogicalUnit );
	
	return logicalUnit;
	
	
ReleaseLogicalUnit:
	
	
	logicalUnit->release ( );
	
	
ErrorExit:
	
	
	return NULL;
	
}
Ejemplo n.º 5
0
bool FakePCIID::init(OSDictionary *propTable)
{
    DebugLog("FakePCIID::init() %p\n", this);
    
    // announce version
    IOLog("FakePCIID: Version %s starting on OS X Darwin %d.%d.\n", kmod_info.version, version_major, version_minor);

    bool ret = super::init(propTable);
    if (!ret)
    {
        AlwaysLog("super::init returned false\n");
        return false;
    }

    // place version/build info in ioreg properties RM,Build and RM,Version
    char buf[128];
    snprintf(buf, sizeof(buf), "%s %s", kmod_info.name, kmod_info.version);
    setProperty("RM,Version", buf);
#ifdef DEBUG
    setProperty("RM,Build", "Debug-" LOGNAME);
#else
    setProperty("RM,Build", "Release-" LOGNAME);
#endif

    // capture vtable pointer for PCIDeviceStub
    PCIDeviceStub *stub = OSTypeAlloc(PCIDeviceStub);
    mStubVtable = getVTable(stub);
    stub->release();

    mDeviceVtable = NULL;
    mProvider = NULL;
    
    return true;
}
IOFireWireIRM * IOFireWireIRM::create( IOFireWireController * controller )
{
    IOReturn 		status = kIOReturnSuccess;
    IOFireWireIRM * me;
        
    if( status == kIOReturnSuccess )
    {
        me = OSTypeAlloc( IOFireWireIRM );
        if( me == NULL )
            status = kIOReturnNoMemory;
    }
    
    if( status == kIOReturnSuccess )
    {
        bool success = me->initWithController( controller );
		if( !success )
		{
			status = kIOReturnError;
		}
    }
    
    if( status != kIOReturnSuccess )
    {
        me = NULL;
    }

	FWLOCALKLOG(( "IOFireWireIRM::create() - created new IRM 0x%08lx\n", (UInt32)me ));
    
    return me;
}
SCSIPathSet *
SCSIPathSet::withCapacity ( unsigned int capacity )
{
	
	SCSIPathSet *	set 	= NULL;
	bool			result	= false;
	
	STATUS_LOG ( ( "+SCSIPathSet::withCapacity\n" ) );
	
	set = OSTypeAlloc ( SCSIPathSet );
	require_nonzero ( set, ErrorExit );
	
	result = set->initWithCapacity ( capacity );
	require ( result, ReleaseSet );
	
	return set;
	
	
ReleaseSet:
	
	
	require_nonzero_quiet ( set, ErrorExit );
	set->release ( );
	set = NULL;
	
	
ErrorExit:
	
	
	return set;
	
}
IOReturn CLASS::newUserClient(task_t owningTask, void* securityID, UInt32 type, IOUserClient ** handler)
{
	IOUserClient *client;

	if (type != kGUXUCType)
		return kIOReturnUnsupported;
	if (!handler)
		return kIOReturnBadArgument;

	client = OSTypeAlloc(GenericUSBXHCIUserClient);
	if (!client)
		return kIOReturnNoMemory;
	if (!client->initWithTask(owningTask, securityID, type)) {
		client->release();
		return kIOReturnInternalError;
	}
	if (!client->attach(this)) {
		client->release();
		return kIOReturnInternalError;
	}
	if (!client->start(this)) {
		client->detach(this);
		client->release();
		return kIOReturnInternalError;
	}
	*handler = client;
	return kIOReturnSuccess;
}
Ejemplo n.º 9
0
IOUSBControllerIsochEndpoint* CLASS::AllocateIsochEP(void)
{
	GenericUSBXHCIIsochEP* obj = OSTypeAlloc(GenericUSBXHCIIsochEP);
	if (obj && !obj->init()) {
		obj->release();
		obj = 0;
	}
	return obj;
}
IOFWSyncer * IOFWSyncer::create(bool twoRetains)
{
    IOFWSyncer * me = OSTypeAlloc( IOFWSyncer );

    if (me && !me->init(twoRetains)) {
        me->release();
        return 0;
    }

    return me;
}
IOFireWirePowerManager * IOFireWirePowerManager::createWithController( IOFireWireController * controller )
{
    IOFireWirePowerManager * me = OSTypeAlloc( IOFireWirePowerManager );
	if( me != NULL )
	{
		if( !me->initWithController(controller) ) 
		{
            me->release();
            me = NULL;
        }
	}

    return me;
}
Ejemplo n.º 12
0
bool FakePCIID_XHCIMux::init(OSDictionary *propTable)
{
    DebugLog("FakePCIID_XHCIMux::init\n");

    if (!super::init(propTable))
        return false;

    // capture vtable pointer for PCIDeviceStub_XHCIMux
    PCIDeviceStub *stub = OSTypeAlloc(PCIDeviceStub_XHCIMux);
    mStubVtable = getVTable(stub);
    stub->release();

    return true;
}
IOFireWireNubAux * IOFireWireNub::createAuxiliary( void )
{
	IOFireWireNubAux * auxiliary;
    
	auxiliary = OSTypeAlloc( IOFireWireNubAux );

    if( auxiliary != NULL && !auxiliary->init(this) ) 
	{
        auxiliary->release();
        auxiliary = NULL;
    }
	
    return auxiliary;
}
IOFWAddressSpaceAux * IOFWPseudoAddressSpace::createAuxiliary( void )
{
	IOFWPseudoAddressSpaceAux * auxiliary;
    
	auxiliary = OSTypeAlloc( IOFWPseudoAddressSpaceAux );

    if( auxiliary != NULL && !auxiliary->init(this) ) 
	{
        auxiliary->release();
        auxiliary = NULL;
    }
	
    return auxiliary;
}
IOFWReadQuadCommand *IOFireWireNub::createReadQuadCommand(FWAddress devAddress, UInt32 *quads, int numQuads,
				FWDeviceCallback completion, void *refcon,
 				bool failOnReset)
{
    IOFWReadQuadCommand * cmd;
    cmd = OSTypeAlloc( IOFWReadQuadCommand );
    if(cmd) { 
        if(!cmd->initAll(this, devAddress, quads, numQuads, 
		completion, refcon, failOnReset)) {
            cmd->release();
            cmd = NULL;
	}
    }
    return cmd;
}
IOFWReadCommand *IOFireWireNub::createReadCommand(FWAddress devAddress, IOMemoryDescriptor *hostMem,
				FWDeviceCallback completion, void *refcon,
 				bool failOnReset)
{
    IOFWReadCommand * cmd;
    cmd = OSTypeAlloc( IOFWReadCommand );
    if(cmd) {
        if(!cmd->initAll(this, devAddress,
                         hostMem, completion, refcon, failOnReset)) {
            cmd->release();
            cmd = NULL;
	}
    }
    return cmd;
}
IOFWWorkLoop * IOFWWorkLoop::workLoop()
{
    IOFWWorkLoop *loop;
    
    loop = OSTypeAlloc( IOFWWorkLoop );
    if( !loop )
        return loop;
		
    if( !loop->init() ) 
	{
        loop->release();
        loop = NULL;
    }
	
    return loop;
}
IOFWCompareAndSwapCommand *
IOFireWireNub::createCompareAndSwapCommand(FWAddress devAddress, const UInt32 *cmpVal, const UInt32 *newVal,
		int size, FWDeviceCallback completion, void *refcon, bool failOnReset)
{
    IOFWCompareAndSwapCommand * cmd;
    cmd = OSTypeAlloc( IOFWCompareAndSwapCommand );
    if(cmd) 
	{
        if(!cmd->initAll(this, devAddress, cmpVal, newVal, size, completion, refcon, failOnReset)) 
		{
            cmd->release();
            cmd = NULL;
		}
    }
	
    return cmd;
}
bool
com_apple_dts_SCSIEmulatorAdapter::InitializeController ( void )
{
	com_apple_dts_SCSIEmulatorAdapterNub *nub = NULL;
	IOReturn ret = kIOReturnSuccess;

	nub	= OSDynamicCast(com_apple_dts_SCSIEmulatorAdapterNub, getProvider());
	if (!nub) {
		IOLog("InitializeController: failed to cast provider\n");
		goto failed;
	}

	mTargetsArray = OSArray::withCapacity(kMaxTargetID);
	
	mResponderEventSource = OSTypeAlloc(com_apple_dts_SCSIEmulatorEventSource);
	if (!mResponderEventSource) {
		IOLog("InitializeController: failed to alloc mResponderEventSource\n");
		goto failed;
	}

	if (!mResponderEventSource->init(this,  &com_apple_dts_SCSIEmulatorAdapter::TaskComplete)) {
		IOLog("InitializeController: failed to init mResponderEventSource\n");
		mResponderEventSource->release();
		goto failed;
	}

	ret = GetWorkLoop()->addEventSource(mResponderEventSource);
	if (ret != kIOReturnSuccess) {
		IOLog("InitializeController: failed to add event source.  ret = 0x%X\n", ret);
		mResponderEventSource->release();
		goto failed;
	}

	goto success;
	
failed:
	return false;
	
success:
	// The controller is now initialized and ready for operation
	return true;
}
bool IOFireWireIRM::initWithController(IOFireWireController * control)
{
	IOReturn status = kIOReturnSuccess;
	
	bool success = OSObject::init();
	FWPANICASSERT( success == true );
	
	fControl = control;

	fIRMNodeID = kFWBadNodeID;
	fOurNodeID = kFWBadNodeID;
	fGeneration = 0;
	
	//
    // create BROADCAST_CHANNEL register
	//
	
	fBroadcastChannelBuffer = OSSwapHostToBigInt32( kBroadcastChannelInitialValues );
    fBroadcastChannelAddressSpace = IOFWPseudoAddressSpace::simpleRWFixed( fControl, FWAddress(kCSRRegisterSpaceBaseAddressHi, kCSRBroadcastChannel), 
																			 sizeof(fBroadcastChannelBuffer), &fBroadcastChannelBuffer );
	FWPANICASSERT( fBroadcastChannelAddressSpace != NULL );
    
	status = fBroadcastChannelAddressSpace->activate();
	FWPANICASSERT( status == kIOReturnSuccess );

	//
	// create lock command
	//
	
	fLockCmdInUse = false;
	fLockCmd = OSTypeAlloc( IOFWCompareAndSwapCommand );
	FWPANICASSERT( fLockCmd != NULL );
	fLockCmd->initAll( fControl, 0, FWAddress(), NULL, NULL, 0, IOFireWireIRM::lockCompleteStatic, this );

	FWLOCALKLOG(( "IOFireWireIRM::initWithController() - IRM intialized\n" ));

	return true;
}
Ejemplo n.º 21
0
bool FakePCIID::init(OSDictionary *propTable)
{
    DebugLog("FakePCIID::init() %p\n", this);
    
    bool ret = super::init(propTable);
    if (!ret)
    {
        AlwaysLog("super::init returned false\n");
        return false;
    }

    IOLog("FakePCIID version 1.2.0 starting.\n");

    // capture vtable pointer for PCIDeviceStub
    PCIDeviceStub *stub = OSTypeAlloc(PCIDeviceStub);
    mStubVtable = getVTable(stub);
    stub->release();

    mDeviceVtable = NULL;
    mProvider = NULL;
    
    return true;
}
IOFWPseudoAddressSpace *IOFWPseudoAddressSpace::simpleRW(IOFireWireBus *control,
								FWAddress *addr, IOMemoryDescriptor * data)
{
    IOFWPseudoAddressSpace * me = OSTypeAlloc( IOFWPseudoAddressSpace );
	do 
	{
        if(!me)
            break;
    
		if(!me->initAll(control, addr, data->getLength(), simpleReader, simpleWriter, (void *)me)) 
		{
            me->release();
            me = NULL;
            break;
        }
        
		data->retain();
        me->fDesc = data;
    
	} while(false);

    return me;
}
IOFWAsyncStreamReceivePort *IOFWAsyncStreamReceiver::CreateAsyncStreamPort(bool talking, DCLCommandStruct *opcodes, void *info,
													UInt32 startEvent, UInt32 startState, UInt32 startMask,
													UInt32 channel )
{
    IOFWAsyncStreamReceivePort *port;

    if(fFWIM == NULL)
    {
		DebugLog("IOFWAsyncStreamReceiver::CreateAsyncStreamPort failed -> FWIM is NULL\n");
		return NULL;
    }

    fIODclProgram = fFWIM->createDCLProgram(talking, opcodes, NULL, startEvent, startState, startMask);
    if(!fIODclProgram) 
	{
		DebugLog("IOFWAsyncStreamReceiver::CreateAsyncStreamPort failed -> fIODclProgram is NULL\n");
		return NULL;
	}

    port = OSTypeAlloc( IOFWAsyncStreamReceivePort );
    if(!port) 
	{
		DebugLog("IOFWAsyncStreamReceiver::CreateAsyncStreamPort failed -> IOFWAsyncStreamReceivePort is NULL\n");
		fIODclProgram->release();
		fIODclProgram = NULL;
		return NULL;
    }

    if(!port->init(fIODclProgram, fControl, channel)) 
	{
		DebugLog("IOFWAsyncStreamReceiver::CreateAsyncStreamPort failed -> IOFWAsyncStreamReceivePort::init failed\n");
		port->release();
		port = NULL;
    }

    return port;
}
SCSIPressurePathManager *
SCSIPressurePathManager::Create ( IOSCSITargetDevice *		target,
								  IOSCSIProtocolServices * 	initialPath )
{
	
	SCSIPressurePathManager *	manager = NULL;
	bool						result	= false;
	
	STATUS_LOG ( ( "+SCSIPressurePathManager::Create\n" ) );
	
	manager = OSTypeAlloc ( SCSIPressurePathManager );
	require_nonzero ( manager, ErrorExit );
	
	result = manager->InitializePathManagerForTarget ( target, initialPath );
	require ( result, ReleasePathManager );
	
	STATUS_LOG ( ( "-SCSIPressurePathManager::Create, manager = %p\n", manager ) );
	
	return manager;
	
	
ReleasePathManager:
	
	
	require_nonzero_quiet ( manager, ErrorExit );
	manager->release ( );
	manager = NULL;
	
	
ErrorExit:
	
	
	STATUS_LOG ( ( "-SCSIPressurePathManager::Create, manager = NULL\n" ) );
	
	return manager;	
	
}
Ejemplo n.º 25
0
IOPolledFilePollers *
IOPolledFilePollers::copyPollers(IOService * media)
{
    IOPolledFilePollers * vars;
    IOReturn              err;
    IOService       * service;
    OSObject        * obj;
    IORegistryEntry * next;
    IORegistryEntry * child;

    if ((obj = media->copyProperty(kIOPolledInterfaceStackKey)))
    {
        return (OSDynamicCast(IOPolledFilePollers, obj));
    }

    do
    {
        vars = OSTypeAlloc(IOPolledFilePollers);
        vars->init();

        vars->pollers = OSArray::withCapacity(4);
        if (!vars->pollers)
        {
            err = kIOReturnNoMemory;
            break;
        }

        next = vars->media = media;
        do
        {
            IOPolledInterface * poller;
            OSObject *          obj;

            obj = next->getProperty(kIOPolledInterfaceSupportKey);
            if (kOSBooleanFalse == obj)
            {
                vars->pollers->flushCollection();
                break;
            }
            else if ((poller = OSDynamicCast(IOPolledInterface, obj)))
                vars->pollers->setObject(poller);

            if ((service = OSDynamicCast(IOService, next))
                    && service->getDeviceMemory()
                    && !vars->pollers->getCount())	break;

            child = next;
        }
        while ((next = child->getParentEntry(gIOServicePlane))
                && child->isParent(next, gIOServicePlane, true));

        if (!vars->pollers->getCount())
        {
            err = kIOReturnUnsupported;
            break;
        }
    }
    while (false);

    media->setProperty(kIOPolledInterfaceStackKey, vars);

    return (vars);
}
Ejemplo n.º 26
0
bool 
com_ximeta_driver_NDASProtocolTransport::start(
						 IOService * provider 
						 )
{
	
	IOReturn				status;
	Boolean					returnValue;
	Boolean 				openSucceeded;
	OSNumber * 				rto;
	OSNumber * 				wto;
	OSDictionary *			dict;
	bool					sucess;
	
	status				= kIOReturnSuccess;
	returnValue			= false;
	openSucceeded		= false;
	rto					= NULL;
	wto					= NULL;
	sucess				= false;
	dict				= NULL;
	
	com_ximeta_driver_NDASSCSICommand *NDCmd_ptr;
	
    DbgIOLog(DEBUG_MASK_PNP_TRACE, ("Entered.\n"));
		
	// See if there is a read time out duration passed in the property dictionary - if not
	// set the default to 30 seconds.
	/*
	rto = OSDynamicCast ( OSNumber, getProperty ( kIOPropertyReadTimeOutDurationKey ) );
	if ( rto == NULL )
	{
		rto = OSNumber::withNumber ( kDefaultTimeOutValue, 32 );
		require ( rto, exit );
		
		sucess = setProperty ( kIOPropertyReadTimeOutDurationKey, rto );
		check ( sucess );
		rto->release();
		
		rto = OSDynamicCast ( OSNumber, getProperty ( kIOPropertyReadTimeOutDurationKey ) );
	}
	
	STATUS_LOG ( ( "%s: start read time out = %ld\n", getName (), rto->unsigned32BitValue ( ) ) );
	
	// See if there is a write time out duration passed in the property dictionary - if not
	// set the default to 30 seconds.
	
	wto = OSDynamicCast ( OSNumber,  getProperty ( kIOPropertyWriteTimeOutDurationKey ) );
	if ( wto == NULL )
	{
		wto = OSNumber::withNumber ( kDefaultTimeOutValue, 32 );
		require ( wto, exit );
		
		sucess = setProperty ( kIOPropertyWriteTimeOutDurationKey, wto );
		check ( sucess );
		wto->release();
		
		wto = OSDynamicCast ( OSNumber, getProperty ( kIOPropertyWriteTimeOutDurationKey ) );
	}
	
	STATUS_LOG ( ( "%s: start read time out = %ld\n", getName (), wto->unsigned32BitValue ( ) ) );
	*/
	
	fProvider = OSDynamicCast ( com_ximeta_driver_NDASProtocolTransportNub, provider );
	require ( fProvider, exit );
	//
	// Add a retain here so we can keep LanScsiDevice from doing garbage
	// collection on us when we are in the middle of our finalize method.
	
	fProvider->retain ( );
	
	openSucceeded = super::start ( provider );
	require ( openSucceeded, exit );
	
	openSucceeded = provider->open ( this );
	require ( openSucceeded, exit );
		
//	bTerminating = false;
	
	/*
	fUnit = fSBPTarget->getFireWireUnit ();
	require ( fUnit, exit );
	
	// Explicitly set the "enable retry on ack d" flag.
	
	fUnit->setNodeFlags ( kIOFWEnableRetryOnAckD );
	
	status = AllocateResources ();
	require_noerr ( status, exit );
	
	// Get us on the workloop so we can sleep the start thread.
	
	fCommandGate->runAction ( ConnectToDeviceStatic );
	
	if ( reserved->fLoginState == kLogginSucceededState )
	{
		registerService ();
	}
	
	STATUS_LOG ( ( "%s: start complete\n", getName () ) );
	
	returnValue = true;
	
	// Copy some values to the Protocol Characteristics Dictionary
	dict = OSDynamicCast ( OSDictionary, getProperty ( kIOPropertyProtocolCharacteristicsKey ) );
	if ( dict != NULL )
	{
		
		OSString *	string = NULL;
		
		string = OSString::withCString ( kFireWireGUIDKey );
		if ( string != NULL )
		{
			
			dict->setObject ( string, getProperty ( kFireWireGUIDKey, gIOServicePlane ) );
			string->release ( );
			
		}
		
		string = OSString::withCString ( kPreferredNameKey );
		if ( string != NULL )
		{
			
			dict->setObject ( kPreferredNameKey, getProperty ( kFireWireVendorNameKey, gIOServicePlane ) );
			string->release ( );
			
		}
		
	}
	*/
	
	// Create IOCommand Pool.
	fCommandPool = IOCommandPool::withWorkLoop(getWorkLoop());
	if(fCommandPool == NULL) {
        DbgIOLog(DEBUG_MASK_DISK_ERROR, ("failed to alloc Command Pool\n"));
		
		goto exit;
	}
	
	// Allocate Command.
	NDCmd_ptr = OSTypeAlloc(com_ximeta_driver_NDASSCSICommand);
    
    if(NDCmd_ptr == NULL || !NDCmd_ptr->init()) {
        DbgIOLog(DEBUG_MASK_DISK_ERROR, ("failed to alloc command class\n"));
		
		if (NDCmd_ptr) {
			NDCmd_ptr->release();
		}
		
		goto exit;
    }
	
	fCommandPool->returnCommand(NDCmd_ptr);
		
	registerService ();
	
	InitializePowerManagement ( provider );
	
	returnValue = true;
	
exit:
	
	if ( returnValue == false )
	{
		
		DbgIOLog(DEBUG_MASK_DISK_ERROR, ("start failed.  status = %x\n", status));
		
		// Call the cleanUp method to clean up any allocated resources.
		cleanUp ();
	}
	
	return returnValue;
	
}