From 40a485c0538894911c1bb2f15dfd9db098946414 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sat, 12 May 2012 00:25:53 +0300 Subject: [PATCH] merge common and linux layers from 1.5.15.2766 (2) --- Makefile | 66 +- include4/servicesext.h | 32 +- services4/include/kerneldisplay.h | 2 +- services4/srvkm/common/power.c | 462 ++++++------- services4/srvkm/common/pvrsrv.c | 620 ++++++++++-------- services4/srvkm/common/ra.c | 502 +++++++++++++- services4/srvkm/devices/sgx/sgxinfokm.h | 24 +- services4/srvkm/devices/sgx/sgxinit.c | 20 +- services4/srvkm/devices/sgx/sgxpower.c | 119 +--- services4/srvkm/devices/sgx/sgxutils.c | 4 +- services4/srvkm/include/power.h | 22 +- services4/system/include/syscommon.h | 22 +- services4/system/omap3430/sysconfig.c | 24 +- tools/intern/debug/dbgdriv/common/dbgdriv.c | 147 ++--- tools/intern/debug/dbgdriv/common/dbgdriv.h | 58 +- tools/intern/debug/dbgdriv/common/hostfunc.h | 2 +- tools/intern/debug/dbgdriv/common/ioctl.c | 5 +- tools/intern/debug/dbgdriv/linux/hostfunc.c | 4 +- .../debug/dbgdriv/linux/kbuild/Makefile | 14 +- tools/intern/debug/dbgdriv/linux/main.c | 220 +++++-- .../debug/dbgdriv/linux/makefile.linux.common | 40 ++ 21 files changed, 1492 insertions(+), 917 deletions(-) create mode 100644 tools/intern/debug/dbgdriv/linux/makefile.linux.common diff --git a/Makefile b/Makefile index 170e8ec..01fbb7d 100644 --- a/Makefile +++ b/Makefile @@ -66,17 +66,30 @@ DEBUG_LINUX_XML_PROC_FILES ?= 0 DEBUG_LINUX_SLAB_ALLOCATIONS ?= 0 DEBUG_BRIDGE_KM ?= 1 DEBUG_TRACE_BRIDGE_KM ?= 0 +DEBUG_BRIDGE_KM_DISPATCH_TABLE ?= 0 +PVRSRV_LOG_MEMORY_ALLOCS ?= 0 +PVRSRV_DEBUG_OS_MEMORY ?= 0 endif -TRANSFER_QUEUE ?= 1 -SUPPORT_SGX_EVENT_OBJECT ?= 1 -SUPPORT_SECURE_HANDLES = 1 -SUPPORT_SECURE_FD_EXPORT = 1 -SUPPORT_SRVINIT = 1 -SUPPORT_PERCONTEXT_PB = 1 -SUPPORT_LINUX_X86_PAT ?=1 -SUPPORT_LINUX_X86_WRITECOMBINE ?=1 -SUPPORT_SGX_LOW_LATENCY_SCHEDULING ?=1 +SUPPORT_SECURE_FD_EXPORT = 1 +ifeq ($(SUPPORT_DRI_DRM),1) +SUPPORT_SECURE_FD_EXPORT = 0 +endif + +PVR_PROC_USE_SEQ_FILE ?= 1 +TRANSFER_QUEUE ?= 1 +SUPPORT_SGX_EVENT_OBJECT ?=1 +SUPPORT_SECURE_HANDLES = 1 +SUPPORT_SRVINIT = 1 +SUPPORT_PERCONTEXT_PB = 1 +SUPPORT_LINUX_X86_PAT ?=1 +SUPPORT_LINUX_X86_WRITECOMBINE ?=1 +SUPPORT_SGX_LOW_LATENCY_SCHEDULING ?=1 + +SUPPORT_CPU_CACHED_BUFFERS ?= 0 + +SUPPORT_CACHEFLUSH_ON_ALLOC ?= 0 +SUPPORT_MEMINFO_IDS ?= 0 SUPPORT_LINUX_USING_WORKQUEUES ?= 1 @@ -119,6 +132,9 @@ SYS_CFLAGS.$(DEBUG_LINUX_SLAB_ALLOCATIONS) += -DDEBUG_LINUX_SLAB_ALLOCATIONS SYS_CFLAGS.$(DEBUG_BRIDGE_KM) += -DDEBUG_BRIDGE_KM SYS_CFLAGS.$(DEBUG_TRACE_BRIDGE_KM) += -DDEBUG_TRACE_BRIDGE_KM SYS_CFLAGS.$(DEBUG_BRIDGE_KM_DISPATCH_TABLE) += -DDEBUG_BRIDGE_KM_DISPATCH_TABLE +SYS_CFLAGS.$(PVRSRV_LOG_MEMORY_ALLOCS) += -DPVRSRV_LOG_MEMORY_ALLOCS +SYS_CFLAGS.$(PVRSRV_DEBUG_OS_MEMORY) += -DPVRSRV_DEBUG_OS_MEMORY +SYS_CFLAGS.$(DEBUG_MESA_OGL_TRACE) += -DDEBUG_MESA_OGL_TRACE SYS_CFLAGS.$(SUPPORT_LINUX_X86_WRITECOMBINE) += -DSUPPORT_LINUX_X86_WRITECOMBINE @@ -128,19 +144,33 @@ SYS_CFLAGS.$(SUPPORT_SGX_TILING) += -DSUPPORT_SGX_TILING SYS_CFLAGS.$(TRANSFER_QUEUE) += -DTRANSFER_QUEUE SYS_CFLAGS.$(SUPPORT_SGX_MMU_DUMMY_PAGE) += -DSUPPORT_SGX_MMU_DUMMY_PAGE +SYS_CFLAGS.$(PVRSRV_DUMP_MK_TRACE) += -DPVRSRV_DUMP_MK_TRACE SYS_CFLAGS.$(PVRSRV_USSE_EDM_STATUS_DEBUG) += -DPVRSRV_USSE_EDM_STATUS_DEBUG +SYS_CFLAGS.$(USE_SUPPORT_STATUSVALS_DEBUG) += -DUSE_SUPPORT_STATUSVALS_DEBUG +SYS_CFLAGS.$(SGX_FAST_DPM_INIT) += -DSGX_FAST_DPM_INIT +SYS_CFLAGS.$(SGX_DISABLE_UKERNEL_SECONDARY_STATE) += -DSGX_DISABLE_UKERNEL_SECONDARY_STATE +SYS_CFLAGS.$(DBGBREAK_ON_SPM) += -DDBGBREAK_ON_SPM +SYS_CFLAGS.$(PVR_DBG_BREAK_ASSERT_FAIL) += -DPVR_DBG_BREAK_ASSERT_FAIL + +SYS_CFLAGS.$(NO_HARDWARE) += -DNO_HARDWARE SYS_CFLAGS.$(SUPPORT_DRI_DRM) += -DSUPPORT_DRI_DRM +SYS_CFLAGS.$(SUPPORT_DRI_DRM_EXT) += -DSUPPORT_DRI_DRM_EXT +SYS_CFLAGS.$(USE_PRIMARY_SURFACE_IN_FLIP_CHAIN) += -DUSE_PRIMARY_SURFACE_IN_FLIP_CHAIN SYS_CFLAGS.$(SYS_USING_INTERRUPTS) += -DSYS_USING_INTERRUPTS SYS_CFLAGS.$(SUPPORT_HW_RECOVERY) += -DSUPPORT_HW_RECOVERY SYS_CFLAGS.$(SUPPORT_ACTIVE_POWER_MANAGEMENT) += -DSUPPORT_ACTIVE_POWER_MANAGEMENT +ifeq ("$(PDUMP)", "1") +SUPPORT_DBGDRV_EVENT_OBJECTS ?=1 +SYS_CFLAGS.$(SUPPORT_DBGDRV_EVENT_OBJECTS) += -DSUPPORT_DBGDRV_EVENT_OBJECTS +endif + SYS_CFLAGS.$(SUPPORT_SECURE_HANDLES) += -DPVR_SECURE_HANDLES SYS_CFLAGS.$(SUPPORT_SECURE_FD_EXPORT) += -DPVR_SECURE_FD_EXPORT - SYS_CFLAGS.$(USE_PTHREADS) += -DUSE_PTHREADS SYS_CFLAGS.$(USE_GCC__thread_KEYWORD) += -DUSE_GCC__thread_KEYWORD SYS_CFLAGS.$(OPTIMISE_NON_NPTL_SINGLE_THREAD_TLS_LOOKUP) += -DOPTIMISE_NON_NPTL_SINGLE_THREAD_TLS_LOOKUP @@ -159,6 +189,22 @@ SYS_CFLAGS.$(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) += -DSUPPORT_SGX_LOW_LATENCY_SC SYS_CFLAGS.$(SUPPORT_LINUX_X86_PAT) += -DSUPPORT_LINUX_X86_PAT +SYS_CFLAGS.$(SUPPORT_CPU_CACHED_BUFFERS) += -DSUPPORT_CPU_CACHED_BUFFERS +SYS_CFLAGS.$(SUPPORT_CACHE_LINE_FLUSH) += -DSUPPORT_CACHE_LINE_FLUSH + + +SYS_CFLAGS.$(SUPPORT_CACHEFLUSH_ON_ALLOC) += -DSUPPORT_CACHEFLUSH_ON_ALLOC +SYS_CFLAGS.$(SUPPORT_MEMINFO_IDS) += -DSUPPORT_MEMINFO_IDS + +SYS_CFLAGS.$(SUPPORT_SGX_EDM_MEMORY_DEBUG) += -DSUPPORT_SGX_EDM_MEMORY_DEBUG + +SYS_CFLAGS.$(SUPPORT_ANDROID_PLATFORM) += -DSUPPORT_ANDROID_PLATFORM +SYS_CFLAGS.$(SUPPORT_GRAPHICS_HAL) += -DSUPPORT_GRAPHICS_HAL +SYS_CFLAGS.$(SUPPORT_GRAPHICS_HAL) += -DGRALLOC_VARIANT="\"$(GRALLOC_VARIANT)\"" + +SYS_CFLAGS += -DDEBUG_LOG_PATH_TRUNCATE=\"$(EURASIAROOT)\" +SYS_CFLAGS.$(PVR_PROC_USE_SEQ_FILE) += -DPVR_PROC_USE_SEQ_FILE + SYS_CFLAGS.$(SUPPORT_LINUX_USING_WORKQUEUES) += -DPVR_LINUX_USING_WORKQUEUES \ -DPVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE diff --git a/include4/servicesext.h b/include4/servicesext.h index 812e46b..2b28c20 100644 --- a/include4/servicesext.h +++ b/include4/servicesext.h @@ -89,20 +89,6 @@ typedef enum _PVRSRV_DEVICE_CLASS_ } PVRSRV_DEVICE_CLASS; - -typedef enum _PVRSRV_POWER_STATE_ -{ - PVRSRV_POWER_Unspecified = -1, - PVRSRV_POWER_STATE_D0 = 0, - PVRSRV_POWER_STATE_D1 = 1, - PVRSRV_POWER_STATE_D2 = 2, - PVRSRV_POWER_STATE_D3 = 3, - PVRSRV_POWER_STATE_D4 = 4, - - PVRSRV_POWER_STATE_FORCE_I32 = 0x7fffffff - -} PVR_POWER_STATE, *PPVR_POWER_STATE; - typedef enum _PVRSRV_SYS_POWER_STATE_ { PVRSRV_SYS_POWER_STATE_Unspecified = -1, @@ -129,11 +115,21 @@ typedef enum _PVRSRV_DEV_POWER_STATE_ } PVRSRV_DEV_POWER_STATE, *PPVRSRV_DEV_POWER_STATE; -typedef PVRSRV_ERROR (*PFN_PRE_POWER) (IMG_HANDLE, PVR_POWER_STATE, PVR_POWER_STATE); -typedef PVRSRV_ERROR (*PFN_POST_POWER) (IMG_HANDLE, PVR_POWER_STATE, PVR_POWER_STATE); +typedef PVRSRV_ERROR (*PFN_PRE_POWER) (IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); +typedef PVRSRV_ERROR (*PFN_POST_POWER) (IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); + + +typedef PVRSRV_ERROR (*PFN_PRE_CLOCKSPEED_CHANGE) (IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); +typedef PVRSRV_ERROR (*PFN_POST_CLOCKSPEED_CHANGE) (IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); -typedef PVRSRV_ERROR (*PFN_PRE_CLOCKSPEED_CHANGE) (IMG_HANDLE, IMG_BOOL, PVR_POWER_STATE); -typedef PVRSRV_ERROR (*PFN_POST_CLOCKSPEED_CHANGE) (IMG_HANDLE, IMG_BOOL, PVR_POWER_STATE); typedef enum _PVRSRV_PIXEL_FORMAT_ { diff --git a/services4/include/kerneldisplay.h b/services4/include/kerneldisplay.h index 1f7b9ba..f761ee3 100644 --- a/services4/include/kerneldisplay.h +++ b/services4/include/kerneldisplay.h @@ -98,7 +98,7 @@ typedef IMG_VOID (*PFN_DC_CMD_COMPLETE)(IMG_HANDLE, IMG_BOOL); typedef PVRSRV_ERROR (*PFN_DC_REGISTER_SYS_ISR)(PFN_ISR_HANDLER, IMG_VOID*, IMG_UINT32, IMG_UINT32); typedef PVRSRV_ERROR (*PFN_DC_REGISTER_POWER)(IMG_UINT32, PFN_PRE_POWER, PFN_POST_POWER, PFN_PRE_CLOCKSPEED_CHANGE, PFN_POST_CLOCKSPEED_CHANGE, - IMG_HANDLE, PVR_POWER_STATE, PVR_POWER_STATE); + IMG_HANDLE, PVRSRV_DEV_POWER_STATE, PVRSRV_DEV_POWER_STATE); typedef struct PVRSRV_DC_DISP2SRV_KMJTABLE_TAG { diff --git a/services4/srvkm/common/power.c b/services4/srvkm/common/power.c index 0f8c0f1..b9048b5 100644 --- a/services4/srvkm/common/power.c +++ b/services4/srvkm/common/power.c @@ -27,6 +27,16 @@ #include "services_headers.h" #include "pdump_km.h" +#include "lists.h" + +DECLARE_LIST_ANY_VA(PVRSRV_POWER_DEV); +DECLARE_LIST_ANY_VA_2(PVRSRV_POWER_DEV, PVRSRV_ERROR, PVRSRV_OK); +DECLARE_LIST_INSERT(PVRSRV_POWER_DEV); +DECLARE_LIST_REMOVE(PVRSRV_POWER_DEV); + +IMG_VOID* MatchPowerDeviceIndex_AnyVaCb(PVRSRV_POWER_DEV *psPowerDev, va_list va); + + static IMG_BOOL gbInitServerRunning = IMG_FALSE; static IMG_BOOL gbInitServerRan = IMG_FALSE; static IMG_BOOL gbInitSuccessful = IMG_FALSE; @@ -80,9 +90,9 @@ IMG_BOOL PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_STATE eInitServerState) return bReturnVal; } -static IMG_BOOL _IsSystemStatePowered(PVR_POWER_STATE eSystemPowerState) +static IMG_BOOL _IsSystemStatePowered(PVRSRV_SYS_POWER_STATE eSystemPowerState) { - return (IMG_BOOL)(eSystemPowerState < PVRSRV_POWER_STATE_D2); + return (IMG_BOOL)(eSystemPowerState < PVRSRV_SYS_POWER_STATE_D2); } @@ -99,11 +109,7 @@ PVRSRV_ERROR PVRSRVPowerLock(IMG_UINT32 ui32CallerID, ui32Timeout *= 60; #endif - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); #if defined(SYS_CUSTOM_POWERLOCK_WRAP) eError = SysPowerLockWrap(psSysData); @@ -161,124 +167,146 @@ IMG_VOID PVRSRVPowerUnlock(IMG_UINT32 ui32CallerID) } -static -PVRSRV_ERROR PVRSRVDevicePrePowerStateKM(IMG_BOOL bAllDevices, - IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVDevicePrePowerStateKM_AnyVaCb(PVRSRV_POWER_DEV *psPowerDevice, va_list va) { - PVRSRV_ERROR eError; - SYS_DATA *psSysData; - PVRSRV_POWER_DEV *psPowerDevice; - PVR_POWER_STATE eNewDevicePowerState; + PVRSRV_DEV_POWER_STATE eNewDevicePowerState; + PVRSRV_ERROR eError; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - return eError; - } + + IMG_BOOL bAllDevices; + IMG_UINT32 ui32DeviceIndex; + PVRSRV_DEV_POWER_STATE eNewPowerState; - psPowerDevice = psSysData->psPowerDeviceList; - while (psPowerDevice) + bAllDevices = va_arg(va, IMG_BOOL); + ui32DeviceIndex = va_arg(va, IMG_UINT32); + eNewPowerState = va_arg(va, PVRSRV_DEV_POWER_STATE); + + if (bAllDevices || (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) { - if (bAllDevices || (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) + eNewDevicePowerState = (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) ? + psPowerDevice->eDefaultPowerState : eNewPowerState; + + if (psPowerDevice->eCurrentPowerState != eNewDevicePowerState) { - eNewDevicePowerState = (eNewPowerState == PVRSRV_POWER_Unspecified) ? - psPowerDevice->eDefaultPowerState : eNewPowerState; - - if (psPowerDevice->eCurrentPowerState != eNewDevicePowerState) + if (psPowerDevice->pfnPrePower != IMG_NULL) { - if (psPowerDevice->pfnPrePower != IMG_NULL) - { - - eError = psPowerDevice->pfnPrePower(psPowerDevice->hDevCookie, - eNewDevicePowerState, - psPowerDevice->eCurrentPowerState); - if (eError != PVRSRV_OK) - { - return eError; - } - } - - eError = SysDevicePrePowerState(psPowerDevice->ui32DeviceIndex, - eNewDevicePowerState, - psPowerDevice->eCurrentPowerState); + eError = psPowerDevice->pfnPrePower(psPowerDevice->hDevCookie, + eNewDevicePowerState, + psPowerDevice->eCurrentPowerState); if (eError != PVRSRV_OK) { return eError; } } - } - psPowerDevice = psPowerDevice->psNext; + + eError = SysDevicePrePowerState(psPowerDevice->ui32DeviceIndex, + eNewDevicePowerState, + psPowerDevice->eCurrentPowerState); + if (eError != PVRSRV_OK) + { + return eError; + } + } } - return PVRSRV_OK; + return PVRSRV_OK; } - static -PVRSRV_ERROR PVRSRVDevicePostPowerStateKM(IMG_BOOL bAllDevices, - IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVDevicePrePowerStateKM(IMG_BOOL bAllDevices, + IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState) { PVRSRV_ERROR eError; SYS_DATA *psSysData; - PVRSRV_POWER_DEV *psPowerDevice; - PVR_POWER_STATE eNewDevicePowerState; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); - psPowerDevice = psSysData->psPowerDeviceList; - while (psPowerDevice) + eError = List_PVRSRV_POWER_DEV_PVRSRV_ERROR_Any_va(psSysData->psPowerDeviceList, + PVRSRVDevicePrePowerStateKM_AnyVaCb, + bAllDevices, + ui32DeviceIndex, + eNewPowerState); + + return eError; +} + +PVRSRV_ERROR PVRSRVDevicePostPowerStateKM_AnyVaCb(PVRSRV_POWER_DEV *psPowerDevice, va_list va) +{ + PVRSRV_DEV_POWER_STATE eNewDevicePowerState; + PVRSRV_ERROR eError; + + + IMG_BOOL bAllDevices; + IMG_UINT32 ui32DeviceIndex; + PVRSRV_DEV_POWER_STATE eNewPowerState; + + + bAllDevices = va_arg(va, IMG_BOOL); + ui32DeviceIndex = va_arg(va, IMG_UINT32); + eNewPowerState = va_arg(va, PVRSRV_DEV_POWER_STATE); + + if (bAllDevices || (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) { - if (bAllDevices || (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) + eNewDevicePowerState = (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) ? + psPowerDevice->eDefaultPowerState : eNewPowerState; + + if (psPowerDevice->eCurrentPowerState != eNewDevicePowerState) { - eNewDevicePowerState = (eNewPowerState == PVRSRV_POWER_Unspecified) ? - psPowerDevice->eDefaultPowerState : eNewPowerState; + + eError = SysDevicePostPowerState(psPowerDevice->ui32DeviceIndex, + eNewDevicePowerState, + psPowerDevice->eCurrentPowerState); + if (eError != PVRSRV_OK) + { + return eError; + } - if (psPowerDevice->eCurrentPowerState != eNewDevicePowerState) + if (psPowerDevice->pfnPostPower != IMG_NULL) { - eError = SysDevicePostPowerState(psPowerDevice->ui32DeviceIndex, - eNewDevicePowerState, - psPowerDevice->eCurrentPowerState); + eError = psPowerDevice->pfnPostPower(psPowerDevice->hDevCookie, + eNewDevicePowerState, + psPowerDevice->eCurrentPowerState); if (eError != PVRSRV_OK) { return eError; } - - if (psPowerDevice->pfnPostPower != IMG_NULL) - { - - eError = psPowerDevice->pfnPostPower(psPowerDevice->hDevCookie, - eNewDevicePowerState, - psPowerDevice->eCurrentPowerState); - if (eError != PVRSRV_OK) - { - return eError; - } - } - - psPowerDevice->eCurrentPowerState = eNewDevicePowerState; } - } - psPowerDevice = psPowerDevice->psNext; + psPowerDevice->eCurrentPowerState = eNewDevicePowerState; + } } - return PVRSRV_OK; } +static +PVRSRV_ERROR PVRSRVDevicePostPowerStateKM(IMG_BOOL bAllDevices, + IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState) +{ + PVRSRV_ERROR eError; + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + + + eError = List_PVRSRV_POWER_DEV_PVRSRV_ERROR_Any_va(psSysData->psPowerDeviceList, + PVRSRVDevicePostPowerStateKM_AnyVaCb, + bAllDevices, + ui32DeviceIndex, + eNewPowerState); + + return eError; +} + -PVRSRV_ERROR PVRSRVSetDevicePowerStateCoreKM(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVSetDevicePowerStateCoreKM(IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState) { PVRSRV_ERROR eError; eError = PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex, eNewPowerState); @@ -293,19 +321,15 @@ PVRSRV_ERROR PVRSRVSetDevicePowerStateCoreKM(IMG_UINT32 ui32DeviceIndex, IMG_EXPORT -PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - IMG_UINT32 ui32CallerID, - IMG_BOOL bRetainMutex) +PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState, + IMG_UINT32 ui32CallerID, + IMG_BOOL bRetainMutex) { PVRSRV_ERROR eError; SYS_DATA *psSysData; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); eError = PVRSRVPowerLock(ui32CallerID, IMG_FALSE); if(eError != PVRSRV_OK) @@ -314,19 +338,19 @@ PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, } #if defined(PDUMP) - if (eNewPowerState == PVRSRV_POWER_Unspecified) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) { - eError = PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex, PVRSRV_POWER_STATE_D0); + eError = PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex, PVRSRV_DEV_POWER_STATE_ON); if(eError != PVRSRV_OK) { goto Exit; } - eError = PVRSRVDevicePostPowerStateKM(IMG_FALSE, ui32DeviceIndex, PVRSRV_POWER_STATE_D0); + eError = PVRSRVDevicePostPowerStateKM(IMG_FALSE, ui32DeviceIndex, PVRSRV_DEV_POWER_STATE_ON); if (eError != PVRSRV_OK) { @@ -340,7 +364,7 @@ PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, eError = PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex, eNewPowerState); if(eError != PVRSRV_OK) { - if (eNewPowerState == PVRSRV_POWER_Unspecified) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) { PDUMPRESUME(); } @@ -349,7 +373,7 @@ PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, eError = PVRSRVDevicePostPowerStateKM(IMG_FALSE, ui32DeviceIndex, eNewPowerState); - if (eNewPowerState == PVRSRV_POWER_Unspecified) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_DEFAULT) { PDUMPRESUME(); } @@ -372,17 +396,13 @@ Exit: IMG_EXPORT -PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVRSRV_SYS_POWER_STATE eNewSysPowerState) { - PVRSRV_ERROR eError; - SYS_DATA *psSysData; - PVR_POWER_STATE eNewDevicePowerState; + PVRSRV_ERROR eError; + SYS_DATA *psSysData; + PVRSRV_DEV_POWER_STATE eNewDevicePowerState; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); eError = PVRSRVPowerLock(KERNEL_ID, IMG_TRUE); @@ -391,17 +411,17 @@ PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVR_POWER_STATE eNewPowerState) return eError; } - if (_IsSystemStatePowered(eNewPowerState) != + if (_IsSystemStatePowered(eNewSysPowerState) != _IsSystemStatePowered(psSysData->eCurrentPowerState)) { - if (_IsSystemStatePowered(eNewPowerState)) + if (_IsSystemStatePowered(eNewSysPowerState)) { - eNewDevicePowerState = PVRSRV_POWER_Unspecified; + eNewDevicePowerState = PVRSRV_DEV_POWER_STATE_DEFAULT; } else { - eNewDevicePowerState = PVRSRV_POWER_STATE_D3; + eNewDevicePowerState = PVRSRV_DEV_POWER_STATE_OFF; } @@ -412,10 +432,10 @@ PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVR_POWER_STATE eNewPowerState) } } - if (eNewPowerState != psSysData->eCurrentPowerState) + if (eNewSysPowerState != psSysData->eCurrentPowerState) { - eError = SysSystemPrePowerState(eNewPowerState); + eError = SysSystemPrePowerState(eNewSysPowerState); if (eError != PVRSRV_OK) { goto ErrorExit; @@ -428,10 +448,10 @@ ErrorExit: PVR_DPF((PVR_DBG_ERROR, "PVRSRVSystemPrePowerStateKM: Transition from %d to %d FAILED 0x%x", - psSysData->eCurrentPowerState, eNewPowerState, eError)); + psSysData->eCurrentPowerState, eNewSysPowerState, eError)); - psSysData->eFailedPowerState = eNewPowerState; + psSysData->eFailedPowerState = eNewSysPowerState; PVRSRVPowerUnlock(KERNEL_ID); @@ -440,39 +460,35 @@ ErrorExit: IMG_EXPORT -PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(PVRSRV_SYS_POWER_STATE eNewSysPowerState) { - PVRSRV_ERROR eError; - SYS_DATA *psSysData; - PVR_POWER_STATE eNewDevicePowerState; + PVRSRV_ERROR eError = PVRSRV_OK; + SYS_DATA *psSysData; + PVRSRV_DEV_POWER_STATE eNewDevicePowerState; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - goto Exit; - } + SysAcquireData(&psSysData); - if (eNewPowerState != psSysData->eCurrentPowerState) + if (eNewSysPowerState != psSysData->eCurrentPowerState) { - eError = SysSystemPostPowerState(eNewPowerState); + eError = SysSystemPostPowerState(eNewSysPowerState); if (eError != PVRSRV_OK) { goto Exit; } } - if (_IsSystemStatePowered(eNewPowerState) != + if (_IsSystemStatePowered(eNewSysPowerState) != _IsSystemStatePowered(psSysData->eCurrentPowerState)) { - if (_IsSystemStatePowered(eNewPowerState)) + if (_IsSystemStatePowered(eNewSysPowerState)) { - eNewDevicePowerState = PVRSRV_POWER_Unspecified; + eNewDevicePowerState = PVRSRV_DEV_POWER_STATE_DEFAULT; } else { - eNewDevicePowerState = PVRSRV_POWER_STATE_D3; + eNewDevicePowerState = PVRSRV_DEV_POWER_STATE_OFF; } @@ -483,17 +499,17 @@ PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(PVR_POWER_STATE eNewPowerState) } } - PVR_DPF((PVR_DBG_WARNING, + PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVSystemPostPowerStateKM: System Power Transition from %d to %d OK", - psSysData->eCurrentPowerState, eNewPowerState)); + psSysData->eCurrentPowerState, eNewSysPowerState)); - psSysData->eCurrentPowerState = eNewPowerState; + psSysData->eCurrentPowerState = eNewSysPowerState; Exit: PVRSRVPowerUnlock(KERNEL_ID); - if (_IsSystemStatePowered(eNewPowerState) && + if (_IsSystemStatePowered(eNewSysPowerState) && PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL)) { @@ -507,31 +523,27 @@ Exit: IMG_EXPORT -PVRSRV_ERROR PVRSRVSetPowerStateKM(PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE eNewSysPowerState) { PVRSRV_ERROR eError; SYS_DATA *psSysData; - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); - eError = PVRSRVSystemPrePowerStateKM(eNewPowerState); + eError = PVRSRVSystemPrePowerStateKM(eNewSysPowerState); if(eError != PVRSRV_OK) { goto ErrorExit; } - eError = PVRSRVSystemPostPowerStateKM(eNewPowerState); + eError = PVRSRVSystemPostPowerStateKM(eNewSysPowerState); if(eError != PVRSRV_OK) { goto ErrorExit; } - psSysData->eFailedPowerState = PVRSRV_POWER_Unspecified; + psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; return PVRSRV_OK; @@ -539,10 +551,10 @@ ErrorExit: PVR_DPF((PVR_DBG_ERROR, "PVRSRVSetPowerStateKM: Transition from %d to %d FAILED 0x%x", - psSysData->eCurrentPowerState, eNewPowerState, eError)); + psSysData->eCurrentPowerState, eNewSysPowerState, eError)); - psSysData->eFailedPowerState = eNewPowerState; + psSysData->eFailedPowerState = eNewSysPowerState; return eError; } @@ -554,8 +566,8 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, PFN_PRE_CLOCKSPEED_CHANGE pfnPreClockSpeedChange, PFN_POST_CLOCKSPEED_CHANGE pfnPostClockSpeedChange, IMG_HANDLE hDevCookie, - PVR_POWER_STATE eCurrentPowerState, - PVR_POWER_STATE eDefaultPowerState) + PVRSRV_DEV_POWER_STATE eCurrentPowerState, + PVRSRV_DEV_POWER_STATE eDefaultPowerState) { PVRSRV_ERROR eError; SYS_DATA *psSysData; @@ -567,11 +579,7 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, return PVRSRVRemovePowerDevice(ui32DeviceIndex); } - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); eError = OSAllocMem( PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_POWER_DEV), @@ -594,8 +602,7 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, psPowerDevice->eDefaultPowerState = eDefaultPowerState; - psPowerDevice->psNext = psSysData->psPowerDeviceList; - psSysData->psPowerDeviceList = psPowerDevice; + List_PVRSRV_POWER_DEV_Insert(&(psSysData->psPowerDeviceList), psPowerDevice); return (PVRSRV_OK); } @@ -603,44 +610,22 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, PVRSRV_ERROR PVRSRVRemovePowerDevice (IMG_UINT32 ui32DeviceIndex) { - PVRSRV_ERROR eError; SYS_DATA *psSysData; - PVRSRV_POWER_DEV *psCurrent, *psPrevious; + PVRSRV_POWER_DEV *psPowerDev; - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return eError; - } + SysAcquireData(&psSysData); - psCurrent = psSysData->psPowerDeviceList; - psPrevious = IMG_NULL; + psPowerDev = (PVRSRV_POWER_DEV*) + List_PVRSRV_POWER_DEV_Any_va(psSysData->psPowerDeviceList, + MatchPowerDeviceIndex_AnyVaCb, + ui32DeviceIndex); - while (psCurrent) + if (psPowerDev) { - if (psCurrent->ui32DeviceIndex == ui32DeviceIndex) - { - - if (psPrevious) - { - psPrevious->psNext = psCurrent->psNext; - } - else - { - - psSysData->psPowerDeviceList = psCurrent->psNext; - } - - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_POWER_DEV), psCurrent, IMG_NULL); - - break; - } - else - { - psPrevious = psCurrent; - psCurrent = psCurrent->psNext; - } + List_PVRSRV_POWER_DEV_Remove(psPowerDev); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_POWER_DEV), psPowerDev, IMG_NULL); + } return (PVRSRV_OK); @@ -650,15 +635,10 @@ PVRSRV_ERROR PVRSRVRemovePowerDevice (IMG_UINT32 ui32DeviceIndex) IMG_EXPORT IMG_BOOL PVRSRVIsDevicePowered(IMG_UINT32 ui32DeviceIndex) { - PVRSRV_ERROR eError; - SYS_DATA *psSysData; + SYS_DATA *psSysData; PVRSRV_POWER_DEV *psPowerDevice; - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - return IMG_FALSE; - } + SysAcquireData(&psSysData); if (OSIsResourceLocked(&psSysData->sPowerStateChangeResource, KERNEL_ID) || OSIsResourceLocked(&psSysData->sPowerStateChangeResource, ISR_ID)) @@ -666,19 +646,12 @@ IMG_BOOL PVRSRVIsDevicePowered(IMG_UINT32 ui32DeviceIndex) return IMG_FALSE; } - psPowerDevice = psSysData->psPowerDeviceList; - while (psPowerDevice) - { - if (psPowerDevice->ui32DeviceIndex == ui32DeviceIndex) - { - return (IMG_BOOL)(psPowerDevice->eCurrentPowerState == PVRSRV_POWER_STATE_D0); - } - - psPowerDevice = psPowerDevice->psNext; - } - - - return IMG_FALSE; + psPowerDevice = (PVRSRV_POWER_DEV*) + List_PVRSRV_POWER_DEV_Any_va(psSysData->psPowerDeviceList, + MatchPowerDeviceIndex_AnyVaCb, + ui32DeviceIndex); + return (psPowerDevice && (psPowerDevice->eCurrentPowerState == PVRSRV_DEV_POWER_STATE_ON)) + ? IMG_TRUE : IMG_FALSE; } @@ -687,17 +660,12 @@ PVRSRV_ERROR PVRSRVDevicePreClockSpeedChange(IMG_UINT32 ui32DeviceIndex, IMG_VOID *pvInfo) { PVRSRV_ERROR eError = PVRSRV_OK; - SYS_DATA *psSysData; + SYS_DATA *psSysData; PVRSRV_POWER_DEV *psPowerDevice; PVR_UNREFERENCED_PARAMETER(pvInfo); - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return eError; - } - + SysAcquireData(&psSysData); if (bIdleDevice) { @@ -711,27 +679,22 @@ PVRSRV_ERROR PVRSRVDevicePreClockSpeedChange(IMG_UINT32 ui32DeviceIndex, } - psPowerDevice = psSysData->psPowerDeviceList; - while (psPowerDevice) + psPowerDevice = (PVRSRV_POWER_DEV*) + List_PVRSRV_POWER_DEV_Any_va(psSysData->psPowerDeviceList, + MatchPowerDeviceIndex_AnyVaCb, + ui32DeviceIndex); + + if (psPowerDevice && psPowerDevice->pfnPostClockSpeedChange) { - if (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex) - { - if (psPowerDevice->pfnPreClockSpeedChange) + eError = psPowerDevice->pfnPreClockSpeedChange(psPowerDevice->hDevCookie, + bIdleDevice, + psPowerDevice->eCurrentPowerState); + if (eError != PVRSRV_OK) { - eError = psPowerDevice->pfnPreClockSpeedChange(psPowerDevice->hDevCookie, - bIdleDevice, - psPowerDevice->eCurrentPowerState); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR, - "PVRSRVDevicePreClockSpeedChange : Device %lu failed, error:0x%lx", - ui32DeviceIndex, eError)); - break; - } + PVR_DPF((PVR_DBG_ERROR, + "PVRSRVDevicePreClockSpeedChange : Device %lu failed, error:0x%lx", + ui32DeviceIndex, eError)); } - } - - psPowerDevice = psPowerDevice->psNext; } if (bIdleDevice && eError != PVRSRV_OK) @@ -753,35 +716,28 @@ IMG_VOID PVRSRVDevicePostClockSpeedChange(IMG_UINT32 ui32DeviceIndex, PVR_UNREFERENCED_PARAMETER(pvInfo); - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - return; - } + SysAcquireData(&psSysData); - psPowerDevice = psSysData->psPowerDeviceList; - while (psPowerDevice) + psPowerDevice = (PVRSRV_POWER_DEV*) + List_PVRSRV_POWER_DEV_Any_va(psSysData->psPowerDeviceList, + MatchPowerDeviceIndex_AnyVaCb, + ui32DeviceIndex); + + if (psPowerDevice && psPowerDevice->pfnPostClockSpeedChange) { - if (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex) + eError = psPowerDevice->pfnPostClockSpeedChange(psPowerDevice->hDevCookie, + bIdleDevice, + psPowerDevice->eCurrentPowerState); + if (eError != PVRSRV_OK) { - if (psPowerDevice->pfnPostClockSpeedChange) - { - eError = psPowerDevice->pfnPostClockSpeedChange(psPowerDevice->hDevCookie, - bIdleDevice, - psPowerDevice->eCurrentPowerState); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR, - "PVRSRVDevicePostClockSpeedChange : Device %lu failed, error:0x%lx", - ui32DeviceIndex, eError)); - } - } + PVR_DPF((PVR_DBG_ERROR, + "PVRSRVDevicePostClockSpeedChange : Device %lu failed, error:0x%lx", + ui32DeviceIndex, eError)); } - - psPowerDevice = psPowerDevice->psNext; } + if (bIdleDevice) { diff --git a/services4/srvkm/common/pvrsrv.c b/services4/srvkm/common/pvrsrv.c index 7b9b465..0cd40da 100644 --- a/services4/srvkm/common/pvrsrv.c +++ b/services4/srvkm/common/pvrsrv.c @@ -32,6 +32,24 @@ #include "ra.h" #include "pvrversion.h" + +#include "lists.h" + +DECLARE_LIST_ANY_VA_2(BM_CONTEXT, PVRSRV_ERROR, PVRSRV_OK); + +DECLARE_LIST_FOR_EACH_VA(BM_HEAP); + +DECLARE_LIST_ANY_2(PVRSRV_DEVICE_NODE, PVRSRV_ERROR, PVRSRV_OK); +DECLARE_LIST_ANY_VA(PVRSRV_DEVICE_NODE); +DECLARE_LIST_ANY_VA_2(PVRSRV_DEVICE_NODE, PVRSRV_ERROR, PVRSRV_OK); +DECLARE_LIST_FOR_EACH_VA(PVRSRV_DEVICE_NODE); +DECLARE_LIST_FOR_EACH(PVRSRV_DEVICE_NODE); +DECLARE_LIST_INSERT(PVRSRV_DEVICE_NODE); +DECLARE_LIST_REMOVE(PVRSRV_DEVICE_NODE); + +IMG_VOID* MatchDeviceKM_AnyVaCb(PVRSRV_DEVICE_NODE* psDeviceNode, va_list va); + + PVRSRV_ERROR AllocateDeviceID(SYS_DATA *psSysData, IMG_UINT32 *pui32DevID) { SYS_DEVICE_ID* psDeviceWalker; @@ -97,7 +115,7 @@ PVRSRV_ERROR FreeDeviceID(SYS_DATA *psSysData, IMG_UINT32 ui32DevID) IMG_EXPORT IMG_UINT32 ReadHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset) { - return *(volatile IMG_UINT32*)((IMG_UINT32)pvLinRegBaseAddr+ui32Offset); + return *(volatile IMG_UINT32*)((IMG_UINTPTR_T)pvLinRegBaseAddr+ui32Offset); } #endif @@ -108,7 +126,7 @@ IMG_VOID WriteHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset, IMG_UINT3 { PVR_DPF((PVR_DBG_MESSAGE,"WriteHWReg Base:%x, Offset: %x, Value %x",pvLinRegBaseAddr,ui32Offset,ui32Value)); - *(IMG_UINT32*)((IMG_UINT32)pvLinRegBaseAddr+ui32Offset) = ui32Value; + *(IMG_UINT32*)((IMG_UINTPTR_T)pvLinRegBaseAddr+ui32Offset) = ui32Value; } #endif @@ -126,14 +144,29 @@ IMG_VOID WriteHWRegs(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Count, PVRSRV_HW } #endif +IMG_VOID PVRSRVEnumerateDevicesKM_ForEachVaCb(PVRSRV_DEVICE_NODE *psDeviceNode, va_list va) +{ + IMG_UINT *pui32DevCount; + PVRSRV_DEVICE_IDENTIFIER **ppsDevIdList; + + pui32DevCount = va_arg(va, IMG_UINT*); + ppsDevIdList = va_arg(va, PVRSRV_DEVICE_IDENTIFIER**); + + if (psDeviceNode->sDevId.eDeviceType != PVRSRV_DEVICE_TYPE_EXT) + { + *(*ppsDevIdList) = psDeviceNode->sDevId; + (*ppsDevIdList)++; + (*pui32DevCount)++; + } +} + + IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevicesKM(IMG_UINT32 *pui32NumDevices, PVRSRV_DEVICE_IDENTIFIER *psDevIdList) { - PVRSRV_ERROR eError; SYS_DATA *psSysData; - PVRSRV_DEVICE_NODE *psDeviceNode; IMG_UINT32 i; if (!pui32NumDevices || !psDevIdList) @@ -142,12 +175,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevicesKM(IMG_UINT32 *pui32NumDevices, return PVRSRV_ERROR_INVALID_PARAMS; } - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVEnumerateDevicesKM: Failed to get SysData")); - return eError; - } + SysAcquireData(&psSysData); @@ -163,19 +191,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevicesKM(IMG_UINT32 *pui32NumDevices, - psDeviceNode = psSysData->psDeviceNodeList; - for (i=0; psDeviceNode != IMG_NULL; i++) - { - - if(psDeviceNode->sDevId.eDeviceType != PVRSRV_DEVICE_TYPE_EXT) - { - - *psDevIdList++ = psDeviceNode->sDevId; - - (*pui32NumDevices)++; - } - psDeviceNode = psDeviceNode->psNext; - } + List_PVRSRV_DEVICE_NODE_ForEach_va(psSysData->psDeviceNodeList, + PVRSRVEnumerateDevicesKM_ForEachVaCb, + pui32NumDevices, + &psDevIdList); + return PVRSRV_OK; } @@ -213,12 +233,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) } - psSysData->eCurrentPowerState = PVRSRV_POWER_STATE_D0; - psSysData->eFailedPowerState = PVRSRV_POWER_Unspecified; - -#if defined(PDUMP) - psSysData->bPowerUpPDumped = IMG_FALSE; -#endif + psSysData->eCurrentPowerState = PVRSRV_SYS_POWER_STATE_D0; + psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, @@ -260,9 +276,11 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData) if(psSysData->psGlobalEventObject) { OSEventObjectDestroy(psSysData->psGlobalEventObject); - OSFreeMem( PVRSRV_PAGEABLE_SELECT, - sizeof(PVRSRV_EVENTOBJECT) , - psSysData->psGlobalEventObject, 0); + OSFreeMem( PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_EVENTOBJECT), + psSysData->psGlobalEventObject, + 0); + psSysData->psGlobalEventObject = IMG_NULL; } eError = PVRSRVHandleDeInit(); @@ -305,6 +323,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVRegisterDevice(PSYS_DATA psSysData, { 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); } @@ -322,8 +341,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVRegisterDevice(PSYS_DATA psSysData, AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex); - psDeviceNode->psNext = psSysData->psDeviceNodeList; - psSysData->psDeviceNodeList = psDeviceNode; + List_PVRSRV_DEVICE_NODE_Insert(&psSysData->psDeviceNodeList, psDeviceNode); *pui32DeviceIndex = psDeviceNode->sDevId.ui32DeviceIndex; @@ -340,31 +358,20 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInitialiseDevice (IMG_UINT32 ui32DevIndex) PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVInitialiseDevice")); - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitialiseDevice: Failed to get SysData")); - return(eError); - } + SysAcquireData(&psSysData); - psDeviceNode = psSysData->psDeviceNodeList; - - while (psDeviceNode) + psDeviceNode = (PVRSRV_DEVICE_NODE*) + List_PVRSRV_DEVICE_NODE_Any_va(psSysData->psDeviceNodeList, + MatchDeviceKM_AnyVaCb, + ui32DevIndex, + IMG_TRUE); + if(!psDeviceNode) { - if (psDeviceNode->sDevId.ui32DeviceIndex == ui32DevIndex) - { - goto FoundDevice; - } - psDeviceNode = psDeviceNode->psNext; + + PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitialiseDevice: requested device is not present")); + return PVRSRV_ERROR_INIT_FAILURE; } - - - PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitialiseDevice: requested device is not present")); - return PVRSRV_ERROR_INIT_FAILURE; - -FoundDevice: - PVR_ASSERT (psDeviceNode->ui32RefCount > 0); @@ -391,20 +398,39 @@ FoundDevice: } +PVRSRV_ERROR PVRSRVFinaliseSystem_SetPowerState_AnyCb(PVRSRV_DEVICE_NODE *psDeviceNode) +{ + PVRSRV_ERROR eError; + eError = PVRSRVSetDevicePowerStateKM(psDeviceNode->sDevId.ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE_DEFAULT, + KERNEL_ID, IMG_FALSE); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVFinaliseSystem: Failed PVRSRVSetDevicePowerStateKM call (device index: %d)", psDeviceNode->sDevId.ui32DeviceIndex)); + } + return eError; +} + +PVRSRV_ERROR PVRSRVFinaliseSystem_CompatCheck_AnyCb(PVRSRV_DEVICE_NODE *psDeviceNode) +{ + PVRSRV_ERROR eError; + eError = PVRSRVDevInitCompatCheck(psDeviceNode); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVFinaliseSystem: Failed PVRSRVDevInitCompatCheck call (device index: %d)", psDeviceNode->sDevId.ui32DeviceIndex)); + } + return eError; +} + + PVRSRV_ERROR IMG_CALLCONV PVRSRVFinaliseSystem(IMG_BOOL bInitSuccessful) { - PVRSRV_DEVICE_NODE *psDeviceNode; SYS_DATA *psSysData; PVRSRV_ERROR eError; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVFinaliseSystem")); - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVFinaliseSystem: Failed to get SysData")); - return(eError); - } + SysAcquireData(&psSysData); if (bInitSuccessful) { @@ -416,43 +442,32 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFinaliseSystem(IMG_BOOL bInitSuccessful) } - psDeviceNode = psSysData->psDeviceNodeList; - while (psDeviceNode) + eError = List_PVRSRV_DEVICE_NODE_PVRSRV_ERROR_Any(psSysData->psDeviceNodeList, + PVRSRVFinaliseSystem_SetPowerState_AnyCb); + if (eError != PVRSRV_OK) { - eError = PVRSRVSetDevicePowerStateKM(psDeviceNode->sDevId.ui32DeviceIndex, - PVRSRV_POWER_Unspecified, - KERNEL_ID, IMG_FALSE); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVFinaliseSystem: Failed PVRSRVSetDevicePowerStateKM call (device index: %d)", psDeviceNode->sDevId.ui32DeviceIndex)); - } - psDeviceNode = psDeviceNode->psNext; + return eError; } - psDeviceNode = psSysData->psDeviceNodeList; - while (psDeviceNode) + eError = List_PVRSRV_DEVICE_NODE_PVRSRV_ERROR_Any(psSysData->psDeviceNodeList, + PVRSRVFinaliseSystem_CompatCheck_AnyCb); + if (eError != PVRSRV_OK) { - if (psDeviceNode->pfnInitDeviceCompatCheck) - { - eError = PVRSRVDevInitCompatCheck(psDeviceNode); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVFinaliseSystem: Failed PVRSRVDevInitCompatCheck call (device index: %d)", psDeviceNode->sDevId.ui32DeviceIndex)); - return eError; - } - } - psDeviceNode = psDeviceNode->psNext; - + return eError; } - } + + + +#if !defined(SUPPORT_DRI_DRM) PDUMPENDINITPHASE(); +#endif return PVRSRV_OK; } @@ -461,7 +476,31 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFinaliseSystem(IMG_BOOL bInitSuccessful) PVRSRV_ERROR PVRSRVDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode) { - return psDeviceNode->pfnInitDeviceCompatCheck(psDeviceNode); + if (psDeviceNode->pfnInitDeviceCompatCheck) + return psDeviceNode->pfnInitDeviceCompatCheck(psDeviceNode); + else + return PVRSRV_OK; +} + +IMG_VOID * PVRSRVAcquireDeviceDataKM_Match_AnyVaCb(PVRSRV_DEVICE_NODE *psDeviceNode, va_list va) +{ + PVRSRV_DEVICE_TYPE eDeviceType; + IMG_UINT32 ui32DevIndex; + + eDeviceType = va_arg(va, PVRSRV_DEVICE_TYPE); + ui32DevIndex = va_arg(va, IMG_UINT32); + + if ((eDeviceType != PVRSRV_DEVICE_TYPE_UNKNOWN && + psDeviceNode->sDevId.eDeviceType == eDeviceType) || + (eDeviceType == PVRSRV_DEVICE_TYPE_UNKNOWN && + psDeviceNode->sDevId.ui32DeviceIndex == ui32DevIndex)) + { + return psDeviceNode; + } + else + { + return IMG_NULL; + } } IMG_EXPORT @@ -471,49 +510,25 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAcquireDeviceDataKM (IMG_UINT32 ui32DevIndex, { PVRSRV_DEVICE_NODE *psDeviceNode; SYS_DATA *psSysData; - PVRSRV_ERROR eError; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVAcquireDeviceDataKM")); - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVAcquireDeviceDataKM: Failed to get SysData")); - return(eError); - } + SysAcquireData(&psSysData); - psDeviceNode = psSysData->psDeviceNodeList; + psDeviceNode = List_PVRSRV_DEVICE_NODE_Any_va(psSysData->psDeviceNodeList, + PVRSRVAcquireDeviceDataKM_Match_AnyVaCb, + eDeviceType, + ui32DevIndex); + - if (eDeviceType != PVRSRV_DEVICE_TYPE_UNKNOWN) + if (!psDeviceNode) { - while (psDeviceNode) - { - if (psDeviceNode->sDevId.eDeviceType == eDeviceType) - { - goto FoundDevice; - } - psDeviceNode = psDeviceNode->psNext; - } - } - else - { - while (psDeviceNode) - { - if (psDeviceNode->sDevId.ui32DeviceIndex == ui32DevIndex) - { - goto FoundDevice; - } - psDeviceNode = psDeviceNode->psNext; - } + + PVR_DPF((PVR_DBG_ERROR,"PVRSRVAcquireDeviceDataKM: requested device is not present")); + return PVRSRV_ERROR_INIT_FAILURE; } - - PVR_DPF((PVR_DBG_ERROR,"PVRSRVAcquireDeviceDataKM: requested device is not present")); - return PVRSRV_ERROR_INIT_FAILURE; - -FoundDevice: - PVR_ASSERT (psDeviceNode->ui32RefCount > 0); @@ -529,38 +544,27 @@ FoundDevice: PVRSRV_ERROR IMG_CALLCONV PVRSRVDeinitialiseDevice(IMG_UINT32 ui32DevIndex) { PVRSRV_DEVICE_NODE *psDeviceNode; - PVRSRV_DEVICE_NODE **ppsDevNode; SYS_DATA *psSysData; PVRSRV_ERROR eError; - eError = SysAcquireData(&psSysData); - if(eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVDeinitialiseDevice: Failed to get SysData")); - return(eError); - } + SysAcquireData(&psSysData); - ppsDevNode = &psSysData->psDeviceNodeList; - while(*ppsDevNode) + psDeviceNode = (PVRSRV_DEVICE_NODE*) + List_PVRSRV_DEVICE_NODE_Any_va(psSysData->psDeviceNodeList, + MatchDeviceKM_AnyVaCb, + ui32DevIndex, + IMG_TRUE); + + if (!psDeviceNode) { - if((*ppsDevNode)->sDevId.ui32DeviceIndex == ui32DevIndex) - { - psDeviceNode = *ppsDevNode; - goto FoundDevice; - } - ppsDevNode = &((*ppsDevNode)->psNext); + PVR_DPF((PVR_DBG_ERROR,"PVRSRVDeinitialiseDevice: requested device %d is not present", ui32DevIndex)); + return PVRSRV_ERROR_GENERIC; } - PVR_DPF((PVR_DBG_ERROR,"PVRSRVDeinitialiseDevice: requested device %d is not present", ui32DevIndex)); - - return PVRSRV_ERROR_GENERIC; - -FoundDevice: - eError = PVRSRVSetDevicePowerStateKM(ui32DevIndex, - PVRSRV_POWER_STATE_D3, + PVRSRV_DEV_POWER_STATE_OFF, KERNEL_ID, IMG_FALSE); if (eError != PVRSRV_OK) @@ -599,13 +603,14 @@ FoundDevice: psDeviceNode->hResManContext = IMG_NULL; - *ppsDevNode = psDeviceNode->psNext; + List_PVRSRV_DEVICE_NODE_Remove(psDeviceNode); - FreeDeviceID(psSysData, ui32DevIndex); + (IMG_VOID)FreeDeviceID(psSysData, ui32DevIndex); OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), psDeviceNode, IMG_NULL); + return (PVRSRV_OK); } @@ -617,21 +622,18 @@ PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr, IMG_UINT32 ui32Waitus, IMG_UINT32 ui32Tries) { - IMG_UINT32 uiMaxTime; - - uiMaxTime = ui32Tries * ui32Waitus; - - - LOOP_UNTIL_TIMEOUT(uiMaxTime) { - if((*pui32LinMemAddr & ui32Mask) == ui32Value) - { - return PVRSRV_OK; - } - OSWaitus(ui32Waitus); - } END_LOOP_UNTIL_TIMEOUT(); - + IMG_UINT32 uiMaxTime = ui32Tries * ui32Waitus; + LOOP_UNTIL_TIMEOUT(uiMaxTime) + { + if((*pui32LinMemAddr & ui32Mask) == ui32Value) + { + return PVRSRV_OK; + } + OSWaitus(ui32Waitus); + } END_LOOP_UNTIL_TIMEOUT(); + } return PVRSRV_ERROR_GENERIC; @@ -647,7 +649,7 @@ PVRSRV_ERROR PollForInterruptKM (IMG_UINT32 ui32Value, IMG_UINT32 ui32Waitus, IMG_UINT32 ui32Tries) { - IMG_UINT32 uiMaxTime; + IMG_UINT32 uiMaxTime; uiMaxTime = ui32Tries * ui32Waitus; @@ -660,18 +662,100 @@ PVRSRV_ERROR PollForInterruptKM (IMG_UINT32 ui32Value, return PVRSRV_OK; } OSWaitus(ui32Waitus); - } END_LOOP_UNTIL_TIMEOUT(); + } END_LOOP_UNTIL_TIMEOUT(); return PVRSRV_ERROR_GENERIC; } #endif +IMG_VOID PVRSRVGetMiscInfoKM_RA_GetStats_ForEachVaCb(BM_HEAP *psBMHeap, va_list va) +{ + IMG_CHAR **ppszStr; + IMG_UINT32 *pui32StrLen; + + ppszStr = va_arg(va, IMG_CHAR**); + pui32StrLen = va_arg(va, IMG_UINT32*); + + if(psBMHeap->pImportArena) + { + RA_GetStats(psBMHeap->pImportArena, + ppszStr, + pui32StrLen); + } + + if(psBMHeap->pVMArena) + { + RA_GetStats(psBMHeap->pVMArena, + ppszStr, + pui32StrLen); + } +} + +PVRSRV_ERROR PVRSRVGetMiscInfoKM_BMContext_AnyVaCb(BM_CONTEXT *psBMContext, va_list va) +{ + + IMG_UINT32 *pui32StrLen; + IMG_INT32 *pi32Count; + IMG_CHAR **ppszStr; + + pui32StrLen = va_arg(va, IMG_UINT32*); + pi32Count = va_arg(va, IMG_INT32*); + ppszStr = va_arg(va, IMG_CHAR**); + + CHECK_SPACE(*pui32StrLen); + *pi32Count = OSSNPrintf(*ppszStr, 100, "\nApplication Context (hDevMemContext) 0x%08X:\n", + (IMG_HANDLE)psBMContext); + UPDATE_SPACE(*ppszStr, *pi32Count, *pui32StrLen); + + List_BM_HEAP_ForEach_va(psBMContext->psBMHeap, + PVRSRVGetMiscInfoKM_RA_GetStats_ForEachVaCb, + ppszStr, + pui32StrLen); + return PVRSRV_OK; +} + + +PVRSRV_ERROR PVRSRVGetMiscInfoKM_Device_AnyVaCb(PVRSRV_DEVICE_NODE *psDeviceNode, va_list va) +{ + IMG_UINT32 *pui32StrLen; + IMG_INT32 *pi32Count; + IMG_CHAR **ppszStr; + + pui32StrLen = va_arg(va, IMG_UINT32*); + pi32Count = va_arg(va, IMG_INT32*); + ppszStr = va_arg(va, IMG_CHAR**); + + CHECK_SPACE(*pui32StrLen); + *pi32Count = OSSNPrintf(*ppszStr, 100, "\n\nDevice Type %d:\n", psDeviceNode->sDevId.eDeviceType); + UPDATE_SPACE(*ppszStr, *pi32Count, *pui32StrLen); + + + if(psDeviceNode->sDevMemoryInfo.pBMKernelContext) + { + CHECK_SPACE(*pui32StrLen); + *pi32Count = OSSNPrintf(*ppszStr, 100, "\nKernel Context:\n"); + UPDATE_SPACE(*ppszStr, *pi32Count, *pui32StrLen); + + + List_BM_HEAP_ForEach_va(psDeviceNode->sDevMemoryInfo.pBMKernelContext->psBMHeap, + PVRSRVGetMiscInfoKM_RA_GetStats_ForEachVaCb, + ppszStr, + pui32StrLen); + } + + + return List_BM_CONTEXT_PVRSRV_ERROR_Any_va(psDeviceNode->sDevMemoryInfo.pBMContext, + PVRSRVGetMiscInfoKM_BMContext_AnyVaCb, + pui32StrLen, + pi32Count, + ppszStr); +} + IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) { SYS_DATA *psSysData; - PVRSRV_ERROR eError; if(!psMiscInfo) { @@ -686,18 +770,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) |PVRSRV_MISC_INFO_CLOCKGATE_PRESENT |PVRSRV_MISC_INFO_MEMSTATS_PRESENT |PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT - |PVRSRV_MISC_INFO_DDKVERSION_PRESENT)) + |PVRSRV_MISC_INFO_DDKVERSION_PRESENT + |PVRSRV_MISC_INFO_CPUCACHEFLUSH_PRESENT)) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: invalid state request flags")); return PVRSRV_ERROR_INVALID_PARAMS; } - eError = SysAcquireData(&psSysData); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: Failed to get SysData")); - return eError; - } + SysAcquireData(&psSysData); if(((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_TIMER_PRESENT) != 0UL) && @@ -727,9 +807,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) (psMiscInfo->pszMemoryStr != IMG_NULL)) { RA_ARENA **ppArena; - BM_HEAP *psBMHeap; - BM_CONTEXT *psBMContext; - PVRSRV_DEVICE_NODE *psDeviceNode; IMG_CHAR *pszStr; IMG_UINT32 ui32StrLen; IMG_INT32 i32Count; @@ -755,70 +832,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } - psDeviceNode = psSysData->psDeviceNodeList; - while(psDeviceNode) - { - CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "\n\nDevice Type %d:\n", psDeviceNode->sDevId.eDeviceType); - UPDATE_SPACE(pszStr, i32Count, ui32StrLen); - - - if(psDeviceNode->sDevMemoryInfo.pBMKernelContext) - { - CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "\nKernel Context:\n"); - UPDATE_SPACE(pszStr, i32Count, ui32StrLen); - - psBMHeap = psDeviceNode->sDevMemoryInfo.pBMKernelContext->psBMHeap; - while(psBMHeap) - { - if(psBMHeap->pImportArena) - { - RA_GetStats(psBMHeap->pImportArena, - &pszStr, - &ui32StrLen); - } - - if(psBMHeap->pVMArena) - { - RA_GetStats(psBMHeap->pVMArena, - &pszStr, - &ui32StrLen); - } - psBMHeap = psBMHeap->psNext; - } - } - - - psBMContext = psDeviceNode->sDevMemoryInfo.pBMContext; - while(psBMContext) - { - CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "\nApplication Context (hDevMemContext) 0x%08X:\n", (IMG_HANDLE)psBMContext); - UPDATE_SPACE(pszStr, i32Count, ui32StrLen); - - psBMHeap = psBMContext->psBMHeap; - while(psBMHeap) - { - if(psBMHeap->pImportArena) - { - RA_GetStats(psBMHeap->pImportArena, - &pszStr, - &ui32StrLen); - } - - if(psBMHeap->pVMArena) - { - RA_GetStats(psBMHeap->pVMArena, - &pszStr, - &ui32StrLen); - } - psBMHeap = psBMHeap->psNext; - } - psBMContext = psBMContext->psNext; - } - psDeviceNode = psDeviceNode->psNext; - } + + List_PVRSRV_DEVICE_NODE_PVRSRV_ERROR_Any_va(psSysData->psDeviceNodeList, + PVRSRVGetMiscInfoKM_Device_AnyVaCb, + &ui32StrLen, + &i32Count, + &pszStr); i32Count = OSSNPrintf(pszStr, 100, "\n\0"); @@ -871,6 +890,42 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } } +#if defined(SUPPORT_CPU_CACHED_BUFFERS) + if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_CPUCACHEFLUSH_PRESENT) != 0UL) + { + if(psMiscInfo->bDeferCPUCacheFlush) + { + + if(!psMiscInfo->bCPUCacheFlushAll) + { + + + + PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVGetMiscInfoKM: don't support deferred range flushes")); + PVR_DPF((PVR_DBG_MESSAGE," using deferred flush all instead")); + } + + psSysData->bFlushAll = IMG_TRUE; + } + else + { + + if(psMiscInfo->bCPUCacheFlushAll) + { + + OSFlushCPUCacheKM(); + + psSysData->bFlushAll = IMG_FALSE; + } + else + { + + OSFlushCPUCacheRangeKM(psMiscInfo->pvRangeAddrStart, psMiscInfo->pvRangeAddrEnd); + } + } + } +#endif + return PVRSRV_OK; } @@ -926,6 +981,32 @@ out: return bStatus; } +IMG_VOID PVRSRVSystemLISR_ForEachVaCb(PVRSRV_DEVICE_NODE *psDeviceNode, va_list va) +{ + + IMG_BOOL *pbStatus; + IMG_UINT32 *pui32InterruptSource; + IMG_UINT32 *pui32ClearInterrupts; + + pbStatus = va_arg(va, IMG_BOOL*); + pui32InterruptSource = va_arg(va, IMG_UINT32*); + pui32ClearInterrupts = va_arg(va, IMG_UINT32*); + + + if(psDeviceNode->pfnDeviceISR != IMG_NULL) + { + if(*pui32InterruptSource & psDeviceNode->ui32SOCInterruptBit) + { + if((*psDeviceNode->pfnDeviceISR)(psDeviceNode->pvISRData)) + { + + *pbStatus = IMG_TRUE; + } + + *pui32ClearInterrupts |= psDeviceNode->ui32SOCInterruptBit; + } + } +} IMG_BOOL IMG_CALLCONV PVRSRVSystemLISR(IMG_VOID *pvSysData) { @@ -933,55 +1014,43 @@ IMG_BOOL IMG_CALLCONV PVRSRVSystemLISR(IMG_VOID *pvSysData) IMG_BOOL bStatus = IMG_FALSE; IMG_UINT32 ui32InterruptSource; IMG_UINT32 ui32ClearInterrupts = 0; - PVRSRV_DEVICE_NODE *psDeviceNode; - if(!psSysData) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVSystemLISR: Invalid params\n")); - goto out; } - - - ui32InterruptSource = SysGetInterruptSource(psSysData, IMG_NULL); - - - if(ui32InterruptSource == 0) + else { - goto out; - } - + + ui32InterruptSource = SysGetInterruptSource(psSysData, IMG_NULL); - psDeviceNode = psSysData->psDeviceNodeList; - while(psDeviceNode != IMG_NULL) - { - if(psDeviceNode->pfnDeviceISR != IMG_NULL) + + if(ui32InterruptSource) { - if(ui32InterruptSource & psDeviceNode->ui32SOCInterruptBit) - { - if((*psDeviceNode->pfnDeviceISR)(psDeviceNode->pvISRData)) - { - - bStatus = IMG_TRUE; - } - - ui32ClearInterrupts |= psDeviceNode->ui32SOCInterruptBit; - } + + List_PVRSRV_DEVICE_NODE_ForEach_va(psSysData->psDeviceNodeList, + PVRSRVSystemLISR_ForEachVaCb, + &bStatus, + &ui32InterruptSource, + &ui32ClearInterrupts); + + SysClearInterrupts(psSysData, ui32ClearInterrupts); } - psDeviceNode = psDeviceNode->psNext; } - - SysClearInterrupts(psSysData, ui32ClearInterrupts); - -out: return bStatus; } +IMG_VOID PVRSRVMISR_ForEachCb(PVRSRV_DEVICE_NODE *psDeviceNode) +{ + if(psDeviceNode->pfnDeviceMISR != IMG_NULL) + { + (*psDeviceNode->pfnDeviceMISR)(psDeviceNode->pvISRData); + } +} + IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) { SYS_DATA *psSysData = pvSysData; - PVRSRV_DEVICE_NODE *psDeviceNode; - if(!psSysData) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVMISR: Invalid params\n")); @@ -989,15 +1058,8 @@ IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) } - psDeviceNode = psSysData->psDeviceNodeList; - while(psDeviceNode != IMG_NULL) - { - if(psDeviceNode->pfnDeviceMISR != IMG_NULL) - { - (*psDeviceNode->pfnDeviceMISR)(psDeviceNode->pvISRData); - } - psDeviceNode = psDeviceNode->psNext; - } + List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList, + PVRSRVMISR_ForEachCb); if (PVRSRVProcessQueues(ISR_ID, IMG_FALSE) == PVRSRV_ERROR_PROCESSING_BLOCKED) @@ -1032,9 +1094,9 @@ IMG_VOID IMG_CALLCONV PVRSRVProcessDisconnect(IMG_UINT32 ui32PID) PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_PBYTE pbyBuffer, - IMG_UINT32 *puiBufSize, IMG_BOOL bSave) + IMG_SIZE_T *puiBufSize, IMG_BOOL bSave) { - IMG_UINT32 uiBytesSaved = 0; + IMG_SIZE_T uiBytesSaved = 0; IMG_PVOID pvLocalMemCPUVAddr; RA_SEGMENT_DETAILS sSegDetails; diff --git a/services4/srvkm/common/ra.c b/services4/srvkm/common/ra.c index e38ee48..5e56a26 100644 --- a/services4/srvkm/common/ra.c +++ b/services4/srvkm/common/ra.c @@ -41,6 +41,32 @@ #define MINIMUM_HASH_SIZE (64) +#if defined(VALIDATE_ARENA_TEST) + +typedef enum RESOURCE_DESCRIPTOR_TAG { + + RESOURCE_SPAN_LIVE = 10, + RESOURCE_SPAN_FREE, + IMPORTED_RESOURCE_SPAN_START, + IMPORTED_RESOURCE_SPAN_LIVE, + IMPORTED_RESOURCE_SPAN_FREE, + IMPORTED_RESOURCE_SPAN_END, + +} RESOURCE_DESCRIPTOR; + +typedef enum RESOURCE_TYPE_TAG { + + IMPORTED_RESOURCE_TYPE = 20, + NON_IMPORTED_RESOURCE_TYPE + +} RESOURCE_TYPE; + + +static IMG_UINT32 ui32BoundaryTagID = 0; + +IMG_UINT32 ValidateArena(RA_ARENA *pArena); +#endif + struct _BT_ { enum bt_type @@ -62,6 +88,15 @@ struct _BT_ struct _BT_ *pPrevFree; BM_MAPPING *psMapping; + +#if defined(VALIDATE_ARENA_TEST) + RESOURCE_DESCRIPTOR eResourceSpan; + RESOURCE_TYPE eResourceType; + + + IMG_UINT32 ui32BoundaryTagID; +#endif + }; typedef struct _BT_ BT; @@ -72,7 +107,7 @@ struct _RA_ARENA_ IMG_CHAR *name; - IMG_UINT32 uQuantum; + IMG_SIZE_T uQuantum; IMG_BOOL (*pImportAlloc)(IMG_VOID *, @@ -84,7 +119,7 @@ struct _RA_ARENA_ IMG_VOID (*pImportFree) (IMG_VOID *, IMG_UINTPTR_T, BM_MAPPING *psMapping); - IMG_VOID (*pBackingStoreFree) (IMG_VOID *, IMG_UINT32, IMG_UINT32, IMG_HANDLE); + IMG_VOID (*pBackingStoreFree) (IMG_VOID *, IMG_SIZE_T, IMG_SIZE_T, IMG_HANDLE); IMG_VOID *pImportHandle; @@ -106,10 +141,17 @@ struct _RA_ARENA_ RA_STATISTICS sStatistics; #endif -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) #define PROC_NAME_SIZE 32 + +#ifdef PVR_PROC_USE_SEQ_FILE + struct proc_dir_entry* pProcInfo; + struct proc_dir_entry* pProcSegs; +#else IMG_CHAR szProcInfoName[PROC_NAME_SIZE]; IMG_CHAR szProcSegsName[PROC_NAME_SIZE]; +#endif + IMG_BOOL bInitProcEntry; #endif }; @@ -117,18 +159,30 @@ struct _RA_ARENA_ IMG_VOID RA_Dump (RA_ARENA *pArena); #endif -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) + +#ifdef PVR_PROC_USE_SEQ_FILE + +static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el); +static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off); + +static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el); +static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off); + +#else static IMG_INT RA_DumpSegs(IMG_CHAR *page, IMG_CHAR **start, off_t off, IMG_INT count, IMG_INT *eof, IMG_VOID *data); static IMG_INT RA_DumpInfo(IMG_CHAR *page, IMG_CHAR **start, off_t off, IMG_INT count, IMG_INT *eof, IMG_VOID *data); -#endif +#endif + +#endif #ifdef USE_BM_FREESPACE_CHECK IMG_VOID CheckBMFreespace(IMG_VOID); #endif -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) static IMG_CHAR *ReplaceSpaces(IMG_CHAR * const pS) { IMG_CHAR *pT; @@ -282,6 +336,12 @@ _SegmentSplit (RA_ARENA *pArena, BT *pBT, IMG_SIZE_T uSize) return IMG_NULL; } + OSMemSet(pNeighbour, 0, sizeof(BT)); + +#if defined(VALIDATE_ARENA_TEST) + pNeighbour->ui32BoundaryTagID = ++ui32BoundaryTagID; +#endif + pNeighbour->pPrevSegment = pBT; pNeighbour->pNextSegment = pBT->pNextSegment; if (pBT->pNextSegment == IMG_NULL) @@ -295,6 +355,25 @@ _SegmentSplit (RA_ARENA *pArena, BT *pBT, IMG_SIZE_T uSize) pNeighbour->base = pBT->base + uSize; pNeighbour->psMapping = pBT->psMapping; pBT->uSize = uSize; + +#if defined(VALIDATE_ARENA_TEST) + if (pNeighbour->pPrevSegment->eResourceType == IMPORTED_RESOURCE_TYPE) + { + pNeighbour->eResourceType = IMPORTED_RESOURCE_TYPE; + pNeighbour->eResourceSpan = IMPORTED_RESOURCE_SPAN_FREE; + } + else if (pNeighbour->pPrevSegment->eResourceType == NON_IMPORTED_RESOURCE_TYPE) + { + pNeighbour->eResourceType = NON_IMPORTED_RESOURCE_TYPE; + pNeighbour->eResourceSpan = RESOURCE_SPAN_FREE; + } + else + { + PVR_DPF ((PVR_DBG_ERROR,"_SegmentSplit: pNeighbour->pPrevSegment->eResourceType unrecognized")); + PVR_DBG_BREAK; + } +#endif + return pNeighbour; } @@ -337,6 +416,12 @@ _BuildSpanMarker (IMG_UINTPTR_T base, IMG_SIZE_T uSize) return IMG_NULL; } + OSMemSet(pBT, 0, sizeof(BT)); + +#if defined(VALIDATE_ARENA_TEST) + pBT->ui32BoundaryTagID = ++ui32BoundaryTagID; +#endif + pBT->type = btt_span; pBT->base = base; pBT->uSize = uSize; @@ -358,6 +443,12 @@ _BuildBT (IMG_UINTPTR_T base, IMG_SIZE_T uSize) return IMG_NULL; } + OSMemSet(pBT, 0, sizeof(BT)); + +#if defined(VALIDATE_ARENA_TEST) + pBT->ui32BoundaryTagID = ++ui32BoundaryTagID; +#endif + pBT->type = btt_free; pBT->base = base; pBT->uSize = uSize; @@ -379,6 +470,12 @@ _InsertResource (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) pBT = _BuildBT (base, uSize); if (pBT != IMG_NULL) { + +#if defined(VALIDATE_ARENA_TEST) + pBT->eResourceSpan = RESOURCE_SPAN_FREE; + pBT->eResourceType = NON_IMPORTED_RESOURCE_TYPE; +#endif + if (_SegmentListInsert (pArena, pBT) != PVRSRV_OK) { PVR_DPF ((PVR_DBG_ERROR,"_InsertResource: call to _SegmentListInsert failed")); @@ -418,18 +515,34 @@ _InsertResourceSpan (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) { goto fail_start; } + +#if defined(VALIDATE_ARENA_TEST) + pSpanStart->eResourceSpan = IMPORTED_RESOURCE_SPAN_START; + pSpanStart->eResourceType = IMPORTED_RESOURCE_TYPE; +#endif + pSpanEnd = _BuildSpanMarker (base + uSize, 0); if (pSpanEnd == IMG_NULL) { goto fail_end; } +#if defined(VALIDATE_ARENA_TEST) + pSpanEnd->eResourceSpan = IMPORTED_RESOURCE_SPAN_END; + pSpanEnd->eResourceType = IMPORTED_RESOURCE_TYPE; +#endif + pBT = _BuildBT (base, uSize); if (pBT == IMG_NULL) { goto fail_bt; } +#if defined(VALIDATE_ARENA_TEST) + pBT->eResourceSpan = IMPORTED_RESOURCE_SPAN_FREE; + pBT->eResourceType = IMPORTED_RESOURCE_TYPE; +#endif + eError = _SegmentListInsert (pArena, pSpanStart); if (eError != PVRSRV_OK) { @@ -457,10 +570,13 @@ _InsertResourceSpan (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) fail_SegListInsert: OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pBT, IMG_NULL); + fail_bt: OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pSpanEnd, IMG_NULL); + fail_end: OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pSpanStart, IMG_NULL); + fail_start: return IMG_NULL; } @@ -501,6 +617,7 @@ _FreeBT (RA_ARENA *pArena, BT *pBT, IMG_BOOL bFreeBackingStore) pBT->base = pNeighbour->base; pBT->uSize += pNeighbour->uSize; OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pNeighbour, IMG_NULL); + #ifdef RA_STATS pArena->sStatistics.uFreeSegmentCount--; #endif @@ -516,6 +633,7 @@ _FreeBT (RA_ARENA *pArena, BT *pBT, IMG_BOOL bFreeBackingStore) _SegmentListRemove (pArena, pNeighbour); pBT->uSize += pNeighbour->uSize; OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pNeighbour, IMG_NULL); + #ifdef RA_STATS pArena->sStatistics.uFreeSegmentCount--; #endif @@ -565,8 +683,11 @@ _FreeBT (RA_ARENA *pArena, BT *pBT, IMG_BOOL bFreeBackingStore) pArena->sStatistics.uTotalResourceCount-=pBT->uSize; #endif OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), next, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), prev, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pBT, IMG_NULL); + } else _FreeListInsert (pArena, pBT); @@ -687,6 +808,21 @@ _AttemptAllocAligned (RA_ARENA *pArena, pBT->type = btt_live; +#if defined(VALIDATE_ARENA_TEST) + if (pBT->eResourceType == IMPORTED_RESOURCE_TYPE) + { + pBT->eResourceSpan = IMPORTED_RESOURCE_SPAN_LIVE; + } + else if (pBT->eResourceType == NON_IMPORTED_RESOURCE_TYPE) + { + pBT->eResourceSpan = RESOURCE_SPAN_LIVE; + } + else + { + PVR_DPF ((PVR_DBG_ERROR,"_AttemptAllocAligned ERROR: pBT->eResourceType unrecognized")); + PVR_DBG_BREAK; + } +#endif if (!HASH_Insert (pArena->pSegmentHash, pBT->base, (IMG_UINTPTR_T) pBT)) { _FreeBT (pArena, pBT, IMG_FALSE); @@ -728,7 +864,7 @@ RA_Create (IMG_CHAR *name, IMG_BOOL (*imp_alloc)(IMG_VOID *, IMG_SIZE_T uSize, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, IMG_UINT32 _flags, IMG_UINTPTR_T *pBase), IMG_VOID (*imp_free) (IMG_VOID *, IMG_UINTPTR_T, BM_MAPPING *), - IMG_VOID (*backingstore_free) (IMG_VOID*, IMG_UINT32, IMG_UINT32, IMG_HANDLE), + IMG_VOID (*backingstore_free) (IMG_VOID*, IMG_SIZE_T, IMG_SIZE_T, IMG_HANDLE), IMG_VOID *pImportHandle) { RA_ARENA *pArena; @@ -771,14 +907,16 @@ RA_Create (IMG_CHAR *name, pArena->sStatistics.uExportCount = 0; #endif -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) if(strcmp(pArena->name,"") != 0) { + +#ifndef PVR_PROC_USE_SEQ_FILE IMG_INT ret; IMG_INT (*pfnCreateProcEntry)(const IMG_CHAR *, read_proc_t, write_proc_t, IMG_VOID *); pArena->bInitProcEntry = !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL); - + pfnCreateProcEntry = pArena->bInitProcEntry ? CreateProcEntry : CreatePerProcessProcEntry; @@ -794,7 +932,7 @@ RA_Create (IMG_CHAR *name, } ret = snprintf(pArena->szProcSegsName, sizeof(pArena->szProcSegsName), "ra_segs_%s", pArena->name); - if (ret > 0 && ret < sizeof(pArena->szProcInfoName)) + if (ret > 0 && ret < sizeof(pArena->szProcSegsName)) { (IMG_VOID) pfnCreateProcEntry(ReplaceSpaces(pArena->szProcSegsName), RA_DumpSegs, 0, pArena); } @@ -803,8 +941,52 @@ RA_Create (IMG_CHAR *name, pArena->szProcSegsName[0] = 0; PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_segs proc entry for arena %s", pArena->name)); } +#else + + IMG_INT ret; + IMG_CHAR szProcInfoName[PROC_NAME_SIZE]; + IMG_CHAR szProcSegsName[PROC_NAME_SIZE]; + struct proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *, + IMG_VOID*, + pvr_next_proc_seq_t, + pvr_show_proc_seq_t, + pvr_off2element_proc_seq_t, + pvr_startstop_proc_seq_t, + write_proc_t); + + pArena->bInitProcEntry = !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL); + + + pfnCreateProcEntrySeq = pArena->bInitProcEntry ? CreateProcEntrySeq : CreatePerProcessProcEntrySeq; + + ret = snprintf(szProcInfoName, sizeof(szProcInfoName), "ra_info_%s", pArena->name); + if (ret > 0 && ret < sizeof(szProcInfoName)) + { + pArena->pProcInfo = pfnCreateProcEntrySeq(ReplaceSpaces(szProcInfoName), pArena, NULL, + RA_ProcSeqShowInfo, RA_ProcSeqOff2ElementInfo, NULL, NULL); + } + else + { + pArena->pProcInfo = 0; + PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_info proc entry for arena %s", pArena->name)); + } + + ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_segs_%s", pArena->name); + if (ret > 0 && ret < sizeof(szProcInfoName)) + { + pArena->pProcSegs = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL, + RA_ProcSeqShowRegs, RA_ProcSeqOff2ElementRegs, NULL, NULL); + } + else + { + pArena->pProcSegs = 0; + PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_segs proc entry for arena %s", pArena->name)); + } + +#endif + } -#endif +#endif pArena->pSegmentHash = HASH_Create (MINIMUM_HASH_SIZE); if (pArena->pSegmentHash==IMG_NULL) @@ -828,6 +1010,7 @@ insert_fail: HASH_Delete (pArena->pSegmentHash); hash_fail: OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RA_ARENA), pArena, IMG_NULL); + arena_fail: return IMG_NULL; } @@ -854,15 +1037,40 @@ RA_Delete (RA_ARENA *pArena) while (pArena->pHeadSegment != IMG_NULL) { BT *pBT = pArena->pHeadSegment; - PVR_ASSERT (pBT->type == btt_free); + + if (pBT->type != btt_free) + { + PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed")); + PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing alocations before destroying devmemcontext")); + PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); + } + _SegmentListRemove (pArena, pBT); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pBT, IMG_NULL); + #ifdef RA_STATS pArena->sStatistics.uSpanCount--; #endif } -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) { + +#ifdef PVR_PROC_USE_SEQ_FILE + IMG_VOID (*pfnRemoveProcEntrySeq)(struct proc_dir_entry*); + + pfnRemoveProcEntrySeq = pArena->bInitProcEntry ? RemoveProcEntrySeq : RemovePerProcessProcEntrySeq; + + if (pArena->pProcInfo != 0) + { + pfnRemoveProcEntrySeq( pArena->pProcInfo ); + } + + if (pArena->pProcSegs != 0) + { + pfnRemoveProcEntrySeq( pArena->pProcSegs ); + } + +#else IMG_VOID (*pfnRemoveProcEntry)(const IMG_CHAR *); pfnRemoveProcEntry = pArena->bInitProcEntry ? RemoveProcEntry : RemovePerProcessProcEntry; @@ -876,10 +1084,13 @@ RA_Delete (RA_ARENA *pArena) { pfnRemoveProcEntry(pArena->szProcSegsName); } + +#endif } #endif HASH_Delete (pArena->pSegmentHash); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RA_ARENA), pArena, IMG_NULL); + } IMG_BOOL @@ -894,6 +1105,8 @@ RA_TestDelete (RA_ARENA *pArena) BT *pBT = pArena->pHeadSegment; if (pBT->type != btt_free) { + PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: detected resource leak!")); + PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); return IMG_FALSE; } } @@ -941,6 +1154,10 @@ RA_Alloc (RA_ARENA *pArena, return IMG_FALSE; } +#if defined(VALIDATE_ARENA_TEST) + ValidateArena(pArena); +#endif + #ifdef USE_BM_FREESPACE_CHECK CheckBMFreespace(); #endif @@ -1023,9 +1240,163 @@ RA_Alloc (RA_ARENA *pArena, +#if defined(VALIDATE_ARENA_TEST) + ValidateArena(pArena); +#endif + return bResult; } + +#if defined(VALIDATE_ARENA_TEST) + +IMG_UINT32 ValidateArena(RA_ARENA *pArena) +{ + BT* pSegment; + RESOURCE_DESCRIPTOR eNextSpan; + + pSegment = pArena->pHeadSegment; + + if (pSegment == IMG_NULL) + { + return 0; + } + + if (pSegment->eResourceType == IMPORTED_RESOURCE_TYPE) + { + PVR_ASSERT(pSegment->eResourceSpan == IMPORTED_RESOURCE_SPAN_START); + + while (pSegment->pNextSegment) + { + eNextSpan = pSegment->pNextSegment->eResourceSpan; + + switch (pSegment->eResourceSpan) + { + case IMPORTED_RESOURCE_SPAN_LIVE: + + if (!((eNextSpan == IMPORTED_RESOURCE_SPAN_LIVE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_FREE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + case IMPORTED_RESOURCE_SPAN_FREE: + + if (!((eNextSpan == IMPORTED_RESOURCE_SPAN_LIVE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + case IMPORTED_RESOURCE_SPAN_END: + + if ((eNextSpan == IMPORTED_RESOURCE_SPAN_LIVE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_FREE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_END)) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + + case IMPORTED_RESOURCE_SPAN_START: + + if (!((eNextSpan == IMPORTED_RESOURCE_SPAN_LIVE) || + (eNextSpan == IMPORTED_RESOURCE_SPAN_FREE))) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + default: + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + break; + } + pSegment = pSegment->pNextSegment; + } + } + else if (pSegment->eResourceType == NON_IMPORTED_RESOURCE_TYPE) + { + PVR_ASSERT((pSegment->eResourceSpan == RESOURCE_SPAN_FREE) || (pSegment->eResourceSpan == RESOURCE_SPAN_LIVE)); + + while (pSegment->pNextSegment) + { + eNextSpan = pSegment->pNextSegment->eResourceSpan; + + switch (pSegment->eResourceSpan) + { + case RESOURCE_SPAN_LIVE: + + if (!((eNextSpan == RESOURCE_SPAN_FREE) || + (eNextSpan == RESOURCE_SPAN_LIVE))) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + case RESOURCE_SPAN_FREE: + + if (!((eNextSpan == RESOURCE_SPAN_FREE) || + (eNextSpan == RESOURCE_SPAN_LIVE))) + { + + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + } + break; + + default: + PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + + PVR_DBG_BREAK; + break; + } + pSegment = pSegment->pNextSegment; + } + + } + else + { + PVR_DPF ((PVR_DBG_ERROR,"ValidateArena ERROR: pSegment->eResourceType unrecognized")); + + PVR_DBG_BREAK; + } + + return 0; +} + +#endif + + IMG_VOID RA_Free (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_BOOL bFreeBackingStore) { @@ -1166,7 +1537,7 @@ IMG_VOID CheckBMFreespace(IMG_VOID) #endif -#if (defined(CONFIG_PROC_FS) && defined(DEBUG)) || defined (RA_STATS) +#if (defined(CONFIG_PROC_FS) && defined(DEBUG_PVR)) || defined (RA_STATS) static IMG_CHAR * _BTType (IMG_INT eType) { @@ -1212,7 +1583,105 @@ RA_Dump (RA_ARENA *pArena) #endif -#if defined(CONFIG_PROC_FS) && defined(DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG_PVR) + + +#ifdef PVR_PROC_USE_SEQ_FILE + +static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el) +{ + PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; + RA_ARENA *pArena = (RA_ARENA *)handlers->data; + IMG_INT off = (IMG_INT)el; + + switch (off) + { + case 1: + seq_printf(sfile, "quantum\t\t\t%lu\n", pArena->uQuantum); + break; + case 2: + seq_printf(sfile, "import_handle\t\t%08X\n", (IMG_UINT)pArena->pImportHandle); + break; +#ifdef RA_STATS + case 3: + seq_printf(sfile,"span count\t\t%lu\n", pArena->sStatistics.uSpanCount); + break; + case 4: + seq_printf(sfile, "live segment count\t%lu\n", pArena->sStatistics.uLiveSegmentCount); + break; + case 5: + seq_printf(sfile, "free segment count\t%lu\n", pArena->sStatistics.uFreeSegmentCount); + break; + case 6: + seq_printf(sfile, "free resource count\t%lu (0x%x)\n", + pArena->sStatistics.uFreeResourceCount, + (IMG_UINT)pArena->sStatistics.uFreeResourceCount); + break; + case 7: + seq_printf(sfile, "total allocs\t\t%lu\n", pArena->sStatistics.uCumulativeAllocs); + break; + case 8: + seq_printf(sfile, "total frees\t\t%lu\n", pArena->sStatistics.uCumulativeFrees); + break; + case 9: + seq_printf(sfile, "import count\t\t%lu\n", pArena->sStatistics.uImportCount); + break; + case 10: + seq_printf(sfile, "export count\t\t%lu\n", pArena->sStatistics.uExportCount); + break; +#endif + } + +} + +static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off) +{ +#ifdef RA_STATS + if(off <= 9) +#else + if(off <= 1) +#endif + return (void*)(IMG_INT)(off+1); + return 0; +} + +static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el) +{ + PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; + RA_ARENA *pArena = (RA_ARENA *)handlers->data; + BT *pBT = (BT*)el; + + if (el == PVR_PROC_SEQ_START_TOKEN) + { + seq_printf(sfile, "Arena \"%s\"\nBase Size Type Ref\n", pArena->name); + return; + } + + if (pBT) + { + seq_printf(sfile, "%08x %8x %4s %08x\n", + (IMG_UINT)pBT->base, (IMG_UINT)pBT->uSize, _BTType (pBT->type), + (IMG_UINT)pBT->psMapping); + } +} + +static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off) +{ + PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; + RA_ARENA *pArena = (RA_ARENA *)handlers->data; + BT *pBT = 0; + + if(off == 0) + return PVR_PROC_SEQ_START_TOKEN; + + for (pBT=pArena->pHeadSegment; --off && pBT; pBT=pBT->pNextSegment); + + return (void*)pBT; +} + + + +#else static IMG_INT RA_DumpSegs(IMG_CHAR *page, IMG_CHAR **start, off_t off, IMG_INT count, IMG_INT *eof, IMG_VOID *data) { @@ -1301,7 +1770,8 @@ RA_DumpInfo(IMG_CHAR *page, IMG_CHAR **start, off_t off, IMG_INT count, IMG_INT *start = (IMG_CHAR *)1; return (len); } -#endif +#endif +#endif #ifdef RA_STATS diff --git a/services4/srvkm/devices/sgx/sgxinfokm.h b/services4/srvkm/devices/sgx/sgxinfokm.h index fac1aee..6a08c07 100644 --- a/services4/srvkm/devices/sgx/sgxinfokm.h +++ b/services4/srvkm/devices/sgx/sgxinfokm.h @@ -313,21 +313,21 @@ PVRSRV_ERROR SGXDeinitialise(IMG_HANDLE hDevCookie); IMG_VOID SGXStartTimer(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bStartOSTimer); -PVRSRV_ERROR SGXPrePowerStateExt(IMG_HANDLE hDevHandle, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState); +PVRSRV_ERROR SGXPrePowerState(IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); -PVRSRV_ERROR SGXPostPowerStateExt(IMG_HANDLE hDevHandle, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState); +PVRSRV_ERROR SGXPostPowerState(IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); -PVRSRV_ERROR SGXPreClockSpeedChange(IMG_HANDLE hDevHandle, - IMG_BOOL bIdleDevice, - PVR_POWER_STATE eCurrentPowerState); +PVRSRV_ERROR SGXPreClockSpeedChange(IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); -PVRSRV_ERROR SGXPostClockSpeedChange(IMG_HANDLE hDevHandle, - IMG_BOOL bIdleDevice, - PVR_POWER_STATE eCurrentPowerState); +PVRSRV_ERROR SGXPostClockSpeedChange(IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode); diff --git a/services4/srvkm/devices/sgx/sgxinit.c b/services4/srvkm/devices/sgx/sgxinit.c index a391e20..18e4e5b 100644 --- a/services4/srvkm/devices/sgx/sgxinit.c +++ b/services4/srvkm/devices/sgx/sgxinit.c @@ -458,11 +458,11 @@ PVRSRV_ERROR DevInitSGXPart2KM (PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevHandle, SGX_BRIDGE_INIT_INFO *psInitInfo) { - PVRSRV_DEVICE_NODE *psDeviceNode; - PVRSRV_SGXDEV_INFO *psDevInfo; - PVRSRV_ERROR eError; - SGX_DEVICE_MAP *psSGXDeviceMap; - PVR_POWER_STATE eDefaultPowerState; + PVRSRV_DEVICE_NODE *psDeviceNode; + PVRSRV_SGXDEV_INFO *psDevInfo; + PVRSRV_ERROR eError; + SGX_DEVICE_MAP *psSGXDeviceMap; + PVRSRV_DEV_POWER_STATE eDefaultPowerState; PDUMPCOMMENT("SGX Initialisation Part 2"); @@ -540,15 +540,15 @@ PVRSRV_ERROR DevInitSGXPart2KM (PVRSRV_PER_PROCESS_DATA *psPerProc, #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) psDevInfo->psSGXHostCtl->ui32PowerStatus |= PVRSRV_USSE_EDM_POWMAN_NO_WORK; - eDefaultPowerState = PVRSRV_POWER_STATE_D3; + eDefaultPowerState = PVRSRV_DEV_POWER_STATE_OFF; #else - eDefaultPowerState = PVRSRV_POWER_STATE_D0; + eDefaultPowerState = PVRSRV_DEV_POWER_STATE_ON; #endif eError = PVRSRVRegisterPowerDevice (psDeviceNode->sDevId.ui32DeviceIndex, - SGXPrePowerStateExt, SGXPostPowerStateExt, + SGXPrePowerState, SGXPostPowerState, SGXPreClockSpeedChange, SGXPostClockSpeedChange, (IMG_HANDLE)psDeviceNode, - PVRSRV_POWER_STATE_D3, + PVRSRV_DEV_POWER_STATE_OFF, eDefaultPowerState); if (eError != PVRSRV_OK) { @@ -1572,7 +1572,7 @@ PVRSRV_ERROR SGXReadDiffCountersKM(IMG_HANDLE hDevHandle, { if (psPowerDevice->ui32DeviceIndex == psDeviceNode->sDevId.ui32DeviceIndex) { - bPowered = (IMG_BOOL)(psPowerDevice->eCurrentPowerState == PVRSRV_POWER_STATE_D0); + bPowered = (IMG_BOOL)(psPowerDevice->eCurrentPowerState == PVRSRV_DEV_POWER_STATE_ON); break; } diff --git a/services4/srvkm/devices/sgx/sgxpower.c b/services4/srvkm/devices/sgx/sgxpower.c index 69c0a8f..b3691d4 100644 --- a/services4/srvkm/devices/sgx/sgxpower.c +++ b/services4/srvkm/devices/sgx/sgxpower.c @@ -34,46 +34,6 @@ #include "pdump_km.h" -typedef enum _PVR_DEVICE_POWER_STATE_ -{ - - PVR_DEVICE_POWER_STATE_ON = 0, - PVR_DEVICE_POWER_STATE_IDLE = 1, - PVR_DEVICE_POWER_STATE_OFF = 2, - - PVR_DEVICE_POWER_STATE_FORCE_I32 = 0x7fffffff - -} PVR_DEVICE_POWER_STATE, *PPVR_DEVICE_POWER_STATE; - - -static PVR_DEVICE_POWER_STATE MapDevicePowerState(PVR_POWER_STATE ePowerState) -{ - PVR_DEVICE_POWER_STATE eDevicePowerState; - - switch (ePowerState) - { - case PVRSRV_POWER_STATE_D0: - { - eDevicePowerState = PVR_DEVICE_POWER_STATE_ON; - break; - } - case PVRSRV_POWER_STATE_D3: - { - eDevicePowerState = PVR_DEVICE_POWER_STATE_OFF; - break; - } - default: - { - PVR_DPF((PVR_DBG_ERROR,"MapDevicePowerState: Invalid state: %ld", ePowerState)); - eDevicePowerState = PVR_DEVICE_POWER_STATE_FORCE_I32; - PVR_DBG_BREAK; - } - } - - return eDevicePowerState; -} - - static IMG_VOID SGXGetTimingInfo(PVRSRV_DEVICE_NODE *psDeviceNode) { PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; @@ -213,12 +173,12 @@ static IMG_VOID SGXPollForClockGating (PVRSRV_SGXDEV_INFO *psDevInfo, } -static PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, - PVR_DEVICE_POWER_STATE eNewPowerState, - PVR_DEVICE_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { if ((eNewPowerState != eCurrentPowerState) && - (eNewPowerState != PVR_DEVICE_POWER_STATE_ON)) + (eNewPowerState != PVRSRV_DEV_POWER_STATE_ON)) { PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle; @@ -236,7 +196,7 @@ static PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, } #endif - if (eNewPowerState == PVR_DEVICE_POWER_STATE_OFF) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF) { ui32PowerCmd = PVRSRV_POWERCMD_POWEROFF; @@ -299,7 +259,7 @@ static PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, "Wait for SGX master clock gating"); #endif - if (eNewPowerState == PVR_DEVICE_POWER_STATE_OFF) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF) { eError = SGXDeinitialise(psDevInfo); @@ -315,12 +275,12 @@ static PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, } -static PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, - PVR_DEVICE_POWER_STATE eNewPowerState, - PVR_DEVICE_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { if ((eNewPowerState != eCurrentPowerState) && - (eCurrentPowerState != PVR_DEVICE_POWER_STATE_ON)) + (eCurrentPowerState != PVRSRV_DEV_POWER_STATE_ON)) { PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle; @@ -337,7 +297,7 @@ static PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, MAKEUNIQUETAG(psDevInfo->psKernelSGXHostCtlMemInfo)); #endif - if (eCurrentPowerState == PVR_DEVICE_POWER_STATE_OFF) + if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_OFF) { @@ -377,42 +337,9 @@ static PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, } -PVRSRV_ERROR SGXPrePowerStateExt (IMG_HANDLE hDevHandle, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState) -{ - PVR_DEVICE_POWER_STATE eNewDevicePowerState = MapDevicePowerState(eNewPowerState); - PVR_DEVICE_POWER_STATE eCurrentDevicePowerState = MapDevicePowerState(eCurrentPowerState); - - return SGXPrePowerState(hDevHandle, eNewDevicePowerState, eCurrentDevicePowerState); -} - - -PVRSRV_ERROR SGXPostPowerStateExt (IMG_HANDLE hDevHandle, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState) -{ - PVRSRV_ERROR eError; - PVR_DEVICE_POWER_STATE eNewDevicePowerState = MapDevicePowerState(eNewPowerState); - PVR_DEVICE_POWER_STATE eCurrentDevicePowerState = MapDevicePowerState(eCurrentPowerState); - - eError = SGXPostPowerState(hDevHandle, eNewDevicePowerState, eCurrentDevicePowerState); - if (eError != PVRSRV_OK) - { - return eError; - } - - PVR_DPF((PVR_DBG_MESSAGE, - "SGXPostPowerState : SGX Power Transition from %d to %d OK", - eCurrentPowerState, eNewPowerState)); - - return eError; -} - - -PVRSRV_ERROR SGXPreClockSpeedChange (IMG_HANDLE hDevHandle, - IMG_BOOL bIdleDevice, - PVR_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SGXPreClockSpeedChange (IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle; @@ -420,15 +347,15 @@ PVRSRV_ERROR SGXPreClockSpeedChange (IMG_HANDLE hDevHandle, PVR_UNREFERENCED_PARAMETER(psDevInfo); - if (eCurrentPowerState == PVRSRV_POWER_STATE_D0) + if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_ON) { if (bIdleDevice) { PDUMPSUSPEND(); - eError = SGXPrePowerState(hDevHandle, PVR_DEVICE_POWER_STATE_IDLE, - PVR_DEVICE_POWER_STATE_ON); + eError = SGXPrePowerState(hDevHandle, PVRSRV_DEV_POWER_STATE_IDLE, + PVRSRV_DEV_POWER_STATE_ON); if (eError != PVRSRV_OK) { @@ -445,9 +372,9 @@ PVRSRV_ERROR SGXPreClockSpeedChange (IMG_HANDLE hDevHandle, } -PVRSRV_ERROR SGXPostClockSpeedChange (IMG_HANDLE hDevHandle, - IMG_BOOL bIdleDevice, - PVR_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SGXPostClockSpeedChange (IMG_HANDLE hDevHandle, + IMG_BOOL bIdleDevice, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVRSRV_DEVICE_NODE *psDeviceNode = hDevHandle; PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; @@ -455,7 +382,7 @@ PVRSRV_ERROR SGXPostClockSpeedChange (IMG_HANDLE hDevHandle, PVR_UNREFERENCED_PARAMETER(ui32OldClockSpeed); - if (eCurrentPowerState == PVRSRV_POWER_STATE_D0) + if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_ON) { @@ -465,8 +392,8 @@ PVRSRV_ERROR SGXPostClockSpeedChange (IMG_HANDLE hDevHandle, { PVRSRV_ERROR eError; - eError = SGXPostPowerState(hDevHandle, PVR_DEVICE_POWER_STATE_ON, - PVR_DEVICE_POWER_STATE_IDLE); + eError = SGXPostPowerState(hDevHandle, PVRSRV_DEV_POWER_STATE_ON, + PVRSRV_DEV_POWER_STATE_IDLE); PDUMPRESUME(); diff --git a/services4/srvkm/devices/sgx/sgxutils.c b/services4/srvkm/devices/sgx/sgxutils.c index 9043a62..381904a 100644 --- a/services4/srvkm/devices/sgx/sgxutils.c +++ b/services4/srvkm/devices/sgx/sgxutils.c @@ -103,7 +103,7 @@ IMG_VOID SGXTestActivePowerEvent (PVRSRV_DEVICE_NODE *psDeviceNode, eError = SysPowerDownMISR(psDeviceNode, ui32CallerID); #else eError = PVRSRVSetDevicePowerStateKM(psDeviceNode->sDevId.ui32DeviceIndex, - PVRSRV_POWER_STATE_D3, + PVRSRV_DEV_POWER_STATE_OFF, ui32CallerID, IMG_FALSE); if (eError == PVRSRV_OK) { @@ -336,7 +336,7 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, eError = PVRSRVSetDevicePowerStateKM(psDeviceNode->sDevId.ui32DeviceIndex, - PVRSRV_POWER_STATE_D0, + PVRSRV_DEV_POWER_STATE_ON, ui32CallerID, IMG_TRUE); diff --git a/services4/srvkm/include/power.h b/services4/srvkm/include/power.h index d09ebc9..079f212 100644 --- a/services4/srvkm/include/power.h +++ b/services4/srvkm/include/power.h @@ -41,8 +41,8 @@ typedef struct _PVRSRV_POWER_DEV_TAG_ PFN_POST_CLOCKSPEED_CHANGE pfnPostClockSpeedChange; IMG_HANDLE hDevCookie; IMG_UINT32 ui32DeviceIndex; - PVR_POWER_STATE eDefaultPowerState; - PVR_POWER_STATE eCurrentPowerState; + PVRSRV_DEV_POWER_STATE eDefaultPowerState; + PVRSRV_DEV_POWER_STATE eCurrentPowerState; struct _PVRSRV_POWER_DEV_TAG_ *psNext; struct _PVRSRV_POWER_DEV_TAG_ **ppsThis; @@ -74,18 +74,18 @@ IMG_IMPORT IMG_VOID PVRSRVPowerUnlock(IMG_UINT32 ui32CallerID); IMG_IMPORT -PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - IMG_UINT32 ui32CallerID, - IMG_BOOL bRetainMutex); +PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState, + IMG_UINT32 ui32CallerID, + IMG_BOOL bRetainMutex); IMG_IMPORT -PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVR_POWER_STATE eNewPowerState); +PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(PVRSRV_SYS_POWER_STATE eNewPowerState); IMG_IMPORT -PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(PVR_POWER_STATE eNewPowerState); +PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(PVRSRV_SYS_POWER_STATE eNewPowerState); IMG_IMPORT -PVRSRV_ERROR PVRSRVSetPowerStateKM (PVR_POWER_STATE ePVRState); +PVRSRV_ERROR PVRSRVSetPowerStateKM (PVRSRV_SYS_POWER_STATE ePVRState); IMG_IMPORT PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, @@ -94,8 +94,8 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, PFN_PRE_CLOCKSPEED_CHANGE pfnPreClockSpeedChange, PFN_POST_CLOCKSPEED_CHANGE pfnPostClockSpeedChange, IMG_HANDLE hDevCookie, - PVR_POWER_STATE eCurrentPowerState, - PVR_POWER_STATE eDefaultPowerState); + PVRSRV_DEV_POWER_STATE eCurrentPowerState, + PVRSRV_DEV_POWER_STATE eDefaultPowerState); IMG_IMPORT PVRSRV_ERROR PVRSRVRemovePowerDevice (IMG_UINT32 ui32DeviceIndex); diff --git a/services4/system/include/syscommon.h b/services4/system/include/syscommon.h index a3675a7..20b83c1 100644 --- a/services4/system/include/syscommon.h +++ b/services4/system/include/syscommon.h @@ -62,8 +62,8 @@ typedef struct _SYS_DATA_TAG_ PVRSRV_DEVICE_NODE *psDeviceNodeList; PVRSRV_POWER_DEV *psPowerDeviceList; PVRSRV_RESOURCE sPowerStateChangeResource; - PVR_POWER_STATE eCurrentPowerState; - PVR_POWER_STATE eFailedPowerState; + PVRSRV_SYS_POWER_STATE eCurrentPowerState; + PVRSRV_SYS_POWER_STATE eFailedPowerState; IMG_UINT32 ui32CurrentOSPowerState; PVRSRV_QUEUE_INFO *psQueueList; PVRSRV_KERNEL_SYNC_INFO *psSharedSyncInfoList; @@ -88,9 +88,9 @@ typedef struct _SYS_DATA_TAG_ IMG_CHAR *pszVersionString; PVRSRV_EVENTOBJECT *psGlobalEventObject; -#if defined(PDUMP) - IMG_BOOL bPowerUpPDumped; -#endif + + IMG_BOOL bFlushAll; + } SYS_DATA; @@ -112,14 +112,14 @@ IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits); PVRSRV_ERROR SysResetDevice(IMG_UINT32 ui32DeviceIndex); -PVRSRV_ERROR SysSystemPrePowerState(PVR_POWER_STATE eNewPowerState); -PVRSRV_ERROR SysSystemPostPowerState(PVR_POWER_STATE eNewPowerState); +PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState); +PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState); PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState); + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState); + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState); #if defined(SYS_CUSTOM_POWERLOCK_WRAP) PVRSRV_ERROR SysPowerLockWrap(SYS_DATA *psSysData); diff --git a/services4/system/omap3430/sysconfig.c b/services4/system/omap3430/sysconfig.c index 8603c9c..694b63c 100644 --- a/services4/system/omap3430/sysconfig.c +++ b/services4/system/omap3430/sysconfig.c @@ -631,11 +631,11 @@ IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits) } -PVRSRV_ERROR SysSystemPrePowerState(PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) { PVRSRV_ERROR eError = PVRSRV_OK; - if (eNewPowerState == PVRSRV_POWER_STATE_D3) + if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D3) { PVR_TRACE(("SysSystemPrePowerState: Entering state D3")); @@ -675,11 +675,11 @@ PVRSRV_ERROR SysSystemPrePowerState(PVR_POWER_STATE eNewPowerState) } -PVRSRV_ERROR SysSystemPostPowerState(PVR_POWER_STATE eNewPowerState) +PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) { PVRSRV_ERROR eError = PVRSRV_OK; - if (eNewPowerState == PVRSRV_POWER_STATE_D0) + if (eNewPowerState == PVRSRV_SYS_POWER_STATE_D0) { PVR_TRACE(("SysSystemPostPowerState: Entering state D0")); @@ -723,9 +723,9 @@ PVRSRV_ERROR SysSystemPostPowerState(PVR_POWER_STATE eNewPowerState) } -PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVR_UNREFERENCED_PARAMETER(eCurrentPowerState); @@ -735,7 +735,7 @@ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) - if (eNewPowerState == PVRSRV_POWER_STATE_D3) + if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF) { PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePrePowerState: SGX Entering state D3")); DisableSGXClocks(gpsSysData); @@ -748,9 +748,9 @@ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, } -PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, - PVR_POWER_STATE eNewPowerState, - PVR_POWER_STATE eCurrentPowerState) +PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVRSRV_ERROR eError = PVRSRV_OK; @@ -762,7 +762,7 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) - if (eCurrentPowerState == PVRSRV_POWER_STATE_D3) + if (eCurrentPowerState == PVRSRV_DEV_POWER_STATE_OFF) { PVR_DPF((PVR_DBG_MESSAGE, "SysDevicePostPowerState: SGX Leaving state D3")); PVRSRVSetDCState(DC_STATE_RESUME_COMMANDS); diff --git a/tools/intern/debug/dbgdriv/common/dbgdriv.c b/tools/intern/debug/dbgdriv/common/dbgdriv.c index f8f3bdb..abd86e5 100644 --- a/tools/intern/debug/dbgdriv/common/dbgdriv.c +++ b/tools/intern/debug/dbgdriv/common/dbgdriv.c @@ -47,7 +47,7 @@ typedef struct _DBG_LASTFRAME_BUFFER_ IMG_UINT8 ui8Buffer[LAST_FRAME_BUF_SIZE]; IMG_UINT32 ui32BufLen; struct _DBG_LASTFRAME_BUFFER_ *psNext; -} DBG_LASTFRAME_BUFFER, *PDBG_LASTFRAME_BUFFER; +} *PDBG_LASTFRAME_BUFFER; static PDBG_STREAM g_psStreamList = 0; @@ -281,34 +281,34 @@ IMG_UINT32 IMG_CALLCONV ExtDBGDrivGetFrame(PDBG_STREAM psStream) return ui32Ret; } -IMG_UINT32 IMG_CALLCONV ExtDBGDrivIsLastCaptureFrame(PDBG_STREAM psStream) +IMG_BOOL IMG_CALLCONV ExtDBGDrivIsLastCaptureFrame(PDBG_STREAM psStream) { - IMG_UINT32 ui32Ret; + IMG_BOOL bRet; HostAquireMutex(g_pvAPIMutex); - ui32Ret = DBGDrivIsLastCaptureFrame(psStream); + bRet = DBGDrivIsLastCaptureFrame(psStream); HostReleaseMutex(g_pvAPIMutex); - return ui32Ret; + return bRet; } -IMG_UINT32 IMG_CALLCONV ExtDBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame) +IMG_BOOL IMG_CALLCONV ExtDBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame) { - IMG_UINT32 ui32Ret; + IMG_BOOL bRet; HostAquireMutex(g_pvAPIMutex); - ui32Ret = DBGDrivIsCaptureFrame(psStream, bCheckPreviousFrame); + bRet = DBGDrivIsCaptureFrame(psStream, bCheckPreviousFrame); HostReleaseMutex(g_pvAPIMutex); - return ui32Ret; + return bRet; } void IMG_CALLCONV ExtDBGDrivOverrideMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode) @@ -498,27 +498,27 @@ IMG_VOID IMG_CALLCONV ExtDBGDrivWaitForEvent(DBG_EVENT eEvent) #if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) DBGDrivWaitForEvent(eEvent); #else - PVR_UNREFERENCED_PARAMETER(eEvent); + PVR_UNREFERENCED_PARAMETER(eEvent); #endif } -IMG_UINT32 AtoI(char *szIn) +IMG_UINT32 AtoI(IMG_CHAR *szIn) { - IMG_UINT32 ui32Len = 0; + IMG_INT iLen = 0; IMG_UINT32 ui32Value = 0; IMG_UINT32 ui32Digit=1; IMG_UINT32 ui32Base=10; - int iPos; - char bc; + IMG_INT iPos; + IMG_CHAR bc; - while (szIn[ui32Len] > 0) + while (szIn[iLen] > 0) { - ui32Len ++; + iLen ++; } - if (ui32Len == 0) + if (iLen == 0) { return (0); } @@ -540,7 +540,7 @@ IMG_UINT32 AtoI(char *szIn) } - for (iPos = ui32Len - 1; iPos >= 0; iPos --) + for (iPos = iLen - 1; iPos >= 0; iPos --) { bc = szIn[iPos]; @@ -561,7 +561,7 @@ IMG_UINT32 AtoI(char *szIn) else return (0); - ui32Value += bc * ui32Digit; + ui32Value += (IMG_UINT32)bc * ui32Digit; ui32Digit = ui32Digit * ui32Base; } @@ -635,7 +635,7 @@ void MonoOut(IMG_CHAR * pszString,IMG_BOOL bNewLine) IMG_UINT32 i; IMG_CHAR * pScreen; - pScreen = (char *) DBGDRIV_MONOBASE; + pScreen = (IMG_CHAR *) DBGDRIV_MONOBASE; pScreen += g_ui32Line * 160; @@ -731,7 +731,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, (!psLFBuffer) ) { - PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't create buffer !!!!!\n\r")); + PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc control structs\n\r")); return((IMG_VOID *) 0); } @@ -747,8 +747,8 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, if (!pvBase) { - PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't create buffer !!!!!\n\r")); - HostNonPageablePageFree(psStream); + PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc Stream buffer\n\r")); + HostNonPageablePageFree(psStream); return((IMG_VOID *) 0); } @@ -757,7 +757,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, psStream->psNext = 0; psStream->ui32Flags = ui32Flags; psStream->ui32Base = (IMG_UINT32)pvBase; - psStream->ui32Size = ui32Size * 4096; + psStream->ui32Size = ui32Size * 4096UL; psStream->ui32RPtr = 0; psStream->ui32WPtr = 0; psStream->ui32DataWritten = 0; @@ -786,7 +786,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, if (!pvBase) { - PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't create buffer !!!!!\n\r")); + PVR_DPF((PVR_DBG_ERROR,"DBGDriv: Couldn't alloc InitStream buffer\n\r")); if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) { @@ -796,14 +796,14 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, { HostPageablePageFree((IMG_VOID *)psStream->ui32Base); } - HostNonPageablePageFree(psStream); + HostNonPageablePageFree(psStream); return((IMG_VOID *) 0); } psInitStream->psNext = 0; psInitStream->ui32Flags = ui32Flags; psInitStream->ui32Base = (IMG_UINT32)pvBase; - psInitStream->ui32Size = ui32Size * 4096; + psInitStream->ui32Size = ui32Size * 4096UL; psInitStream->ui32RPtr = 0; psInitStream->ui32WPtr = 0; psInitStream->ui32DataWritten = 0; @@ -824,11 +824,11 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, psLFBuffer->psStream = psStream; - psLFBuffer->ui32BufLen = 0; + psLFBuffer->ui32BufLen = 0UL; g_bHotkeyMiddump = IMG_FALSE; - g_ui32HotkeyMiddumpStart = 0xffffffff; - g_ui32HotkeyMiddumpEnd = 0xffffffff; + g_ui32HotkeyMiddumpStart = 0xffffffffUL; + g_ui32HotkeyMiddumpEnd = 0xffffffffUL; @@ -840,9 +840,9 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, ui32Off++; } - while ((pszName[ui32Off] != 0) && (ui32Off < (4096 - sizeof(DBG_STREAM)))); + while ((pszName[ui32Off] != 0) && (ui32Off < (4096UL - sizeof(DBG_STREAM)))); - psStream->szName[ui32Off] = pszName[ui32Off]; + psStream->szName[ui32Off] = pszName[ui32Off]; @@ -1000,7 +1000,7 @@ IMG_VOID * IMG_CALLCONV DBGDrivFindStream(IMG_CHAR * pszName, IMG_BOOL bResetStr if(bResetStream && psStream) { - static char szComment[] = "-- Init phase terminated\r\n"; + static IMG_CHAR szComment[] = "-- Init phase terminated\r\n"; psStream->psInitStream->ui32RPtr = 0; psStream->ui32RPtr = 0; psStream->ui32WPtr = 0; @@ -1024,14 +1024,14 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteStringCM(PDBG_STREAM psStream,IMG_CHAR * psz if (!StreamValid(psStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) + if ((psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE) == 0) { return(0); } @@ -1062,20 +1062,20 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszSt if (!StreamValid(psStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (!(psStream->ui32DebugLevel & ui32Level)) + if ((psStream->ui32DebugLevel & ui32Level) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC)) + if ((psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC) == 0) { if (psStream->ui32OutMode & DEBUG_OUTMODE_STANDARDDBG) { @@ -1096,12 +1096,12 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszSt if ( !( - (psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) || - (psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC) + ((psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) != 0) || + ((psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC) != 0) ) ) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } @@ -1119,7 +1119,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszSt while((pszString[ui32Len] != 0) && (ui32Len < ui32Space)) { - pui8Buffer[ui32WPtr] = pszString[ui32Len]; + pui8Buffer[ui32WPtr] = (IMG_UINT8)pszString[ui32Len]; ui32Len++; ui32WPtr++; if (ui32WPtr == psStream->ui32Size) @@ -1131,7 +1131,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszSt if (ui32Len < ui32Space) { - pui8Buffer[ui32WPtr] = pszString[ui32Len]; + pui8Buffer[ui32WPtr] = (IMG_UINT8)pszString[ui32Len]; ui32Len++; ui32WPtr++; if (ui32WPtr == psStream->ui32Size) @@ -1213,7 +1213,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivReadString(PDBG_STREAM psStream,IMG_CHAR * pszStr while ((pui8Buff[ui32Offset] != 0) && (ui32Len < ui32Limit)) { - pszString[ui32Len] = pui8Buff[ui32Offset]; + pszString[ui32Len] = (IMG_CHAR)pui8Buff[ui32Offset]; ui32Offset++; ui32Len++; @@ -1225,7 +1225,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivReadString(PDBG_STREAM psStream,IMG_CHAR * pszStr } } - pszString[ui32Len] = pui8Buff[ui32Offset]; + pszString[ui32Len] = (IMG_CHAR)pui8Buff[ui32Offset]; psStream->ui32RPtr = ui32Offset + 1; @@ -1246,29 +1246,29 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWrite(PDBG_STREAM psMainStream,IMG_UINT8 * pui8In if (!StreamValid(psMainStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (!(psMainStream->ui32DebugLevel & ui32Level)) + if ((psMainStream->ui32DebugLevel & ui32Level) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } if (psMainStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psMainStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) + if ((psMainStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } } else if (psMainStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) { if ((psMainStream->ui32Current != g_ui32HotKeyFrame) || (g_bHotKeyPressed == IMG_FALSE)) - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } if(psMainStream->bInitPhaseComplete) @@ -1286,7 +1286,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWrite(PDBG_STREAM psMainStream,IMG_UINT8 * pui8In - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE)) + if ((psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) == 0) { return(0); } @@ -1323,16 +1323,16 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteCM(PDBG_STREAM psStream,IMG_UINT8 * pui8InBu if (!StreamValid(psStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) + if ((psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } } else @@ -1341,7 +1341,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteCM(PDBG_STREAM psStream,IMG_UINT8 * pui8InBu { if ((psStream->ui32Current != g_ui32HotKeyFrame) || (g_bHotKeyPressed == IMG_FALSE)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } } } @@ -1358,14 +1358,14 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWrite2(PDBG_STREAM psMainStream,IMG_UINT8 * pui8I if (!StreamValid(psMainStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (!(psMainStream->ui32DebugLevel & ui32Level)) + if ((psMainStream->ui32DebugLevel & ui32Level) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } if(psMainStream->bInitPhaseComplete) @@ -1383,7 +1383,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWrite2(PDBG_STREAM psMainStream,IMG_UINT8 * pui8I - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE)) + if ((psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) == 0) { return(0); } @@ -1641,7 +1641,8 @@ void IMG_CALLCONV DBGDrivSetFrame(PDBG_STREAM psStream,IMG_UINT32 ui32Frame) - if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) && (psStream->ui32CapMode & DEBUG_CAPMODE_HOTKEY)) + if (((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) != 0) && + ((psStream->ui32CapMode & DEBUG_CAPMODE_HOTKEY) != 0)) { if (!g_bHotkeyMiddump) { @@ -1681,7 +1682,7 @@ IMG_UINT32 IMG_CALLCONV DBGDrivGetFrame(PDBG_STREAM psStream) return(psStream->ui32Current); } -IMG_UINT32 IMG_CALLCONV DBGDrivIsLastCaptureFrame(PDBG_STREAM psStream) +IMG_BOOL IMG_CALLCONV DBGDrivIsLastCaptureFrame(PDBG_STREAM psStream) { IMG_UINT32 ui32NextFrame; @@ -1703,9 +1704,9 @@ IMG_UINT32 IMG_CALLCONV DBGDrivIsLastCaptureFrame(PDBG_STREAM psStream) return IMG_FALSE; } -IMG_UINT32 IMG_CALLCONV DBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame) +IMG_BOOL IMG_CALLCONV DBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame) { - IMG_UINT32 ui32FrameShift = bCheckPreviousFrame ? 1 : 0; + IMG_UINT32 ui32FrameShift = bCheckPreviousFrame ? 1UL : 0UL; @@ -1854,29 +1855,29 @@ IMG_UINT32 IMG_CALLCONV DBGDrivWriteLF(PDBG_STREAM psStream, IMG_UINT8 * pui8InB if (!StreamValid(psStream)) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (!(psStream->ui32DebugLevel & ui32Level)) + if ((psStream->ui32DebugLevel & ui32Level) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) + if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) != 0) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) + if ((psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE) == 0) { - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } } else if (psStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) { if ((psStream->ui32Current != g_ui32HotKeyFrame) || (g_bHotKeyPressed == IMG_FALSE)) - return(0xFFFFFFFF); + return(0xFFFFFFFFUL); } psLFBuffer = FindLFBuf(psStream); @@ -1963,7 +1964,7 @@ IMG_BOOL ExpandStreamBuffer(PDBG_STREAM psStream, IMG_UINT32 ui32NewSize) - ui32NewSizeInPages = ((ui32NewSize + 0xfff) & ~0xfff) / 4096; + ui32NewSizeInPages = ((ui32NewSize + 0xfffUL) & ~0xfffUL) / 4096UL; if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) { diff --git a/tools/intern/debug/dbgdriv/common/dbgdriv.h b/tools/intern/debug/dbgdriv/common/dbgdriv.h index cdd9312..d05745d 100644 --- a/tools/intern/debug/dbgdriv/common/dbgdriv.h +++ b/tools/intern/debug/dbgdriv/common/dbgdriv.h @@ -43,38 +43,38 @@ IMG_VOID * IMG_CALLCONV DBGDrivCreateStream(IMG_CHAR * pszName, IMG_UINT32 ui32OutMode, IMG_UINT32 ui32Flags, IMG_UINT32 ui32Pages); -IMG_VOID IMG_CALLCONV DBGDrivDestroyStream(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV DBGDrivDestroyStream(PDBG_STREAM psStream); IMG_VOID * IMG_CALLCONV DBGDrivFindStream(IMG_CHAR * pszName, IMG_BOOL bResetStream); IMG_UINT32 IMG_CALLCONV DBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV DBGDrivReadString(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Limit); IMG_UINT32 IMG_CALLCONV DBGDrivWrite(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV DBGDrivWrite2(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV DBGDrivRead(PDBG_STREAM psStream, IMG_BOOL bReadInitBuffer, IMG_UINT32 ui32OutBufferSize,IMG_UINT8 *pui8OutBuf); -IMG_VOID IMG_CALLCONV DBGDrivSetCaptureMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode,IMG_UINT32 ui32Start,IMG_UINT32 ui32Stop,IMG_UINT32 ui32SampleRate); -IMG_VOID IMG_CALLCONV DBGDrivSetOutputMode(PDBG_STREAM psStream,IMG_UINT32 ui32OutMode); -IMG_VOID IMG_CALLCONV DBGDrivSetDebugLevel(PDBG_STREAM psStream,IMG_UINT32 ui32DebugLevel); -IMG_VOID IMG_CALLCONV DBGDrivSetFrame(PDBG_STREAM psStream,IMG_UINT32 ui32Frame); +IMG_VOID IMG_CALLCONV DBGDrivSetCaptureMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode,IMG_UINT32 ui32Start,IMG_UINT32 ui32Stop,IMG_UINT32 ui32SampleRate); +IMG_VOID IMG_CALLCONV DBGDrivSetOutputMode(PDBG_STREAM psStream,IMG_UINT32 ui32OutMode); +IMG_VOID IMG_CALLCONV DBGDrivSetDebugLevel(PDBG_STREAM psStream,IMG_UINT32 ui32DebugLevel); +IMG_VOID IMG_CALLCONV DBGDrivSetFrame(PDBG_STREAM psStream,IMG_UINT32 ui32Frame); IMG_UINT32 IMG_CALLCONV DBGDrivGetFrame(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV DBGDrivOverrideMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode); -IMG_VOID IMG_CALLCONV DBGDrivDefaultMode(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV DBGDrivOverrideMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode); +IMG_VOID IMG_CALLCONV DBGDrivDefaultMode(PDBG_STREAM psStream); IMG_UINT32 IMG_CALLCONV DBGDrivGetServiceTable(IMG_VOID); IMG_UINT32 IMG_CALLCONV DBGDrivWriteStringCM(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV DBGDrivWriteCM(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); -IMG_VOID IMG_CALLCONV DBGDrivSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker); +IMG_VOID IMG_CALLCONV DBGDrivSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker); IMG_UINT32 IMG_CALLCONV DBGDrivGetMarker(PDBG_STREAM psStream); -IMG_UINT32 IMG_CALLCONV DBGDrivIsLastCaptureFrame(PDBG_STREAM psStream); -IMG_UINT32 IMG_CALLCONV DBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame); +IMG_BOOL IMG_CALLCONV DBGDrivIsLastCaptureFrame(PDBG_STREAM psStream); +IMG_BOOL IMG_CALLCONV DBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame); IMG_UINT32 IMG_CALLCONV DBGDrivWriteLF(PDBG_STREAM psStream, IMG_UINT8 *pui8InBuf, IMG_UINT32 ui32InBuffSize, IMG_UINT32 ui32Level, IMG_UINT32 ui32Flags); IMG_UINT32 IMG_CALLCONV DBGDrivReadLF(PDBG_STREAM psStream, IMG_UINT32 ui32OutBuffSize, IMG_UINT8 *pui8OutBuf); -IMG_VOID IMG_CALLCONV DBGDrivStartInitPhase(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV DBGDrivStopInitPhase(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV DBGDrivStartInitPhase(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV DBGDrivStopInitPhase(PDBG_STREAM psStream); IMG_UINT32 IMG_CALLCONV DBGDrivGetStreamOffset(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV DBGDrivSetStreamOffset(PDBG_STREAM psStream, IMG_UINT32 ui32StreamOffset); -IMG_VOID IMG_CALLCONV DBGDrivWaitForEvent(DBG_EVENT eEvent); +IMG_VOID IMG_CALLCONV DBGDrivSetStreamOffset(PDBG_STREAM psStream, IMG_UINT32 ui32StreamOffset); +IMG_VOID IMG_CALLCONV DBGDrivWaitForEvent(DBG_EVENT eEvent); IMG_VOID DestroyAllStreams(IMG_VOID); -IMG_UINT32 AtoI(char *szIn); +IMG_UINT32 AtoI(IMG_CHAR *szIn); IMG_VOID HostMemSet(IMG_VOID *pvDest,IMG_UINT8 ui8Value,IMG_UINT32 ui32Size); IMG_VOID HostMemCopy(IMG_VOID *pvDest,IMG_VOID *pvSrc,IMG_UINT32 ui32Size); @@ -84,33 +84,33 @@ IMG_VOID MonoOut(IMG_CHAR * pszString,IMG_BOOL bNewLine); IMG_VOID * IMG_CALLCONV ExtDBGDrivCreateStream(IMG_CHAR * pszName, IMG_UINT32 ui32CapMode, IMG_UINT32 ui32OutMode, IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size); -IMG_VOID IMG_CALLCONV ExtDBGDrivDestroyStream(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV ExtDBGDrivDestroyStream(PDBG_STREAM psStream); IMG_VOID * IMG_CALLCONV ExtDBGDrivFindStream(IMG_CHAR * pszName, IMG_BOOL bResetStream); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWriteString(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV ExtDBGDrivReadString(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Limit); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWrite(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV ExtDBGDrivRead(PDBG_STREAM psStream, IMG_BOOL bReadInitBuffer, IMG_UINT32 ui32OutBuffSize,IMG_UINT8 *pui8OutBuf); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetCaptureMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode,IMG_UINT32 ui32Start,IMG_UINT32 ui32End,IMG_UINT32 ui32SampleRate); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetOutputMode(PDBG_STREAM psStream,IMG_UINT32 ui32OutMode); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetDebugLevel(PDBG_STREAM psStream,IMG_UINT32 ui32DebugLevel); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetFrame(PDBG_STREAM psStream,IMG_UINT32 ui32Frame); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetCaptureMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode,IMG_UINT32 ui32Start,IMG_UINT32 ui32End,IMG_UINT32 ui32SampleRate); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetOutputMode(PDBG_STREAM psStream,IMG_UINT32 ui32OutMode); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetDebugLevel(PDBG_STREAM psStream,IMG_UINT32 ui32DebugLevel); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetFrame(PDBG_STREAM psStream,IMG_UINT32 ui32Frame); IMG_UINT32 IMG_CALLCONV ExtDBGDrivGetFrame(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV ExtDBGDrivOverrideMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode); -IMG_VOID IMG_CALLCONV ExtDBGDrivDefaultMode(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV ExtDBGDrivOverrideMode(PDBG_STREAM psStream,IMG_UINT32 ui32Mode); +IMG_VOID IMG_CALLCONV ExtDBGDrivDefaultMode(PDBG_STREAM psStream); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWrite2(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWriteStringCM(PDBG_STREAM psStream,IMG_CHAR * pszString,IMG_UINT32 ui32Level); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWriteCM(PDBG_STREAM psStream,IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize,IMG_UINT32 ui32Level); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetMarker(PDBG_STREAM psStream, IMG_UINT32 ui32Marker); IMG_UINT32 IMG_CALLCONV ExtDBGDrivGetMarker(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV ExtDBGDrivStartInitPhase(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV ExtDBGDrivStopInitPhase(PDBG_STREAM psStream); -IMG_UINT32 IMG_CALLCONV ExtDBGDrivIsLastCaptureFrame(PDBG_STREAM psStream); -IMG_UINT32 IMG_CALLCONV ExtDBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame); +IMG_VOID IMG_CALLCONV ExtDBGDrivStartInitPhase(PDBG_STREAM psStream); +IMG_VOID IMG_CALLCONV ExtDBGDrivStopInitPhase(PDBG_STREAM psStream); +IMG_BOOL IMG_CALLCONV ExtDBGDrivIsLastCaptureFrame(PDBG_STREAM psStream); +IMG_BOOL IMG_CALLCONV ExtDBGDrivIsCaptureFrame(PDBG_STREAM psStream, IMG_BOOL bCheckPreviousFrame); IMG_UINT32 IMG_CALLCONV ExtDBGDrivWriteLF(PDBG_STREAM psStream, IMG_UINT8 *pui8InBuf, IMG_UINT32 ui32InBuffSize, IMG_UINT32 ui32Level, IMG_UINT32 ui32Flags); IMG_UINT32 IMG_CALLCONV ExtDBGDrivReadLF(PDBG_STREAM psStream, IMG_UINT32 ui32OutBuffSize, IMG_UINT8 *pui8OutBuf); IMG_UINT32 IMG_CALLCONV ExtDBGDrivGetStreamOffset(PDBG_STREAM psStream); -IMG_VOID IMG_CALLCONV ExtDBGDrivSetStreamOffset(PDBG_STREAM psStream, IMG_UINT32 ui32StreamOffset); -IMG_VOID IMG_CALLCONV ExtDBGDrivWaitForEvent(DBG_EVENT eEvent); +IMG_VOID IMG_CALLCONV ExtDBGDrivSetStreamOffset(PDBG_STREAM psStream, IMG_UINT32 ui32StreamOffset); +IMG_VOID IMG_CALLCONV ExtDBGDrivWaitForEvent(DBG_EVENT eEvent); #endif diff --git a/tools/intern/debug/dbgdriv/common/hostfunc.h b/tools/intern/debug/dbgdriv/common/hostfunc.h index 7b588b5..3a29db6 100644 --- a/tools/intern/debug/dbgdriv/common/hostfunc.h +++ b/tools/intern/debug/dbgdriv/common/hostfunc.h @@ -30,7 +30,7 @@ #define HOST_PAGESIZE (4096) #define DBG_MEMORY_INITIALIZER (0xe2) -IMG_UINT32 HostReadRegistryDWORDFromString(char *pcKey, char *pcValueName, IMG_UINT32 *pui32Data); +IMG_UINT32 HostReadRegistryDWORDFromString(IMG_CHAR *pcKey, IMG_CHAR *pcValueName, IMG_UINT32 *pui32Data); IMG_VOID * HostPageablePageAlloc(IMG_UINT32 ui32Pages); IMG_VOID HostPageablePageFree(IMG_VOID * pvBase); diff --git a/tools/intern/debug/dbgdriv/common/ioctl.c b/tools/intern/debug/dbgdriv/common/ioctl.c index 8ef809f..a624635 100644 --- a/tools/intern/debug/dbgdriv/common/ioctl.c +++ b/tools/intern/debug/dbgdriv/common/ioctl.c @@ -41,7 +41,7 @@ IMG_UINT32 DBGDIOCDrivCreateStream(IMG_VOID * pvInBuffer, IMG_VOID * pvOutBuffer PDBG_IN_CREATESTREAM psIn; IMG_VOID * *ppvOut; #ifdef LINUX - static char name[32]; + static IMG_CHAR name[32]; #endif psIn = (PDBG_IN_CREATESTREAM) pvInBuffer; @@ -50,7 +50,10 @@ IMG_UINT32 DBGDIOCDrivCreateStream(IMG_VOID * pvInBuffer, IMG_VOID * pvOutBuffer #ifdef LINUX if(copy_from_user(name, psIn->pszName, 32) != 0) + { return IMG_FALSE; + } + *ppvOut = ExtDBGDrivCreateStream(name, psIn->ui32CapMode, psIn->ui32OutMode, 0, psIn->ui32Pages); #else diff --git a/tools/intern/debug/dbgdriv/linux/hostfunc.c b/tools/intern/debug/dbgdriv/linux/hostfunc.c index dc2f035..5301a58 100644 --- a/tools/intern/debug/dbgdriv/linux/hostfunc.c +++ b/tools/intern/debug/dbgdriv/linux/hostfunc.c @@ -51,8 +51,9 @@ #include "pvr_debug.h" #include "dbgdrvif.h" -#include "hostfunc.h" +#include "dbgdriv/common/hostfunc.h" +#if !defined(SUPPORT_DRI_DRM) IMG_UINT32 gPVRDebugLevel = DBGPRIV_WARNING; #define PVR_STRING_TERMINATOR '\0' @@ -144,6 +145,7 @@ void PVRSRVDebugPrintf ( va_end (vaArgs); } } +#endif IMG_VOID HostMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_UINT32 ui32Size) { diff --git a/tools/intern/debug/dbgdriv/linux/kbuild/Makefile b/tools/intern/debug/dbgdriv/linux/kbuild/Makefile index d61a64e..5fb9b1e 100644 --- a/tools/intern/debug/dbgdriv/linux/kbuild/Makefile +++ b/tools/intern/debug/dbgdriv/linux/kbuild/Makefile @@ -28,16 +28,8 @@ include $(EURASIAROOT)/eurasiacon/build/linux/kbuild/Makefile.kbuild_subdir_comm MODULE = dbgdrv -INCLUDES = -I$(EURASIAROOT)/include4 \ - -I$(EURASIAROOT)/tools/intern/debug/dbgdriv/common \ - -I$(EURASIAROOT)/tools/intern/debug/dbgdriv/linux \ - -I$(EURASIAROOT)/tools/intern/debug/client +INCLUDES = -SOURCES = ../main.c \ - ../../common/dbgdriv.c \ - ../../common/ioctl.c \ - ../hostfunc.c \ - ../../common/hotkey.c +SOURCES = - - +include $(EURASIAROOT)/tools/intern/debug/dbgdriv/linux/makefile.linux.common diff --git a/tools/intern/debug/dbgdriv/linux/main.c b/tools/intern/debug/dbgdriv/linux/main.c index 09f9ab3..f20e88a 100644 --- a/tools/intern/debug/dbgdriv/linux/main.c +++ b/tools/intern/debug/dbgdriv/linux/main.c @@ -33,37 +33,58 @@ #include #include #include +#include + +#if defined(LDM_PLATFORM) && !defined(SUPPORT_DRI_DRM) +#include +#endif + +#if defined(LDM_PCI) && !defined(SUPPORT_DRI_DRM) +#include +#endif + #include +#if defined(SUPPORT_DRI_DRM) +#include "drmP.h" +#include "drm.h" +#endif + #include "img_types.h" -#include "linuxsrv.h" -#include "ioctl.h" +#include "client/linuxsrv.h" +#include "dbgdriv/common/ioctl.h" #include "dbgdrvif.h" -#include "dbgdriv.h" -#include "hostfunc.h" +#include "dbgdriv/common/dbgdriv.h" +#include "dbgdriv/common/hostfunc.h" #include "pvr_debug.h" +#include "pvrmodule.h" +#if defined(SUPPORT_DRI_DRM) -#define DRVNAME "dbgdrv" +#include "pvr_drm_shared.h" +#include "pvr_drm.h" + +#else -MODULE_AUTHOR("Imagination Technologies Ltd. "); -MODULE_LICENSE("GPL"); +#define DRVNAME "dbgdrv" MODULE_SUPPORTED_DEVICE(DRVNAME); -static int AssignedMajorNumber = 0; +#if (defined(LDM_PLATFORM) || defined(LDM_PCI)) && !defined(SUPPORT_DRI_DRM) +static struct class *psDbgDrvClass; +#endif -extern DBGKM_SERVICE_TABLE g_sDBGKMServices; +static int AssignedMajorNumber = 0; long dbgdrv_ioctl(struct file *, unsigned int, unsigned long); static int dbgdrv_open(struct inode unref__ * pInode, struct file unref__ * pFile) { - return 0; + return 0; } static int dbgdrv_release(struct inode unref__ * pInode, struct file unref__ * pFile) { - return 0; + return 0; } static int dbgdrv_mmap(struct file* pFile, struct vm_area_struct* ps_vma) @@ -72,95 +93,151 @@ static int dbgdrv_mmap(struct file* pFile, struct vm_area_struct* ps_vma) } static struct file_operations dbgdrv_fops = { - owner:THIS_MODULE, - unlocked_ioctl:dbgdrv_ioctl, - open:dbgdrv_open, - release:dbgdrv_release, - mmap:dbgdrv_mmap, + .owner = THIS_MODULE, + .unlocked_ioctl = dbgdrv_ioctl, + .open = dbgdrv_open, + .release = dbgdrv_release, + .mmap = dbgdrv_mmap, }; +#endif void DBGDrvGetServiceTable(void **fn_table) { - *fn_table = &g_sDBGKMServices; + extern DBGKM_SERVICE_TABLE g_sDBGKMServices; + *fn_table = &g_sDBGKMServices; } +#if defined(SUPPORT_DRI_DRM) +void dbgdrv_cleanup(void) +#else void cleanup_module(void) +#endif { - if (AssignedMajorNumber > 0) - { +#if !defined(SUPPORT_DRI_DRM) +#if defined(LDM_PLATFORM) || defined(LDM_PCI) + device_destroy(psDbgDrvClass, MKDEV(AssignedMajorNumber, 0)); + class_destroy(psDbgDrvClass); +#endif unregister_chrdev(AssignedMajorNumber, DRVNAME); - } - +#endif #if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - HostDestroyEventObjects(); + HostDestroyEventObjects(); #endif - - if (g_pvAPIMutex != IMG_NULL) - { HostDestroyMutex(g_pvAPIMutex); - } - - return; + return; } +#if defined(SUPPORT_DRI_DRM) +IMG_INT dbgdrv_init(void) +#else int init_module(void) +#endif { - - if ((g_pvAPIMutex=HostCreateMutex()) == IMG_NULL) - { - cleanup_module(); - return -ENOMEM; - } +#if (defined(LDM_PLATFORM) || defined(LDM_PCI)) && !defined(SUPPORT_DRI_DRM) + struct device *psDev; +#endif + +#if !defined(SUPPORT_DRI_DRM) + int err = -EBUSY; +#endif + + + if ((g_pvAPIMutex=HostCreateMutex()) == IMG_NULL) + { + return -ENOMEM; + } #if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - - (void) HostCreateEventObjects(); + + (void) HostCreateEventObjects(); #endif - AssignedMajorNumber = - register_chrdev(AssignedMajorNumber, DRVNAME, &dbgdrv_fops); +#if !defined(SUPPORT_DRI_DRM) + AssignedMajorNumber = + register_chrdev(AssignedMajorNumber, DRVNAME, &dbgdrv_fops); - if (AssignedMajorNumber <= 0) - { + if (AssignedMajorNumber <= 0) + { PVR_DPF((PVR_DBG_ERROR," unable to get major\n")); - cleanup_module(); - return -EBUSY; - } + goto ErrDestroyEventObjects; + } + +#if defined(LDM_PLATFORM) || defined(LDM_PCI) + + psDbgDrvClass = class_create(THIS_MODULE, DRVNAME); + if (IS_ERR(psDbgDrvClass)) + { + PVR_DPF((PVR_DBG_ERROR, "%s: unable to create class (%ld)", + __func__, PTR_ERR(psDbgDrvClass))); + goto ErrUnregisterCharDev; + } + + psDev = device_create(psDbgDrvClass, NULL, MKDEV(AssignedMajorNumber, 0), +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) + NULL, +#endif + DRVNAME); + if (IS_ERR(psDev)) + { + PVR_DPF((PVR_DBG_ERROR, "%s: unable to create device (%ld)", + __func__, PTR_ERR(psDev))); + goto ErrDestroyClass; + } +#endif +#endif - return 0; + return 0; + +#if !defined(SUPPORT_DRI_DRM) +ErrDestroyEventObjects: +#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) + HostDestroyEventObjects(); +#endif +#if defined(LDM_PLATFORM) || defined(LDM_PCI) +ErrUnregisterCharDev: + unregister_chrdev(AssignedMajorNumber, DRVNAME); +ErrDestroyClass: + class_destroy(psDbgDrvClass); +#endif + return err; +#endif } -long dbgdrv_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +#if defined(SUPPORT_DRI_DRM) +IMG_INT dbgdrv_ioctl(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile) +#else +long dbgdrv_ioctl(struct file *file, unsigned int ioctlCmd, unsigned long arg) +#endif { - IOCTL_PACKAGE *pIP = (IOCTL_PACKAGE *) arg; + IOCTL_PACKAGE *pIP = (IOCTL_PACKAGE *) arg; + char *buffer, *in, *out; + unsigned int cmd; - char *buffer, *in, *out; - - if((pIP->ui32InBufferSize > (PAGE_SIZE >> 1) ) || (pIP->ui32OutBufferSize > (PAGE_SIZE >> 1))) - { + if((pIP->ui32InBufferSize > (PAGE_SIZE >> 1) ) || (pIP->ui32OutBufferSize > (PAGE_SIZE >> 1))) + { PVR_DPF((PVR_DBG_ERROR,"Sizes of the buffers are too large, cannot do ioctl\n")); return -1; - } + } - buffer = (char *) HostPageablePageAlloc(1); - if(!buffer) - { - PVR_DPF((PVR_DBG_ERROR,"Failed to allocate buffer, cannot do ioctl\n")); - return -EFAULT; - } + buffer = (char *) HostPageablePageAlloc(1); + if(!buffer) + { + PVR_DPF((PVR_DBG_ERROR,"Failed to allocate buffer, cannot do ioctl\n")); + return -EFAULT; + } - in = buffer; - out = buffer + (PAGE_SIZE >>1); + in = buffer; + out = buffer + (PAGE_SIZE >>1); - if(copy_from_user(in, pIP->pInBuffer, pIP->ui32InBufferSize) != 0) + if(copy_from_user(in, pIP->pInBuffer, pIP->ui32InBufferSize) != 0) { goto init_failed; } - cmd = ((pIP->ui32Cmd >> 2) & 0xFFF) - 0x801; - + cmd = ((pIP->ui32Cmd >> 2) & 0xFFF) - 0x801; + if(pIP->ui32Cmd == DEBUG_SERVICE_READ) { IMG_CHAR *ui8Tmp; @@ -168,14 +245,17 @@ long dbgdrv_ioctl(struct file *file, unsigned int cmd, unsigned long arg) DBG_IN_READ *psReadInParams = (DBG_IN_READ *)in; ui8Tmp = vmalloc(psReadInParams->ui32OutBufferSize); + if(!ui8Tmp) { goto init_failed; } + *pui32BytesCopied = ExtDBGDrivRead((DBG_STREAM *)psReadInParams->pvStream, psReadInParams->bReadInitBuffer, psReadInParams->ui32OutBufferSize, ui8Tmp); + if(copy_to_user(psReadInParams->pui8OutBuffer, ui8Tmp, *pui32BytesCopied) != 0) @@ -183,24 +263,25 @@ long dbgdrv_ioctl(struct file *file, unsigned int cmd, unsigned long arg) vfree(ui8Tmp); goto init_failed; } + vfree(ui8Tmp); - } + } else { (g_DBGDrivProc[cmd])(in, out); } - - if(copy_to_user(pIP->pOutBuffer, out, pIP->ui32OutBufferSize) != 0) + + if(copy_to_user(pIP->pOutBuffer, out, pIP->ui32OutBufferSize) != 0) { goto init_failed; } - HostPageablePageFree((IMG_VOID *)buffer); - return 0; + HostPageablePageFree((IMG_VOID *)buffer); + return 0; init_failed: - HostPageablePageFree((IMG_VOID *)buffer); - return -EFAULT; + HostPageablePageFree((IMG_VOID *)buffer); + return -EFAULT; } @@ -215,4 +296,3 @@ void DefineHotKey(unsigned ScanCode, unsigned ShiftState, void *pInfo) } EXPORT_SYMBOL(DBGDrvGetServiceTable); - diff --git a/tools/intern/debug/dbgdriv/linux/makefile.linux.common b/tools/intern/debug/dbgdriv/linux/makefile.linux.common new file mode 100644 index 0000000..d2a2932 --- /dev/null +++ b/tools/intern/debug/dbgdriv/linux/makefile.linux.common @@ -0,0 +1,40 @@ +# +# Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms and conditions of the GNU General Public License, +# version 2, as published by the Free Software Foundation. +# +# This program is distributed in the hope it will be useful but, except +# as otherwise stated in writing, without any warranty; without even the +# implied warranty of merchantability or fitness for a particular purpose. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +# +# The full GNU General Public License is included in this distribution in +# the file called "COPYING". +# +# Contact Information: +# Imagination Technologies Ltd. +# Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK +# +# +# + +ifeq ($(SUPPORT_DRI_DRM),1) +DBGDRV_SOURCES_ROOT = $(KBUILDROOT)/../tools/intern/debug/dbgdriv +else +DBGDRV_SOURCES_ROOT = ../.. +endif + +INCLUDES += -I$(EURASIAROOT)/include4 \ + -I$(EURASIAROOT)/tools/intern/debug + +SOURCES += $(DBGDRV_SOURCES_ROOT)/linux/main.c \ + $(DBGDRV_SOURCES_ROOT)/common/dbgdriv.c \ + $(DBGDRV_SOURCES_ROOT)/common/ioctl.c \ + $(DBGDRV_SOURCES_ROOT)/linux/hostfunc.c \ + $(DBGDRV_SOURCES_ROOT)/common/hotkey.c -- 2.39.5