/*!
******************************************************************************

 @Function				SYSDEVKM_OpenDevice

******************************************************************************/
IMG_RESULT SYSDEVKM_OpenDevice(
	IMG_CHAR *				pszDeviceName,
	IMG_HANDLE *			phSysDevHandle
)
{
	IMG_UINT32			ui32Result;
	SYSDEVKM_sDevice *	psDevice;

	/* Allocate a device structure...*/
	psDevice = IMG_MALLOC(sizeof(*psDevice));
	IMG_ASSERT(psDevice != IMG_NULL);
	if (psDevice == IMG_NULL)
	{
		return IMG_ERROR_OUT_OF_MEMORY;
	}
	IMG_MEMSET(psDevice, 0, sizeof(*psDevice));

	/* Get the device id...*/
	ui32Result = SYSDEVU_GetDeviceId(pszDeviceName, &psDevice->ui32DeviceId);
	IMG_ASSERT(ui32Result == IMG_SUCCESS);
	if (ui32Result != IMG_SUCCESS)
	{
		return ui32Result;
	}

	/* Return the device handle...*/
	*phSysDevHandle = psDevice;

	/* Update count...*/
	SYSOSKM_DisableInt();
	gsActiveOpenCnt++;
	SYSOSKM_EnableInt();

	return IMG_SUCCESS;
}
Exemplo n.º 2
0
/*!
******************************************************************************

 @Function                POOL_PoolCreate

******************************************************************************/
IMG_RESULT POOL_PoolCreate(
    IMG_HANDLE *  phPoolHandle
)
{
    POOL_sResPool *  psResPool;
    IMG_UINT32       ui32Result;

    IMG_ASSERT(gInitialised);

    /* Allocate a pool structure...*/
    psResPool = IMG_MALLOC(sizeof(*psResPool));
    IMG_ASSERT(psResPool != IMG_NULL);
    if (psResPool == IMG_NULL)
    {
        return IMG_ERROR_OUT_OF_MEMORY;
    }
    IMG_MEMSET(psResPool, 0, sizeof(*psResPool));

    /* Initialise the pool info...*/
    LST_init(&psResPool->sFreeResList);
    LST_init(&psResPool->sActResList);

    /* Create mutex...*/
    ui32Result = SYSOSKM_CreateMutex(&psResPool->hMutexHandle);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        goto error_create_mutex;
    }

    /* Create context for the Id generator...*/
    ui32Result = IDGEN_CreateContext(POOL_IDGEN_MAX_ID, POOL_IDGEN_BLOCK_SIZE,IMG_FALSE, &psResPool->hIdGenHandle);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        goto error_create_context;
    }

    /* Disable interrupts.  */
    SYSOSKM_DisableInt();

    /* Add to list of pools...*/
    LST_add(&gsPoolList, psResPool);

    /* Enable interrupts.  */
    SYSOSKM_EnableInt();

    /* Return handle to pool...*/
    *phPoolHandle = psResPool;

    return IMG_SUCCESS;

    /* Error handling. */
error_create_context:
    SYSOSKM_DestroyMutex(psResPool->hMutexHandle);
error_create_mutex:
    IMG_FREE(psResPool);

    return ui32Result;
}
Exemplo n.º 3
0
static uint32_t
jpg_vlc_decode_direct_symbols(const vlc_symbol_code_jpeg * symbol_code, uint16_t * const table_ram, const uint32_t width,
                              const uint32_t leading) {
    uint32_t offset, limit;
    uint16_t entry;

    /* this function is only for codes short enough to produce valid symbols */
    IMG_ASSERT( symbol_code->code_length <= leading + width );
    IMG_ASSERT( symbol_code->code_length > leading );

    /* lose bits already decoded */
    offset = symbol_code->code << leading;
    offset &= JPG_MAKE_MASK(JPG_VLC_MAX_CODE_LEN);

    /* convert truncated code to offset */
    offset >>= (JPG_VLC_MAX_CODE_LEN - width);
    /* expand offset to encorporate undefined code bits */
    limit = offset + (1 << (width - (symbol_code->code_length - leading)));

    /* for all code variants - insert symbol into the decode direct result table */
    entry = jpg_vlc_valid_symbol( symbol_code, leading );
    for (; offset < limit; offset++) {
        table_ram[offset] = entry;
    }

    /* return the number of entries written */
    return limit - offset - 1;
}
Exemplo n.º 4
0
/*!
******************************************************************************

 @Function              VXDIO_PDUMPDisableCmds

******************************************************************************/
IMG_UINT32
VXDIO_PDUMPDisableCmds(
    const IMG_HANDLE    hVxdCtx,
    IMG_UINT32          ui32MemRegion,
    IMG_UINT32          ui32Offset,
    IMG_UINT32          ui32DisableFlags
)
{
    VXDIO_sContext *psVxdCtx  = (VXDIO_sContext *)hVxdCtx;

    IMG_ASSERT(psVxdCtx != IMG_NULL);
    IMG_ASSERT(psVxdCtx->ui32MemSpaceCount != 0);

    if (ui32MemRegion >= psVxdCtx->ui32MemSpaceCount)
    {
        REPORT(REPORT_MODULE_VXDIO, REPORT_ERR,
               "A valid VXD memory region must be provided");
        return IMG_ERROR_INVALID_PARAMETERS;
    }

    TALPDUMP_DisableCmds(psVxdCtx->pahMemSpace[ui32MemRegion],
        ui32Offset, ui32DisableFlags);

    return IMG_SUCCESS;
}
Exemplo n.º 5
0
/*!
******************************************************************************

 @Function				SYSDEVU_InvokeDevKmLisr

******************************************************************************/
IMG_RESULT SYSDEVU_InvokeDevKmLisr(
	IMG_UINT32					ui32DeviceId
)
{
    IMG_UINT32  ui32Result;
	SYSDEVU_sInfo *dev = findDeviceById(ui32DeviceId);
	if(!gSysDevInitialised || !dev)
	{
		IMG_ASSERT(gSysDevInitialised);
		IMG_ASSERT(dev);

		ui32Result = IMG_ERROR_INVALID_PARAMETERS;
        return ui32Result;
	}

	IMG_ASSERT(dev->pfnDevKmLisr != IMG_NULL);
    if(dev->pfnDevKmLisr == IMG_NULL)
	{
		ui32Result = IMG_ERROR_INVALID_PARAMETERS;
        return ui32Result;
	}

	dev->pfnDevKmLisr(dev->pvParam);

    return IMG_SUCCESS;
}
static IMG_PHYSADDR CpuKmAddrToCpuPAddr(
    SYSMEM_Heap *  heap,
    IMG_VOID *     pvCpuKmAddr
)
{
    IMG_PHYSADDR ret = 0;

    if(virt_addr_valid(pvCpuKmAddr))
    {
        /* direct mapping of kernel addresses.
         * this works for kmalloc.
         */
        ret = virt_to_phys(pvCpuKmAddr);
    }
    else
    {
        /* walk the page table.
         * Works for ioremap, vmalloc, and kmalloc(GPF_DMA),
          but not, for some reason, kmalloc(GPF_KERNEL)
         */
        struct page * pg = vmalloc_to_page(pvCpuKmAddr);
        if(pg) {
            ret = page_to_phys(pg);
        }
        else {
            IMG_ASSERT(!"vmalloc_to_page failure");
        }
    }

    IMG_ASSERT(ret != 0);

    return ret;
}
Exemplo n.º 7
0
/*!
********************************************************************************

 @Function				POOL_Free

 @Description

 Free an sObject previously allocated from an sObject sPool.

 @Input	    psPool      : Object Pool pointer.

 @Output    hObject     : Handle to the object to be freed.

 @Return    IMG_RESULT  : IMG_SUCCESS or an error code.

********************************************************************************/
IMG_RESULT POOL_Free(
    struct  sPool * const       psPool, 
            IMG_HANDLE const    hObject
)
{
    struct sObject * psObject = IMG_NULL;
    IMG_UINT32 ui32Result = IMG_ERROR_FATAL;

    IMG_ASSERT(IMG_NULL != psPool);
    IMG_ASSERT(IMG_NULL != hObject);
    if (IMG_NULL == psPool ||
        IMG_NULL == hObject)
    {
        ui32Result = IMG_ERROR_INVALID_PARAMETERS;
        goto error;
    }

    psObject = (struct sObject *)hObject;
    psObject->psNext = psPool->psObjects;
    psPool->psObjects = psObject;

    ui32Result = IMG_SUCCESS;

error:
    return ui32Result;
}
Exemplo n.º 8
0
IMG_VOID SYSDEVU_GetMemoryInfo(
	IMG_UINT32			ui32DeviceId,
	IMG_VOID **			ppvKmMemory,
	IMG_PHYSADDR *			ppaPhysMemory,
	IMG_UINT64 *		pui64MemSize,
	IMG_UINT64 *		pui64DevMemoryBase
) {

#ifndef __FAKE_HW__
	SYSDEVU_sInfo *dev = findDeviceById(ui32DeviceId);
	if(!gSysDevInitialised || !dev)
	{
		IMG_ASSERT(gSysDevInitialised);
		IMG_ASSERT(dev);
		return;
	}

	if(ppvKmMemory)
		*ppvKmMemory = dev->pui32KmMemBase;

	if(ppaPhysMemory)
		*ppaPhysMemory = dev->paPhysMemBase;

	if(pui64MemSize)
		*pui64MemSize = dev->ui32MemSize;

	if(pui64DevMemoryBase)
		*pui64DevMemoryBase = (IMG_UINT64)dev->pui64DevMemoryBase;
#endif
}
Exemplo n.º 9
0
/*!
******************************************************************************

 @Function				mmu_GetTileRegion

******************************************************************************/
IMG_INT32 mmu_GetTileRegion(
    IMG_UINT32				ui32MMUId,
    IMG_UINT64              ui64DevVirtAddr
)
{
    IMG_UINT32              i;
	MMU_sContextCB			*psContextCB = mmu_GetContext(ui32MMUId);

	IMG_ASSERT(gbMMUInitialised);
	IMG_ASSERT (psContextCB);

    /* If the context has tile regions...*/
    if (psContextCB->bTiledRegionDefined)
    {
        /* Loop over regions...*/
        for (i=0; i<MMU_NUMBER_OF_TILED_REGIONS; i++)
        {
            /* If region defined...*/
            if (psContextCB->asTiledRegionCB[i].ui64Size != 0)
            {
                /* If device virtual address is within a tiled region...*/
                if (
                        (ui64DevVirtAddr >= psContextCB->asTiledRegionCB[i].ui64DevVirtAddr) &&
                        (ui64DevVirtAddr < (psContextCB->asTiledRegionCB[i].ui64DevVirtAddr+psContextCB->asTiledRegionCB[i].ui64Size))
                        )
                {
                    return i;
                }
            }
        }
    }
    return -1;
}
Exemplo n.º 10
0
/*!
******************************************************************************

 @Function				LOG_Enable

******************************************************************************/
IMG_VOID LOG_Enable(
	IMG_UINT32		ui32Api,
	LOG_eLevel		eLevel,
	LOG_eLogMode	eLogMode
)
{
	if (ui32Api == LOG_ALL_APIS)
	{
		/* Loop over APIs */
		for (ui32Api=0; ui32Api<API_ID_MAX; ui32Api++)
		{
			LOG_Enable(ui32Api, eLevel, eLogMode);
		}
	}
	else
	{
		IMG_ASSERT(gInitialised);

		/* Ensure that the API is valid */
		IMG_ASSERT(ui32Api < API_ID_MAX);

		gbLogEnabled = IMG_TRUE;

		/* Set log level and mode */
		gaeLogApi[ui32Api].eLevel	= eLevel;
		gaeLogApi[ui32Api].eLogMode = eLogMode;
	}
}
/*!
******************************************************************************

 @Function                SYSDEVU_SetPowerState

******************************************************************************/
IMG_VOID SYSDEVU_SetPowerState(
    IMG_HANDLE           hSysDevHandle,
    SYSOSKM_ePowerState  ePowerState,
    IMG_BOOL             forAPM
)
{
	SYSDEVU_sInfo *  psDevice = (SYSDEVU_sInfo *)hSysDevHandle;
    IMG_ASSERT(gSysDevInitialised);
    IMG_ASSERT(hSysDevHandle != IMG_NULL);

    if (hSysDevHandle == IMG_NULL)
    {
        return;
    }

    switch(ePowerState) {
    case SYSOSKM_POWERSTATE_S5:        // suspend
        SYSDEVU_HandleSuspend(psDevice, forAPM);
        break;
    case SYSOSKM_POWERSTATE_S0:        // resume
        SYSDEVU_HandleResume(psDevice, forAPM);
        break;
    }

}
Exemplo n.º 12
0
/*!
******************************************************************************

 @Function				MMU_Setup

******************************************************************************/
IMG_RESULT MMU_Setup (
	IMG_UINT32		ui32MMUId,
	IMG_UINT64		ui64PCAddress,
	IMG_UINT32		ui32MMUType,
	MMU_pfnReadMem	pfnReadMem
	)
{
	MMU_sContextCB *psContextCB;

	IMG_ASSERT(gbMMUInitialised);
	IMG_ASSERT(ui32MMUId < MMU_NUMBER_OF_CONTEXTS);
	
	psContextCB = &gasContextCBs[ui32MMUId];
	if (psContextCB->ui32MMUType == MMU_TYPE_NONE)
		gui32ContextsInUse++;
	memset(psContextCB, 0, sizeof(MMU_sContextCB));

	psContextCB->ui64PCAddress = ui64PCAddress;
	psContextCB->ui32MMUType = ui32MMUType;
	psContextCB->ui32BusWidth = gasMMUTypesLookup[ui32MMUType].ui32BusWidth;
	psContextCB->pfnReadLookup = pfnReadMem;
	psContextCB->pfnReadPage = pfnReadMem;
	
	return IMG_SUCCESS;
}
/*!
******************************************************************************

 @Function                SYSDEVU_RegisterDevKmLisr

******************************************************************************/
IMG_VOID SYSDEVU_RegisterDevKmLisr(
    IMG_HANDLE             hSysDevHandle,
    SYSDEVU_pfnDevKmLisr  pfnDevKmLisr,
    IMG_VOID *             pvParam
)
{
	SYSDEVU_sInfo *  dev = (SYSDEVU_sInfo *)hSysDevHandle;

    IMG_ASSERT(gSysDevInitialised);
    IMG_ASSERT(hSysDevHandle != IMG_NULL);
    if (hSysDevHandle == IMG_NULL)
    {
        return;
    }

	if (
			(pfnDevKmLisr != IMG_NULL) &&
			(dev->pfnDevKmLisr != IMG_NULL)
		)
	{
		IMG_ASSERT(dev->pfnDevKmLisr == pfnDevKmLisr);
		IMG_ASSERT(dev->pvParam == pvParam);
	}
	else
	{
		dev->pfnDevKmLisr = pfnDevKmLisr;
		dev->pvParam = pvParam;
	}
}
/*!
******************************************************************************

 @Function                SYSDEVU_CpuPAddrToDevPAddr

******************************************************************************/
IMG_PHYSADDR SYSDEVU_CpuPAddrToDevPAddr(
    IMG_HANDLE  hSysDevHandle,
    IMG_PHYSADDR  paCpuPAddr
)
{
    SYSDEVU_sInfo *  psSysDev = (SYSDEVU_sInfo *)hSysDevHandle;

    IMG_ASSERT(gSysDevInitialised);

    IMG_ASSERT(hSysDevHandle != IMG_NULL);
    if (hSysDevHandle == IMG_NULL)
    {
        return 0;
    }

    /*
     * If conversion routines isn't added by the customer ( using sysdev ),
     *  we assume that it's a unified memory model where pa == dev_pa
     */
    if (!psSysDev->ops->paddr_to_devpaddr)
    	return paCpuPAddr;


    return psSysDev->ops->paddr_to_devpaddr(psSysDev, paCpuPAddr);
}
/*!
******************************************************************************

 @Function				SYSDEVU_Initialise

******************************************************************************/
IMG_RESULT SYSDEVU_Initialise(IMG_VOID)
{
	/* If not initialised...*/
	if (!gSysDevInitialised)
	{
		IMG_RESULT eResult;

		eResult = SYSOSKM_CreateAtomic(&gsActiveOpenCnt);
		IMG_ASSERT(eResult == IMG_SUCCESS);
		if (eResult != IMG_SUCCESS)
		{
			return eResult;
		}

		LST_init(&gsDevList);

		eResult = SYSOSKM_CreateMutex(&hNextDeviceIdMutex);
		IMG_ASSERT(eResult == IMG_SUCCESS);
		if (eResult != IMG_SUCCESS)
		{
			return eResult;
		}

		/* use a magic number to help detect dereferences of
		   DeviceId when (wrongly) casted as a pointer */
		gui32NextDeviceId = 0xbeef00;
		/* Now we are initialised...*/
		gSysDevInitialised = IMG_TRUE;
	}

	return IMG_SUCCESS;
}
Exemplo n.º 16
0
/*!
******************************************************************************

 @Function				SYSDEVKM_CpuPAddrToDevPAddr

******************************************************************************/
IMG_PHYSADDR SYSDEVKM_CpuPAddrToDevPAddr(
	IMG_HANDLE				hSysDevHandle,
	IMG_PHYSADDR				paCpuPAddr
)
{
	SYSDEVKM_sDevice *	psDevice = (SYSDEVKM_sDevice *)hSysDevHandle;
	
	IMG_ASSERT(gSysDevInitialised);
	IMG_ASSERT(hSysDevHandle != IMG_NULL);
	if (hSysDevHandle == IMG_NULL)
	{
		return 0;
	}

	if (asDevMem[psDevice->ui32DeviceId].ui64MemorySize == 0)
	{
		SYSDEVU_GetMemoryInfo(
			psDevice->ui32DeviceId,
			&asDevMem[psDevice->ui32DeviceId].pvKmMemory,
			&asDevMem[psDevice->ui32DeviceId].paPhysMemory,
			&asDevMem[psDevice->ui32DeviceId].ui64MemorySize,
			&asDevMem[psDevice->ui32DeviceId].ui64DevMemoryBase
		);
	}
	paCpuPAddr -= (IMG_UINTPTR)asDevMem[psDevice->ui32DeviceId].pvKmMemory;
	paCpuPAddr += asDevMem[psDevice->ui32DeviceId].ui64DevMemoryBase;
	IMG_ASSERT(paCpuPAddr < asDevMem[psDevice->ui32DeviceId].ui64MemorySize);

	/* One-to-one CPU to device mapping...*/
	return paCpuPAddr;
}
Exemplo n.º 17
0
/*!
******************************************************************************

 @Function				MMU_GetPageDirEntryAddress

******************************************************************************/
IMG_UINT64 MMU_GetPageDirEntryAddress (
	IMG_UINT32				ui32MMUId,
	IMG_UINT64              ui64DevVirtAddr,
	IMG_UINT64				ui64PCEntry
)
{
	MMU_sContextCB			*psContextCB = mmu_GetContext(ui32MMUId);
	IMG_UINT64				ui64PageDirAddr, ui64PageDirEntryAddr;

	IMG_ASSERT(gbMMUInitialised);
	IMG_ASSERT (psContextCB);
	
	switch (psContextCB->ui32MMUType)
	{
	case MMU_TYPE_VP_40BIT_ADDR:
		ui64PageDirAddr = MMU_MASK_AND_SHIFTL(ui64PCEntry, MMU_PC_PDP_MASK, MMU_PC_PDP_SHIFT);
		break;
	case MMU_TYPE_NONE:
	case MMU_TYPE_4K_PAGES_32BIT_ADDR:
	case MMU_TYPE_VARIABLE_PAGE_32BIT_ADDR:
	case MMU_TYPE_4K_PAGES_36BIT_ADDR:
	case MMU_TYPE_4K_PAGES_40BIT_ADDR:
		ui64PageDirAddr = psContextCB->ui64PCAddress;
		break;
	default:
		IMG_ASSERT(IMG_FALSE);
	}

	ui64PageDirEntryAddr = ui64PageDirAddr;
	ui64PageDirEntryAddr |= MMU_MASK_AND_SHIFTR(ui64DevVirtAddr, THIS_BUS_WIDTH.ui64Vaddr_PDMask, THIS_BUS_WIDTH.ui32Vaddr_PDShift );
	return ui64PageDirEntryAddr;
}
Exemplo n.º 18
0
/*!
******************************************************************************

 @Function                pciio_DeviceAttach

******************************************************************************/
static IMG_RESULT pciio_DeviceAttach(
    IMG_CHAR *      pszDevName,
    SECDEV_eMapArea  eArea
)
{
    IMG_UINT32  ui32Result;

    IMG_ASSERT(gpszDevName != IMG_NULL);
    if (gpszDevName != IMG_NULL)
    {
        IMG_ASSERT(IMG_STRCMP(pszDevName, gpszDevName) == 0);
    }
    else
    {
        return IMG_ERROR_GENERIC_FAILURE;
    }

    /* In this implementation we initialise the PCI component */
    ui32Result = pciio_PciDetectDevice(eArea);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        return ui32Result;
    }

    return IMG_SUCCESS;
}
Exemplo n.º 19
0
IMG_VOID MMU_SetTiledRegion(
	IMG_UINT32				ui32MMUId,
    IMG_UINT32              ui32TiledRegionNo,
	IMG_UINT64				ui64DevVirtAddr,
    IMG_UINT64              ui64Size,
    IMG_UINT32              ui32XTileStride
)
{
	MMU_sContextCB *psContextCB;
	IMG_UINT32		i;

	IMG_ASSERT(gbMMUInitialised);
	/* Check MMU Id and Tiled Id are Valid */
	IMG_ASSERT(ui32MMUId < MMU_NUMBER_OF_CONTEXTS);
	IMG_ASSERT(ui32TiledRegionNo < MMU_NUMBER_OF_TILED_REGIONS);

	psContextCB = &gasContextCBs[ui32MMUId];
	IMG_ASSERT(psContextCB->ui32MMUType < MMU_NO_TYPES);
	IMG_ASSERT(psContextCB->ui32MMUType != MMU_TYPE_NONE);
	
    /* Set the tiled region parameters...*/
    psContextCB->asTiledRegionCB[ui32TiledRegionNo].ui64DevVirtAddr    = ui64DevVirtAddr;
    psContextCB->asTiledRegionCB[ui32TiledRegionNo].ui64Size           = ui64Size;
    psContextCB->asTiledRegionCB[ui32TiledRegionNo].ui32XTileStride    = ui32XTileStride;

    /* See if tiled region defined...*/
    psContextCB->bTiledRegionDefined = IMG_FALSE;
    for (i=0; i<MMU_NUMBER_OF_TILED_REGIONS; i++)
    {
        if (psContextCB->asTiledRegionCB[i].ui64Size != 0)
        {
            psContextCB->bTiledRegionDefined = IMG_TRUE;
        }
    }
}
Exemplo n.º 20
0
/*!
******************************************************************************

 @Function				LOG_ElapseTimeStart

******************************************************************************/
IMG_VOID LOG_ElapseTimeStart(
	LOG_sElapseTime	*	psElapseTime
)
{
	IMG_ASSERT(0);
#if 0
 	volatile IMG_UINT32 *       pTimer = LOG_TIMER_ADDR;
	IMG_UINT32					ui32Time = *pTimer;

	/* Cannot start when the previous count was not finished */
	IMG_ASSERT ( psElapseTime->bCounting == IMG_FALSE );

	/* If the "looks" like teh fisrt time...*/
	if (psElapseTime->ui32TimeStamp == 0)
	{
		/* Reset minimum */
		psElapseTime->ui32MinTime = 0xFFFFFFFF;
	}

	/* Set the time stamp */
	psElapseTime->ui32TimeStamp = ui32Time;

	psElapseTime->ui32StartCount ++;
	psElapseTime->bCounting = IMG_TRUE;
#endif
}
Exemplo n.º 21
0
/*!
******************************************************************************

@Function				ADDR_CxMallocRes

******************************************************************************/
IMG_RESULT ADDR_CxMallocRes(
            ADDR_sContext * const   psContext,
    const   IMG_CHAR * const        pszName,
            IMG_UINT64              ui64Size,
            IMG_UINT64 * const      pui64Base
)
{
    IMG_RESULT ui32Result = IMG_ERROR_FATAL;

    IMG_ASSERT(IMG_NULL != psContext);
    IMG_ASSERT(IMG_NULL != pszName);
    IMG_ASSERT(IMG_NULL != pui64Base);

    if(IMG_NULL == psContext ||
        IMG_NULL == pszName ||
        IMG_NULL == pui64Base)
    {
        ui32Result = IMG_ERROR_INVALID_PARAMETERS;
        goto error_invalid_parameters;
    }

    addr_alloc_Lock();
    ui32Result = addr_CxMalloc1(psContext, pszName, ui64Size, 1, pui64Base);
    addr_alloc_UnLock();

    IMG_ASSERT(IMG_SUCCESS == ui32Result);
    if (IMG_SUCCESS != ui32Result)
    {
        //error handling
    }

error_invalid_parameters:
    return ui32Result;
}
Exemplo n.º 22
0
IMG_RESULT SYSDEVU_UnRegisterDevice(
	SYSDEVU_sInfo *psInfo
)
{
	IMG_UINT32			ui32Result;

	IMG_ASSERT(gSysDevInitialised);
	if(!LST_remove(&gsDevList, psInfo))
	{
		IMG_ASSERT(IMG_FALSE);
		return IMG_ERROR_GENERIC_FAILURE;
	}

	gui32NoDevices--;

	ui32Result = DMANKM_UnRegisterDevice(psInfo->sDevInfo.pszDeviceName);
	IMG_ASSERT(ui32Result == IMG_SUCCESS);
	if(ui32Result != IMG_SUCCESS)
		return ui32Result;

	/* Initialise parts of the device info structure...*/
	psInfo->bDevLocated	= IMG_FALSE;
	psInfo->pvLocParam = IMG_NULL;

	/* Return success...*/
	return IMG_SUCCESS;
}
Exemplo n.º 23
0
/*!
******************************************************************************

@Function				ADDR_CxMalloc1Res

******************************************************************************/
IMG_RESULT ADDR_CxMalloc1Res(
            ADDR_sContext * const   psContext,
    const   IMG_CHAR * const        pszName,
            IMG_UINT64              ui64Size,
            IMG_UINT64              ui64Alignment,
            IMG_UINT64 * const      pui64Base
)
{
    IMG_RESULT ui32Result;

    IMG_ASSERT(IMG_NULL != psContext);
    IMG_ASSERT(IMG_NULL != pui64Base);
    if(IMG_NULL == psContext ||
        IMG_NULL == pui64Base)
    {
        ui32Result = IMG_ERROR_INVALID_PARAMETERS;
        goto error_invalid_parameters;
    }

    addr_alloc_Lock();
    ui32Result = addr_CxMalloc1(psContext, pszName, ui64Size, ui64Alignment, pui64Base);
    addr_alloc_UnLock();

error_invalid_parameters:
    return ui32Result;
}
Exemplo n.º 24
0
/*!
******************************************************************************

 @Function				SYSDEVU_RegisterDevKmLisr

******************************************************************************/
IMG_VOID SYSDEVU_RegisterDevKmLisr(
	IMG_UINT32					ui32DeviceId,
	SYSDEVKM_pfnDevKmLisr		pfnDevKmLisr,
    IMG_VOID *                  pvParam
)
{
	SYSDEVU_sInfo *dev = findDeviceById(ui32DeviceId);
	if(!gSysDevInitialised || !dev)
	{
		IMG_ASSERT(gSysDevInitialised);
		IMG_ASSERT(dev);
		return;
	}

	if (
			(pfnDevKmLisr != IMG_NULL) &&
			(dev->pfnDevKmLisr != IMG_NULL)
		)
	{
		IMG_ASSERT(dev->pfnDevKmLisr == pfnDevKmLisr);
		IMG_ASSERT(dev->pvParam == pvParam);
	}
	else
	{
		dev->pfnDevKmLisr = pfnDevKmLisr;
		dev->pvParam = pvParam;
	}
}
Exemplo n.º 25
0
/*!
******************************************************************************

 @Function                PALLOCKM_CloneAlloc

******************************************************************************/
IMG_RESULT PALLOCKM_CloneAlloc(
    IMG_UINT32    ui32AllocId,
    IMG_HANDLE    hResBHandle,
    IMG_HANDLE *  phResHandle,
    IMG_UINT32 *  pui32AllocId
)
{
    IMG_UINT32  ui32Result;
    IMG_HANDLE  hResHandle;

    /* Get the resource info from the id...*/
    ui32Result = RMAN_GetResource(ui32AllocId, PALLOC_RES_TYPE_1, IMG_NULL, &hResHandle);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        return ui32Result;
    }

    /* Create a cloned reference...*/
    ui32Result = RMAN_CloneResourceHandle(hResHandle, hResBHandle, phResHandle, pui32AllocId);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        return ui32Result;
    }

    /* Return IMG_SUCCESS...*/
    return IMG_SUCCESS;
}
Exemplo n.º 26
0
/*!
******************************************************************************

 @Function				SYSDEVU_RegisterDevices

******************************************************************************/
IMG_RESULT SYSDEVU_RegisterDevice(
	SYSDEVU_sInfo *psInfo
)
{
	IMG_UINT32			ui32Result;

	IMG_ASSERT(gSysDevInitialised);
	/* Initialise parts of the device info structure...*/
	psInfo->bDevLocated	= IMG_FALSE;
	psInfo->pvLocParam = IMG_NULL;

	SYSOSKM_LockMutex(hNextDeviceIdMutex);
	psInfo->ui32DeviceId = gui32NextDeviceId;
	gui32NextDeviceId += 1;
	SYSOSKM_UnlockMutex(hNextDeviceIdMutex);

	/* Register the device with the device manager...*/
	ui32Result = DMANKM_RegisterDevice(psInfo->sDevInfo.pszDeviceName, psInfo->sDevInfo.pfnDevRegister);
	IMG_ASSERT(ui32Result == IMG_SUCCESS);
	if (ui32Result != IMG_SUCCESS)
	{
		return ui32Result;
	}

	/* Initialise the devices...*/
	LST_add(&gsDevList, psInfo);
	gui32NoDevices++;

	/* Return success...*/
	return IMG_SUCCESS;
}
Exemplo n.º 27
0
/*!
******************************************************************************

 @Function				SYSDEVKM_GetCpuKmAddr

******************************************************************************/
IMG_RESULT SYSDEVKM_GetCpuKmAddr(
	IMG_HANDLE				hSysDevHandle,
	SYSDEVKM_eRegionId		eRegionId,
	IMG_VOID **				ppvCpuKmAddr,
	IMG_UINT32 *			pui32Size
)
{
	SYSDEVKM_sDevice *		psDevice = (SYSDEVKM_sDevice *)hSysDevHandle;
	IMG_UINT32				ui32Result;
	
	IMG_ASSERT(hSysDevHandle != IMG_NULL);
	if (hSysDevHandle == IMG_NULL)
	{
		return IMG_ERROR_GENERIC_FAILURE;
	}

	ui32Result = SYSDEVU_GetCpuAddrs(psDevice->ui32DeviceId, eRegionId, ppvCpuKmAddr, IMG_NULL, pui32Size);
	IMG_ASSERT(ui32Result == IMG_SUCCESS);
	if (ui32Result != IMG_SUCCESS)
	{
		return ui32Result;
	}

	return IMG_SUCCESS;
}
Exemplo n.º 28
0
/*!
******************************************************************************

 @Function				RMAN_CreateBucket

******************************************************************************/
IMG_RESULT RMAN_CreateBucket(
    IMG_HANDLE *		phResBHandle
)
{
    RMAN_sBucket *			psBucket;
    IMG_UINT32				i;
    IMG_RESULT              i32Result;

    IMG_ASSERT(gInitialised);

    /* Allocate a bucket structure...*/
    psBucket = IMG_MALLOC(sizeof(*psBucket));
    IMG_ASSERT(psBucket != IMG_NULL);
    if (psBucket == IMG_NULL)
    {
        return IMG_ERROR_OUT_OF_MEMORY;
    }
    IMG_MEMSET(psBucket, 0, sizeof(*psBucket));

    /* Intialise the resource list...*/
    DQ_init(&psBucket->sResList);

    /* The start allocating resource ids at the first...*/
    i32Result = IDGEN_CreateContext(RMAN_MAX_ID, RMAN_ID_BLOCKSIZE, IMG_FALSE, &psBucket->hIdGenerator);
    if(i32Result != IMG_SUCCESS)
    {
        IMG_FREE(psBucket);
        IMG_ASSERT(!"failed to create IDGEN context");
        return i32Result;
    }

    /* Locate free bucket index within the table...*/
    SYSOSKM_DisableInt();
    for (i=0; i<RMAN_CRESID_MAX_BUCKET_INDEX; i++)
    {
        if (gapsBucket[i] == IMG_NULL)
        {
            break;
        }
    }
    if (i >= RMAN_CRESID_MAX_BUCKET_INDEX) {
        SYSOSKM_EnableInt();
        IDGEN_DestroyContext(psBucket->hIdGenerator);
        IMG_FREE(psBucket);
        IMG_ASSERT(!"No free buckets left");
        return IMG_ERROR_GENERIC_FAILURE;
    }

    /* Allocate bucket index...*/
    psBucket->ui32BucketIndex = i;
    gapsBucket[i] = psBucket;

    SYSOSKM_EnableInt();

    /* Return the bucket handle...*/
    *phResBHandle = psBucket;

    return IMG_SUCCESS;
}
Exemplo n.º 29
0
/*!
******************************************************************************

 @Function              palloc_fnCompConnect

******************************************************************************/
static IMG_RESULT palloc_fnCompConnect (
    IMG_HANDLE   hAttachHandle,
    IMG_VOID **  ppvCompAttachmentData
)
{
    PALLOC_sAttachContext *  psAttachContext;
    IMG_UINT32               ui32Result;
    IMG_CHAR *               pszDeviceName;

    /* Allocate attachment context structure...*/
    psAttachContext = IMG_MALLOC(sizeof(*psAttachContext));
    IMG_ASSERT(psAttachContext != IMG_NULL);
    if (psAttachContext == IMG_NULL)
    {
        return IMG_ERROR_OUT_OF_MEMORY;
    }
    IMG_MEMSET(psAttachContext, 0, sizeof(*psAttachContext));

    /* Ensure the resource manager is initialised...*/
    ui32Result = RMAN_Initialise();
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        goto error_rman_init;
    }

    /* Create a bucket for the resources...*/
    ui32Result = RMAN_CreateBucket(&psAttachContext->hResBHandle);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        goto error_rman_bucket;
    }

    /* Get device information...*/
    psAttachContext->hDevHandle = DMANKM_GetDevHandleFromAttach(hAttachHandle);
    pszDeviceName = DMANKM_GetDeviceName(psAttachContext->hDevHandle);
    ui32Result = SYSDEVU_OpenDevice(pszDeviceName, &psAttachContext->hSysDevHandle);
    IMG_ASSERT(ui32Result == IMG_SUCCESS);
    if (ui32Result != IMG_SUCCESS)
    {
        goto error_sysdev_open;
    }

    /* Return attachment context...*/
    *ppvCompAttachmentData = psAttachContext;

    /* Return success...*/
    return IMG_SUCCESS;

    /* Error handling. */
error_sysdev_open:
    RMAN_DestroyBucket(psAttachContext->hResBHandle);
error_rman_bucket:
error_rman_init:
    IMG_FREE(psAttachContext);

    return ui32Result;
}
Exemplo n.º 30
0
/*!
******************************************************************************

 @Function				RMAN_GetGlobalBucket

******************************************************************************/
IMG_HANDLE RMAN_GetGlobalBucket(IMG_VOID)
{
    IMG_ASSERT(gInitialised);
    IMG_ASSERT(gpsGlobalResBucket != IMG_NULL);

    /* Return the handle of the global resource bucket...*/
    return gpsGlobalResBucket;
}