本文整理汇总了C++中OSObject类的典型用法代码示例。如果您正苦于以下问题:C++ OSObject类的具体用法?C++ OSObject怎么用?C++ OSObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyProperty
bool
IOUSBNub::USBCompareProperty( OSDictionary * matching, const OSSymbol * key )
{
// We return success iff we match the key in the dictionary with the key in
// the property table.
//
OSObject *value;
bool matches = false;
OSObject *myProperty = NULL;
value = matching->getObject( key );
if ( value)
{
myProperty = copyProperty(key);
if (myProperty)
{
matches = value->isEqualTo( myProperty);
myProperty->release();
}
}
else
matches = false;
return matches;
}
示例2:
OSObject * FileNVRAM::getProperty(const OSSymbol *aKey) const
{
OSObject* value = IOService::getProperty(aKey);
if (value)
{
OSSerialize *s = OSSerialize::withCapacity(1000);
if (value->serialize(s))
{
LOG(INFO, "getProperty(%s) = %s called\n", aKey->getCStringNoCopy(), s->text());
}
else
{
LOG(INFO, "getProperty(%s) = %p called\n", aKey->getCStringNoCopy(), value);
}
s->release();
}
else
{
// Ignore BSD Name for now in logs, it pollutes
if (!aKey->isEqualTo("BSD Name"))
{
LOG(INFO, "getProperty(%s) = %p called\n", aKey->getCStringNoCopy(), (void*)NULL);
}
}
return value;
}
示例3: CompareProperty
//---------------------------------------------------------------------------
// Compare the properties in the supplied table to this object's properties.
bool CompareProperty( IOService * owner, OSDictionary * matching, const char * key, SInt32 * score, SInt32 increment)
{
// We return success if we match the key in the dictionary with the key in
// the property table, or if the prop isn't present
//
OSObject * value;
OSObject * property;
bool matches = true;
value = matching->getObject( key );
if( value)
{
property = owner->copyProperty( key );
if ( property )
{
matches = value->isEqualTo( property );
if (matches && score)
*score += increment;
property->release();
}
else
matches = false;
}
return matches;
}
示例4: DbgLog
IOACPIPlatformDevice * ACPIBacklightPanel::getChildWithBacklightMethods(IOACPIPlatformDevice * GPUdevice)
{
DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
OSIterator * iter = NULL;
OSObject * entry;
iter = GPUdevice->getChildIterator(gIOACPIPlane);
if (iter)
{
while ( true )
{
entry = iter->getNextObject();
if (NULL == entry)
break;
if (entry->metaCast("IOACPIPlatformDevice"))
{
IOACPIPlatformDevice * device = (IOACPIPlatformDevice *) entry;
if (hasBacklightMethods(device))
{
IOLog("ACPIBacklight: Found Backlight Device: %s\n", device->getName());
return device;
}
}
else {
DbgLog("%s: getChildWithBacklightMethods() Cast Error\n", this->getName());
}
} //end while
iter->release();
DbgLog("%s: getChildWithBacklightMethods() iterator end\n", this->getName());
}
return NULL;
}
示例5: pmem_iokit_enumerate_pci
kern_return_t pmem_iokit_enumerate_pci(pmem_pci_callback_t callback,
void *ctx) {
kern_return_t error = KERN_FAILURE;
OSObject *obj = nullptr;
OSDictionary *search = nullptr;
OSIterator *iter = nullptr;
IOPCIDevice *dev = nullptr;
IODeviceMemory *mem = nullptr;
IOItemCount mem_count = 0;
int cmp;
search = IOService::serviceMatching("IOPCIDevice");
iter = IOService::getMatchingServices(search);
if (!iter) {
pmem_error("Couldn't find any PCI devices.");
goto bail;
}
while ((obj = iter->getNextObject())) {
cmp = strncmp("IOPCIDevice",
obj->getMetaClass()->getClassName(),
strlen("IOPCIDevice"));
if (cmp != 0) {
// I haven't seen the above return anything other than
// PCI devices, but Apple's documentation is sparse (which
// is a nice word for what it is) and doesn't actually
// say anything about what's guaranteed to be returned.
// I'd just as well rather not chance it.
pmem_warn("Expected IOPCIDevice but got %s - skipping.",
obj->getMetaClass()->getClassName());
continue;
}
dev = (IOPCIDevice *)obj;
mem_count = dev->getDeviceMemoryCount();
pmem_debug("Found PCI device %s", dev->getName());
for (unsigned idx = 0; idx < mem_count; ++idx) {
pmem_debug("Memory segment %d found.", idx);
mem = dev->getDeviceMemoryWithIndex(idx);
pmem_signal_t signal = callback(dev, mem, idx, ctx);
if (signal == pmem_Stop) {
error = KERN_FAILURE;
goto bail;
}
}
}
error = KERN_SUCCESS;
bail:
if (iter) {
iter->release();
}
if (search) {
search->release();
}
return error;
}
示例6: iokit_post_constructor_init
void iokit_post_constructor_init(void)
{
IORegistryEntry * root;
OSObject * obj;
root = IORegistryEntry::initialize();
assert( root );
IOService::initialize();
IOCatalogue::initialize();
IOStatistics::initialize();
OSKext::initialize();
IOUserClient::initialize();
IOMemoryDescriptor::initialize();
IORootParent::initialize();
// Initializes IOPMinformeeList class-wide shared lock
IOPMinformeeList::getSharedRecursiveLock();
obj = OSString::withCString( version );
assert( obj );
if( obj ) {
root->setProperty( kIOKitBuildVersionKey, obj );
obj->release();
}
obj = IOKitDiagnostics::diagnostics();
if( obj ) {
root->setProperty( kIOKitDiagnosticsKey, obj );
obj->release();
}
}
示例7: IOLog
/******************************************************************************
* ACPIDebug::PrintTraces
******************************************************************************/
void ACPIDebug::PrintTraces()
{
for (;;)
{
// see if there are any trace items in the RING
UInt32 count = 0;
if (kIOReturnSuccess != m_pDevice->evaluateInteger("COUN", &count))
{
IOLog("ACPIDebug: evaluateObject of COUN method failed\n");
break;
}
if (!count)
break;
// gather the next item from RING and print it
OSObject* debug;
if (kIOReturnSuccess == m_pDevice->evaluateObject("FTCH", &debug) &&
NULL != debug)
{
static char buf[2048];
// got a valid object, format and print it...
FormatDebugString(debug, buf, sizeof(buf)/sizeof(buf[0]));
IOLog("ACPIDebug: %s\n", buf);
debug->release();
}
}
}
示例8: initWithTask
bool IOHIDEventSystemUserClient::
initWithTask(task_t owningTask, void * /* security_id */, UInt32 /* type */)
{
bool result = false;
OSObject* entitlement = copyClientEntitlement(owningTask, kIOHIDSystemUserAccessServiceEntitlement);
if (entitlement) {
result = (entitlement == kOSBooleanTrue);
entitlement->release();
}
if (!result) {
proc_t process;
process = (proc_t)get_bsdtask_info(owningTask);
char name[255];
bzero(name, sizeof(name));
proc_name(proc_pid(process), name, sizeof(name));
HIDLogError("%s is not entitled", name);
goto exit;
}
result = super::init();
require_action(result, exit, HIDLogError("failed"));
exit:
return result;
}
示例9: matchPropertyTable
bool IOFireWireMagicMatchingNub::matchPropertyTable( OSDictionary * table )
{
OSObject *clientClass;
clientClass = table->getObject("IOClass");
if(!clientClass)
return false;
return clientClass->isEqualTo( getProperty( "IODesiredChild" ) );
}
示例10: newUserClient
IOReturn
IOI2CDevice::newUserClient(
task_t owningTask,
void *securityID,
UInt32 type,
OSDictionary *properties,
IOUserClient **handler)
{
IOUserClient *client;
OSObject *temp;
DLOG("%s::newUserClient\n", getName());
if (type != kIOI2CUserClientType)
return super::newUserClient(owningTask,securityID,type,properties,handler);
if (IOUserClient::clientHasPrivilege(securityID, "root") != kIOReturnSuccess)
{
ERRLOG("%s::newUserClient: Can't create user client, not privileged\n", getName());
return kIOReturnNotPrivileged;
}
temp = OSMetaClass::allocClassWithName("IOI2CUserClient");
if (!temp)
return kIOReturnNoMemory;
if (OSDynamicCast(IOUserClient, temp))
client = (IOUserClient *) temp;
else
{
temp->release();
return kIOReturnUnsupported;
}
if ( !client->initWithTask(owningTask, securityID, type, properties) )
{
client->release();
return kIOReturnBadArgument;
}
if ( !client->attach(this) )
{
client->release();
return kIOReturnUnsupported;
}
if ( !client->start(this) )
{
client->detach(this);
client->release();
return kIOReturnUnsupported;
}
*handler = client;
return kIOReturnSuccess;
}
示例11: 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);
}
示例12: CompareDeviceUsage
bool CompareDeviceUsage( IOService * owner, OSDictionary * matching, SInt32 * score, SInt32 increment)
{
// We return success if we match the key in the dictionary with the key in
// the property table, or if the prop isn't present
//
OSObject * usage;
OSObject * usagePage;
OSArray * functions;
OSDictionary * pair;
bool matches = true;
int count;
usage = matching->getObject( kIOHIDDeviceUsageKey );
usagePage = matching->getObject( kIOHIDDeviceUsagePageKey );
functions = OSDynamicCast(OSArray, owner->copyProperty( kIOHIDDeviceUsagePairsKey ));
if ( functions )
{
if ( usagePage || usage )
{
count = functions->getCount();
for (int i=0; i<count; i++)
{
if ( !(pair = (OSDictionary *)functions->getObject(i)) )
continue;
if ( !usagePage ||
!(matches = usagePage->isEqualTo(pair->getObject(kIOHIDDeviceUsagePageKey))) )
continue;
if ( score && !usage )
{
*score += increment / 2;
break;
}
if ( !usage ||
!(matches = usage->isEqualTo(pair->getObject(kIOHIDDeviceUsageKey))) )
continue;
if ( score )
*score += increment;
break;
}
}
functions->release();
} else {
matches = false;
}
return matches;
}
示例13: testObject
void SessionObjectTests::testDestroyObjectFails()
{
// Create test object instance
SessionObject testObject(NULL, 1, 1);
CPPUNIT_ASSERT(testObject.isValid());
OSObject* testIF = (OSObject*) &testObject;
CPPUNIT_ASSERT(!testIF->destroyObject());
}
示例14: getProperty
OSObject * FileNVRAM::copyProperty(const char *aKey) const
{
OSObject* prop = getProperty(aKey);
if (prop)
{
prop->retain();
}
return prop;
}
示例15: setInterface
void USBInterfaceShim::setInterface(IOService* interface)
{
OSObject* prev = m_pInterface;
m_pInterface = OSDynamicCast(IOUSBInterface, interface);
if (m_pInterface)
m_pInterface->retain();
if (prev)
prev->release();
}