本文整理汇总了C++中OSData::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ OSData::getLength方法的具体用法?C++ OSData::getLength怎么用?C++ OSData::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSData
的用法示例。
在下文中一共展示了OSData::getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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");
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: sizeof
IOMapper * IOMapper::copyMapperForDeviceWithIndex(IOService * device, unsigned int index)
{
OSData *data;
OSObject * obj;
IOMapper * mapper = NULL;
OSDictionary * matching;
obj = device->copyProperty("iommu-parent");
if (!obj) return (NULL);
if ((mapper = OSDynamicCast(IOMapper, obj))) goto found;
if ((data = OSDynamicCast(OSData, obj)))
{
if (index >= data->getLength() / sizeof(UInt32)) goto done;
data = OSData::withBytesNoCopy((UInt32 *)data->getBytesNoCopy() + index, sizeof(UInt32));
if (!data) goto done;
matching = IOService::propertyMatching(gIOMapperIDKey, data);
data->release();
}
else
matching = IOService::propertyMatching(gIOMapperIDKey, obj);
if (matching)
{
mapper = OSDynamicCast(IOMapper, IOService::waitForMatchingService(matching));
matching->release();
}
done:
if (obj) obj->release();
found:
if (mapper)
{
if (!mapper->fAllocName)
{
char name[MACH_ZONE_NAME_MAX_LEN];
char kmodname[KMOD_MAX_NAME];
vm_tag_t tag;
uint32_t kmodid;
tag = IOMemoryTag(kernel_map);
if (!(kmodid = vm_tag_get_kext(tag, &kmodname[0], KMOD_MAX_NAME)))
{
snprintf(kmodname, sizeof(kmodname), "%d", tag);
}
snprintf(name, sizeof(name), "%s.DMA.%s", kmodname, device->getName());
mapper->fAllocName = kern_allocation_name_allocate(name, 16);
}
}
return (mapper);
}
示例9: newReportDescriptor
//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newReportDescriptor
//----------------------------------------------------------------------------------------------------
IOReturn IOHIDUserDevice::newReportDescriptor(IOMemoryDescriptor ** descriptor ) const
{
OSData * data;
data = OSDynamicCast(OSData, _properties->getObject(kIOHIDReportDescriptorKey));
if ( !data )
return kIOReturnError;
*descriptor = IOBufferMemoryDescriptor::withBytes(data->getBytesNoCopy(), data->getLength(), kIODirectionNone);
return kIOReturnSuccess;
}
示例10: initMACfromProvider
bool NullEthernet::initMACfromProvider()
{
bool result = false;
OSData* pData = OSDynamicCast(OSData, m_pProvider->getProperty("RM,MAC-address"));
if (pData && pData->getLength() == kIOEthernetAddressSize)
{
bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
AlwaysLog("Using MAC address from provider: %02x:%02x:%02x:%02x:%02x:%02x\n", m_rgMacAddr[0], m_rgMacAddr[1], m_rgMacAddr[2], m_rgMacAddr[3], m_rgMacAddr[4], m_rgMacAddr[5]);
result = true;
}
return result;
}
示例11: return
static bool GetUInt32( IORegistryEntry * regEntry, const OSSymbol * name,
UInt32 * value )
{
OSData *data;
if( (data = OSDynamicCast( OSData, regEntry->getProperty( name )))
&& (4 == data->getLength())) {
*value = *((UInt32 *) data->getBytesNoCopy());
return( true );
} else
return( false );
}
示例12: readNVRAM
OSReturn NoSleepExtension::readNVRAM(UInt8 *value)
{
#ifdef DEBUG
IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, value);
#endif
OSReturn ret = kOSReturnError;
IORegistryEntry *entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
if ( entry )
{
OSObject *rawValue = entry->getProperty(IORegistrySleepSuppressionMode);
if(rawValue != NULL) {
#ifdef DEBUG
IOLog("%s: rawValueClassName: %s\n", getName(), rawValue->getMetaClass()->getClassName());
#endif
OSData *data = OSDynamicCast(OSData, rawValue);
if(data->getLength() == 1) {
*value = ((UInt8 *)data->getBytesNoCopy())[0];
ret = kOSReturnSuccess;
#ifdef DEBUG
IOLog("%s: reading nvram, value: 0x%02x\n", getName(), (*value));
#endif
}
#ifdef DEBUG
else {
IOLog("%s: read error: data->Len %s 1\n", getName(),
(data->getLength() == 1)?"==":"!=");
}
#endif
}
entry->release();
}
return ret;
}
示例13: initMACfromACPI
bool NullEthernet::initMACfromACPI()
{
bool result = false;
OSObject *ret = NULL;
IOACPIPlatformDevice* pACPI = OSDynamicCast(IOACPIPlatformDevice, m_pProvider);
if (NULL != pACPI && kIOReturnSuccess == pACPI->evaluateObject("MAC", &ret) && NULL != ret)
{
// get MAC address from DSDT if provided...
OSData* pData = OSDynamicCast(OSData, ret);
if (pData && pData->getLength() == kIOEthernetAddressSize)
{
bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
AlwaysLog("Using MAC address from DSDT: %02x:%02x:%02x:%02x:%02x:%02x\n", m_rgMacAddr[0], m_rgMacAddr[1], m_rgMacAddr[2], m_rgMacAddr[3], m_rgMacAddr[4], m_rgMacAddr[5]);
result = true;
}
ret->release();
}
return result;
}
示例14: IODTGetDefault
int IODTGetDefault(const char *key, void *infoAddr, unsigned int infoSize )
{
IORegistryEntry *defaults;
OSData *defaultObj;
unsigned int defaultSize;
defaults = IORegistryEntry::fromPath( "/defaults", gIODTPlane );
if ( defaults == 0 ) return -1;
defaultObj = OSDynamicCast( OSData, defaults->getProperty(key) );
if ( defaultObj == 0 ) return -1;
defaultSize = defaultObj->getLength();
if ( defaultSize > infoSize) return -1;
memcpy( infoAddr, defaultObj->getBytesNoCopy(), defaultSize );
return 0;
}
示例15: newReportDescriptor
IOReturn org_litio_OzoneStrikeBattle::newReportDescriptor(IOMemoryDescriptor** descriptor) const {
// TODO: Define new device descriptor struct for the keyboard.
// Assigning current descriptor.
IOLog("OzoneStrike::%s[%p] - Setting HID report descriptor.\n", getName(), this);
OSData *reportDescriptor = OSData::withBytes(Ozone::HIDReportDescriptor, sizeof(Ozone::HIDReportDescriptor));
OSData *reportDescriptorNew = OSDynamicCast(OSData, getProperty("ReportDescriptorOverride"));
if (reportDescriptor == NULL) {
IOLog("OzoneStrike::%s[%p] - reportDescriptor OSData not set.\n", getName(), this);
return kIOReturnNoResources;
}
printBytes(reportDescriptorNew);
printBytes(reportDescriptor);
IOLog("OzoneStrike::%s[%p] - reportDescriptor OSData set (size: %d, data: %s).\n", getName(), this, reportDescriptor->getLength(), reportDescriptor->getBytesNoCopy());
//OSData *reportDescriptor = OSDynamicCast(OSData, Ozone::HIDReportDescriptor);
IOBufferMemoryDescriptor *bufferDescriptor = IOBufferMemoryDescriptor::withBytes(reportDescriptor->getBytesNoCopy(),
reportDescriptor->getLength(),
kIODirectionOutIn);
//IOBufferMemoryDescriptor *bufferDescriptor = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task,
// 0,
// sizeof(Ozone::HIDReportDescriptor));
/*
if (bufferDescriptor == NULL) {
return kIOReturnNoResources;
}
bufferDescriptor->writeBytes(0, Ozone::HIDReportDescriptor,sizeof(Ozone::HIDReportDescriptor));
*/
if (bufferDescriptor) {
*descriptor = bufferDescriptor;
return kIOReturnSuccess;
} else {
bufferDescriptor->release();
*descriptor = NULL;
return kIOReturnNoMemory;
}
//return IOUSBHostHIDDevice::newReportDescriptor(descriptor);
}