Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 692a059865
Fetching contributors…

Cannot retrieve contributors at this time

executable file 740 lines (502 sloc) 17.734 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
/**********************************************************************
*
* Copyright (C) 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. <gpl-support@imgtec.com>
* Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
*
******************************************************************************/

#include "services_headers.h"
#include "resman.h"

#include <linux/version.h>
#ifdef __linux__
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#endif

#include <linux/sched.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9)
#include <linux/hardirq.h>
#else
#include <asm/hardirq.h>
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
#include <linux/semaphore.h>
#else
#include <asm/semaphore.h>
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
static DEFINE_SEMAPHORE(lock);
#else
static DECLARE_MUTEX(lock);
#endif

#define ACQUIRE_SYNC_OBJ do { \
if (in_interrupt()) { \
printk ("ISR cannot take RESMAN mutex\n"); \
BUG(); \
} \
else down (&lock); \
} while (0)
#define RELEASE_SYNC_OBJ up (&lock)

#else

#define ACQUIRE_SYNC_OBJ
#define RELEASE_SYNC_OBJ

#endif

#define RESMAN_SIGNATURE 0x12345678

typedef struct _RESMAN_ITEM_
{
#ifdef DEBUG
IMG_UINT32 ui32Signature;
#endif
struct _RESMAN_ITEM_ **ppsThis;
struct _RESMAN_ITEM_ *psNext;

IMG_UINT32 ui32Flags;
IMG_UINT32 ui32ResType;

IMG_PVOID pvParam;
IMG_UINT32 ui32Param;

RESMAN_FREE_FN pfnFreeResource;
} RESMAN_ITEM;


typedef struct _RESMAN_CONTEXT_
{
#ifdef DEBUG
IMG_UINT32 ui32Signature;
#endif
struct _RESMAN_CONTEXT_ **ppsThis;
struct _RESMAN_CONTEXT_ *psNext;

PVRSRV_PER_PROCESS_DATA *psPerProc;

RESMAN_ITEM *psResItemList;

} RESMAN_CONTEXT;


typedef struct
{
RESMAN_CONTEXT *psContextList;

} RESMAN_LIST, *PRESMAN_LIST;


PRESMAN_LIST gpsResList = IMG_NULL;

#include "lists.h"

static IMPLEMENT_LIST_ANY_VA(RESMAN_ITEM)
static IMPLEMENT_LIST_ANY_VA_2(RESMAN_ITEM, IMG_BOOL, IMG_FALSE)
static IMPLEMENT_LIST_INSERT(RESMAN_ITEM)
static IMPLEMENT_LIST_REMOVE(RESMAN_ITEM)
static IMPLEMENT_LIST_REVERSE(RESMAN_ITEM)

static IMPLEMENT_LIST_REMOVE(RESMAN_CONTEXT)
static IMPLEMENT_LIST_INSERT(RESMAN_CONTEXT)


#define PRINT_RESLIST(x, y, z)

static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, IMG_BOOL bExecuteCallback, IMG_BOOL bForceCleanup);

static PVRSRV_ERROR FreeResourceByCriteria(PRESMAN_CONTEXT psContext,
IMG_UINT32 ui32SearchCriteria,
IMG_UINT32 ui32ResType,
IMG_PVOID pvParam,
IMG_UINT32 ui32Param,
IMG_BOOL bExecuteCallback);


#ifdef DEBUG
static IMG_VOID ValidateResList(PRESMAN_LIST psResList);
#define VALIDATERESLIST() ValidateResList(gpsResList)
#else
#define VALIDATERESLIST()
#endif






PVRSRV_ERROR ResManInit(IMG_VOID)
{
if (gpsResList == IMG_NULL)
{

if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
sizeof(*gpsResList),
(IMG_VOID **)&gpsResList, IMG_NULL,
"Resource Manager List") != PVRSRV_OK)
{
return PVRSRV_ERROR_OUT_OF_MEMORY;
}


gpsResList->psContextList = IMG_NULL;


VALIDATERESLIST();
}

return PVRSRV_OK;
}


IMG_VOID ResManDeInit(IMG_VOID)
{
if (gpsResList != IMG_NULL)
{

OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(*gpsResList), gpsResList, IMG_NULL);
gpsResList = IMG_NULL;
}
}


PVRSRV_ERROR PVRSRVResManConnect(IMG_HANDLE hPerProc,
PRESMAN_CONTEXT *phResManContext)
{
PVRSRV_ERROR eError;
PRESMAN_CONTEXT psResManContext;


ACQUIRE_SYNC_OBJ;


VALIDATERESLIST();


eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(*psResManContext),
(IMG_VOID **)&psResManContext, IMG_NULL,
"Resource Manager Context");
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVResManConnect: ERROR allocating new RESMAN context struct"));


VALIDATERESLIST();


RELEASE_SYNC_OBJ;

return eError;
}

#ifdef DEBUG
psResManContext->ui32Signature = RESMAN_SIGNATURE;
#endif
psResManContext->psResItemList = IMG_NULL;
psResManContext->psPerProc = hPerProc;


List_RESMAN_CONTEXT_Insert(&gpsResList->psContextList, psResManContext);


VALIDATERESLIST();


RELEASE_SYNC_OBJ;

*phResManContext = psResManContext;

return PVRSRV_OK;
}


IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext,
IMG_BOOL bKernelContext)
{

ACQUIRE_SYNC_OBJ;


VALIDATERESLIST();


PRINT_RESLIST(gpsResList, psResManContext, IMG_TRUE);



if (!bKernelContext)
{

FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_OS_USERMODE_MAPPING, 0, 0, IMG_TRUE);


FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DMA_CLIENT_FIFO_DATA, 0, 0, IMG_TRUE);


FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_EVENT_OBJECT, 0, 0, IMG_TRUE);



List_RESMAN_ITEM_Reverse(&psResManContext->psResItemList);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_MODIFY_SYNC_OPS, 0, 0, IMG_TRUE);
List_RESMAN_ITEM_Reverse(&psResManContext->psResItemList);


FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_HW_RENDER_CONTEXT, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_HW_TRANSFER_CONTEXT, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_HW_2D_CONTEXT, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_TRANSFER_CONTEXT, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_PB_DESC_CREATE_LOCK, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_PB_DESC, 0, 0, IMG_TRUE);




FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SYNC_INFO, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICECLASSMEM_MAPPING, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_WRAP, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE);


FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_SWAPCHAIN_REF, 0, 0, IMG_TRUE);
FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_DEVICE, 0, 0, IMG_TRUE);


FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_BUFFERCLASS_DEVICE, 0, 0, IMG_TRUE);
}


PVR_ASSERT(psResManContext->psResItemList == IMG_NULL);


List_RESMAN_CONTEXT_Remove(psResManContext);


OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RESMAN_CONTEXT), psResManContext, IMG_NULL);




VALIDATERESLIST();


PRINT_RESLIST(gpsResList, psResManContext, IMG_FALSE);


RELEASE_SYNC_OBJ;
}


PRESMAN_ITEM ResManRegisterRes(PRESMAN_CONTEXT psResManContext,
IMG_UINT32 ui32ResType,
IMG_PVOID pvParam,
IMG_UINT32 ui32Param,
RESMAN_FREE_FN pfnFreeResource)
{
PRESMAN_ITEM psNewResItem;

PVR_ASSERT(psResManContext != IMG_NULL);
PVR_ASSERT(ui32ResType != 0);

if (psResManContext == IMG_NULL)
{
PVR_DPF((PVR_DBG_ERROR, "ResManRegisterRes: invalid parameter - psResManContext"));
return (PRESMAN_ITEM) IMG_NULL;
}


ACQUIRE_SYNC_OBJ;


VALIDATERESLIST();

PVR_DPF((PVR_DBG_MESSAGE, "ResManRegisterRes: register resource "
"Context 0x%x, ResType 0x%x, pvParam 0x%x, ui32Param 0x%x, "
"FreeFunc %08X",
(IMG_UINTPTR_T)psResManContext,
ui32ResType,
(IMG_UINTPTR_T)pvParam,
ui32Param,
(IMG_UINTPTR_T)pfnFreeResource));


if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
sizeof(RESMAN_ITEM), (IMG_VOID **)&psNewResItem,
IMG_NULL,
"Resource Manager Item") != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "ResManRegisterRes: "
"ERROR allocating new resource item"));


RELEASE_SYNC_OBJ;

return((PRESMAN_ITEM)IMG_NULL);
}

#ifdef DEBUG
psNewResItem->ui32Signature = RESMAN_SIGNATURE;
#endif
psNewResItem->ui32ResType = ui32ResType;
psNewResItem->pvParam = pvParam;
psNewResItem->ui32Param = ui32Param;
psNewResItem->pfnFreeResource = pfnFreeResource;
psNewResItem->ui32Flags = 0;


List_RESMAN_ITEM_Insert(&psResManContext->psResItemList, psNewResItem);


VALIDATERESLIST();


RELEASE_SYNC_OBJ;

return(psNewResItem);
}

PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem, IMG_BOOL bForceCleanup)
{
PVRSRV_ERROR eError;

PVR_ASSERT(psResItem != IMG_NULL);

if (psResItem == IMG_NULL)
{
PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: NULL ptr - nothing to do"));
return PVRSRV_OK;
}

PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: freeing resource at %08X",
(IMG_UINTPTR_T)psResItem));


ACQUIRE_SYNC_OBJ;


VALIDATERESLIST();


eError = FreeResourceByPtr(psResItem, IMG_TRUE, bForceCleanup);


VALIDATERESLIST();


RELEASE_SYNC_OBJ;

return(eError);
}


PVRSRV_ERROR ResManFreeResByCriteria(PRESMAN_CONTEXT psResManContext,
IMG_UINT32 ui32SearchCriteria,
IMG_UINT32 ui32ResType,
IMG_PVOID pvParam,
IMG_UINT32 ui32Param)
{
PVRSRV_ERROR eError;

PVR_ASSERT(psResManContext != IMG_NULL);


ACQUIRE_SYNC_OBJ;


VALIDATERESLIST();

PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByCriteria: "
"Context 0x%x, Criteria 0x%x, Type 0x%x, Addr 0x%x, Param 0x%x",
(IMG_UINTPTR_T)psResManContext, ui32SearchCriteria, ui32ResType,
(IMG_UINTPTR_T)pvParam, ui32Param));


eError = FreeResourceByCriteria(psResManContext, ui32SearchCriteria,
ui32ResType, pvParam, ui32Param,
IMG_TRUE);


VALIDATERESLIST();


RELEASE_SYNC_OBJ;

return eError;
}


PVRSRV_ERROR ResManDissociateRes(RESMAN_ITEM *psResItem,
PRESMAN_CONTEXT psNewResManContext)
{
PVRSRV_ERROR eError = PVRSRV_OK;

PVR_ASSERT(psResItem != IMG_NULL);

if (psResItem == IMG_NULL)
{
PVR_DPF((PVR_DBG_ERROR, "ResManDissociateRes: invalid parameter - psResItem"));
PVR_DBG_BREAK;
return PVRSRV_ERROR_INVALID_PARAMS;
}

#ifdef DEBUG
PVR_ASSERT(psResItem->ui32Signature == RESMAN_SIGNATURE);
#endif

if (psNewResManContext != IMG_NULL)
{

List_RESMAN_ITEM_Remove(psResItem);


List_RESMAN_ITEM_Insert(&psNewResManContext->psResItemList, psResItem);

}
else
{
eError = FreeResourceByPtr(psResItem, IMG_FALSE, CLEANUP_WITH_POLL);
if(eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "ResManDissociateRes: failed to free resource by pointer"));
return eError;
}
}

return eError;
}

static IMG_BOOL ResManFindResourceByPtr_AnyVaCb(RESMAN_ITEM *psCurItem, va_list va)
{
RESMAN_ITEM *psItem;

psItem = va_arg(va, RESMAN_ITEM*);

return (IMG_BOOL)(psCurItem == psItem);
}


IMG_INTERNAL PVRSRV_ERROR ResManFindResourceByPtr(PRESMAN_CONTEXT psResManContext,
RESMAN_ITEM *psItem)
{
PVRSRV_ERROR eResult;

PVR_ASSERT(psResManContext != IMG_NULL);
PVR_ASSERT(psItem != IMG_NULL);

if ((psItem == IMG_NULL) || (psResManContext == IMG_NULL))
{
PVR_DPF((PVR_DBG_ERROR, "ResManFindResourceByPtr: invalid parameter"));
PVR_DBG_BREAK;
return PVRSRV_ERROR_INVALID_PARAMS;
}

#ifdef DEBUG
PVR_ASSERT(psItem->ui32Signature == RESMAN_SIGNATURE);
#endif


ACQUIRE_SYNC_OBJ;

PVR_DPF((PVR_DBG_MESSAGE,
"FindResourceByPtr: psItem=%08X, psItem->psNext=%08X",
(IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext));

PVR_DPF((PVR_DBG_MESSAGE,
"FindResourceByPtr: Resource Ctx 0x%x, Type 0x%x, Addr 0x%x, "
"Param 0x%x, FnCall %08X, Flags 0x%x",
(IMG_UINTPTR_T)psResManContext,
psItem->ui32ResType,
(IMG_UINTPTR_T)psItem->pvParam,
psItem->ui32Param,
(IMG_UINTPTR_T)psItem->pfnFreeResource,
psItem->ui32Flags));


if(List_RESMAN_ITEM_IMG_BOOL_Any_va(psResManContext->psResItemList,
&ResManFindResourceByPtr_AnyVaCb,
psItem))
{
eResult = PVRSRV_OK;
}
else
{
eResult = PVRSRV_ERROR_NOT_OWNER;
}


RELEASE_SYNC_OBJ;

return eResult;
}

static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem,
IMG_BOOL bExecuteCallback,
IMG_BOOL bForceCleanup)
{
PVRSRV_ERROR eError = PVRSRV_OK;

PVR_ASSERT(psItem != IMG_NULL);

if (psItem == IMG_NULL)
{
PVR_DPF((PVR_DBG_ERROR, "FreeResourceByPtr: invalid parameter"));
return PVRSRV_ERROR_INVALID_PARAMS;
}

#ifdef DEBUG
PVR_ASSERT(psItem->ui32Signature == RESMAN_SIGNATURE);
#endif

PVR_DPF((PVR_DBG_MESSAGE,
"FreeResourceByPtr: psItem=%08X, psItem->psNext=%08X",
(IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext));

PVR_DPF((PVR_DBG_MESSAGE,
"FreeResourceByPtr: Type 0x%x, Addr 0x%x, "
"Param 0x%x, FnCall %08X, Flags 0x%x",
psItem->ui32ResType,
(IMG_UINTPTR_T)psItem->pvParam, psItem->ui32Param,
(IMG_UINTPTR_T)psItem->pfnFreeResource, psItem->ui32Flags));


List_RESMAN_ITEM_Remove(psItem);



RELEASE_SYNC_OBJ;


if (bExecuteCallback)
{
eError = psItem->pfnFreeResource(psItem->pvParam, psItem->ui32Param, bForceCleanup);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "FreeResourceByPtr: ERROR calling FreeResource function"));
}
}


ACQUIRE_SYNC_OBJ;


OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RESMAN_ITEM), psItem, IMG_NULL);

return(eError);
}

static IMG_VOID* FreeResourceByCriteria_AnyVaCb(RESMAN_ITEM *psCurItem, va_list va)
{
IMG_UINT32 ui32SearchCriteria;
IMG_UINT32 ui32ResType;
IMG_PVOID pvParam;
IMG_UINT32 ui32Param;

ui32SearchCriteria = va_arg(va, IMG_UINT32);
ui32ResType = va_arg(va, IMG_UINT32);
pvParam = va_arg(va, IMG_PVOID);
ui32Param = va_arg(va, IMG_UINT32);


if(

(((ui32SearchCriteria & RESMAN_CRITERIA_RESTYPE) == 0UL) ||
(psCurItem->ui32ResType == ui32ResType))
&&

(((ui32SearchCriteria & RESMAN_CRITERIA_PVOID_PARAM) == 0UL) ||
(psCurItem->pvParam == pvParam))
&&

(((ui32SearchCriteria & RESMAN_CRITERIA_UI32_PARAM) == 0UL) ||
(psCurItem->ui32Param == ui32Param))
)
{
return psCurItem;
}
else
{
return IMG_NULL;
}
}

static PVRSRV_ERROR FreeResourceByCriteria(PRESMAN_CONTEXT psResManContext,
IMG_UINT32 ui32SearchCriteria,
IMG_UINT32 ui32ResType,
IMG_PVOID pvParam,
IMG_UINT32 ui32Param,
IMG_BOOL bExecuteCallback)
{
PRESMAN_ITEM psCurItem;
PVRSRV_ERROR eError = PVRSRV_OK;



while((psCurItem = (PRESMAN_ITEM)
List_RESMAN_ITEM_Any_va(psResManContext->psResItemList,
&FreeResourceByCriteria_AnyVaCb,
ui32SearchCriteria,
ui32ResType,
pvParam,
ui32Param)) != IMG_NULL
&& eError == PVRSRV_OK)
{
eError = FreeResourceByPtr(psCurItem, bExecuteCallback, CLEANUP_WITH_POLL);
}

return eError;
}


#ifdef DEBUG
static IMG_VOID ValidateResList(PRESMAN_LIST psResList)
{
PRESMAN_ITEM psCurItem, *ppsThisItem;
PRESMAN_CONTEXT psCurContext, *ppsThisContext;


if (psResList == IMG_NULL)
{
PVR_DPF((PVR_DBG_MESSAGE, "ValidateResList: resman not initialised yet"));
return;
}

psCurContext = psResList->psContextList;
ppsThisContext = &psResList->psContextList;


while(psCurContext != IMG_NULL)
{

PVR_ASSERT(psCurContext->ui32Signature == RESMAN_SIGNATURE);
if (psCurContext->ppsThis != ppsThisContext)
{
PVR_DPF((PVR_DBG_WARNING,
"psCC=%08X psCC->ppsThis=%08X psCC->psNext=%08X ppsTC=%08X",
(IMG_UINTPTR_T)psCurContext,
(IMG_UINTPTR_T)psCurContext->ppsThis,
(IMG_UINTPTR_T)psCurContext->psNext,
(IMG_UINTPTR_T)ppsThisContext));
PVR_ASSERT(psCurContext->ppsThis == ppsThisContext);
}


psCurItem = psCurContext->psResItemList;
ppsThisItem = &psCurContext->psResItemList;
while(psCurItem != IMG_NULL)
{

PVR_ASSERT(psCurItem->ui32Signature == RESMAN_SIGNATURE);
if (psCurItem->ppsThis != ppsThisItem)
{
PVR_DPF((PVR_DBG_WARNING,
"psCurItem=%08X psCurItem->ppsThis=%08X psCurItem->psNext=%08X ppsThisItem=%08X",
(IMG_UINTPTR_T)psCurItem,
(IMG_UINTPTR_T)psCurItem->ppsThis,
(IMG_UINTPTR_T)psCurItem->psNext,
(IMG_UINTPTR_T)ppsThisItem));
PVR_ASSERT(psCurItem->ppsThis == ppsThisItem);
}


ppsThisItem = &psCurItem->psNext;
psCurItem = psCurItem->psNext;
}


ppsThisContext = &psCurContext->psNext;
psCurContext = psCurContext->psNext;
}
}
#endif
Something went wrong with that request. Please try again.