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


C++ OSData::getBytesNoCopy方法代码示例

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


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

示例1: OSDynamicCast

IOService* X3100monitor::probe(IOService *provider, SInt32 *score)
{
	if (super::probe(provider, score) != this) return 0;
	UInt32 vendor_id, device_id;
	if (OSDictionary * dictionary = serviceMatching(kGenericPCIDevice)) {
		if (OSIterator * iterator = getMatchingServices(dictionary)) {
			
			IOPCIDevice* device = 0;
			
			while (device = OSDynamicCast(IOPCIDevice, iterator->getNextObject())) {
				OSData *data = OSDynamicCast(OSData, device->getProperty("vendor-id"));
				if (data)
					vendor_id = *(UInt32*)data->getBytesNoCopy();
				
				data = OSDynamicCast(OSData, device->getProperty("device-id"));				
				if (data)
					device_id = *(UInt32*)data->getBytesNoCopy();
				
				if ((vendor_id==0x8086) && (device_id==0x2a00)){
					InfoLog("found %lx chip", (long unsigned int)device_id);
					VCard = device;
				}
			}
		}
	}	
	return this;
}
开发者ID:Beshuta,项目名称:HWSensors,代码行数:27,代码来源:X3100.cpp

示例2: registerNVRAMController

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");
}
开发者ID:Dracophoenix1,项目名称:xnu-1,代码行数:58,代码来源:IOPlatformExpert.cpp

示例3: probe

IOService* GeforceSensors::probe(IOService *provider, SInt32 *score)
{
  UInt32 vendor_id, device_id, class_id;
	DebugLog("Probing...");
	
	if (super::probe(provider, score) != this) return 0;
	
	InfoLog("GeforceSensors by kozlek (C) 2012");
	s8 ret = 0;
	if (OSDictionary * dictionary = serviceMatching(kGenericPCIDevice)) {
		if (OSIterator * iterator = getMatchingServices(dictionary)) {
			ret = 1;
			IOPCIDevice* device = 0;
			do {
			  device = OSDynamicCast(IOPCIDevice, iterator->getNextObject());
        if (!device) {
          break;
        }
				OSData *data = OSDynamicCast(OSData, device->getProperty(fVendor));
        vendor_id = 0;
				if (data)
					vendor_id = *(UInt32*)data->getBytesNoCopy();
				
        device_id = 0;
				data = OSDynamicCast(OSData, device->getProperty(fDevice));				
				if (data)
					device_id = *(UInt32*)data->getBytesNoCopy();
				
        class_id = 0;
				data = OSDynamicCast(OSData, device->getProperty(fClass));				
				if (data)
					class_id = *(UInt32*)data->getBytesNoCopy();
				
				if ((vendor_id==0x10de) && (class_id == 0x030000)) {
					InfoLog("found %x Nvidia chip", (unsigned int)device_id);
					card.pcidev = device;
          card.device_id = device_id;
					ret = 1; //TODO - count a number of cards
          card.card_index = ret;
					break;
				}
			} while (device);	
		}
	}
	if(ret)
		return this;
	else return 0;
	
	return this;
}
开发者ID:RehabMan,项目名称:OS-X-FakeSMC-slice,代码行数:50,代码来源:GeforceSensors.cpp

示例4: initIfnetParams

bool IOEthernetInterface::initIfnetParams(struct ifnet_init_params *params)
{
	OSData *uniqueID;
	//get the default values
    super::initIfnetParams( params );
		
    uniqueID = OSDynamicCast(OSData, getProvider()->getProperty(kIOMACAddress));
    if ( (uniqueID == 0) || (uniqueID->getLength() != ETHER_ADDR_LEN) )
    {
        DLOG("%s: kIOMACAddress property access error (len %d)\n",
             getName(), uniqueID ? uniqueID->getLength() : 0);
        return false;
    }
	
	// fill in ethernet specific values
	params->uniqueid = uniqueID->getBytesNoCopy();
	params->uniqueid_len = uniqueID->getLength();
	params->family = APPLE_IF_FAM_ETHERNET;
	params->demux = ether_demux;
	params->add_proto = ether_add_proto;
	params->del_proto = ether_del_proto;
	params->framer = ether_frameout;
	params->check_multi = ether_check_multi;
	params->broadcast_addr = ether_broadcast_addr;
	params->broadcast_len = sizeof(ether_broadcast_addr);
    return true;
}
开发者ID:wzw19890321,项目名称:IONetworkingFamily,代码行数:27,代码来源:IOEthernetInterface.cpp

示例5: PEReadNVRAMProperty

/* pass in a NULL value if you just want to figure out the len */
boolean_t PEReadNVRAMProperty(const char *symbol, void *value,
                              unsigned int *len)
{
    OSObject  *obj;
    OSData *data;
    unsigned int vlen;

    if (!symbol || !len)
        goto err;

    if (init_gIOOptionsEntry() < 0)
        goto err;

    vlen = *len;
    *len = 0;

    obj = gIOOptionsEntry->getProperty(symbol);
    if (!obj)
        goto err;

    /* convert to data */
    data = OSDynamicCast(OSData, obj);
    if (!data) 
        goto err;

    *len  = data->getLength();
    vlen  = min(vlen, *len);
    if (value && vlen)
        memcpy((void *) value, data->getBytesNoCopy(), vlen);

    return TRUE;

err:
    return FALSE;
}
开发者ID:Dracophoenix1,项目名称:xnu-1,代码行数:36,代码来源:IOPlatformExpert.cpp

示例6: enableInterrupt

IOReturn IOSharedInterruptController::enableInterrupt(IOService *nub,
						      int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
  if (!vector->interruptDisabledSoft) {
    IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
    return kIOReturnSuccess;
  }
  
  vector->interruptDisabledSoft = 0;
  vectorsEnabled++;
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (controllerDisabled && (vectorsEnabled == vectorsRegistered)) {
    controllerDisabled = 0;
    provider->enableInterrupt(0);
  }
  
  return kIOReturnSuccess;
}
开发者ID:aglab2,项目名称:darwin-xnu,代码行数:31,代码来源:IOInterruptController.cpp

示例7: disableInterrupt

IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
						       int source)
{
  IOInterruptSource *interruptSources;
  long              vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(long *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
  if (!vector->interruptDisabledSoft) {
    vector->interruptDisabledSoft = 1;
#if __ppc__
    sync();
    isync();
#endif
    vectorsEnabled--;
  }
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (!getPlatform()->atInterruptLevel()) {
    while (vector->interruptActive);
#if __ppc__
    isync();
#endif
  }
  
  return kIOReturnSuccess;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:34,代码来源:IOInterruptController.cpp

示例8: init

bool NullEthernet::init(OSDictionary *properties)
{
    DebugLog("init() ===>\n");

    if (!super::init(properties))
    {
        DebugLog("super::init failed\n");
        return false;
    }

    m_pProvider = NULL;
    m_netif = NULL;
    m_isEnabled = false;
    unitNumber = 0;

    // load default MAC address (can be overridden in DSDT)
    static unsigned char rgDefault[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
    bcopy(rgDefault, m_rgMacAddr, kIOEthernetAddressSize);
    if (properties)
    {
        OSData* pData = OSDynamicCast(OSData, properties->getObject("MAC-address"));
        if (pData && pData->getLength() == kIOEthernetAddressSize)
            bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
    }

    DebugLog("init() <===>\n");
    return true;
}
开发者ID:queer1,项目名称:OS-X-Null-Ethernet,代码行数:28,代码来源:NullEthernet.cpp

示例9: getModelName

bool IODTPlatformExpert::getModelName( char * name, int maxLength )
{
    OSData *		prop;
    const char *	str;
    int			len;
    char		c;
    bool		ok = false;

    maxLength--;

    prop = (OSData *) getProvider()->getProperty( gIODTCompatibleKey );
    if( prop ) {
	str = (const char *) prop->getBytesNoCopy();

	if( 0 == strncmp( str, "AAPL,", strlen( "AAPL," ) ))
	    str += strlen( "AAPL," );

	len = 0;
	while( (c = *str++)) {
	    if( (c == '/') || (c == ' '))
		c = '-';

	    name[ len++ ] = c;
	    if( len >= maxLength)
		break;
	}

	name[ len ] = 0;
	ok = true;
    }
    return( ok );
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:32,代码来源:IOPlatformExpert.cpp

示例10: cast

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;
}
开发者ID:Piker-Alpha,项目名称:FileNVRAM,代码行数:32,代码来源:FileNVRAM.cpp

示例11: disableInterrupt

IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
						       int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
  if (!vector->interruptDisabledSoft) {
    vector->interruptDisabledSoft = 1;
#if !defined(__i386__) && !defined(__x86_64__)
    OSMemoryBarrier();
#endif

    vectorsEnabled--;
  }
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (!getPlatform()->atInterruptLevel()) {
    while (vector->interruptActive)
	{}
  }
  
  return kIOReturnSuccess;
}
开发者ID:aglab2,项目名称:darwin-xnu,代码行数:32,代码来源:IOInterruptController.cpp

示例12: init

bool FakeSMC::init(OSDictionary *properties)
{	
	if (!super::init(properties))
		return false;
    
    IOLog("FakeSMC v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR);

    if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) {
        if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node
            OSData *buffer = OSData::withCapacity(128);
            const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy());
            
            for (unsigned int index = 0; index < vendor->getLength(); index += 2) {
                buffer->appendByte(data[index], 1);
            }
            
            OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy()));
            
            setProperty(kFakeSMCFirmwareVendor, name);
            
            //OSSafeRelease(vendor);
            //OSSafeRelease(name);
            OSSafeRelease(buffer);
        }
        
        OSSafeRelease(efi);
    }
		
	return true;
}
开发者ID:ritzcarltn,项目名称:HWSensors,代码行数:30,代码来源:FakeSMC.cpp

示例13: OSDynamicCast

UInt32 PCIDeviceStub_XHCIMux::getUInt32Property(const char* name)
{
    UInt32 result = 0;
    OSData* data = OSDynamicCast(OSData, getProperty(name));
    if (data && data->getLength() == 4)
        result = *static_cast<const UInt32*>(data->getBytesNoCopy());
    return result;
}
开发者ID:OuYuBin,项目名称:OS-X-Fake-PCI-ID,代码行数:8,代码来源:FakePCIID_XHCIMux.cpp

示例14: getBoolProperty

bool PCIDeviceStub_XHCIMux::getBoolProperty(const char* name, bool defValue)
{
    bool result = defValue;
    OSData* data = OSDynamicCast(OSData, getProperty(name));
    if (data && data->getLength() == 1)
        result = *static_cast<const UInt8*>(data->getBytesNoCopy());
    return result;
}
开发者ID:OuYuBin,项目名称:OS-X-Fake-PCI-ID,代码行数:8,代码来源:FakePCIID_XHCIMux.cpp

示例15: controllerDidOpen

bool IOEthernetInterface::controllerDidOpen(IONetworkController * ctr)
{
    bool                 ret = false;
    OSData *             addrData;
    IOEthernetAddress *  addr;

    do {
        // Call the controllerDidOpen() in superclass first.

        if ( (ctr == 0) || (super::controllerDidOpen(ctr) == false) )
             break;

        // If the controller supports some form of multicast filtering,
        // then set the ifnet IFF_MULTICAST flag.

        if ( GET_SUPPORTED_FILTERS(gIONetworkFilterGroup) &
             (kIOPacketFilterMulticast | kIOPacketFilterMulticastAll) )
        {
            setFlags(IFF_MULTICAST);
        }

        // Advertise Wake on Magic Packet feature if supported.
        
        if ( _supportedWakeFilters & kIOEthernetWakeOnMagicPacket )
        {
            IOPMrootDomain * root = getPMRootDomain();
            if ( root ) root->publishFeature( kWOMPFeatureKey,
                             kIOPMSupportedOnAC | kIOPMSupportedOnUPS, 
                             (uint32_t *)&_publishedFeatureID);
        }

        // Get the controller's MAC/Ethernet address.

        addrData = OSDynamicCast(OSData, ctr->getProperty(kIOMACAddress));
        if ( (addrData == 0) || (addrData->getLength() != ETHER_ADDR_LEN) )
        {
            DLOG("%s: kIOMACAddress property access error (len %d)\n",
                 getName(), addrData ? addrData->getLength() : 0);
            break;
        }

        addr = (IOEthernetAddress *) addrData->getBytesNoCopy();

        DLOG("%s: Ethernet address %02x:%02x:%02x:%02x:%02x:%02x\n",
              ctr->getName(),
              addr->bytes[0],
              addr->bytes[1],
              addr->bytes[2],
              addr->bytes[3],
              addr->bytes[4],
              addr->bytes[5]);

        ret = true;
    }
    while (0);

    return ret;
}
开发者ID:wzw19890321,项目名称:IONetworkingFamily,代码行数:58,代码来源:IOEthernetInterface.cpp


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