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


C++ IOService::getChildEntry方法代码示例

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


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

示例1: start

bool AppleGPIO::start(IOService *provider)
{
	bool					doSleepWake;
	UInt32					i, flags, intCapable;
	IOPlatformFunction		*func;
	const OSSymbol			*functionSymbol = OSSymbol::withCString("InstantiatePlatformFunctions");
	IOReturn				retval;
	IOService				*parentDev;
	OSData					*data;

	if (!super::start(provider)) return(false);
	
	// set my id
	data = OSDynamicCast(OSData, provider->getProperty("reg"));
	if (!data) return(false);
	
	fGPIOID = *(UInt32 *)data->getBytesNoCopy();
	
	// find the gpio parent
	parentDev = OSDynamicCast(IOService, provider->getParentEntry(gIODTPlane));
	if (!parentDev) return(false);

	fParent = OSDynamicCast(IOService, parentDev->getChildEntry(gIOServicePlane));
	if (!fParent) return(false);

	// Create the interrupt register/enable symbols
	fSymIntRegister 	= OSSymbol::withCString(kIOPFInterruptRegister);
	fSymIntUnRegister 	= OSSymbol::withCString(kIOPFInterruptUnRegister);
	fSymIntEnable 		= OSSymbol::withCString(kIOPFInterruptEnable);
	fSymIntDisable		= OSSymbol::withCString(kIOPFInterruptDisable);

	// Allocate our constant callPlatformFunction symbols so we can be called at interrupt time.

	fSymGPIOParentWriteGPIO = OSSymbol::withCString(kSymGPIOParentWriteGPIO);
	fSymGPIOParentReadGPIO = OSSymbol::withCString(kSymGPIOParentReadGPIO);

	// Scan for platform-do-xxx functions
	fPlatformFuncArray = NULL;

	DLOG("AppleGPIO::start(%[email protected]%lx) - calling InstantiatePlatformFunctions\n",
			provider->getName(), fGPIOID);

	retval = provider->getPlatform()->callPlatformFunction(functionSymbol, false,
			(void *)provider, (void *)&fPlatformFuncArray, (void *)0, (void *)0);

	DLOG("AppleGPIO::start(%[email protected]%lx) - InstantiatePlatformFunctions returned %ld, pfArray %sNULL\n",
			provider->getName(), fGPIOID, retval, fPlatformFuncArray ? "NOT " : "");

	if (retval == kIOReturnSuccess && (fPlatformFuncArray != NULL))
	{
		// Find out if the GPIO parent supports interrupt events
		if (fParent->callPlatformFunction(kSymGPIOParentIntCapable, false, &intCapable, 0, 0, 0)
				!= kIOReturnSuccess)
		{
			intCapable = 0;
		}

		DLOG("AppleGPIO::start(%[email protected]%lx) - iterating platformFunc array, count = %ld\n",
			provider->getName(), fGPIOID, fPlatformFuncArray->getCount());

		doSleepWake = false;

		UInt32 count = fPlatformFuncArray->getCount();
		for (i = 0; i < count; i++)
		{
			if (func = OSDynamicCast(IOPlatformFunction, fPlatformFuncArray->getObject(i)))
			{
				flags = func->getCommandFlags();

				DLOG ("AppleGPIO::start(%[email protected]%lx) - functionCheck - got function, flags 0x%lx, pHandle 0x%lx\n", 
					provider->getName(), fGPIOID, flags, func->getCommandPHandle());

				// If this function is flagged to be performed at initialization, do it
				if (flags & kIOPFFlagOnInit)
				{
					performFunction(func, (void *)1, (void *)0, (void *)0, (void *)0);
				}

				if ((flags & kIOPFFlagOnDemand) || ((flags & kIOPFFlagIntGen) && intCapable))
				{
					// Set the flag to indicate whether any of the platform functions are using
					// interrupts -- this is used to allocate some locks that are needed for this
					// functionality
					if ((flags & kIOPFFlagIntGen) && (fIntGen == false))
					{
						fIntGen = true;

						// Allocate event-related state variable locks
						fClientsLock = IOSimpleLockAlloc();
						fAmRegisteredLock = IOLockAlloc();
						fAmEnabledLock = IOSimpleLockAlloc();
					}
					
					// This is a bit of overkill.  Strictly speaking the lock needs to protect
					// individual platformFunc array entries so that only one thread is executing
					// that function at a time.  The way we're using it here is only one of *any*
					// of the platform functions can be executing at a time.
					if (!fPFLock) fPFLock = IOLockAlloc();	// Use for both On-Demand and IntGen functions

					// On-Demand and IntGen functions need to have a resource published
//.........这里部分代码省略.........
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:101,代码来源:AppleGPIO.cpp


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