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


C++ IOBufferMemoryDescriptor::getPhysicalAddress方法代码示例

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


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

示例1: IOMallocContiguous

void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
			   IOPhysicalAddress * physicalAddress)
{
    mach_vm_address_t	address = 0;

    if (size == 0)
	return 0;
    if (alignment == 0) 
	alignment = 1;

    /* Do we want a physical address? */
    if (!physicalAddress)
    {
	address = IOKernelAllocateWithPhysicalRestrict(size, 0 /*maxPhys*/, alignment, true);
    }
    else do
    {
	IOBufferMemoryDescriptor * bmd;
	mach_vm_address_t          physicalMask;
	vm_offset_t		   alignMask;

	alignMask = alignment - 1;
	physicalMask = (0xFFFFFFFF ^ alignMask);

	bmd = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(
		kernel_task, kIOMemoryPhysicallyContiguous, size, physicalMask);
	if (!bmd)
	    break;
	
	_IOMallocContiguousEntry *
	entry = IONew(_IOMallocContiguousEntry, 1);
	if (!entry)
	{
	    bmd->release();
	    break;
	}
	entry->virtualAddr = (mach_vm_address_t) bmd->getBytesNoCopy();
	entry->md          = bmd;
	lck_mtx_lock(gIOMallocContiguousEntriesLock);
	queue_enter( &gIOMallocContiguousEntries, entry, 
		    _IOMallocContiguousEntry *, link );
	lck_mtx_unlock(gIOMallocContiguousEntriesLock);

	address          = (mach_vm_address_t) entry->virtualAddr;
	*physicalAddress = bmd->getPhysicalAddress();
    }
    while (false);

	if (address) {
	    IOStatisticsAlloc(kIOStatisticsMallocContiguous, size);
    }

    return (void *) address;
}
开发者ID:Prajna,项目名称:xnu,代码行数:54,代码来源:IOLib.cpp

示例2: limit

IOBufferMemoryDescriptor *kXAudioEngine::my_alloc_contiguous(mach_vm_size_t size, void **addr, dword *phys)
{
    if(size<PAGE_SIZE)
		size=PAGE_SIZE;
    
#ifdef DEBUGGING
    size += 2 * PAGE_SIZE;
#endif	
		//void *addr=IOMallocContiguous(size+PAGE_SIZE+PAGE_SIZE,alignment,phys);	
    
    mach_vm_address_t mask = 0x000000007FFFFFFFULL & ~(PAGE_SIZE - 1);
    
    IOBufferMemoryDescriptor *desc =
    IOBufferMemoryDescriptor::inTaskWithPhysicalMask(
													 kernel_task,
													 kIODirectionInOut | kIOMemoryPhysicallyContiguous,
													 size,
													 mask);
    
    if(desc)
    {
		desc->prepare();
		
		IOPhysicalAddress pa = desc->getPhysicalAddress();
		
		if (pa & ~mask)
			debug("kXAudioEngine[%p]::my_alloc_contiguous() - memory misaligned or beyond 2GB limit (%p)\n", this, (void *)pa);
		
		*phys = (dword)pa;
		*addr = desc->getBytesNoCopy();
		
#ifdef DEBUGGING
		memset(addr,0x11,PAGE_SIZE);
		memset((UInt8 *)addr+PAGE_SIZE+size,0x22,PAGE_SIZE);
		
		*((UInt8 *)addr) += PAGE_SIZE;
		*phys += PAGE_SIZE;
#endif
    }
    else
		debug("kXAudioEngine[%p]::my_alloc_contiguous() - allocation failed\n",this);
    
    return desc;
}
开发者ID:dmitrygorelov,项目名称:kx-audio-driver,代码行数:44,代码来源:AudioEngine.cpp


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