1 /**********************************************************************
3 * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful but, except
10 * as otherwise stated in writing, without any warranty; without even the
11 * implied warranty of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
22 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
25 ******************************************************************************/
29 #include "services_headers.h"
30 #include "buffer_manager.h"
31 #include "pvr_bridge_km.h"
34 #include "pvr_pdump.h"
36 #include "pvr_events.h"
38 #include "pvrversion.h"
40 #define HASH_TAB_INIT_SIZE 32
41 enum PVRSRV_ERROR AllocateDeviceID(struct SYS_DATA *psSysData, u32 *pui32DevID)
43 struct SYS_DEVICE_ID *psDeviceWalker;
44 struct SYS_DEVICE_ID *psDeviceEnd;
46 psDeviceWalker = &psSysData->sDeviceID[0];
47 psDeviceEnd = psDeviceWalker + psSysData->ui32NumDevices;
49 while (psDeviceWalker < psDeviceEnd) {
50 if (!psDeviceWalker->bInUse) {
51 psDeviceWalker->bInUse = IMG_TRUE;
52 *pui32DevID = psDeviceWalker->uiID;
58 PVR_DPF(PVR_DBG_ERROR,
59 "AllocateDeviceID: No free and valid device IDs available!");
61 PVR_ASSERT(psDeviceWalker < psDeviceEnd);
63 return PVRSRV_ERROR_GENERIC;
66 enum PVRSRV_ERROR FreeDeviceID(struct SYS_DATA *psSysData, u32 ui32DevID)
68 struct SYS_DEVICE_ID *psDeviceWalker;
69 struct SYS_DEVICE_ID *psDeviceEnd;
71 psDeviceWalker = &psSysData->sDeviceID[0];
72 psDeviceEnd = psDeviceWalker + psSysData->ui32NumDevices;
74 while (psDeviceWalker < psDeviceEnd) {
75 if ((psDeviceWalker->uiID == ui32DevID) &&
76 (psDeviceWalker->bInUse)) {
77 psDeviceWalker->bInUse = IMG_FALSE;
83 PVR_DPF(PVR_DBG_ERROR,
84 "FreeDeviceID: no matching dev ID that is in use!");
86 PVR_ASSERT(psDeviceWalker < psDeviceEnd);
88 return PVRSRV_ERROR_GENERIC;
91 enum PVRSRV_ERROR PVRSRVEnumerateDevicesKM(u32 *pui32NumDevices,
92 struct PVRSRV_DEVICE_IDENTIFIER *psDevIdList)
94 enum PVRSRV_ERROR eError;
95 struct SYS_DATA *psSysData;
96 struct PVRSRV_DEVICE_NODE *psDeviceNode;
99 if (!pui32NumDevices || !psDevIdList) {
100 PVR_DPF(PVR_DBG_ERROR,
101 "PVRSRVEnumerateDevicesKM: Invalid params");
102 return PVRSRV_ERROR_INVALID_PARAMS;
105 eError = SysAcquireData(&psSysData);
106 if (eError != PVRSRV_OK) {
107 PVR_DPF(PVR_DBG_ERROR,
108 "PVRSRVEnumerateDevicesKM: Failed to get SysData");
112 for (i = 0; i < PVRSRV_MAX_DEVICES; i++)
113 psDevIdList[i].eDeviceType = PVRSRV_DEVICE_TYPE_UNKNOWN;
115 *pui32NumDevices = 0;
117 psDeviceNode = psSysData->psDeviceNodeList;
118 for (i = 0; psDeviceNode != NULL; i++) {
119 if (psDeviceNode->sDevId.eDeviceType !=
120 PVRSRV_DEVICE_TYPE_EXT) {
121 *psDevIdList++ = psDeviceNode->sDevId;
122 (*pui32NumDevices)++;
124 psDeviceNode = psDeviceNode->psNext;
130 enum PVRSRV_ERROR PVRSRVInit(struct SYS_DATA *psSysData)
132 enum PVRSRV_ERROR eError;
134 eError = ResManInit();
135 if (eError != PVRSRV_OK)
138 eError = PVRSRVPerProcessDataInit();
139 if (eError != PVRSRV_OK)
142 eError = PVRSRVHandleInit();
143 if (eError != PVRSRV_OK)
146 psSysData->eCurrentPowerState = PVRSRV_POWER_STATE_D0;
147 psSysData->eFailedPowerState = PVRSRV_POWER_Unspecified;
149 if (OSAllocMem(PVRSRV_PAGEABLE_SELECT,
150 sizeof(struct PVRSRV_EVENTOBJECT),
151 (void **) &psSysData->psGlobalEventObject,
156 if (OSEventObjectCreate("PVRSRV_GLOBAL_EVENTOBJECT",
157 psSysData->psGlobalEventObject) != PVRSRV_OK)
163 PVRSRVDeInit(psSysData);
167 void PVRSRVDeInit(struct SYS_DATA *psSysData)
169 enum PVRSRV_ERROR eError;
171 PVR_UNREFERENCED_PARAMETER(psSysData);
173 if (psSysData == NULL) {
174 PVR_DPF(PVR_DBG_ERROR, "PVRSRVDeInit: "
175 "PVRSRVHandleDeInit failed - invalid param");
179 if (psSysData->psGlobalEventObject) {
180 OSEventObjectDestroy(psSysData->psGlobalEventObject);
181 OSFreeMem(PVRSRV_PAGEABLE_SELECT,
182 sizeof(struct PVRSRV_EVENTOBJECT),
183 psSysData->psGlobalEventObject, NULL);
186 eError = PVRSRVHandleDeInit();
187 if (eError != PVRSRV_OK)
188 PVR_DPF(PVR_DBG_ERROR,
189 "PVRSRVDeInit: PVRSRVHandleDeInit failed");
191 eError = PVRSRVPerProcessDataDeInit();
192 if (eError != PVRSRV_OK)
193 PVR_DPF(PVR_DBG_ERROR,
194 "PVRSRVDeInit: PVRSRVPerProcessDataDeInit failed");
199 enum PVRSRV_ERROR PVRSRVRegisterDevice(struct SYS_DATA *psSysData,
200 enum PVRSRV_ERROR(*pfnRegisterDevice)
201 (struct PVRSRV_DEVICE_NODE *),
202 u32 ui32SOCInterruptBit,
203 u32 *pui32DeviceIndex)
205 enum PVRSRV_ERROR eError;
206 struct PVRSRV_DEVICE_NODE *psDeviceNode;
208 if (OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
209 sizeof(struct PVRSRV_DEVICE_NODE),
210 (void **) &psDeviceNode, NULL) != PVRSRV_OK) {
211 PVR_DPF(PVR_DBG_ERROR, "PVRSRVRegisterDevice : "
212 "Failed to alloc memory for psDeviceNode");
213 return PVRSRV_ERROR_OUT_OF_MEMORY;
215 OSMemSet(psDeviceNode, 0, sizeof(struct PVRSRV_DEVICE_NODE));
217 eError = pfnRegisterDevice(psDeviceNode);
218 if (eError != PVRSRV_OK) {
219 OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
220 sizeof(struct PVRSRV_DEVICE_NODE), psDeviceNode,
222 PVR_DPF(PVR_DBG_ERROR, "PVRSRVRegisterDevice : "
223 "Failed to register device");
224 return PVRSRV_ERROR_DEVICE_REGISTER_FAILED;
227 psDeviceNode->ui32RefCount = 1;
228 psDeviceNode->psSysData = psSysData;
229 psDeviceNode->ui32SOCInterruptBit = ui32SOCInterruptBit;
231 AllocateDeviceID(psSysData, &psDeviceNode->sDevId.ui32DeviceIndex);
233 psDeviceNode->psNext = psSysData->psDeviceNodeList;
234 psSysData->psDeviceNodeList = psDeviceNode;
236 *pui32DeviceIndex = psDeviceNode->sDevId.ui32DeviceIndex;
241 enum PVRSRV_ERROR PVRSRVInitialiseDevice(u32 ui32DevIndex)
243 struct PVRSRV_DEVICE_NODE *psDeviceNode;
244 struct SYS_DATA *psSysData;
245 enum PVRSRV_ERROR eError;
247 PVR_DPF(PVR_DBG_MESSAGE, "PVRSRVInitialiseDevice");
249 eError = SysAcquireData(&psSysData);
250 if (eError != PVRSRV_OK) {
251 PVR_DPF(PVR_DBG_ERROR,
252 "PVRSRVInitialiseDevice: Failed to get SysData");
256 psDeviceNode = psSysData->psDeviceNodeList;
258 while (psDeviceNode) {
259 if (psDeviceNode->sDevId.ui32DeviceIndex == ui32DevIndex)
261 psDeviceNode = psDeviceNode->psNext;
264 PVR_DPF(PVR_DBG_ERROR,
265 "PVRSRVInitialiseDevice: requested device is not present");
266 return PVRSRV_ERROR_INIT_FAILURE;
270 PVR_ASSERT(psDeviceNode->ui32RefCount > 0);
272 eError = PVRSRVResManConnect(NULL, &psDeviceNode->hResManContext);
273 if (eError != PVRSRV_OK) {
274 PVR_DPF(PVR_DBG_ERROR, "PVRSRVInitialiseDevice: "
275 "Failed PVRSRVResManConnect call");
279 if (psDeviceNode->pfnInitDevice != NULL) {
280 eError = psDeviceNode->pfnInitDevice(psDeviceNode);
281 if (eError != PVRSRV_OK) {
282 PVR_DPF(PVR_DBG_ERROR, "PVRSRVInitialiseDevice: "
283 "Failed InitDevice call");
288 psDeviceNode->sync_table = HASH_Create(HASH_TAB_INIT_SIZE);
289 if (psDeviceNode->sync_table == NULL) {
290 PVR_DPF(PVR_DBG_ERROR, "InitDevInfo: "
291 "Couldn't create syncobject hash table");
292 eError = PVRSRV_ERROR_GENERIC;
299 enum PVRSRV_ERROR PVRSRVFinaliseSystem(IMG_BOOL bInitSuccessful)
301 struct PVRSRV_DEVICE_NODE *psDeviceNode;
302 struct SYS_DATA *psSysData;
303 enum PVRSRV_ERROR eError;
305 PVR_DPF(PVR_DBG_MESSAGE, "PVRSRVFinaliseSystem");
307 eError = SysAcquireData(&psSysData);
308 if (eError != PVRSRV_OK) {
309 PVR_DPF(PVR_DBG_ERROR,
310 "PVRSRVFinaliseSystem: Failed to get SysData");
314 if (bInitSuccessful) {
315 eError = SysFinalise();
316 if (eError != PVRSRV_OK) {
317 PVR_DPF(PVR_DBG_ERROR,
318 "PVRSRVFinaliseSystem: SysFinalise failed (%d)",
323 psDeviceNode = psSysData->psDeviceNodeList;
324 while (psDeviceNode) {
326 PVRSRVSetDevicePowerStateKM(
327 psDeviceNode->sDevId.ui32DeviceIndex,
328 PVRSRV_POWER_Unspecified);
329 if (eError != PVRSRV_OK)
330 PVR_DPF(PVR_DBG_ERROR, "PVRSRVFinaliseSystem: "
331 "Failed PVRSRVSetDevicePowerStateKM "
332 "call (device index: %d)",
333 psDeviceNode->sDevId.ui32DeviceIndex);
334 psDeviceNode = psDeviceNode->psNext;
337 psDeviceNode = psSysData->psDeviceNodeList;
338 while (psDeviceNode) {
339 if (psDeviceNode->pfnInitDeviceCompatCheck) {
340 eError = PVRSRVDevInitCompatCheck(psDeviceNode);
341 if (eError != PVRSRV_OK) {
342 PVR_DPF(PVR_DBG_ERROR,
343 "PVRSRVFinaliseSystem: "
344 "Failed PVRSRVDevInitCompatCheck "
345 "call (device index: %d)",
346 psDeviceNode->sDevId.
351 psDeviceNode = psDeviceNode->psNext;
360 enum PVRSRV_ERROR PVRSRVDevInitCompatCheck(struct PVRSRV_DEVICE_NODE
364 return psDeviceNode->pfnInitDeviceCompatCheck(psDeviceNode);
367 enum PVRSRV_ERROR PVRSRVAcquireDeviceDataKM(u32 ui32DevIndex,
368 enum PVRSRV_DEVICE_TYPE eDeviceType,
371 struct PVRSRV_DEVICE_NODE *psDeviceNode;
372 struct SYS_DATA *psSysData;
373 enum PVRSRV_ERROR eError;
375 PVR_DPF(PVR_DBG_MESSAGE, "PVRSRVAcquireDeviceDataKM");
377 eError = SysAcquireData(&psSysData);
378 if (eError != PVRSRV_OK) {
379 PVR_DPF(PVR_DBG_ERROR,
380 "PVRSRVAcquireDeviceDataKM: Failed to get SysData");
384 psDeviceNode = psSysData->psDeviceNodeList;
386 if (eDeviceType != PVRSRV_DEVICE_TYPE_UNKNOWN) {
387 while (psDeviceNode) {
388 if (psDeviceNode->sDevId.eDeviceType == eDeviceType)
390 psDeviceNode = psDeviceNode->psNext;
393 while (psDeviceNode) {
394 if (psDeviceNode->sDevId.ui32DeviceIndex ==
398 psDeviceNode = psDeviceNode->psNext;
402 PVR_DPF(PVR_DBG_ERROR,
403 "PVRSRVAcquireDeviceDataKM: requested device is not present");
404 return PVRSRV_ERROR_INIT_FAILURE;
408 PVR_ASSERT(psDeviceNode->ui32RefCount > 0);
411 *phDevCookie = (void *) psDeviceNode;
416 enum PVRSRV_ERROR PVRSRVDeinitialiseDevice(u32 ui32DevIndex)
418 struct PVRSRV_DEVICE_NODE *psDeviceNode;
419 struct PVRSRV_DEVICE_NODE **ppsDevNode;
420 struct SYS_DATA *psSysData;
421 enum PVRSRV_ERROR eError;
423 eError = SysAcquireData(&psSysData);
424 if (eError != PVRSRV_OK) {
425 PVR_DPF(PVR_DBG_ERROR,
426 "PVRSRVDeinitialiseDevice: Failed to get SysData");
430 ppsDevNode = &psSysData->psDeviceNodeList;
431 while (*ppsDevNode) {
432 if ((*ppsDevNode)->sDevId.ui32DeviceIndex == ui32DevIndex) {
433 psDeviceNode = *ppsDevNode;
436 ppsDevNode = &((*ppsDevNode)->psNext);
439 PVR_DPF(PVR_DBG_ERROR,
440 "PVRSRVDeinitialiseDevice: requested device %d is not present",
443 return PVRSRV_ERROR_GENERIC;
447 eError = PVRSRVSetDevicePowerStateKM(ui32DevIndex,
448 PVRSRV_POWER_STATE_D3);
449 if (eError != PVRSRV_OK) {
450 PVR_DPF(PVR_DBG_ERROR, "PVRSRVDeinitialiseDevice: "
451 "Failed PVRSRVSetDevicePowerStateKM call");
455 HASH_Delete(psDeviceNode->sync_table);
457 ResManFreeResByCriteria(psDeviceNode->hResManContext,
458 RESMAN_CRITERIA_RESTYPE,
459 RESMAN_TYPE_DEVICEMEM_ALLOCATION,
462 if (psDeviceNode->pfnDeInitDevice != NULL) {
463 eError = psDeviceNode->pfnDeInitDevice(psDeviceNode);
464 if (eError != PVRSRV_OK) {
465 PVR_DPF(PVR_DBG_ERROR, "PVRSRVDeinitialiseDevice: "
466 "Failed DeInitDevice call");
471 PVRSRVResManDisconnect(psDeviceNode->hResManContext, IMG_TRUE);
472 psDeviceNode->hResManContext = NULL;
474 *ppsDevNode = psDeviceNode->psNext;
476 FreeDeviceID(psSysData, ui32DevIndex);
477 OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
478 sizeof(struct PVRSRV_DEVICE_NODE), psDeviceNode, NULL);
483 enum PVRSRV_ERROR PollForValueKM(u32 __iomem *pui32LinMemAddr,
484 u32 ui32Value, u32 ui32Mask, u32 ui32Waitus,
489 uiMaxTime = ui32Tries * ui32Waitus;
491 LOOP_UNTIL_TIMEOUT(uiMaxTime) {
492 if ((readl(pui32LinMemAddr) & ui32Mask) == ui32Value)
495 END_LOOP_UNTIL_TIMEOUT();
497 return PVRSRV_ERROR_GENERIC;
501 enum PVRSRV_ERROR PVRSRVGetMiscInfoKM(struct PVRSRV_MISC_INFO *psMiscInfo)
503 struct SYS_DATA *psSysData;
504 enum PVRSRV_ERROR eError;
507 PVR_DPF(PVR_DBG_ERROR,
508 "PVRSRVGetMiscInfoKM: invalid parameters");
509 return PVRSRV_ERROR_INVALID_PARAMS;
512 psMiscInfo->ui32StatePresent = 0;
514 if (psMiscInfo->ui32StateRequest & ~(
515 PVRSRV_MISC_INFO_TIMER_PRESENT |
516 PVRSRV_MISC_INFO_CLOCKGATE_PRESENT |
517 PVRSRV_MISC_INFO_MEMSTATS_PRESENT |
518 PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT |
519 PVRSRV_MISC_INFO_DDKVERSION_PRESENT)) {
520 PVR_DPF(PVR_DBG_ERROR,
521 "PVRSRVGetMiscInfoKM: invalid state request flags");
522 return PVRSRV_ERROR_INVALID_PARAMS;
525 eError = SysAcquireData(&psSysData);
526 if (eError != PVRSRV_OK) {
527 PVR_DPF(PVR_DBG_ERROR,
528 "PVRSRVGetMiscInfoKM: Failed to get SysData");
532 if (((psMiscInfo->ui32StateRequest &
533 PVRSRV_MISC_INFO_TIMER_PRESENT) != 0UL) &&
534 (psSysData->pvSOCTimerRegisterKM != NULL)) {
535 psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_TIMER_PRESENT;
536 psMiscInfo->pvSOCTimerRegisterKM =
537 psSysData->pvSOCTimerRegisterKM;
538 psMiscInfo->hSOCTimerRegisterOSMemHandle =
539 psSysData->hSOCTimerRegisterOSMemHandle;
541 psMiscInfo->pvSOCTimerRegisterKM = NULL;
542 psMiscInfo->hSOCTimerRegisterOSMemHandle = NULL;
545 if (((psMiscInfo->ui32StateRequest &
546 PVRSRV_MISC_INFO_CLOCKGATE_PRESENT) != 0UL) &&
547 (psSysData->pvSOCClockGateRegsBase != NULL)) {
548 psMiscInfo->ui32StatePresent |=
549 PVRSRV_MISC_INFO_CLOCKGATE_PRESENT;
550 psMiscInfo->pvSOCClockGateRegs =
551 psSysData->pvSOCClockGateRegsBase;
552 psMiscInfo->ui32SOCClockGateRegsSize =
553 psSysData->ui32SOCClockGateRegsSize;
556 if (((psMiscInfo->ui32StateRequest &
557 PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0UL) &&
558 (psMiscInfo->pszMemoryStr != NULL)) {
559 struct RA_ARENA **ppArena;
560 struct BM_HEAP *psBMHeap;
561 struct BM_CONTEXT *psBMContext;
562 struct PVRSRV_DEVICE_NODE *psDeviceNode;
567 pszStr = psMiscInfo->pszMemoryStr;
568 ui32StrLen = psMiscInfo->ui32MemoryStrLen;
570 psMiscInfo->ui32StatePresent |=
571 PVRSRV_MISC_INFO_MEMSTATS_PRESENT;
573 ppArena = &psSysData->apsLocalDevMemArena[0];
575 CHECK_SPACE(ui32StrLen);
577 OSSNPrintf(pszStr, 100, "\nLocal Backing Store:\n");
578 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
580 RA_GetStats(*ppArena, &pszStr, &ui32StrLen);
585 psDeviceNode = psSysData->psDeviceNodeList;
586 while (psDeviceNode) {
587 CHECK_SPACE(ui32StrLen);
589 OSSNPrintf(pszStr, 100, "\n\nDevice Type %d:\n",
590 psDeviceNode->sDevId.eDeviceType);
591 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
593 if (psDeviceNode->sDevMemoryInfo.pBMKernelContext) {
594 CHECK_SPACE(ui32StrLen);
596 OSSNPrintf(pszStr, 100,
597 "\nKernel Context:\n");
598 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
601 psDeviceNode->sDevMemoryInfo.
602 pBMKernelContext->psBMHeap;
604 if (psBMHeap->pImportArena) {
605 RA_GetStats(psBMHeap->
611 if (psBMHeap->pVMArena) {
612 RA_GetStats(psBMHeap->pVMArena,
616 psBMHeap = psBMHeap->psNext;
620 psBMContext = psDeviceNode->sDevMemoryInfo.pBMContext;
621 while (psBMContext) {
622 CHECK_SPACE(ui32StrLen);
624 OSSNPrintf(pszStr, 100,
625 "\nApplication Context (hDevMemContext) 0x%08X:\n",
626 (void *)psBMContext);
627 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
629 psBMHeap = psBMContext->psBMHeap;
631 if (psBMHeap->pImportArena) {
632 RA_GetStats(psBMHeap->
638 if (psBMHeap->pVMArena) {
639 RA_GetStats(psBMHeap->pVMArena,
643 psBMHeap = psBMHeap->psNext;
645 psBMContext = psBMContext->psNext;
647 psDeviceNode = psDeviceNode->psNext;
650 i32Count = OSSNPrintf(pszStr, 100, "\n\0");
651 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
654 if (((psMiscInfo->ui32StateRequest &
655 PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT) != 0UL) &&
656 (psSysData->psGlobalEventObject != NULL)) {
657 psMiscInfo->ui32StatePresent |=
658 PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT;
659 psMiscInfo->sGlobalEventObject =
660 *psSysData->psGlobalEventObject;
663 if (((psMiscInfo->ui32StateRequest &
664 PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0UL) &&
665 ((psMiscInfo->ui32StateRequest &
666 PVRSRV_MISC_INFO_MEMSTATS_PRESENT) == 0UL) &&
667 (psMiscInfo->pszMemoryStr != NULL)) {
670 u32 ui32LenStrPerNum = 12;
673 psMiscInfo->ui32StatePresent |=
674 PVRSRV_MISC_INFO_DDKVERSION_PRESENT;
676 psMiscInfo->aui32DDKVersion[0] = PVRVERSION_MAJ;
677 psMiscInfo->aui32DDKVersion[1] = PVRVERSION_MIN;
678 psMiscInfo->aui32DDKVersion[2] = PVRVERSION_BRANCH;
679 psMiscInfo->aui32DDKVersion[3] = PVRVERSION_BUILD;
681 pszStr = psMiscInfo->pszMemoryStr;
682 ui32StrLen = psMiscInfo->ui32MemoryStrLen;
684 for (i = 0; i < 4; i++) {
685 if (ui32StrLen < ui32LenStrPerNum)
686 return PVRSRV_ERROR_INVALID_PARAMS;
688 i32Count = OSSNPrintf(pszStr, ui32LenStrPerNum, "%ld",
689 psMiscInfo->aui32DDKVersion[i]);
690 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
692 i32Count = OSSNPrintf(pszStr, 2, ".");
693 UPDATE_SPACE(pszStr, i32Count, ui32StrLen);
701 enum PVRSRV_ERROR PVRSRVGetFBStatsKM(u32 *pui32Total, u32 *pui32Available)
703 u32 ui32Total = 0, i = 0;
704 u32 ui32Available = 0;
709 while (BM_ContiguousStatistics(i, &ui32Total, &ui32Available) ==
711 *pui32Total += ui32Total;
712 *pui32Available += ui32Available;
720 IMG_BOOL PVRSRVDeviceLISR(struct PVRSRV_DEVICE_NODE *psDeviceNode)
722 struct SYS_DATA *psSysData;
723 IMG_BOOL bStatus = IMG_FALSE;
724 u32 ui32InterruptSource;
727 PVR_DPF(PVR_DBG_ERROR, "PVRSRVDeviceLISR: Invalid params\n");
730 psSysData = psDeviceNode->psSysData;
732 ui32InterruptSource = SysGetInterruptSource(psSysData, psDeviceNode);
733 if (ui32InterruptSource & psDeviceNode->ui32SOCInterruptBit) {
734 if (psDeviceNode->pfnDeviceISR != NULL)
736 (*psDeviceNode->pfnDeviceISR) (psDeviceNode->
739 SysClearInterrupts(psSysData,
740 psDeviceNode->ui32SOCInterruptBit);
747 IMG_BOOL PVRSRVSystemLISR(void *pvSysData)
749 struct SYS_DATA *psSysData = pvSysData;
750 IMG_BOOL bStatus = IMG_FALSE;
751 u32 ui32InterruptSource;
752 u32 ui32ClearInterrupts = 0;
753 struct PVRSRV_DEVICE_NODE *psDeviceNode;
756 PVR_DPF(PVR_DBG_ERROR, "PVRSRVSystemLISR: Invalid params\n");
760 ui32InterruptSource = SysGetInterruptSource(psSysData, NULL);
762 if (ui32InterruptSource == 0)
765 psDeviceNode = psSysData->psDeviceNodeList;
766 while (psDeviceNode != NULL) {
767 if (psDeviceNode->pfnDeviceISR != NULL)
768 if (ui32InterruptSource & psDeviceNode->
769 ui32SOCInterruptBit) {
770 if ((*psDeviceNode->pfnDeviceISR)
771 (psDeviceNode->pvISRData))
774 ui32ClearInterrupts |=
775 psDeviceNode->ui32SOCInterruptBit;
777 psDeviceNode = psDeviceNode->psNext;
780 SysClearInterrupts(psSysData, ui32ClearInterrupts);
786 void PVRSRVMISR(void *pvSysData)
788 struct SYS_DATA *psSysData = pvSysData;
789 struct PVRSRV_DEVICE_NODE *psDeviceNode;
792 PVR_DPF(PVR_DBG_ERROR, "PVRSRVMISR: Invalid params\n");
798 if (pvr_is_disabled()) {
803 psDeviceNode = psSysData->psDeviceNodeList;
804 while (psDeviceNode != NULL) {
805 if (psDeviceNode->pfnDeviceMISR != NULL)
806 (*psDeviceNode->pfnDeviceMISR)(psDeviceNode->
808 psDeviceNode = psDeviceNode->psNext;
811 PVRSRVProcessQueues(IMG_FALSE);
813 if (psSysData->psGlobalEventObject) {
815 psSysData->psGlobalEventObject->hOSEventKM;
817 OSEventObjectSignal(hOSEventKM);
820 pvr_handle_sync_events();
825 enum PVRSRV_ERROR PVRSRVProcessConnect(u32 ui32PID)
827 return PVRSRVPerProcessDataConnect(ui32PID);
830 void PVRSRVProcessDisconnect(u32 ui32PID)
832 PVRSRVPerProcessDataDisconnect(ui32PID);
835 enum PVRSRV_ERROR PVRSRVSaveRestoreLiveSegments(void *hArena, u8 *pbyBuffer,
836 u32 *puiBufSize, IMG_BOOL bSave)
838 u32 uiBytesSaved = 0;
839 void *pvLocalMemCPUVAddr;
840 struct RA_SEGMENT_DETAILS sSegDetails;
843 return PVRSRV_ERROR_INVALID_PARAMS;
845 sSegDetails.uiSize = 0;
846 sSegDetails.sCpuPhyAddr.uiAddr = 0;
847 sSegDetails.hSegment = NULL;
849 while (RA_GetNextLiveSegment(hArena, &sSegDetails))
850 if (pbyBuffer == NULL) {
852 sizeof(sSegDetails.uiSize) + sSegDetails.uiSize;
854 if ((uiBytesSaved + sizeof(sSegDetails.uiSize) +
855 sSegDetails.uiSize) > *puiBufSize)
856 return PVRSRV_ERROR_OUT_OF_MEMORY;
858 PVR_DPF(PVR_DBG_MESSAGE,
859 "PVRSRVSaveRestoreLiveSegments: "
860 "Base %08x size %08x",
861 sSegDetails.sCpuPhyAddr.uiAddr,
864 pvLocalMemCPUVAddr = (void __force *)
865 OSMapPhysToLin(sSegDetails.sCpuPhyAddr,
867 PVRSRV_HAP_KERNEL_ONLY |
868 PVRSRV_HAP_UNCACHED, NULL);
869 if (pvLocalMemCPUVAddr == NULL) {
870 PVR_DPF(PVR_DBG_ERROR,
871 "PVRSRVSaveRestoreLiveSegments: "
872 "Failed to map local memory to host");
873 return PVRSRV_ERROR_OUT_OF_MEMORY;
877 OSMemCopy(pbyBuffer, &sSegDetails.uiSize,
878 sizeof(sSegDetails.uiSize));
879 pbyBuffer += sizeof(sSegDetails.uiSize);
881 OSMemCopy(pbyBuffer, pvLocalMemCPUVAddr,
883 pbyBuffer += sSegDetails.uiSize;
887 OSMemCopy(&uiSize, pbyBuffer,
888 sizeof(sSegDetails.uiSize));
890 if (uiSize != sSegDetails.uiSize) {
891 PVR_DPF(PVR_DBG_ERROR,
892 "PVRSRVSaveRestoreLiveSegments:"
893 " Segment size error");
895 pbyBuffer += sizeof(sSegDetails.uiSize);
897 OSMemCopy(pvLocalMemCPUVAddr, pbyBuffer,
899 pbyBuffer += sSegDetails.uiSize;
904 sizeof(sSegDetails.uiSize) + sSegDetails.uiSize;
906 OSUnMapPhysToLin((void __force __iomem *)
909 PVRSRV_HAP_KERNEL_ONLY |
910 PVRSRV_HAP_UNCACHED, NULL);
913 if (pbyBuffer == NULL)
914 *puiBufSize = uiBytesSaved;