halwrapper.c

来自「SAMSUNG S3C6410 CPU BSP for winmobile6」· C语言 代码 · 共 535 行 · 第 1/2 页

C
535
字号
/*****************************************************************************/
/*                                                                           */
/* PROJECT : PocketStore II                                                  */
/* FILE    : HALWrapper.h                                                    */
/* PURPOSE : This file contains a wrapper interface of WinCE HAL             */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*          COPYRIGHT 2003-2006 SAMSUNG ELECTRONICS CO., LTD.                */
/*                          ALL RIGHTS RESERVED                              */
/*                                                                           */
/*   Permission is hereby granted to licensees of Samsung Electronics        */
/*   Co., Ltd. products to use or abstract this computer program for the     */
/*   sole purpose of implementing a product based on Samsung                 */
/*   Electronics Co., Ltd. products. No other rights to reproduce, use,      */
/*   or disseminate this computer program, whether in part or in whole,      */
/*   are granted.                                                            */
/*                                                                           */
/*   Samsung Electronics Co., Ltd. makes no representation or warranties     */
/*   with respect to the performance of this computer program, and           */
/*   specifically disclaims any responsibility for any damages,              */
/*   special or consequential, connected with the use of this program.       */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/* REVISION HISTORY                                                          */
/*                                                                           */
/*   14-JAN-2003 [SongHo Yoon]: first writing                                */
/*   18-APR-2003 [SongHo Yoon]: add case(PS_HAL_FM_GET_PARTITIONINFO)        */
/*   12-APR-2004 [Janghwan Kim]: Migration for PocketStoreII                 */
/*   30-MAY-2005 [SungKug Cho] : add case{PS_HAL_BML_COPY}		     */
/*                                                                           */
/*****************************************************************************/

#include <windows.h>
#include <Xsr.h>
#include <OCLD.h>
#include <HALWrapper.h>

/*****************************************************************************/
/* Debug Definitions                                                         */
/*****************************************************************************/
#define HALWP_RTL_PRINT(x)           PSII_RTL_PRINT(x)

#if HALWP_ERR_MSG_ON
#define HALWP_ERR_PRINT(x)           PSII_RTL_PRINT(x)
#else
#define HALWP_ERR_PRINT(x)        
#endif /* #if HALWP_ERR_MSG_ON */

#if HALWP_LOG_MSG_ON
#define HALWP_LOG_PRINT(x)           PSII_DBG_PRINT(x)
#else
#define HALWP_LOG_PRINT(x)        
#endif  /* #if HALWP_LOG_MSG_ON */

#if HALWP_INF_MSG_ON
#define HALWP_INF_PRINT(x)           PSII_DBG_PRINT(x)
#else
#define HALWP_INF_PRINT(x)        
#endif  /* #if HALWP_INF_MSG_ON */

/*****************************************************************************/
/* Code Implementation                                                       */
/*****************************************************************************/

/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      PSII_HALWrapper                                                      */
/* DESCRIPTION                                                               */
/*      free all resources associated with the specified disk                */
/* PARAMETERS                                                                */
/*      pPacket                                                              */
/*          Pointer to packet                                                */
/*      pInOutBuf                                                            */
/*          Pointer to Input/Output buffer                                   */
/*      pResult                                                              */
/*          Pointer to result                                                */
/* RETURN VALUES                                                             */
/*      If it successes, it returns TRUE. otherwize it returns FALSE         */
/*                                                                           */
/*****************************************************************************/
UINT32
PSII_HALWrapper(VOID *pPacket, VOID *pInOutBuf, UINT32 *pResult)
{
    BMLPacket  *pstInPacket;
	UINT32      nIndex;
	UINT32      nVol;
	UINT32      nVbn;
	UINT32      nVsn;
	UINT32      nNumOfScts;
	UINT32      nFlag;
	UINT8      *pMBuf;
	UINT8      *pSBuf;
	MEBArg	   *pstMEBArg=NULL;
	SGL	   *pSGLBuf;	/* added for XSR v1.5.x */

    HALWP_LOG_PRINT((TEXT("[HALWP: IN] ++PSII_HALWrapper()\r\n")));
    
	pstInPacket = (BMLPacket*)pPacket;

	nVol        = pstInPacket->nVol;
    nVbn        = pstInPacket->nVbn;
	nVsn        = pstInPacket->nVsn;
	nNumOfScts  = pstInPacket->nNumOfScts;
	pMBuf       = pstInPacket->pMBuf;
	pSBuf       = pstInPacket->pSBuf;
	nFlag       = pstInPacket->nOpFlag;
	pstMEBArg	= pstInPacket->pstMEBArg;
	pSGLBuf		= pstInPacket->pSGLBuf;	/* added for XSR v1.5.x */
	
	switch (pstInPacket->nCtrlCode)
	{
	case PS_HAL_BML_INIT:
        HALWP_RTL_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_INIT\r\n")));

	    *pResult = (UINT32)BML_Init();
	    pInOutBuf = NULL;
	    break;

	case PS_HAL_BML_OPEN:
        HALWP_RTL_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_OPEN\r\n")));
        HALWP_RTL_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));

        *pResult = (UINT32)BML_Open(nVol);
        pInOutBuf = NULL;
        break;

	case PS_HAL_BML_CLOSE:
        HALWP_RTL_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_CLOSE\r\n")));
        HALWP_RTL_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));

        *pResult = (UINT32)BML_Close(nVol);
        pInOutBuf = NULL;
        break;

	case PS_HAL_BML_READ:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_READ\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pMBuf     = 0x%x\r\n"), (UINT32)pMBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));
        
	    *pResult = (UINT32)BML_Read(nVol,
	                                nVsn,
	                                nNumOfScts,
	                                (UCHAR*)pMBuf,
	                                (UCHAR*)pSBuf,
	                                nFlag);
	    break;

    case PS_HAL_BML_MREAD:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_MREAD\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pMBuf     = 0x%x\r\n"), (UINT32)pMBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));
                
	    *pResult = (UINT32)BML_MRead(nVol,
	                                nVsn,
	                                nNumOfScts,
	                                (UCHAR*)pMBuf,
	                                (UCHAR*)pSBuf,
	                                nFlag);
	    break;
	    
    case PS_HAL_BML_SGLREAD:	/* added for XSR v1.5.x */
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_MREAD\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        //HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSGLBuf     = 0x%x\r\n"), (UINT32)pSGLBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));
                
	    *pResult = (UINT32)BML_SGLRead(nVol,
	                                nVsn,
	                                nNumOfScts,
	                                pSGLBuf,
	                                (UCHAR*)pSBuf,
	                                nFlag);
	    break;

    case PS_HAL_BML_WRITE:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_READ\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pMBuf     = 0x%x\r\n"), (UINT32)pMBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));

        *pResult = (UINT32)BML_Write(nVol,
                                     nVsn,
                                     nNumOfScts,
	                                 (UCHAR*)pMBuf,
	                                 (UCHAR*)pSBuf,
	                                 nFlag);
        break;

	case PS_HAL_BML_MWRITE:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_MWRITE\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pMBuf     = 0x%x\r\n"), (UINT32)pMBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));
        				
        *pResult = (UINT32)BML_MWrite(nVol,
                                     nVsn,
                                     nNumOfScts,
	                                 (UCHAR*)pMBuf,
	                                 (UCHAR*)pSBuf,
	                                 nFlag);
        break;
	
	case PS_HAL_BML_SGLWRITE:	/* added for XSR v1.5.x */
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_MWRITE\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVsn      = %d(0x%x)\r\n"), nVsn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nNumOfScts= %d\r\n"), nNumOfScts));
        //HALWP_INF_PRINT((TEXT("[HALWP:INF]  pMBuf     = 0x%x\r\n"), (UINT32)pMBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  pSBuf     = 0x%x\r\n"), (UINT32)pSBuf));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));
        				
        *pResult = (UINT32)BML_SGLWrite(nVol,
                                     nVsn,
                                     nNumOfScts,
	                                 pSGLBuf,
	                                 (UCHAR*)pSBuf,
	                                 nFlag);
        break;

	case PS_HAL_BML_ERASE:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_ERASE\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVbn      = %d(0x%x)\r\n"), nVbn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));

		*pResult = (UINT32)BML_EraseBlk(nVol,
		                                nVbn,
    	                                nFlag);
		pInOutBuf = NULL;
		break;

	case PS_HAL_BML_MEraseBlk:
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nCtrlCode = PS_HAL_BML_MEraseBlk\r\n")));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVol      = %d\r\n"), nVol));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nVbn      = %d(0x%x)\r\n"), nVbn));
        HALWP_INF_PRINT((TEXT("[HALWP:INF]  nFlag     = 0x%x\r\n"), (UINT32)nFlag));

		*pResult = (UINT32)BML_MEraseBlk(nVol,
		                                (MEBArg*) pstMEBArg,
    	                                nFlag);
		pInOutBuf = NULL;
		break;
	
	case PS_HAL_BML_READXID:
	    {
	        BMLVolSpec  stVolSpec;
	        INT32       nRet;
            

⌨️ 快捷键说明

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