本文整理汇总了C++中OSData类的典型用法代码示例。如果您正苦于以下问题:C++ OSData类的具体用法?C++ OSData怎么用?C++ OSData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OSDynamicCast
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;
}
示例2: IOLog
//====================================================================================================
// IOHIDEventService::handleServicePublicationGated
//====================================================================================================
void IOHIDEventSystem::handleServicePublicationGated(IOService * service)
{
IOLog("IOHIDEventSystem::handleServicePublicationGated\n");
EventServiceInfo tempEventServiceInfo;
OSData * tempData;
IOHIDEventService * eventService;
if ( !(eventService = OSDynamicCast(IOHIDEventService, service)) )
return;
attach( eventService );
tempEventServiceInfo.service = eventService;
tempData = OSData::withBytes(&tempEventServiceInfo, sizeof(EventServiceInfo));
if ( tempData )
{
_eventServiceInfoArray->setObject(tempData);
tempData->release();
}
if ( _eventsOpen )
registerEventSource( eventService );
}
示例3: 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;
}
示例4: OSDynamicCast
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;
}
示例5: 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;
}
示例6: getProvider
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 );
}
示例7: PEWriteNVRAMProperty
boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value,
const unsigned int len)
{
const OSSymbol *sym;
OSData *data;
bool ret = false;
if (!symbol || !value || !len)
goto err;
if (init_gIOOptionsEntry() < 0)
goto err;
sym = OSSymbol::withCStringNoCopy(symbol);
if (!sym)
goto err;
data = OSData::withBytes((void *) value, len);
if (!data)
goto sym_done;
ret = gIOOptionsEntry->setProperty(sym, data);
data->release();
sym_done:
sym->release();
if (ret == true) {
gIOOptionsEntry->sync();
return TRUE;
}
err:
return FALSE;
}
示例8: enableInterrupt
IOReturn IOInterruptController::enableInterrupt(IOService *nub, int source)
{
IOInterruptSource *interruptSources;
IOInterruptVectorNumber vectorNumber;
IOInterruptVector *vector;
OSData *vectorData;
interruptSources = nub->_interruptSources;
vectorData = interruptSources[source].vectorData;
vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
vector = &vectors[vectorNumber];
if (vector->interruptDisabledSoft) {
vector->interruptDisabledSoft = 0;
#if !defined(__i386__) && !defined(__x86_64__)
OSMemoryBarrier();
#endif
if (!getPlatform()->atInterruptLevel()) {
while (vector->interruptActive)
{}
}
if (vector->interruptDisabledHard) {
vector->interruptDisabledHard = 0;
enableVector(vectorNumber, vector);
}
}
return kIOReturnSuccess;
}
示例9: DLOG
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;
}
示例10: IOLog
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;
}
示例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;
}
示例12: while
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;
}
示例13: IOLog
OSReturn NoSleepExtension::writeNVRAM(UInt8 value)
{
#ifdef DEBUG
IOLog("%s: writing nvram, value: 0x%02x\n", getName(), value);
#endif
bool ret;
IORegistryEntry *entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
if ( entry )
{
OSData *dataToSave = OSData::withBytes(&value, 1);
ret = entry->setProperty(IORegistrySleepSuppressionMode, dataToSave);
dataToSave->release();
entry->release();
#ifdef DEBUG
IOLog("%s: writing nvram, result: %s\n", getName(), ret?"true":"false");
#endif
} else {
return kOSReturnError;
}
return ret?kOSReturnSuccess:kOSReturnError;
}
示例14: DebugLog
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;
}
示例15: 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;
}