winceoam.cpp
来自「SAMSUNG S3C6410 CPU BSP for winmobile6」· C++ 代码 · 共 547 行 · 第 1/2 页
CPP
547 行
/* OAM_DestroySM */
/* DESCRIPTION */
/* This function destroys semaphore. */
/* */
/* PARAMETERS */
/* nHandle Handle of semaphore to be destroyed */
/* */
/* RETURN VALUES */
/* If this function destroys semaphore successfully, it returns TRUE32. */
/* else it returns FALSE32. */
/* NOTES */
/* This function is called by function that wants to destroy semaphore */
/* */
/*****************************************************************************/
BOOL32
OAM_DestroySM(SM32 nHandle)
{
UINT32 nIdx = (UINT32) nHandle;
if (nIdx >= XSR_MAX_SEMAPHORE)
return FALSE32;
if (CloseHandle((HANDLE) gSMCxt[nIdx].hHandle) == TRUE)
{
gSMCxt[nIdx].bUsed = FALSE32;
return TRUE32;
}
return FALSE32;
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_AcquireSM */
/* DESCRIPTION */
/* This function acquires semaphore. */
/* */
/* PARAMETERS */
/* nHandle Handle of semaphore to be acquired */
/* */
/* RETURN VALUES */
/* If this function acquires semaphore successfully, it returns TRUE32. */
/* else it returns FALSE32. */
/* NOTES */
/* This function is called by function that wants to acquire semaphore */
/* */
/*****************************************************************************/
BOOL32
OAM_AcquireSM(SM32 nHandle)
{
UINT32 nIdx = (UINT32) nHandle;
DWORD nRe;
if (nIdx >= XSR_MAX_SEMAPHORE)
return FALSE32;
nRe = WaitForSingleObject((HANDLE) gSMCxt[nIdx].hHandle,INFINITE);
if (nRe == WAIT_FAILED)
return FALSE32;
return TRUE32;
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_ReleaseSM */
/* DESCRIPTION */
/* This function releases semaphore. */
/* */
/* PARAMETERS */
/* nHandle [IN] */
/* Handle of semaphore to be released */
/* */
/* RETURN VALUES */
/* If this function releases semaphore successfully, it returns TRUE32. */
/* else it returns FALSE32. */
/* NOTES */
/* This function is called by function that wants to release semaphore */
/* */
/*****************************************************************************/
BOOL32
OAM_ReleaseSM(SM32 nHandle)
{
UINT32 nIdx = (UINT32) nHandle;
if (nIdx >= XSR_MAX_SEMAPHORE)
return FALSE32;
if (ReleaseSemaphore((HANDLE) gSMCxt[nIdx].hHandle, 1, NULL) == TRUE)
return TRUE32;
return FALSE32;
}
#include <stdlib.h>
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Pa2Va */
/* DESCRIPTION */
/* This function gets virtual address for NAND device physical address */
/* */
/* PARAMETERS */
/* nPAddr physical address of NAND device */
/* */
/* RETURN VALUES */
/* Virtual address of NAND device that Symbian OS using */
/* */
/* NOTES */
/* This function makes virtual address for NAND device when system */
/* initialized */
/* */
/*****************************************************************************/
VOID
OAM_Debug(VOID *pFmt, ...)
{
UINT8 aStr[4096];
va_list ap;
va_start(ap, pFmt);
vsprintf((char *) aStr, (char *) pFmt, ap);
//#if defined(WIN32OAM_FILE_DEBUG)
// clDebug.Print((UINT8 *) aStr);
// printf((const char *) aStr);
//#else //(WIN32OAM_FILE_DEBUG)
printf((const char *) aStr);
//#endif
va_end(ap);
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Pa2Va */
/* DESCRIPTION */
/* This function gets virtual address for NAND device physical address */
/* */
/* PARAMETERS */
/* nPAddr physical address of NAND device */
/* */
/* RETURN VALUES */
/* Virtual address of NAND device that Symbian OS using */
/* */
/* NOTES */
/* This function makes virtual address for NAND device when system */
/* initialized */
/* */
/*****************************************************************************/
UINT32
OAM_Pa2Va(UINT32 nPAddr)
{
return nPAddr;
}
static UINT32 gnCounter = 0;
/*****************************************************************************/
/* */
/* NAME */
/* OAM_ResetTimer */
/* DESCRIPTION */
/* This function reset timer for using asynchronous write operation */
/* */
/* PARAMETERS */
/* none */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* This function is called in STL layer */
/* */
/*****************************************************************************/
VOID
OAM_ResetTimer(VOID)
{
gnCounter = 0;
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_GetTime */
/* DESCRIPTION */
/* This function returns cureent timer value */
/* */
/* PARAMETERS */
/* none */
/* */
/* RETURN VALUES */
/* Current timer value */
/* */
/* NOTES */
/* This function is called in STL layer */
/* */
/*****************************************************************************/
UINT32
OAM_GetTime(VOID)
{
return gnCounter++;
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Idle */
/* DESCRIPTION */
/* This function is called when XSR is at idle time */
/* */
/* PARAMETERS */
/* */
/* RETURN VALUES */
/* */
/* NOTES */
/* If XSR is polling on the device status, this function is called. */
/* At idle, instead of keeping polling and waiting, other operation can be */
/* done by implementing this function */
/* Caution : Do not perform any NAND operation (XSR operation) in this */
/* function. */
/* */
/*****************************************************************************/
VOID
OAM_Idle(VOID)
{
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_WaitNMSec */
/* DESCRIPTION */
/* This function waits N msec */
/* */
/* PARAMETERS */
/* nNMSec msec time for waiting */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* */
/*****************************************************************************/
VOID
OAM_WaitNMSec(UINT32 nNMSec)
{
Sleep(nNMSec);
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_GetROLockFlag */
/* DESCRIPTION */
/* This function returns TRUE32 in _IsROPartition() */
/* */
/* PARAMETERS */
/* NONE */
/* */
/* RETURN VALUES */
/* TREU32 */
/* */
/* NOTES */
/* */
/*****************************************************************************/
BOOL32
OAM_GetROLockFlag(VOID)
{
// Always return TRUE in WinCEOAM (dummy function)
return TRUE32;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?