Ejemplo n.º 1
0
IOReturn RootDomainUserClient::secureSleepSystemOptions(
    const void      *inOptions,
    IOByteCount     inOptionsSize,
    uint32_t        *returnCode)
{

    int             local_priv = 0;
    int             admin_priv = 0;
    IOReturn        ret = kIOReturnNotPrivileged;
    OSDictionary    *unserializedOptions =  NULL;
    OSString        *unserializeErrorString = NULL;

    ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeLocalUser);
    local_priv = (kIOReturnSuccess == ret);

    ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator);
    admin_priv = (kIOReturnSuccess == ret);


    if (inOptions)
    {
        unserializedOptions = OSDynamicCast( OSDictionary,
                                             OSUnserializeXML((const char *)inOptions, inOptionsSize, &unserializeErrorString));

        if (!unserializedOptions) {
            IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n",
                unserializeErrorString ? unserializeErrorString->getCStringNoCopy() : "Unknown");
        }
    }

    if ( (local_priv || admin_priv) && fOwner )
    {
        proc_t p;
        p = (proc_t)get_bsdtask_info(fOwningTask);
        if (p) {
            fOwner->setProperty("SleepRequestedByPID", proc_pid(p), 32);
        }

        if (unserializedOptions)
        {
            // Publish Sleep Options in registry under root_domain
            fOwner->setProperty( kRootDomainSleepOptionsKey, unserializedOptions);

            *returnCode = fOwner->sleepSystemOptions( unserializedOptions );

            unserializedOptions->release();
        } else {
            // No options
            // Clear any pre-existing options
            fOwner->removeProperty( kRootDomainSleepOptionsKey );

            *returnCode = fOwner->sleepSystemOptions( NULL );
        }

    } else {
        *returnCode = kIOReturnNotPrivileged;
    }

    return kIOReturnSuccess;
}
Ejemplo n.º 2
0
FakeSMCSensor *FakeSMCPlugin::addSensor(OSObject *node, kFakeSMCCategory category, UInt32 group, UInt32 index)
{
    SYNCLOCK;
    
    FakeSMCSensor *sensor = NULL;
    
    if (node) {
 
        float reference = 0, gain = 0, offset = 0;
        OSString *abbriviation = NULL;
        
        if (OSDictionary *dictionary = OSDynamicCast(OSDictionary, node)) {
            if ((abbriviation = OSDynamicCast(OSString, dictionary->getObject("name")))) {
                FakeSMCSensor::parseModifiers(dictionary, &reference, &gain, &offset);
            }
        }
        else abbriviation = OSDynamicCast(OSString, node);

        if (abbriviation)
            sensor = addSensor(abbriviation->getCStringNoCopy(), category, group, index, reference, gain, offset);
    }
    
    SYNCUNLOCK;
    return sensor;
}
bool
IOFWUserAsyncStreamListener::serialize(OSSerialize *s) const
{
	if (s->previouslySerialized(this))
		return true ;
	
	char temp[256] ;
	
	if ( fFlags )
	{
		snprintf(temp+strlen(temp), sizeof(temp), ", flags:") ;
	}
	else
	{
		snprintf(temp+strlen(temp), sizeof(temp), ", no flags") ;
	}
	
	OSString*	string = OSString::withCString(temp) ;
	if (!string)
		return false ;
		
	bool result =  string->serialize(s) ;
	string->release() ;
	
	return result ;
}
Ejemplo n.º 4
0
bool OSSerialize::previouslySerialized(const OSMetaClassBase *o)
{
	char temp[16];
	OSString *tagString;

	if (binary) return (binarySerialize(o));

	// look it up
	tagString = (OSString *)tags->getObject((const OSSymbol *) o);

// xx-review: no error checking here for addString calls!
	// does it exist?
	if (tagString) {
		addString("<reference IDREF=\"");
		addString(tagString->getCStringNoCopy());
		addString("\"/>");
		return true;
	}

	// build a tag
	snprintf(temp, sizeof(temp), "%u", tag++);
	tagString = OSString::withCString(temp);

	// add to tag dictionary
        tags->setObject((const OSSymbol *) o, tagString);// XXX check return
	tagString->release();

	return false;
}
Ejemplo n.º 5
0
void SuperIO::LoadConfiguration(IOService* provider) {
	m_Service = provider;
	
	OSBoolean* fanControl = OSDynamicCast(OSBoolean, provider->getProperty("Enable Fan Control"));	
	m_FanControl = fanControl->getValue();
	
	OSBoolean* alternateRegisters = OSDynamicCast(OSBoolean, provider->getProperty("Register number alternative variant"));
	m_AlternateRegisters = alternateRegisters->getValue();
		
	OSArray* fanIDs = OSDynamicCast(OSArray, provider->getProperty("Fan Names"));	
	if (fanIDs) fanIDs = OSArray::withArray(fanIDs);	
    if (fanIDs)  {
		UInt32 count = fanIDs->getCount();
		
		if(count > 5)
			count = 5;
		
		for (UInt32 i = 0; i < count; i++) {
			OSString* name = OSDynamicCast(OSString, fanIDs->getObject(i)); 
			FanName[i] = name->getCStringNoCopy();
		}
		
		fanIDs->release();
    }
}
UInt32 FakeSMCKeyStore::addKeysFromDictionary(OSDictionary* dictionary)
{
    UInt32 keysAdded = 0;

    if (dictionary) {
        if (OSIterator *iterator = OSCollectionIterator::withCollection(dictionary)) {
            while (const OSSymbol *key = (const OSSymbol *)iterator->getNextObject()) {
                if (OSArray *array = OSDynamicCast(OSArray, dictionary->getObject(key))) {
                    if (OSIterator *aiterator = OSCollectionIterator::withCollection(array)) {

                        OSString *type = OSDynamicCast(OSString, aiterator->getNextObject());
                        OSData *value = OSDynamicCast(OSData, aiterator->getNextObject());

                        if (type && value) {
                            addKeyWithValue(key->getCStringNoCopy(), type->getCStringNoCopy(), value->getLength(), value->getBytesNoCopy());
                            keysAdded++;
                        }

                        OSSafeRelease(aiterator);
                    }
                }
                key = 0;
            }
            
            OSSafeRelease(iterator);
        }
    }

    return keysAdded;
}
Ejemplo n.º 7
0
OSObject* FileNVRAM::cast(const OSSymbol* key, OSObject* obj)
{
	const char* legacy[] = {
		"boot-args",
		"boot-script",
	};

	OSString* str = OSDynamicCast(OSString, key);

	if (str)
	{
		for (int i = 0; i < sizeof(legacy)/sizeof(char*); i++)
		{
			if (str->isEqualTo(legacy[i]))
			{
				LOG(NOTICE, "Found legacy key %s\n", str->getCStringNoCopy());

				// add null char, convert to OSString
				OSData* data = OSDynamicCast(OSData, obj);

				if (data)
				{
					data->appendByte(0x00, 1);

					return OSString::withCString((const char*)data->getBytesNoCopy());
				}
			}
		}
	}

	return obj;
}
OSString * ACPIBacklightPanel::getACPIPath(IOACPIPlatformDevice * acpiDevice)
{
    OSString * separator = OSString::withCStringNoCopy(".");
    OSArray * array = OSArray::withCapacity(10);
    
    char devicePath[512];
    bzero(devicePath, sizeof(devicePath));
    IOACPIPlatformDevice * parent = acpiDevice;
    
    IORegistryIterator * iter = IORegistryIterator::iterateOver(acpiDevice, gIOACPIPlane, kIORegistryIterateParents | kIORegistryIterateRecursively);
    if (iter)
    {
        do {
            array->setObject(parent->copyName(gIOACPIPlane));
            array->setObject(separator);
            parent = OSDynamicCast(IOACPIPlatformDevice, iter->getNextObject());
        } while (parent);
        iter->release();
        
        int offset = 0;
        OSString * str = OSDynamicCast(OSString, array->getLastObject());
        for (int i = array->getCount()-2; ((i>=0) || ((offset + str->getLength()) > sizeof(devicePath))) ; i--)
        {
            str = OSDynamicCast(OSString, array->getObject(i));
            strncpy(devicePath + offset, str->getCStringNoCopy(), str->getLength());
            offset += str->getLength();
        }
    }
    return OSString::withCString(devicePath);
}
Ejemplo n.º 9
0
bool ACPISensors::willReadSensorValue(FakeSMCSensor *sensor, float *outValue)
{
    UInt32 value = 0;
    OSString *method = NULL;
    
    if (sensor->getIndex() < methods->getCount() && (method = (OSString*)methods->getObject(sensor->getIndex()))) {
        if (kIOReturnSuccess == acpiDevice->evaluateInteger(method->getCStringNoCopy(), &value)) {
            switch(sensor->getGroup()) {
                case kFakeSMCTemperatureSensor:                    
                    // all temperatures returned from ACPI should be in Kelvins?
                    if (useKelvins)
                        *outValue = ((float)value - (float)0xAAC) / (float)0xA;
                    else
                        *outValue = (float)value;
                    break;
                    
                case kFakeSMCVoltageSensor:
                case kFakeSMCCurrentSensor:
                case kFakeSMCPowerSensor:
                    // all voltages returned from ACPI should be in millivolts?
                    *outValue = (float)value * 0.001f;
                    break;
            
                case kFakeSMCTachometerSensor:
                default:
                    *outValue = (float)value;
                    break;
            }
        }
        else return false;
    }
    else return false;
    
    return true;
}
Ejemplo n.º 10
0
bool FakeSMC::start(IOService *provider)
{
	if (!super::start(provider)) 
        return false;
    
    OSString *vendor = OSDynamicCast(OSString, getProperty(kFakeSMCFirmwareVendor));
    
    int arg_value = 1;
    
    if (PE_parse_boot_argn("-fakesmc-force-start", &arg_value, sizeof(arg_value))) {
        HWSensorsInfoLog("firmware vendor check disabled");
    }
    else if (vendor && vendor->isEqualTo("Apple")) {
        HWSensorsFatalLog("forbidding start on Apple hardware");
        return false;
    }
    
	if (!smcDevice->initAndStart(provider, this)) {
        HWSensorsInfoLog("failed to initialize SMC device");
		return false;
    }

	registerService();
    
    // Load keys from NVRAM
    if (PE_parse_boot_argn("-fakesmc-use-nvram", &arg_value, sizeof(arg_value))) {
        if (UInt32 count = smcDevice->loadKeysFromNVRAM())
            HWSensorsInfoLog("%d key%s loaded from NVRAM", count, count == 1 ? "" : "s");
        else
            HWSensorsInfoLog("NVRAM will be used to store system written keys...");
    }

	return true;
}
Ejemplo n.º 11
0
void IOCatalogue::initialize(void)
{
    OSArray              * array;
    OSString             * errorString;
    bool		   rc;

    extern const char * gIOKernelConfigTables;

    array = OSDynamicCast(OSArray, OSUnserialize(gIOKernelConfigTables, &errorString));
    if (!array && errorString) {
        IOLog("KernelConfigTables syntax error: %s\n",
              errorString->getCStringNoCopy());
        errorString->release();
    }

    gIOClassKey              = OSSymbol::withCStringNoCopy( kIOClassKey );
    gIOProbeScoreKey 	     = OSSymbol::withCStringNoCopy( kIOProbeScoreKey );
    gIOModuleIdentifierKey   = OSSymbol::withCStringNoCopy( kCFBundleIdentifierKey );

    assert( array && gIOClassKey && gIOProbeScoreKey
            && gIOModuleIdentifierKey);

    gIOCatalogue = new IOCatalogue;
    assert(gIOCatalogue);
    rc = gIOCatalogue->init(array);
    assert(rc);
    array->release();
}
Ejemplo n.º 12
0
bool FileNVRAM::setProperty(const OSSymbol *aKey, OSObject *anObject)
{
	// Verify permissions.
	if (IOUserClient::clientHasPrivilege(current_task(), kIOClientPrivilegeAdministrator) != kIOReturnSuccess)
	{
		// Not priveleged!
		return false;
	}
	
	// Check for SIP configuration variables.
	if ((strncmp("csr-data", aKey->getCStringNoCopy(), 8) == 0) || (strncmp("csr-active-config", aKey->getCStringNoCopy(), 17) == 0))
	{
		// We have a match so first verify the entitlements.
		if (IOUserClient::copyClientEntitlement(current_task(), "com.apple.private.iokit.nvram-csr") == NULL)
		{
			LOG(INFO, "setProperty(%s, (%s) %p) failed (not entitled)\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), anObject);
			// Not entitled!
			return false;
		}
	}
	
	OSSerialize *s = OSSerialize::withCapacity(1000);
	
	if (anObject->serialize(s))
	{
		
		LOG(INFO, "setProperty(%s, (%s) %s) called\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), s->text());
	}
	else
	{
		LOG(INFO, "setProperty(%s, (%s) %p) called\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), anObject);
	}
	
	s->release();
	
	// Check for special FileNVRAM properties:
	if (strncmp(FILE_NVRAM_GUID ":", aKey->getCStringNoCopy(), MIN(aKey->getLength(), strlen(FILE_NVRAM_GUID ":"))) == 0)
	{
		unsigned long bytes = aKey->getLength() - strlen(FILE_NVRAM_GUID ":") + 1;
		// Found GUID
		char* newKey = (char*)IOMalloc(bytes);
		snprintf(newKey, bytes+1, "%s", &(aKey->getCStringNoCopy()[strlen(FILE_NVRAM_GUID ":")]));
		
		// Send d
		OSString* str = OSString::withCString(newKey);
		handleSetting(str, anObject, this);
		str->release();
		IOFree(newKey, bytes);
	}
	
	bool stat = IOService::setProperty(aKey, cast(aKey, anObject));
	
	if (mInitComplete)
	{
		sync();
	}
	
	return stat;
}
Ejemplo n.º 13
0
void IOCatalogue::moduleHasLoaded(const char * moduleName)
{
    OSString * name;

    name = OSString::withCString(moduleName);
    moduleHasLoaded(name);
    name->release();
}
Ejemplo n.º 14
0
void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
{
    OSData *          data;
    IORegistryEntry * entry;
    OSString *        string = 0;
    uuid_string_t     uuid;

    entry = IORegistryEntry::fromPath( "/efi/platform", gIODTPlane );
    if ( entry )
    {
        data = OSDynamicCast( OSData, entry->getProperty( "system-id" ) );
        if ( data && data->getLength( ) == 16 )
        {
            SHA1_CTX     context;
            uint8_t      digest[ SHA_DIGEST_LENGTH ];
            const uuid_t space = { 0x2A, 0x06, 0x19, 0x90, 0xD3, 0x8D, 0x44, 0x40, 0xA1, 0x39, 0xC4, 0x97, 0x70, 0x37, 0x65, 0xAC };

            SHA1Init( &context );
            SHA1Update( &context, space, sizeof( space ) );
            SHA1Update( &context, data->getBytesNoCopy( ), data->getLength( ) );
            SHA1Final( digest, &context );

            digest[ 6 ] = ( digest[ 6 ] & 0x0F ) | 0x50;
            digest[ 8 ] = ( digest[ 8 ] & 0x3F ) | 0x80;

            uuid_unparse( digest, uuid );
            string = OSString::withCString( uuid );
        }

        entry->release( );
    }

    if ( string == 0 )
    {
        entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
        if ( entry )
        {
            data = OSDynamicCast( OSData, entry->getProperty( "platform-uuid" ) );
            if ( data && data->getLength( ) == sizeof( uuid_t ) )
            {
                uuid_unparse( ( uint8_t * ) data->getBytesNoCopy( ), uuid );
                string = OSString::withCString( uuid );
            }

            entry->release( );
        }
    }

    if ( string )
    {
        getProvider( )->setProperty( kIOPlatformUUIDKey, string );
        publishResource( kIOPlatformUUIDKey, string );

        string->release( );
    }

    publishResource("IONVRAM");
}
Ejemplo n.º 15
0
bool net_lundman_zfs_zvol::start (IOService *provider)
{
    bool res = super::start(provider);


    IOLog("ZFS: Loading module ... \n");

	/*
	 * Initialize /dev/zfs, this calls spa_init->dmu_init->arc_init-> etc
	 */
	zfs_ioctl_osx_init();

	///sysctl_register_oid(&sysctl__debug_maczfs);
	//sysctl_register_oid(&sysctl__debug_maczfs_stalk);

    zfs_vfsops_init();

    /*
     * When is the best time to start the system_taskq? It is strictly
     * speaking not used by SPL, but by ZFS. ZFS should really start it?
     */
    system_taskq_init();


    /*
     * hostid is left as 0 on OSX, and left to be set if developers wish to
     * use it. If it is 0, we will hash the hardware.uuid into a 32 bit
     * value and set the hostid.
     */
    if (!zone_get_hostid(NULL)) {
      uint32_t myhostid = 0;
      IORegistryEntry *ioregroot =  IORegistryEntry::getRegistryRoot();
      if(ioregroot) {
        //IOLog("ioregroot is '%s'\n", ioregroot->getName(gIOServicePlane));
        IORegistryEntry *macmodel = ioregroot->getChildEntry(gIOServicePlane);
        if(macmodel) {
          //IOLog("macmodel is '%s'\n", macmodel->getName(gIOServicePlane));
          OSObject *ioplatformuuidobj;
          //ioplatformuuidobj = ioregroot->getProperty("IOPlatformUUID", gIOServicePlane, kIORegistryIterateRecursively);
          ioplatformuuidobj = macmodel->getProperty(kIOPlatformUUIDKey);
          if(ioplatformuuidobj) {
            OSString *ioplatformuuidstr = OSDynamicCast(OSString, ioplatformuuidobj);
            //IOLog("IOPlatformUUID is '%s'\n", ioplatformuuidstr->getCStringNoCopy());

            myhostid = fnv_32a_str(ioplatformuuidstr->getCStringNoCopy(),
                                   FNV1_32A_INIT);

            sysctlbyname("kern.hostid", NULL, NULL, &myhostid, sizeof(myhostid));
            printf("ZFS: hostid set to %08x from UUID '%s'\n",
                   myhostid, ioplatformuuidstr->getCStringNoCopy());
          }
        }
      }
    }

    return res;
}
Ejemplo n.º 16
0
bool IOPlatformExpert::start( IOService * provider )
{
    IORangeAllocator *	physicalRanges;
    OSData *		busFrequency;
    
    if (!super::start(provider))
      return false;

    // Register the presence or lack thereof a system 
    // PCI address mapper with the IOMapper class

#if 1
    IORegistryEntry * regEntry = IORegistryEntry::fromPath("/u3/dart", gIODTPlane);
    if (!regEntry)
	regEntry = IORegistryEntry::fromPath("/dart", gIODTPlane);
    if (regEntry) {
	int debugFlags;
	if (!PE_parse_boot_arg("dart", &debugFlags) || debugFlags)
	    setProperty(kIOPlatformMapperPresentKey, kOSBooleanTrue);
	regEntry->release();
    }
#endif

    IOMapper::setMapperRequired(0 != getProperty(kIOPlatformMapperPresentKey));
    
    gIOInterruptControllers = OSDictionary::withCapacity(1);
    gIOInterruptControllersLock = IOLockAlloc();
    
    // Correct the bus frequency in the device tree.
    busFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.bus_clock_rate_hz, 4);
    provider->setProperty("clock-frequency", busFrequency);
    busFrequency->release();
    
    gPlatformInterruptControllerName = (OSSymbol *)OSSymbol::withCStringNoCopy("IOPlatformInterruptController");
    
    physicalRanges = IORangeAllocator::withRange(0xffffffff, 1, 16,
						 IORangeAllocator::kLocking);
    assert(physicalRanges);
    setProperty("Platform Memory Ranges", physicalRanges);
    
    setPlatform( this );
    gIOPlatform = this;
    
    PMInstantiatePowerDomains();
    
    // Parse the serial-number data and publish a user-readable string
    OSData* mydata = (OSData*) (provider->getProperty("serial-number"));
    if (mydata != NULL) {
        OSString *serNoString = createSystemSerialNumberString(mydata);
        if (serNoString != NULL) {
            provider->setProperty(kIOPlatformSerialNumberKey, serNoString);
            serNoString->release();
        }
    }
    
    return( configure(provider) );
}
Ejemplo n.º 17
0
static void setStringInDict(OSDictionary* dict, const char* key, const char* value)
{
    OSString* str = OSString::withCStringNoCopy(value);
    if (str)
    {
        dict->setObject(key, str);
        str->release();
    }
}
OSString* org_litio_OzoneStrikeBattle::newProductString() const {
    OSString * string = OSDynamicCast(OSString, getProperty("ProductString"));

    if (!string)
        return NULL;

    string->retain();

    return string;
}
Ejemplo n.º 19
0
OSString* Xbox360ControllerClass::newProductString() const
{
    OSString *retString = getDeviceString(GetOwnerProvider(this)->GetProductStringIndex());
    if (retString->isEqualTo("Controller")) {
        retString->release();
        return OSString::withCString("Xbox 360 Wired Controller");
    } else {
        return retString;
    }
}
Ejemplo n.º 20
0
OSString *OSString::withStringOfLength(const char *cString, size_t length)
{
    OSString *me = new OSString;

    if (me && !me->initWithStringOfLength(cString, length)) {
        me->release();
        return 0;
    }

    return me;
}
Ejemplo n.º 21
0
OSString *OSString::withString(const OSString *aString)
{
    OSString *me = new OSString;

    if (me && !me->initWithString(aString)) {
        me->release();
        return 0;
    }

    return me;
}
Ejemplo n.º 22
0
OSString *OSString::withCStringNoCopy(const char *cString)
{
    OSString *me = new OSString;

    if (me && !me->initWithCStringNoCopy(cString)) {
        me->release();
        return 0;
    }

    return me;
}
//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newSerialNumberString
//----------------------------------------------------------------------------------------------------
OSString *IOHIDUserDevice::newSerialNumberString() const
{
    OSString * string = OSDynamicCast(OSString, _properties->getObject(kIOHIDSerialNumberKey));
    
    if ( !string ) 
        return NULL;
        
    string->retain();
        
    return string;
}
//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newProductString
//----------------------------------------------------------------------------------------------------
OSString *IOHIDUserDevice::newProductString() const
{
    OSString * string = OSDynamicCast(OSString, _properties->getObject(kIOHIDProductKey));
    
    if ( !string ) 
        return NULL;
        
    string->retain();
        
    return string;
}
Ejemplo n.º 25
0
OSDictionary * AppleLVMVolume::propsFromHeader(AppleLVMVolumeOnDisk * lve)
{
    OSString * errmsg = 0;
    OSDictionary * lvProps = OSDynamicCast(OSDictionary, OSUnserializeXML(lve->plist, &errmsg));
    if (!lvProps) {
	if (errmsg) {
	    IOLog("AppleLVMVolume::propsFromHeader - XML parsing failed with %s\n", errmsg->getCStringNoCopy());
	    errmsg->release();
	}
	return NULL;
    }

    return lvProps;
}
Ejemplo n.º 26
0
void BrcmPatchRAM::printPersonalities()
{
    // Matching dictionary for the current device
    OSDictionary* dict = OSDictionary::withCapacity(5);
    if (!dict) return;
    setStringInDict(dict, kIOProviderClassKey, kIOUSBDeviceClassName);
    setNumberInDict(dict, kUSBProductID, mProductId);
    setNumberInDict(dict, kUSBVendorID, mVendorId);
    
    SInt32 generatonCount;
    if (OSOrderedSet* set = gIOCatalogue->findDrivers(dict, &generatonCount))
    {
        AlwaysLog("[%04x:%04x]: %d matching driver personalities.\n", mVendorId, mProductId, set->getCount());
        if (OSCollectionIterator* iterator = OSCollectionIterator::withCollection(set))
        {
            while (OSDictionary* personality = static_cast<OSDictionary*>(iterator->getNextObject()))
            {
                OSString* bundleId = OSDynamicCast(OSString, personality->getObject(kBundleIdentifier));
                AlwaysLog("[%04x:%04x]: existing IOKit personality \"%s\".\n", mVendorId, mProductId, bundleId->getCStringNoCopy());
            }
            iterator->release();
        }
        set->release();
    }
    dict->release();
}
Ejemplo n.º 27
0
IOReturn IOCatalogue::terminateDriversForModule(
    const char * moduleName,
    bool unload)
{
    OSString * name;
    IOReturn ret;

    name = OSString::withCString(moduleName);
    if ( !name )
        return kIOReturnNoMemory;

    ret = terminateDriversForModule(name, unload);
    name->release();

    return ret;
}
Ejemplo n.º 28
0
bool FileNVRAM::passiveMatch (OSDictionary *matching, bool changesOK)
{
	OSString *str = OSDynamicCast(OSString, matching->getObject(gIOProviderClassKey));

	if (str)
	{
		LOG(NOTICE, "passiveMatch(%s) called\n", str->getCStringNoCopy());
	}
	
	if (str && str->isEqualTo("AppleEFINVRAM"))
	{
		return true;
	}

	return super::passiveMatch (matching, changesOK);
}
bool
IOATABlockStorageDriver::inspectDevice ( IOATADevice * ataDevice )
{
	
	OSString *		string			= NULL;
	IOReturn		theErr			= kIOReturnSuccess;
	
	// Fetch ATA device information from the nub.
	string = OSDynamicCast ( 	OSString,
								ataDevice->getProperty ( kATAVendorPropertyKey ) );
	
	if ( string != NULL )
	{
		
		strncpy ( fModel, string->getCStringNoCopy ( ), kSizeOfATAModelString );
		fModel[kSizeOfATAModelString] = '\0';
		
	}
	
	string = OSDynamicCast ( 	OSString,
								ataDevice->getProperty ( kATARevisionPropertyKey ) );
	
	if ( string != NULL )
	{
		
		strncpy ( fRevision, string->getCStringNoCopy ( ), kSizeOfATARevisionString );
		fRevision[kSizeOfATARevisionString] = '\0';
		
	}
	
	theErr = identifyAndConfigureATADevice ( );
	if ( theErr != kIOReturnSuccess )
	{
		
		ERROR_LOG ( ( "IOATABlockStorageDriver::inspectDevice theErr = %ld\n", ( UInt32 ) theErr ) );
		return false;
		
	}	
	
	// Add an OSNumber property indicating the supported features.
	setProperty ( 	kIOATASupportedFeaturesKey,
					fSupportedFeatures,
					sizeof ( fSupportedFeatures ) * 8 );
	
	return true;
	
}
Ejemplo n.º 30
0
/*
 * Callback for device termination events, ie, disks removed.
 */
bool IOkit_disk_removed_callback(void* target,
								 void* refCon,
								 IOService* newService,
								 IONotifier* notifier)
{
	OSObject *prop = 0;
	OSString* bsdnameosstr = 0;

	prop = newService->getProperty(kIOBSDNameKey, gIOServicePlane,
								   kIORegistryIterateRecursively);
	if (prop) {
		spa_t *spa = NULL;

		bsdnameosstr = OSDynamicCast(OSString, prop);
		printf("ZFS: Device removal detected: '%s'\n",
			   bsdnameosstr->getCStringNoCopy());

		for (spa = spa_next(NULL);
			 spa != NULL; spa = spa_next(spa)) {
		  vdev_t *vd;

		  dprintf("ZFS: Scanning pool '%s'\n", spa_name(spa));

		  vd = vdev_lookup_by_path(spa->spa_root_vdev,
								   bsdnameosstr->getCStringNoCopy());

		  if (vd && vd->vdev_path) {

			printf("ZFS: Device '%s' removal requested\n",
				   vd->vdev_path);
			(void) thread_create(NULL, 0, vdev_close_thread,
								 vd, 0, &p0,
								 TS_RUN, minclsyspri);

			vd->vdev_remove_wanted = B_TRUE;
			spa_async_request(spa, SPA_ASYNC_REMOVE);

			break;
		  }

		} // for all spa

	} // if has BSDname

	return true;
}