Exemple #1
0
char *net_habitue_device_SC101::getProductString(void)
{
  OSData *partNumber = OSDynamicCast(OSData, getProperty(gSC101DevicePartNumberKey));
  char *productString = (char *)"Unknown";
  
  if (partNumber)
  {
    if (partNumber->isEqualTo(kSC101PartNumber, sizeof(kSC101PartNumber)))
      productString = (char *)"SC101";
    else if (partNumber->isEqualTo(kSC101TPartNumber, sizeof(kSC101TPartNumber)))
      productString = (char *)"SC101T";
  }
  
  return productString;
}
IOService* 
OHareATA::probe(IOService* provider,	SInt32*	score)
{

    OSData		*compatibleEntry;
	
	DLOG("OHareATA starting probe\n");


	compatibleEntry  = OSDynamicCast( OSData, provider->getProperty( "compatible" ) );
	if ( compatibleEntry == 0 ) 
	{
		// error unknown controller type.

		DLOG("OHareATA failed getting compatible property\n");
		return 0;

	}

	
	// test the compatible property for a match to the controller type name.
	if ( compatibleEntry->isEqualTo( kCompatibleString, sizeof(kCompatibleString)-1 ) == false ) 
	{
		// not our type of controller		
		DLOG("OHareATA compatible property doesn't match\n");
		return 0;
		
	}

	// ok, it is the type of cell we control
	
	return this;


}
Exemple #3
0
void net_habitue_device_SC101::diskCompletion(void *parameter, IOReturn status, UInt64 actualByteCount)
{
  if (status != kIOReturnSuccess || actualByteCount != sizeof(psan_get_response_disk_t))
  {
    KINFO("disk query on %s failed", getID()->getCStringNoCopy());
    return;
  }
  
  IOBufferMemoryDescriptor *buffer = (IOBufferMemoryDescriptor *)parameter;
  
  psan_get_response_disk_t *disk = (psan_get_response_disk_t *)buffer->getBytesNoCopy();
  
  OSData *partNumber = OSData::withBytes(disk->part_number, sizeof(disk->part_number));
  if (partNumber)
  {
    OSString *resourceFile = NULL;

    if (partNumber->isEqualTo(kSC101PartNumber, sizeof(kSC101PartNumber)))
      resourceFile = OSString::withCString("SC101.icns");
    else if (partNumber->isEqualTo(kSC101TPartNumber, sizeof(kSC101TPartNumber)))
      resourceFile = OSString::withCString("SC101T.icns");
    
    if (resourceFile)
    {
      setIcon(resourceFile);
      resourceFile->release();
    }
    
    setProperty(gSC101DevicePartNumberKey, partNumber);    
    partNumber->release();
  }
  
  OSString *version = OSString::withCString(disk->version);
  if (version)
  {
    setProperty(gSC101DeviceVersionKey, version);
    version->release();
  }
  
  partition(disk->partitions);
}
Exemple #4
0
IOReturn AppleI386AGP::createAGPSpace( IOAGPDevice * master, 
				      IOOptionBits options,
				      IOPhysicalAddress * address, 
				      IOPhysicalLength * length )
{
    IOReturn		err;
    IOPCIAddressSpace 	target = getBridgeSpace();
    IOPhysicalLength	agpLength;
    UInt32		agpCtrl;
    
    enum { agpSpacePerPage = 4 * 1024 * 1024 };
    enum { agpBytesPerGartByte = 1024 };
    enum { alignLen = 4 * 1024 * 1024 - 1 };

    destroyAGPSpace( master );

    agpCommandMask = 0xffffffff;
    agpCommandMask &= ~kIOAGPFastWrite;
//  agpCommandMask &= ~kIOAGPSideBandAddresssing;

    {
	// There's an nVidia NV11 ROM (revision 1017) that says that it can do fast writes,
	// but can't, and can often lock the machine up when fast writes are enabled.
	
	#define kNVIDIANV11EntryName	"NVDA,NVMac"
	#define kNVROMRevPropertyName 	"rom-revision"
	#define kNVBadRevision			'1017'

	const UInt32    badRev = kNVBadRevision;
	OSData *	data;

	if( (0 == strcmp( kNVIDIANV11EntryName, master->getName()))
	 && (data = OSDynamicCast(OSData, master->getProperty(kNVROMRevPropertyName)))
	 && (data->isEqualTo( &badRev, sizeof(badRev) )))

	    agpCommandMask &= ~kIOAGPFastWrite;
    }

    agpLength = *length;
    if( !agpLength)
	agpLength = 32 * 1024 * 1024;

    agpLength = (agpLength + alignLen) & ~alignLen;

    err = kIOReturnVMError;
    do {

	gartLength = agpLength / agpBytesPerGartByte;
	gartArray = (volatile UInt32 *) IOMallocContiguous( 
				gartLength, 4096, &gartPhys );
	if( !gartArray)
	    continue;
	IOSetProcessorCacheMode(kernel_task, (vm_address_t) gartArray, gartLength, kIOInhibitCache);
        bzero( (void *) gartArray, gartLength);

//	IOUnmapPages( kernel_map, (vm_address_t) gartArray, gartLength );
	// is this std?
        systemBase	= configRead32( target, kiAPBASE ) & 0xfffffff0;
	DEBG("APSIZE: %08lx\n", (UInt32)configRead8(target, kiAPSIZE));
        systemLength	= (((configRead8( target, kiAPSIZE ) & 0x3f) ^ 0x3f) + 1) << 22;

	DEBG("sysB %08lx, sysL %08lx\n", systemBase, systemLength);

	if( !systemLength)
	    continue;

if (systemLength > agpLength)
    systemLength = agpLength;

	DEBG("sysB %08lx, sysL %08lx\n", systemBase, systemLength);

	agpRange = IORangeAllocator::withRange( agpLength, 4096 );
	if( !agpRange)
	    continue;

        *address = systemBase;
        *length = systemLength;

	agpCtrl = configRead32(target, kiAGPCTRL);
	agpCtrl &= ~(1 << 7);
	configWrite32( target, kiAGPCTRL, agpCtrl ); 		// b7 gtlb ena

//        configWrite32( target, kiAGPCTRL, 0 << 7 ); 		// b7 gtlb ena

//        assert( 0 == (gartPhys & 0xfff));

        configWrite32( target, kiATTBASE, gartPhys );

	agpCtrl = configRead32(target, kiAGPCTRL);
	//agpCtrl |= (1 << 7);
	configWrite32( target, kiAGPCTRL, agpCtrl ); 		// b7 gtlb ena

	DEBG("kiAGPCTRL %08lx, kiATTBASE %08lx\n", 
	    configRead32( target, kiAGPCTRL ), 
	    configRead32( target, kiATTBASE ));

        err = kIOReturnSuccess;

    } while( false );

    if( kIOReturnSuccess == err)
        setAGPEnable( master, true, 0 );
    else
	destroyAGPSpace( master );

    return( err );
}
Exemple #5
0
IOService* 
AppleKiwiATA::probe(IOService* provider,	SInt32*	score)
{

    OSData		*compatibleEntry;
	
	DLOG("AppleKiwiATA starting probe\n");


	compatibleEntry  = OSDynamicCast( OSData, provider->getProperty( "compatible" ) );
	if ( compatibleEntry == 0 ) 
	{
		// error unknown controller type.

		DLOG("AppleKiwiATA failed getting compatible property\n");
		return 0;

	}

	
	// test the compatible property for a match to the controller type name.
	if ( compatibleEntry->isEqualTo( kCompatibleString, sizeof(kCompatibleString)-1 ) == false ) 
	{
		// not our type of controller		
		DLOG("AppleKiwiATA compatible property doesn't match\n");
		return 0;
		
	}


	// do a little initialization here once the probe is succesful so we can start clean.

	OSData		*registryEntry;
	registryEntry = OSDynamicCast( OSData, provider->getProperty( kModelPropertyKey ) );
	if( registryEntry == 0)
	{
		DLOG("AppleKiwiATA unknown model property.\n");
		return 0;
	}


	// test for pci inline.
	if ( !provider->getProperty( kPCIInlineKey ) ) 
	{
		DLOG("AppleKiwiATA pci_inline enable lock\n");
		forcePCIInline = true;
	} else { 
	
		DLOG("AppleKiwiATA pci_inline disable lock\n");
		forcePCIInline = false;
	}

	// test for mode 6.
	if ( !provider->getProperty( kMode6Key ) ) 
	{
		DLOG("AppleKiwiATA mode 5\n");
		mode6Capable = false;	
	} else { 
	
		DLOG("AppleKiwiATA mode 6\n");
			mode6Capable = true;
	}



	
	return this;


}
Exemple #6
0
bool AppleMediaBay::start(IOService *provider)
{
    OSData      *compatibleEntry;

    // If the super class failed there is little point in 
    // going on:
    if (!super::start(provider))
        return false;
    
    // Find out the controller for the mediabay:
    mbControllerType = kMBControllerUndefined;
        
    compatibleEntry  = OSDynamicCast( OSData, provider->getProperty( "compatible" ) );
    if ( compatibleEntry == 0 ) {
#ifdef APPLEMB_VERBOSE
        IOLog("No compatible entry found.\n");
#endif //APPLEMB_VERBOSE
        return false;
    }

    if ( compatibleEntry->isEqualTo( "keylargo-media-bay", sizeof("keylargo-media-bay")-1 ) == true ) {
#ifdef APPLEMB_VERBOSE
        IOLog("Found KeyLargo compatible property.\n");
#endif // APPLEMB_VERBOSE

        mbControllerType = kMBControllerKeyLargo;
 
        myMacIO = waitForService(serviceMatching("KeyLargo"));
    }

    if ( compatibleEntry->isEqualTo( "heathrow-media-bay", sizeof("heathrow-media-bay")-1 ) == true )  {
#ifdef APPLEMB_VERBOSE
         IOLog("Found Heathrow compatible property.\n");
#endif // APPLEMB_VERBOSE

        mbControllerType = kMBControllerHeathrow;
        
        // now the parent could be either Hetrow or Gatwick
        // so jump back looking for my MacIO:
        myMacIO = OSDynamicCast(AppleMacIO, provider->getProvider());
    }

    if ( compatibleEntry->isEqualTo( "ohare-media-bay", sizeof("ohare-media-bay")-1 ) == true ) {
#ifdef APPLEMB_VERBOSE
         IOLog("Found OHare compatible property.\n");
#endif // APPLEMB_VERBOSE

        mbControllerType = kMBControllerOHare;
        myMacIO = waitForService(serviceMatching("OHare"));
    }
    
    if( (configAddrMap = provider->mapDeviceMemoryWithIndex( 0 )))
    {
        configAddr = (volatile UInt32 *) configAddrMap->getVirtualAddress();

#ifdef APPLEMB_VERBOSE
         IOLog("configAddr = 0x%08lx.\n",(unsigned int)configAddr);
#endif // APPLEMB_VERBOSE
    }
    else {
#ifdef APPLEMB_VERBOSE
        IOLog("configAddrMap failed.\n");
#endif // APPLEMB_VERBOSE
        return false;
    }

    if (myMacIO == NULL) {
#ifdef APPLEMB_VERBOSE
        IOLog("myMacIO == NULL.\n");
#endif // APPLEMB_VERBOSE
        return false;
    }

    workloop = IOWorkLoop::workLoop();      // make the workloop
    if(!workloop) {
#ifdef APPLEMB_VERBOSE
        IOLog("Error creating workloop.\n");
#endif // APPLEMB_VERBOSE
        return false;
    }
    
    intSource = IOInterruptEventSource::interruptEventSource
                (this, (IOInterruptEventAction) &handleInterrupt,
                 provider);

    if ((intSource == NULL) || (workloop->addEventSource(intSource) != kIOReturnSuccess)) {
#ifdef APPLEMB_VERBOSE
        IOLog("Problem adding interrupt event source...\n");
#endif // APPLEMB_VERBOSE

        return false;
    }
    else
        workloop->enableAllInterrupts();

    // Creates the command gate for the events that need to be in the queue
    commandGate = IOCommandGate::commandGate(this, commandGateCaller);

    // and adds it to the workloop:
    if ((commandGate == NULL) || 
        (workloop->addEventSource(commandGate) != kIOReturnSuccess))
    {
#ifdef VERBOSE_LOGS_ON_PMU_INT
        IOLog("Can not add a new IOCommandGate\n");
#endif // VERBOSE_LOGS_ON_PMU_INT
        return false;
    }

    // by default we start without client:
    ioClient = NULL;
    
    // The symbol to change power to the media bay:
    powerMediaBay = OSSymbol::withCString("powerMediaBay");

    // Remember with wich device we are starting:
    mbCurrentDevice = readMBID();

    // Starts the power managment. NOTE: to assure the correct behavior
    // of the driver initForPM should be called AFTER mbCurrentDevice is
    // set to its initial value.
    if (!initForPM(provider)) {
#ifdef APPLEMB_VERBOSE
        IOLog("Error joining the power managment tree.\n");
#endif // APPLEMB_VERBOSE
        return false;
    }
    
    // calls registerService so that the ata nubs can find this driver
    // and register with it:
    registerService();
    
    return true;
}