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


C++ OSDynamicCast函数代码示例

本文整理汇总了C++中OSDynamicCast函数的典型用法代码示例。如果您正苦于以下问题:C++ OSDynamicCast函数的具体用法?C++ OSDynamicCast怎么用?C++ OSDynamicCast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: OSDynamicCast

IOReturn AppleUSBCDC::setPropertiesAction(	OSObject	*owner, 
														void		*arg1, 
														void		*arg2, 
														void		*arg3, 
														void		*arg4 )
{
	IOReturn result = kIOReturnBadArgument;
	
	if ( owner != NULL )
	{
		AppleUSBCDC *me = OSDynamicCast( AppleUSBCDC, owner );
		
		if ( me != NULL )
		{
			result = me->setPropertiesWL( (OSObject *)arg1 );
		}
	}
	
	return result;
}
开发者ID:Kiichi77,项目名称:MacOSX,代码行数:20,代码来源:AppleUSBCDC.cpp

示例2: DEBUG_LOG

/******************************************************************************
 * ACPIDebug::init
 ******************************************************************************/
bool ACPIDebug::init(OSDictionary *dict)
{
    DEBUG_LOG("ACPIDebug::init: Initializing\n");
    
    bool result = super::init(dict);
    m_pDevice = NULL;
    m_pWorkLoop = NULL;
    m_pTimer = NULL;
    m_pCmdGate = NULL;
    m_pLock = NULL;
    
    m_nPollingInterval = 100;
	if (OSNumber* num = OSDynamicCast(OSNumber, dict->getObject("PollingInterval")))
    {
		m_nPollingInterval = (int)num->unsigned32BitValue();
        //setProperty("PollingInterval", _wakedelay, 32);
    }
    
    return result;
}
开发者ID:52M,项目名称:OS-X-ACPI-Debug,代码行数:23,代码来源:ACPIDebug.cpp

示例3: bcopy

IOReturn IT87x::callPlatformFunction(const OSSymbol *functionName, bool waitForFunction, void *param1, void *param2, void *param3, void *param4 )
{
	if (functionName->isEqualTo(kFakeSMCGetValueCallback)) {
		const char* name = (const char*)param1;
		void * data = param2;
		//UInt32 size = (UInt64)param3;
		
        
		if (name && data)
			if (SuperIOSensor * sensor = getSensor(name)) {
				UInt16 value = sensor->getValue();
				
				bcopy(&value, data, 2);
				
				return kIOReturnSuccess;
			}
		
		return kIOReturnBadArgument;
	}
    
	if (functionName->isEqualTo(kFakeSMCSetValueCallback)) {
		const char* name = (const char*)param1;
		void * data = param2;
		//UInt32 size = (UInt64)param3;
		
        
		if (name && data)
			if (IT87xSensor *sensor = OSDynamicCast(IT87xSensor, getSensor(name))) {
				UInt16 value;
                bcopy(data, &value, 2);
				sensor->setValue(value);
				
				
				return kIOReturnSuccess;
			}
		
		return kIOReturnBadArgument;
	}    
    
	return super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4);
}
开发者ID:AppleLife,项目名称:FakeSMC,代码行数:41,代码来源:ITEIT87x.cpp

示例4: callPlatformFunction

IOReturn X3100monitor::callPlatformFunction(const OSSymbol *functionName, bool waitForFunction, void *param1, void *param2, void *param3, void *param4 )
{
	UInt16 t;

	if (functionName->isEqualTo(kFakeSMCGetValueCallback)) {
		const char* name = (const char*)param1;
		void* data = param2;
		
		if (name && data) {
			if (OSNumber *number = OSDynamicCast(OSNumber, sensors->getObject(name))) {				
				UInt32 index = number->unsigned16BitValue();
				if (index != numCard) {
					return kIOReturnBadArgument;
				}
			}
			short value;
			if (mmio_base) {
				OUTVID(TIC1, 3);
				//		if ((INVID16(TSC1) & (1<<15)) && !(INVID16(TSC1) & (1<<8)))//enabled and ready
				for (int i=0; i<1000; i++) {  //attempts to ready
					
					if (INVID16(TSS1) & (1<<10))   //valid?
						break;
					IOSleep(10);
				}				
				value = INVID8(TR1);
			}				
			
			t = 140 - value;
			bcopy(&t, data, 2);
			
			return kIOReturnSuccess;
		}
		
		//DebugLog("bad argument key name or data");
		
		return kIOReturnBadArgument;
	}
	
	return super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4);
}
开发者ID:Beshuta,项目名称:HWSensors,代码行数:41,代码来源:X3100.cpp

示例5: DebugLog

bool NullEthernet::start(IOService *provider)
{
    DebugLog("start() ===>\n");

    if (!super::start(provider))
    {
        AlwaysLog("NullEthernet: IOEthernetController::start failed.\n");
        return false;
    }

    // retain provider...
    m_pProvider = OSDynamicCast(IOService, provider);
    if (!m_pProvider)
    {
        AlwaysLog("NullEthernet: No provider.\n");
        return false;
    }
    m_pProvider->retain();

    // initialize MAC address: priority is from DSDT, then provider, last is default
    if (!initMACfromACPI() && !initMACfromProvider())
    {
        AlwaysLog("Using default MAC address: %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]);
    }
    
    if (!attachInterface(reinterpret_cast<IONetworkInterface**>(&m_netif)))
    {
        AlwaysLog("NullEthernet: attachInterface() failed.\n");
        goto error1;
    }

    AlwaysLog("NullEthernet: NullEthernet v1.0.0 starting.\n");

done:
    DebugLog("start() <===\n");
    return true;

error1:
    OSSafeReleaseNULL(m_pProvider);
    return false;
}
开发者ID:queer1,项目名称:OS-X-Null-Ethernet,代码行数:41,代码来源:NullEthernet.cpp

示例6: mergeProperties

bool CLASS::init( IOService *       provider,
                  OSDictionary *    properties,
                  IORegistryEntry * dtEntry )
{
    if ( dtEntry )
    {
        if ( super::init( dtEntry, gIODTPlane ) == false ||
             mergeProperties( properties ) == false )
             return false;
    }
    else
    {
        if ( super::init( properties ) == false )
             return false;
    }

    fProvider = OSDynamicCast(AppleOnboardPCATARoot, provider);
    if (fProvider == 0)
        return false;

    // Call platform to register the interrupt assigned to each ATA
    // channel. For PCI interrupts (native mode), each channel will
    // share the same interrupt vector assigned to the PCI device.
    // Legacy mode channels will attempt to register IRQ 14 and 15.

    UInt32 vector = getInterruptVector();
    if (provider->callPlatformFunction( "SetDeviceInterrupts",
                   /* waitForFunction */ false,
                   /* nub             */ this,
                   /* vectors         */ (void *) &vector,
                   /* vectorCount     */ (void *) 1,
                   /* exclusive       */ (void *) false )
                                         != kIOReturnSuccess)
    {
        return false;
    }

    setLocation( getChannelNumber() ? "1" : "0" );

    return true;
}
开发者ID:OTiZ,项目名称:osx,代码行数:41,代码来源:AppleOnboardPCATAChannel.cpp

示例7: OSDynamicCast

  bool
  ListHookedKeyboard::Item::restoreEventAction(void)
  {
    if (! device_) return false;

    IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, device_);
    if (! kbd) return false;

    bool result = false;

    // ----------------------------------------
    {
      KeyboardEventCallback callback = reinterpret_cast<KeyboardEventCallback>(kbd->_keyboardEventAction);
      if (callback == EventInputQueue::push_KeyboardEventCallback) {
        IOLOG_DEBUG("HookedKeyboard::restoreEventAction (KeyboardEventCallback) device_:%p (%p -> %p)\n",
                    device_, callback, orig_keyboardEventAction_);

        kbd->_keyboardEventAction = reinterpret_cast<KeyboardEventAction>(orig_keyboardEventAction_);

        result = true;
      }
    }
    {
      UpdateEventFlagsCallback callback = reinterpret_cast<UpdateEventFlagsCallback>(kbd->_updateEventFlagsAction);
      if (callback == EventInputQueue::push_UpdateEventFlagsCallback) {
        IOLOG_DEBUG("HookedKeyboard::restoreEventAction (UpdateEventFlagsCallback) device_:%p (%p -> %p)\n",
                    device_, callback, orig_updateEventFlagsAction_);

        kbd->_updateEventFlagsAction = reinterpret_cast<UpdateEventFlagsAction>(orig_updateEventFlagsAction_);

        result = true;
      }
    }

    orig_keyboardEventAction_ = NULL;
    orig_keyboardEventTarget_ = NULL;
    orig_updateEventFlagsAction_ = NULL;
    orig_updateEventFlagsTarget_ = NULL;

    return result;
  }
开发者ID:kurobeniq,项目名称:KeyRemap4MacBook,代码行数:41,代码来源:ListHookedKeyboard.cpp

示例8: handleStart

bool IOHIDDeviceShim::handleStart( IOService * provider )
{
    IOService *device = 0;
    
    if (!super::handleStart(provider))
        return false;

    if ((_hiDevice = OSDynamicCast(IOHIDevice, provider)))
    {
        if (_hiDevice->getProperty(kIOHIDVirtualHIDevice) == kOSBooleanTrue)
            return false;
            
        device = _hiDevice;
        do {
			if ((_device = (IOService *)device->metaCast("IOHIDDevice")))
			{
				break;
			}
			
            if ((_device = (IOService *)device->metaCast("IOUSBDevice")) || (_device = (IOService *)device->metaCast("IOUSBInterface")))
            {
                _transport = kIOHIDTransportUSB;
                break;
            }
                
			if (_device = (IOService *)device->metaCast("IOADBDevice"))
            {
                _transport = kIOHIDTransportADB;
                break;
            }
            
			if (_device = (IOService *)device->metaCast("ApplePS2Controller"))
            {
                _transport = kIOHIDTransportPS2;
                break;
            }
        } while (device = device->getProvider());
    }
                
    return true;
}
开发者ID:MomandDad,项目名称:netbook-installer,代码行数:41,代码来源:IOHIDDeviceShim.cpp

示例9: OSDynamicCast

  bool
  ListHookedPointing::Item::restoreEventAction(void)
  {
    if (! device_) return false;

    IOHIPointing* pointing = OSDynamicCast(IOHIPointing, device_);
    if (! pointing) return false;

    bool result = false;

    // ----------------------------------------
    {
      RelativePointerEventCallback callback = reinterpret_cast<RelativePointerEventCallback>(pointing->_relativePointerEventAction);

      if (callback == EventInputQueue::push_RelativePointerEventCallback) {
        IOLOG_DEBUG("HookedPointing::restoreEventAction (RelativePointerEventCallback) device_:%p\n", device_);

        pointing->_relativePointerEventAction = reinterpret_cast<RelativePointerEventAction>(orig_relativePointerEventAction_);

        result = true;
      }
    }
    {
      ScrollWheelEventCallback callback = reinterpret_cast<ScrollWheelEventCallback>(pointing->_scrollWheelEventAction);

      if (callback == EventInputQueue::push_ScrollWheelEventCallback) {
        IOLOG_DEBUG("HookedPointing::restoreEventAction (ScrollWheelEventCallback) device_:%p\n", device_);

        pointing->_scrollWheelEventAction = reinterpret_cast<ScrollWheelEventAction>(orig_scrollWheelEventAction_);

        result = true;
      }
    }

    orig_relativePointerEventAction_ = NULL;
    orig_scrollWheelEventAction_ = NULL;
    orig_relativePointerEventTarget_ = NULL;
    orig_scrollWheelEventTarget_ = NULL;

    return result;
  }
开发者ID:CharlseLee,项目名称:KeyRemap4MacBook,代码行数:41,代码来源:ListHookedPointing.cpp

示例10: OSDynamicCast

  bool
  ListHookedConsumer::Item::replaceEventAction(void)
  {
    if (! device_) return false;

    IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, device_);
    if (! kbd) return false;

    KeyboardSpecialEventCallback callback = reinterpret_cast<KeyboardSpecialEventCallback>(kbd->_keyboardSpecialEventAction);
    if (callback == EventInputQueue::push_KeyboardSpecialEventCallback) return false;

    // ------------------------------------------------------------
    IOLOG_DEBUG("HookedConsumer::replaceEventAction device_:%p\n", device_);

    orig_keyboardSpecialEventAction_ = callback;
    orig_keyboardSpecialEventTarget_ = kbd->_keyboardSpecialEventTarget;

    kbd->_keyboardSpecialEventAction = reinterpret_cast<KeyboardSpecialEventAction>(EventInputQueue::push_KeyboardSpecialEventCallback);

    return true;
  }
开发者ID:CharlseLee,项目名称:KeyRemap4MacBook,代码行数:21,代码来源:ListHookedConsumer.cpp

示例11: Flags

  void
  EventInputQueue::push_UpdateEventFlagsCallback(OSObject* target,
                                                 unsigned flags,
                                                 OSObject* sender,
                                                 void* refcon)
  {
    GlobalLock::ScopedLock lk;
    if (! lk) return;

    Params_UpdateEventFlagsCallback::log(true, Flags(flags));

    // ------------------------------------------------------------
    // update device priority by calling ListHookedKeyboard::instance().get(kbd).
    IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender);
    if (! device) return;

    ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get(device));
    if (! item) return;

    // Don't push_back for UpdateEventFlagsCallback.
  }
开发者ID:selflearner,项目名称:KeyRemap4MacBook,代码行数:21,代码来源:EventInputQueue.cpp

示例12:

void
IOI2CDevice::performFunctionsWithFlags(
	UInt32				flags)
{
	UInt32				count, i;
	IOPlatformFunction	*func;

	if (0 == fPlatformFuncArray)
		return;

	// Execute any functions flagged as "on sleep"
	count = fPlatformFuncArray->getCount();
	for (i = 0; i < count; i++)
	{
		if (func = OSDynamicCast(IOPlatformFunction, fPlatformFuncArray->getObject(i)))
		{
			if (func->getCommandFlags() & flags)
				performFunction(func);
		}
	}
}
开发者ID:aosm,项目名称:IOI2CFamily,代码行数:21,代码来源:IOI2CDevice.cpp

示例13: OSDynamicCast

void ListHookedKeyboard::Item::apply(const Params_UpdateEventFlagsCallback& params) {
  // ------------------------------------------------------------
  UpdateEventFlagsCallback callback = orig_updateEventFlagsAction_;
  if (!callback) return;

  OSObject* target = orig_updateEventFlagsTarget_;
  if (!target) return;

  OSObject* sender = OSDynamicCast(OSObject, device_);
  if (!sender) return;

  OSObject* refcon = nullptr;

  Params_UpdateEventFlagsCallback::log(false, params.flags);
  {
    // We need to unlock the global lock while we are calling the callback function.
    // For more information, See ListHookedKeyboard::Item::apply(const Params_KeyboardEventCallBack& params)
    GlobalLock::ScopedUnlock lk;
    callback(target, params.flags.get(), sender, refcon);
  }
}
开发者ID:hjmf1954,项目名称:Karabiner,代码行数:21,代码来源:ListHookedKeyboard.cpp

示例14: OSDynamicCast

  bool
  HookedKeyboard::restoreEventAction(void)
  {
    if (! device_) return false;

    IOHIKeyboard* kbd = OSDynamicCast(IOHIKeyboard, device_);
    if (! kbd) return false;

    KeyboardEventCallback callback = reinterpret_cast<KeyboardEventCallback>(kbd->_keyboardEventAction);
    if (callback != hook_KeyboardEventCallback) return false;

    // ----------------------------------------
    IOLog("KeyRemap4MacBook HookedKeyboard::restoreEventAction (device_ = 0x%p)\n", device_);

    kbd->_keyboardEventAction = reinterpret_cast<KeyboardEventAction>(orig_keyboardEventAction_);

    orig_keyboardEventAction_ = NULL;
    orig_keyboardEventTarget_ = NULL;

    return true;
  }
开发者ID:dodamn,项目名称:keyremap4macbook,代码行数:21,代码来源:ListHookedKeyboard.cpp

示例15: OSDynamicCast

bool com_ximeta_driver_NDASPhysicalUnitDevice::sendNDASFamilyIOMessage(UInt32 type, void * argument, vm_size_t argSize) 
{
	if (!fDevice) {
		return false;
	}
	
	com_ximeta_driver_NDASBusEnumerator	*bus;
	
	bus = OSDynamicCast(com_ximeta_driver_NDASBusEnumerator, 
						fDevice->getParentEntry(gIOServicePlane));
	
	if (NULL == bus) {
		DbgIOLog(DEBUG_MASK_NDAS_INFO, ("sendNDASFamilyIIOMessage: Can't Find bus.\n"));
		
		return false;
	} else {
		bus->messageClients(type, argument, argSize);
		
		return true;
	}
}	
开发者ID:dansdrivers,项目名称:ndas4mac,代码行数:21,代码来源:NDASPhysicalUnitDevice.cpp


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