⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winsys.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
字号:
/******************************************************************************
* Name         : winsys.h
* Title        : System dependant functions.
* Author(s)    : Imagination Technologies
* Created      : 1st August 2003
*
* Copyright    : 2003 by Imagination Technologies Limited.
*                All rights reserved.  No part of this software, either
*                material or conceptual may be copied or distributed,
*                transmitted, transcribed, stored in a retrieval system 
*                or translated into any human or computer language in any
*                form by any means, electronic, mechanical, manual or
*                other-wise, or disclosed to third parties without the
*                express written permission of Imagination Technologies
*                Limited, Unit 8, HomePark Industrial Estate, 
*                King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description  : System dependant functions.
*
* Platform     : Generic
*
* Notes        : formerly system.h mks rev 1.5
*
* Modifications:-
* $Log: winsys.cpp $
*
*  --- Revision Logs Removed --- 
*
*  --- Revision Logs Removed --- 
*
*
******************************************************************************/
#include	"precomp.h"

#include "pvr_debug.h"
#include "regpaths.h"
#include "memchk.h"
///#include <stdio.h>
#define VLSprintf wsprintf


/* This is the handle to our private system memory heap. */
static HANDLE g_hHeap = (HANDLE)NULL;

/* This really belongs in a header file. */
#define SYSTEM_MEM_HEAP_SIZE 393216


/*****************************************************************************
 Function Name  : InitializeSystemMem
 Inputs         : none
 Outputs        : none
 Returns        : TRUE if successful
 Globals used   : none
 Description    : This function initializes our access to dynamic system memory
				  services. In practice, this means that we create a private heap
				  for the driver's use.
				  The GWES process heap is littered with many allocations that
				  make it slower and possibly less useable than a private heap.
*****************************************************************************/
BOOL InitializeSystemMem()
{
	BOOL bRetVal = FALSE;  // Return value for this function.

	//////////DPFENTER((L"->InitializeSystemMem"));

	// Because all driver access is serialezed through the GWES lock, we do not
	// need to serialize access to our private heap. The size specified is the
	// initial size : all CE heaps grow if needed.

	if (g_hHeap == (HANDLE)NULL)
	{
		g_hHeap = HeapCreate(HEAP_NO_SERIALIZE,
							SYSTEM_MEM_HEAP_SIZE,
							0);						// Maximum size is unsupported
	}

	if (g_hHeap != NULL)
	{
		bRetVal = TRUE;
	}
	else
	{
		DPFWARNING((L"Unable to create private system memory heap!"));
	}

	/////DPFEXIT((L"<-InitializeSystemMem"));

	return bRetVal;
}


/*****************************************************************************
 Function Name  : DestroySystemMemHeap
 Inputs         : none
 Outputs        : none
 Returns        : TRUE if successful
 Globals used   : none
 Description    : This function frees the heap created by InitializeSystemMem.
*****************************************************************************/
BOOL DestroySystemMemHeap()
{
	BOOL bRtn = TRUE;

	/////DPFENTER((L"->DestroySystemMemHeap"));

	if (g_hHeap != NULL)
	{
		bRtn = HeapDestroy(g_hHeap);
		if (bRtn)
		{
			g_hHeap = NULL;
		}
		else
		{
			DPFWARNING((L"Unable to destroy private system memory heap!"));
		}
	}

	/////DPFEXIT((L"<-DestroySystemMemHeap"));

	return (bRtn);
}


/*****************************************************************************
 Function Name  : AllocSharedMem
 Inputs         : none
 Outputs        : none
 Returns        : pointer to allocated memory
 Globals used   : none
 Description    : 
*****************************************************************************/
PVOID AllocSharedMem(DWORD dwSize)
{
	LPVOID pvPointer = NULL;  // Return value for this function.

	// No parameter check - Size can be anything.

	//////////DPFENTER((L"->AllocSharedMem"));

	pvPointer = HeapAlloc ( g_hHeap,
							HEAP_ZERO_MEMORY,
							dwSize);

	/////DPFEXIT((L"<-AllocSharedMem"));

	return (pvPointer);
}



//#define MEMCHK
#ifdef MEMCHK
/*****************************************************************************
 Function Name  : DBGAllocSharedMem
 Inputs         : none
 Outputs        : none
 Returns        : pointer to allocated memory
 Globals used   : none
 Description    : As AllocSharedMem but with debug info printed
*****************************************************************************/
PVOID DBGAllocSharedMem(DWORD dwSize, PSTR pszFile, DWORD dwLine)
{
	LPVOID pvPointer = NULL;  // Return value for this function.

	pvPointer = AllocSharedMem(dwSize);

	DPFINFO("DBGAllocSharedMem: User buf 0x%lx size 0x%lx by caller @ %hs line %d",
		pvPointer, dwSize, pszFile, dwLine);

	return (pvPointer);
}
#endif /* #ifdef MEMCHK */


/*****************************************************************************
 Function Name  : FreeSharedMem
 Inputs         : PVOID pvMem
 Outputs        : none
 Returns        : none
 Globals used   : none
 Description    : 
*****************************************************************************/
void FreeSharedMem(PVOID pvMem)
{
	//////////DPFENTER((L"->FreeSharedMem"));

	HeapFree(g_hHeap,
			 0,				// No flags (flags inherited from heap itself.)
			 pvMem);

	/////DPFEXIT((L"<-FreeSharedMem"));
}
/*****************************************************************************
 End of file (winsys.c)
*****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -