/*! ****************************************************************************** @Function PVRSRVRegisterDevice @Description registers a device with the system @Input psSysData : sysdata structure @Input pfnRegisterDevice : device registration function @Input ui32SOCInterruptBit : SoC interrupt bit for this device @Output pui32DeviceIndex : unique device key (for case of multiple identical devices) @Return PVRSRV_ERROR : ******************************************************************************/ PVRSRV_ERROR IMG_CALLCONV PVRSRVRegisterDevice(PSYS_DATA psSysData, PVRSRV_ERROR (*pfnRegisterDevice)(PVRSRV_DEVICE_NODE*), IMG_UINT32 ui32SOCInterruptBit, IMG_UINT32 *pui32DeviceIndex) { PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; /* Allocate device node */ if(OSAllocMem( PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), (IMG_VOID **)&psDeviceNode, IMG_NULL, "Device Node") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVRegisterDevice : Failed to alloc memory for psDeviceNode")); return (PVRSRV_ERROR_OUT_OF_MEMORY); } OSMemSet (psDeviceNode, 0, sizeof(PVRSRV_DEVICE_NODE)); eError = pfnRegisterDevice(psDeviceNode); if (eError != PVRSRV_OK) { OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), psDeviceNode, IMG_NULL); /*not nulling pointer, out of scope*/ PVR_DPF((PVR_DBG_ERROR,"PVRSRVRegisterDevice : Failed to register device")); return (PVRSRV_ERROR_DEVICE_REGISTER_FAILED); } /* make the refcount 1 and test on this to initialise device at acquiredevinfo. On release if refcount is 1, deinitialise and when refcount is 0 (sysdata de-alloc) deallocate the device structures */ psDeviceNode->ui32RefCount = 1; psDeviceNode->psSysData = psSysData; psDeviceNode->ui32SOCInterruptBit = ui32SOCInterruptBit; /* all devices need a unique identifier */ AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex); /* and finally insert the device into the dev-list */ List_PVRSRV_DEVICE_NODE_Insert(&psSysData->psDeviceNodeList, psDeviceNode); /* and copy back index */ *pui32DeviceIndex = psDeviceNode->sDevId.ui32DeviceIndex; return PVRSRV_OK; }
PVRSRV_ERROR IMG_CALLCONV PVRSRVRegisterDevice(PSYS_DATA psSysData, PVRSRV_ERROR (*pfnRegisterDevice)(PVRSRV_DEVICE_NODE*), IMG_UINT32 ui32SOCInterruptBit, IMG_UINT32 *pui32DeviceIndex) { PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; if(OSAllocMem( PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), (IMG_VOID **)&psDeviceNode, IMG_NULL, "Device Node") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVRegisterDevice : Failed to alloc memory for psDeviceNode")); return (PVRSRV_ERROR_OUT_OF_MEMORY); } OSMemSet (psDeviceNode, 0, sizeof(PVRSRV_DEVICE_NODE)); eError = pfnRegisterDevice(psDeviceNode); if (eError != PVRSRV_OK) { OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), psDeviceNode, IMG_NULL); PVR_DPF((PVR_DBG_ERROR,"PVRSRVRegisterDevice : Failed to register device")); return (PVRSRV_ERROR_DEVICE_REGISTER_FAILED); } psDeviceNode->ui32RefCount = 1; psDeviceNode->psSysData = psSysData; psDeviceNode->ui32SOCInterruptBit = ui32SOCInterruptBit; AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex); List_PVRSRV_DEVICE_NODE_Insert(&psSysData->psDeviceNodeList, psDeviceNode); *pui32DeviceIndex = psDeviceNode->sDevId.ui32DeviceIndex; return PVRSRV_OK; }
enum PVRSRV_ERROR PVRSRVRegisterDevice(struct SYS_DATA *psSysData, enum PVRSRV_ERROR(*pfnRegisterDevice) (struct PVRSRV_DEVICE_NODE *), u32 ui32SOCInterruptBit, u32 *pui32DeviceIndex) { enum PVRSRV_ERROR eError; struct PVRSRV_DEVICE_NODE *psDeviceNode; if (OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(struct PVRSRV_DEVICE_NODE), (void **) &psDeviceNode, NULL) != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVRegisterDevice : " "Failed to alloc memory for psDeviceNode"); return PVRSRV_ERROR_OUT_OF_MEMORY; } OSMemSet(psDeviceNode, 0, sizeof(struct PVRSRV_DEVICE_NODE)); eError = pfnRegisterDevice(psDeviceNode); if (eError != PVRSRV_OK) { OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(struct PVRSRV_DEVICE_NODE), psDeviceNode, NULL); PVR_DPF(PVR_DBG_ERROR, "PVRSRVRegisterDevice : " "Failed to register device"); return PVRSRV_ERROR_DEVICE_REGISTER_FAILED; } psDeviceNode->ui32RefCount = 1; psDeviceNode->psSysData = psSysData; psDeviceNode->ui32SOCInterruptBit = ui32SOCInterruptBit; AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex); psDeviceNode->psNext = psSysData->psDeviceNodeList; psSysData->psDeviceNodeList = psDeviceNode; *pui32DeviceIndex = psDeviceNode->sDevId.ui32DeviceIndex; return PVRSRV_OK; }