当前位置: 首页>>代码示例>>C++>>正文


C++ IOService::getProperty方法代码示例

本文整理汇总了C++中IOService::getProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ IOService::getProperty方法的具体用法?C++ IOService::getProperty怎么用?C++ IOService::getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOService的用法示例。


在下文中一共展示了IOService::getProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getACStatus

bool getACStatus()
{
	IOService * batteryDevice = getBatteryDevice();
	
	if (NULL != batteryDevice)
	{
		OSObject * obj = batteryDevice->getProperty("ExternalConnected");
		OSBoolean * status = OSDynamicCast(OSBoolean, obj);
        if (status)
            return status->getValue();
	}
    return true;
}
开发者ID:htge,项目名称:AutoDisableTurboBoost,代码行数:13,代码来源:Battery.cpp

示例2: getACStatus

bool ACPIBacklightPanel::getACStatus()
{
    DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
    
	IOService * batteryDevice = getBatteryDevice();
	
	if (NULL != batteryDevice)
	{
		OSObject * obj = batteryDevice->getProperty("ExternalConnected");
		OSBoolean * status = OSDynamicCast(OSBoolean, obj);
        if (status)
        {
            DbgLog("%s: getACStatus() AC is %d\n", this->getName(), status->getValue());
            return status->getValue();
        }
        else
            DbgLog("%s: getACStatus() unable to get \"ExternalConnected\" property\n", this->getName());
	}
    return true;
}
开发者ID:chemschool,项目名称:OS-X-ACPI-Backlight,代码行数:20,代码来源:ACPIBacklight.cpp

示例3: getName

bool
AppleFileSystemDriver::start(IOService * provider)
{
    OSDictionary *      matching;
    OSString *          uuidString;
    const char *        uuidCString;
    IOService *         resourceService;
    OSDictionary *      dict;


    DEBUG_LOG("%s[%p]::%s\n", getName(), this, __func__);

    DEBUG_LOG("%s provider is '%s'\n", getName(), provider->getName());

    do {
        resourceService = getResourceService();
        if (resourceService == 0) break;

        uuidString = OSDynamicCast( OSString, resourceService->getProperty("boot-uuid") );
        if (uuidString) {
            _uuidString = uuidString;
            _uuidString->retain();
            uuidCString = uuidString->getCStringNoCopy();
            DEBUG_LOG("%s: got UUID string '%s'\n", getName(), uuidCString);
            if (uuid_parse(uuidCString, _uuid) != 0) {
                IOLog("%s: Invalid UUID string '%s'\n", getName(), uuidCString);
                break;
            }
        } else {
            IOLog("%s: Error getting boot-uuid property\n", getName());
            break;
        }
                
        // Match IOMedia objects matching our criteria (from kext .plist)
        dict = OSDynamicCast( OSDictionary, getProperty( kMediaMatchKey ) );
        if (dict == 0) break;
        
        dict = OSDictionary::withDictionary(dict);
        if (dict == 0) break;

        matching = IOService::serviceMatching( "IOMedia", dict );
        if ( matching == 0 )
            return false;
        
        // Retain for asynchronous matching notification
        retain();

        // Set up notification for newly-appearing devices.
        // This will also notify us about existing devices.
        
        _notifier = IOService::addMatchingNotification( gIOMatchedNotification, matching,
                                                &mediaNotificationHandler,
                                                this, 0 );
        matching->release();

        DEBUG_LOG("%s[%p]::%s finishes TRUE\n", getName(), this, __func__);

        return true;

    } while (false);
    
    DEBUG_LOG("%s[%p]::%s finishes false\n", getName(), this, __func__);

    return false;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:65,代码来源:AppleFileSystemDriver.cpp

示例4: if

bool IT87x::startPlugin()
{
	DebugLog("starting...");

	
	InfoLog("found ITE %s", getModelName());
    OSDictionary* list = OSDynamicCast(OSDictionary, getProperty("Sensors Configuration"));
    IOService * fRoot = getServiceRoot();
    OSString *vendor=NULL, *product=NULL;
    OSDictionary *configuration=NULL; 
    
    
    if(fRoot)
    {
        vendor = vendorID( OSDynamicCast(OSString, fRoot->getProperty("oem-mb-manufacturer") ? fRoot->getProperty("oem-mb-manufacturer") :  (fRoot->getProperty("oem-manufacturer") ? fRoot->getProperty("oem-manufacturer") : NULL)));
        product = OSDynamicCast(OSString, fRoot->getProperty("oem-mb-product") ? fRoot->getProperty("oem-mb-product") :  (fRoot->getProperty("oem-product-name") ? fRoot->getProperty("oem-product-name") : NULL));
        
    }
    if (vendor)
        if (OSDictionary *link = OSDynamicCast(OSDictionary, list->getObject(vendor)))
            if(product)
                configuration = OSDynamicCast(OSDictionary, link->getObject(product));

    
    if (list && !configuration) 
        configuration = OSDynamicCast(OSDictionary, list->getObject("Default"));
    
    if(configuration)
        this->setProperty("Current Configuration", configuration);
	
	// Temperature Sensors
	if (configuration) {
		for (int i = 0; i < 3; i++) 
		{				
			char key[8];
			
			snprintf(key, 8, "TEMPIN%X", i);
            if(readTemperature(i)<MAX_TEMP_THRESHOLD)  // Need to check if temperature sensor valid
    			if (OSString* name = OSDynamicCast(OSString, configuration->getObject(key)))
                    if (name->isEqualTo("CPU")) {
                        if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, i))
                            WarningLog("error adding heatsink temperature sensor");
                    }
                    else if (name->isEqualTo("System")) {				
                        if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor,i))
                            WarningLog("error adding system temperature sensor");
                    }
                    else if (name->isEqualTo("Ambient")) {				
                        if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor,i))
                            WarningLog("error adding Ambient temperature sensor");
				}
		}
	}
	else {
        if(readTemperature(0)<MAX_TEMP_THRESHOLD)  // Need to check if temperature sensor valid
             if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 0))
                 WarningLog("error adding heatsink temperature sensor");
        if(readTemperature(1)<MAX_TEMP_THRESHOLD)  // Need to check if temperature sensor valid
            if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 1))
                WarningLog("error adding Ambient temperature sensor");
        if(readTemperature(2)<MAX_TEMP_THRESHOLD)  // Need to check if temperature sensor valid
            if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 2))
                WarningLog("error adding system temperature sensor");
	}
	
	
	// Voltage
    UInt8 tmp = readByte(address, ITE_ADC_CHANNEL_ENABLE);
    DebugLog("ADC Enable register = %X",tmp);
    
    vbat_updates=false;
    if(configuration)
    {
        if(OSBoolean* smartGuard=OSDynamicCast(OSBoolean, configuration->getObject("VBATNeedUpdates")))
            if(smartGuard->isTrue())
                vbat_updates=true;
        
    }
    // Refresh VBAT reading on each access to the key
    if(vbat_updates)
        writeByte(address, ITE_CONFIGURATION_REGISTER, readByte(address, ITE_CONFIGURATION_REGISTER) | 0x40);
    
	if (configuration) {
		for (int i = 0; i < 9; i++) 
		{				
			char key[5];
            OSString * name;
            long Ri=0;
            long Rf=1;
            long Vf=0;
			
			snprintf(key, 5, "VIN%X", i);
			
			if (process_sensor_entry(configuration->getObject(key), &name, &Ri, &Rf, &Vf)) {
				if (name->isEqualTo("CPU")) {
					if (!addSensor(KEY_CPU_VRM_SUPPLY0, TYPE_FP2E, 2, kSuperIOVoltageSensor, i,Ri,Rf,Vf))
						WarningLog("error adding CPU voltage sensor");
				}
				else if (name->isEqualTo("Memory")) {
					if (!addSensor(KEY_MEMORY_VOLTAGE, TYPE_FP2E, 2, kSuperIOVoltageSensor, i,Ri,Rf,Vf))
//.........这里部分代码省略.........
开发者ID:AppleLife,项目名称:FakeSMC,代码行数:101,代码来源:ITEIT87x.cpp

示例5: OSDynamicCast

bool MacRISC2CPU::start(IOService *provider)
{
    kern_return_t        result;
    IORegistryEntry      *cpusRegEntry, *uniNRegEntry, *mpicRegEntry, *devicetreeRegEntry;
    OSIterator           *cpusIterator;
    OSData               *tmpData;
    IOService            *service;
    const OSSymbol       *interruptControllerName;
    OSData               *interruptData;
    OSArray              *tmpArray;
    UInt32               maxCPUs, uniNVersion, physCPU;
    ml_processor_info_t  processor_info;
    
#if enableUserClientInterface    
	DFScontMode = 0;
    fWorkLoop = 0;
    DFS_Status = false;
    GPU_Status = kGPUHigh;
	vStepped = false;
#endif

    // callPlatformFunction symbols
    mpic_getProvider = OSSymbol::withCString("mpic_getProvider");
    mpic_getIPIVector= OSSymbol::withCString("mpic_getIPIVector");
    mpic_setCurrentTaskPriority = OSSymbol::withCString("mpic_setCurrentTaskPriority");
    mpic_setUpForSleep = OSSymbol::withCString("mpic_setUpForSleep");
    mpic_dispatchIPI = OSSymbol::withCString("mpic_dispatchIPI");
    keyLargo_restoreRegisterState = OSSymbol::withCString("keyLargo_restoreRegisterState");
    keyLargo_syncTimeBase = OSSymbol::withCString("keyLargo_syncTimeBase");
    keyLargo_saveRegisterState = OSSymbol::withCString("keyLargo_saveRegisterState");
    keyLargo_turnOffIO = OSSymbol::withCString("keyLargo_turnOffIO");
    keyLargo_writeRegUInt8 = OSSymbol::withCString("keyLargo_writeRegUInt8");
    keyLargo_getHostKeyLargo = OSSymbol::withCString("keyLargo_getHostKeyLargo");
    keyLargo_setPowerSupply = OSSymbol::withCString("setPowerSupply");
    uniN_setPowerState = OSSymbol::withCString(kUniNSetPowerState);
    uniN_setAACKDelay = OSSymbol::withCString(kUniNSetAACKDelay);
	pmu_cpuReset = OSSymbol::withCString("cpuReset");
	ati_prepareDMATransaction = OSSymbol::withCString(kIOFBPrepareDMAValueKey);
    ati_performDMATransaction = OSSymbol::withCString(kIOFBPerformDMAValueKey);
    
    macRISC2PE = OSDynamicCast(MacRISC2PE, getPlatform());
    if (macRISC2PE == 0) return false;
  
    if (!super::start(provider)) return false;

    // Get the Uni-N Version.
    uniNRegEntry = fromPath("/uni-n", gIODTPlane);
    if (uniNRegEntry == 0) return false;
    tmpData = OSDynamicCast(OSData, uniNRegEntry->getProperty("device-rev"));
    if (tmpData == 0) return false;
    uniNVersion = *(long *)tmpData->getBytesNoCopy();
  
    // Find out if this is the boot CPU.
    bootCPU = false;
    tmpData = OSDynamicCast(OSData, provider->getProperty("state"));
    if (tmpData == 0) return false;
    if (!strcmp((char *)tmpData->getBytesNoCopy(), "running")) bootCPU = true;

    // Count the CPUs.
    numCPUs = 0;
    cpusRegEntry = fromPath("/cpus", gIODTPlane);
    if (cpusRegEntry == 0) return false;
    cpusIterator = cpusRegEntry->getChildIterator(gIODTPlane);
    while (cpusIterator->getNextObject()) numCPUs++;
    cpusIterator->release();
  
	// [3830950] - The bootCPU driver inits globals for all instances (like gCPUIC) so if we're not the
	// boot CPU driver we wait here for that driver to finish its initialization
	if ((numCPUs > 1) && !bootCPU)
		// Wait for bootCPU driver to say it's up and running
		(void) waitForService (resourceMatching ("BootCPU"));
		
    // Limit the number of CPUs to one if uniNVersion is 1.0.7 or less.
    if (uniNVersion < kUniNVersion107) numCPUs = 1;
  
    // Limit the number of CPUs by the cpu=# boot arg.
    if (PE_parse_boot_arg("cpus", &maxCPUs))
    {
        if (numCPUs > maxCPUs) numCPUs = maxCPUs;
    }
	
	ignoreSpeedChange = false;
	doSleep = false;
	topLevelPCIBridgeCount = 0;
  
    // Get the "flush-on-lock" property from the first cpu node.
    flushOnLock = false;
    cpusRegEntry = fromPath("/cpus/@0", gIODTPlane);
    if (cpusRegEntry == 0) return false;
    if (cpusRegEntry->getProperty("flush-on-lock") != 0) flushOnLock = true;
  
    // Set flushOnLock when numCPUs is not one.
    if (numCPUs != 1) flushOnLock = true;
  
    // If system is PowerMac3,5 (TowerG4), then set flushOnLock to disable nap
    devicetreeRegEntry = fromPath("/", gIODTPlane);
    tmpData = OSDynamicCast(OSData, devicetreeRegEntry->getProperty("model"));
    if (tmpData == 0) return false;
#if 0
    if(!strcmp((char *)tmpData->getBytesNoCopy(), "PowerMac3,5"))
//.........这里部分代码省略.........
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:101,代码来源:MacRISC2CPU.cpp

示例6: start

bool Andigilog::start(IOService *provider)
{
    int i;
    bool res;
    UInt8 cmd, data, addrs[] = ASC7621_ADDRS;
    /* Mapping common for Intel boards */
    struct MList list[] = {
        { ASC7621_TEMP1H, ASC7621_TEMP1L, {"TC0D",TYPE_SP78,2,-1}, -1, 0, true },
        { ASC7621_TEMP2H, ASC7621_TEMP2L, {KEY_AMBIENT_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true },
        { ASC7621_TEMP3H, ASC7621_TEMP3L, {KEY_DIMM_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true },
        { ASC7621_TEMP4H, ASC7621_TEMP4L, {KEY_CPU_HEATSINK_TEMPERATURE,TYPE_SP78,2,-1}, -1, 0, true },
        
        { ASC7621_TACH1L, ASC7621_TACH1H, {"Fan 1",TYPE_FPE2,2,0}, true, 0, true },
        { ASC7621_TACH2L, ASC7621_TACH2H, {"Fan 2",TYPE_FPE2,2,1}, true, 0, true },
        { ASC7621_TACH3L, ASC7621_TACH3H, {"Fan 3",TYPE_FPE2,2,2}, true, 0, true },
        { ASC7621_TACH4L, ASC7621_TACH4H, {"Fan 4",TYPE_FPE2,2,2}, true, 0, true }
    };
    struct PList pwm[] = {
        { ASC7621_PWM1R, 0, -2 },
        { ASC7621_PWM2R, 0, -2 },
        { ASC7621_PWM3R, 0, -2 },
    };

    OSDictionary *conf = NULL, *sconf = OSDynamicCast(OSDictionary, getProperty("Sensors Configuration")), *dict;
    IOService *fRoot = getServiceRoot();
    OSString *str, *vendor = NULL;
    char *key;
    char tempkey[] = "_temp ", /* Ugly hack to keep keys in order for auto-generated plist */
    fankey[] = "tach ";

    
    res = super::start(provider);
    DbgPrint("start\n");
    
    if (!(i2cNub = OSDynamicCast(I2CDevice, provider))) {
        IOPrint("Failed to cast provider\n");
        return false;
    }
    
    i2cNub->retain();
    i2cNub->open(this);
    
    for (i = 0; i < sizeof(addrs) / sizeof(addrs[0]); i++)
        if (!i2cNub->ReadI2CBus(addrs[i], &(cmd = ASC7621_VID_REG), sizeof(cmd), &data,
                            sizeof(data)) && data == ASC7621_VID &&
            !i2cNub->ReadI2CBus(addrs[i], &(cmd = ASC7621_PID_REG), sizeof(cmd), &data,
                            sizeof(data)) && (data == ASC7621_PID || data == ASC7621A_PID)) {
                Asc7621_addr = addrs[i];
                IOPrint("aSC7621 attached at 0x%x.\n", Asc7621_addr);
                break;
            }
    if (!Asc7621_addr) {
        IOPrint("Device matching failed.\n");
        return false;
    }
    
    memcpy(&Measures, &list, sizeof(Measures));
    memcpy(&Pwm, &pwm, sizeof(Pwm));
    
    if (fRoot) {
        vendor = vendorID(OSDynamicCast(OSString, fRoot->getProperty("oem-mb-manufacturer") ?
                                        fRoot->getProperty("oem-mb-manufacturer") :
                                        (fRoot->getProperty("oem-manufacturer") ?
                                         fRoot->getProperty("oem-manufacturer") : NULL)));
        str = OSDynamicCast(OSString, fRoot->getProperty("oem-mb-product") ?
                            fRoot->getProperty("oem-mb-product") :
                            (fRoot->getProperty("oem-product-name") ?
                             fRoot->getProperty("oem-product-name") : NULL));
    }
    if (vendor)
        if (OSDictionary *link = OSDynamicCast(OSDictionary, sconf->getObject(vendor)))
            if(str)
                conf = OSDynamicCast(OSDictionary, link->getObject(str));
    if (sconf && !conf)
        conf = OSDynamicCast(OSDictionary, sconf->getObject("Active"));
    i = 0;
    for (int s = 0, j = 0, k = 0; i < NUM_SENSORS; i++) {
        if (conf) {
                if (Measures[i].fan < 0) {
                    snprintf(&tempkey[5], 2, "%d", j++);
                    key = tempkey;
                } else {
                    snprintf(&fankey[4], 2, "%d", k++);
                    key = fankey;
                }
                if ((dict = OSDynamicCast(OSDictionary, conf->getObject(key)))) {
                    str = OSDynamicCast(OSString, dict->getObject("id"));
                    memcpy(Measures[i].hwsensor.key, str->getCStringNoCopy(), str->getLength()+1);
                    if (Measures[i].fan > -1)
                        Measures[i].hwsensor.pwm = ((OSNumber *)OSDynamicCast(OSNumber, dict->getObject("pwm")))->
                        unsigned8BitValue();
                    Measures[i].hwsensor.size = ((OSNumber *)OSDynamicCast(OSNumber, dict->getObject("size")))->
                    unsigned8BitValue();
                    str = OSDynamicCast(OSString, dict->getObject("type"));
                    memcpy(Measures[i].hwsensor.type, str->getCStringNoCopy(), str->getLength()+1);
                }
        }
        if (Measures[i].hwsensor.key[0]) {
            if (Measures[i].fan < 0) {
                addSensor(Measures[i].hwsensor.key, Measures[i].hwsensor.type,
//.........这里部分代码省略.........
开发者ID:bigmagic,项目名称:osx-goodies,代码行数:101,代码来源:Andigilog.cpp

示例7: IONew

IOReturn
IOPolledFileOpen(const char * filename,
                 uint64_t setFileSize, uint64_t fsFreeSize,
                 void * write_file_addr, size_t write_file_len,
                 IOPolledFileIOVars ** fileVars,
                 OSData ** imagePath,
                 uint8_t * volumeCryptKey, size_t keySize)
{
    IOReturn             err = kIOReturnSuccess;
    IOPolledFileIOVars * vars;
    _OpenFileContext     ctx;
    OSData *             extentsData;
    OSNumber *           num;
    IOService *          part = 0;
    dev_t                block_dev;
    dev_t                image_dev;
    AbsoluteTime         startTime, endTime;
    uint64_t             nsec;

    vars = IONew(IOPolledFileIOVars, 1);
    if (!vars) return (kIOReturnNoMemory);
    bzero(vars, sizeof(*vars));
    vars->allocated = true;

    do
    {
        extentsData = OSData::withCapacity(32);
        ctx.extents = extentsData;
        ctx.size    = 0;
        clock_get_uptime(&startTime);

        vars->fileRef = kern_open_file_for_direct_io(filename,
                        (write_file_addr != NULL) || (0 != setFileSize),
                        &file_extent_callback, &ctx,
                        setFileSize,
                        fsFreeSize,
                        // write file:
                        0, write_file_addr, write_file_len,
                        // results
                        &block_dev,
                        &image_dev,
                        &vars->block0,
                        &vars->maxiobytes,
                        &vars->flags);
#if 0
        uint32_t msDelay = (131071 & random());
        HIBLOG("sleep %d\n", msDelay);
        IOSleep(msDelay);
#endif
        clock_get_uptime(&endTime);
        SUB_ABSOLUTETIME(&endTime, &startTime);
        absolutetime_to_nanoseconds(endTime, &nsec);

        if (!vars->fileRef) err = kIOReturnNoSpace;

        HIBLOG("kern_open_file_for_direct_io took %qd ms\n", nsec / 1000000ULL);
        if (kIOReturnSuccess != err) break;

        HIBLOG("Opened file %s, size %qd, extents %ld, maxio %qx ssd %d\n", filename, ctx.size,
               (extentsData->getLength() / sizeof(IOPolledFileExtent)) - 1,
               vars->maxiobytes, kIOPolledFileSSD & vars->flags);
        assert(!vars->block0);
        if (extentsData->getLength() < sizeof(IOPolledFileExtent))
        {
            err = kIOReturnNoSpace;
            break;
        }

        vars->fileSize = ctx.size;
        vars->extentMap = (IOPolledFileExtent *) extentsData->getBytesNoCopy();

        part = IOCopyMediaForDev(image_dev);
        if (!part)
        {
            err = kIOReturnNotFound;
            break;
        }

        if (!(vars->pollers = IOPolledFilePollers::copyPollers(part))) break;

        if ((num = OSDynamicCast(OSNumber, part->getProperty(kIOMediaPreferredBlockSizeKey))))
            vars->blockSize = num->unsigned32BitValue();
        if (vars->blockSize < 4096) vars->blockSize = 4096;

        HIBLOG("polled file major %d, minor %d, blocksize %ld, pollers %d\n",
               major(image_dev), minor(image_dev), (long)vars->blockSize,
               vars->pollers->pollers->getCount());

        OSString * keyUUID = NULL;
        if (volumeCryptKey)
        {
            err = IOGetVolumeCryptKey(block_dev, &keyUUID, volumeCryptKey, keySize);
        }

        *fileVars    = vars;
        vars->fileExtents = extentsData;

        // make imagePath
        OSData * data;
        if (imagePath)
//.........这里部分代码省略.........
开发者ID:JackieXie168,项目名称:xnu,代码行数:101,代码来源:IOPolledInterface.cpp


注:本文中的IOService::getProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。