vfree(LinAddr);
}
-static BCE_ERROR
-BCAllocContigMemory(unsigned long ulSize,
- BCE_HANDLE unref__ * phMemHandle,
- IMG_CPU_VIRTADDR * pLinAddr, IMG_CPU_PHYADDR * pPhysAddr)
-{
-#if defined(LMA)
- void *pvLinAddr;
-
-
- if (g_ulMemCurrent + ulSize >= PVR_BUFFERCLASS_MEMSIZE) {
- return (BCE_ERROR_OUT_OF_MEMORY);
- }
-
- pvLinAddr = ioremap(g_ulMemBase + g_ulMemCurrent, ulSize);
-
- if (pvLinAddr) {
- pPhysAddr->uiAddr = g_ulMemBase + g_ulMemCurrent;
- *pLinAddr = pvLinAddr;
-
- g_ulMemCurrent += ulSize;
- return (BCE_OK);
- }
- return (BCE_ERROR_OUT_OF_MEMORY);
-#else
-#if defined(BCE_USE_SET_MEMORY)
- void *pvLinAddr;
- unsigned long ulAlignedSize = PAGE_ALIGN(ulSize);
- int iPages = (int)(ulAlignedSize >> PAGE_SHIFT);
- int iError;
-
- pvLinAddr = kmalloc(ulAlignedSize, GFP_KERNEL);
- BUG_ON(((unsigned long) pvLinAddr) & ~PAGE_MASK);
-
- iError = set_memory_wc((unsigned long) pvLinAddr, iPages);
- if (iError != 0) {
- printk(KERN_ERR DRVNAME
- ": BCAllocContigMemory: set_memory_wc failed (%d)\n", iError);
- return (BCE_ERROR_OUT_OF_MEMORY);
- }
-
- pPhysAddr->uiAddr = virt_to_phys(pvLinAddr);
- *pLinAddr = pvLinAddr;
-
- return (BCE_OK);
-#else
- dma_addr_t dma;
- void *pvLinAddr;
-
- pvLinAddr = dma_alloc_coherent(NULL, ulSize, &dma, GFP_KERNEL);
- if (pvLinAddr == NULL) {
- return (BCE_ERROR_OUT_OF_MEMORY);
- }
-
- pPhysAddr->uiAddr = dma;
- *pLinAddr = pvLinAddr;
-
- return (BCE_OK);
-#endif
-#endif
-}
-
-static void
-BCFreeContigMemory(unsigned long ulSize,
- BCE_HANDLE unref__ hMemHandle,
- IMG_CPU_VIRTADDR LinAddr, IMG_CPU_PHYADDR PhysAddr)
-{
-#if defined(LMA)
- g_ulMemCurrent -= ulSize;
- iounmap(LinAddr);
-#else
-#if defined(BCE_USE_SET_MEMORY)
- unsigned long ulAlignedSize = PAGE_ALIGN(ulSize);
- int iError;
- int iPages = (int)(ulAlignedSize >> PAGE_SHIFT);
-
- iError = set_memory_wb((unsigned long) LinAddr, iPages);
- if (iError != 0) {
- printk(KERN_ERR DRVNAME
- ": BCFreeContigMemory: set_memory_wb failed (%d)\n", iError);
- }
- kfree(LinAddr);
-#else
- dma_free_coherent(NULL, ulSize, LinAddr, (dma_addr_t) PhysAddr.uiAddr);
-#endif
-#endif
-}
-
IMG_SYS_PHYADDR
CpuPAddrToSysPAddrBC(IMG_CPU_PHYADDR cpu_paddr)
{