pseudobml.c

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

C
1,257
字号
/*****************************************************************************/
/*                                                                           */
/* PROJECT : PocketStoreII                                                   */
/* MODULE  : Pseudo BML                                                      */
/* NAME    : Pseudo BML                                                      */
/* FILE    : PseudoBML.c                                                     */
/* PURPOSE : This file contains the exported routine for interfacing with    */
/*           the upper layer of BML.                                         */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*          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                                                          */
/*                                                                           */
/*   19-APR-2004 [Janghwan Kim]: First writing                               */
/*   20-MAY-2004 [Janghwan Kim]: IOCTL_POCKETSTOREII_CMD added               */
/*	 25-Jan-2005 [EunKyoung Lim]: BML_Mxxx(), BML_Copy() is added	     */
/*                                                                           */
/*****************************************************************************/
/*****************************************************************************/
/* Headerfile Include                                                        */
/*****************************************************************************/
#include <windows.h>
#include <bldver.h>
#include <windev.h>
#include <types.h>
#include <excpt.h>
#include <tchar.h>
#include <devload.h>
#include <diskio.h>

#include <XSR.h>
#include <HALWrapper.h>

#include <storemgr.h>
#include <pm.h>

/*****************************************************************************/
/* Debug Definitions                                                         */
/*****************************************************************************/

#define BMLP_RTL_PRINT(x)        PSII_RTL_PRINT(x)

#if BMLP_ERR_MSG_ON
#define BMLP_ERR_PRINT(x)        PSII_RTL_PRINT(x)
#else
#define BMLP_ERR_PRINT(x)        
#endif /* #if BMLP_ERR_MSG_ON */

#if BMLP_LOG_MSG_ON
#define BMLP_LOG_PRINT(x)        PSII_DBG_PRINT(x)
#else
#define BMLP_LOG_PRINT(x)        
#endif  /* #if BMLP_LOG_MSG_ON */

#if BMLP_INF_MSG_ON
#define BMLP_INF_PRINT(x)        PSII_DBG_PRINT(x)
#else
#define BMLP_INF_PRINT(x)        
#endif  /* #if BMLP_INF_MSG_ON */


/*****************************************************************************/
/* Global Variables                                                          */
/*****************************************************************************/


/*****************************************************************************/
/* Imported variable declarations                                            */
/*****************************************************************************/


/*****************************************************************************/
/* Imported function declarations                                            */
/*****************************************************************************/


/*****************************************************************************/
/* Local #define                                                             */
/*****************************************************************************/


/*****************************************************************************/
// Local constant definitions
/*****************************************************************************/


/*****************************************************************************/
// Local typedefs
/*****************************************************************************/


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*		BML_Init                                                             */
/* DESCRIPTION                                                               */
/*      This function initializes the data structure of BML                  */
/* PARAMETERS                                                                */
/*      none                                                                 */
/* RETURN VALUES                                                             */
/*      BML_ALREADY_INITIALIZED                                              */
/*      BML_CRITICAL_ERROR                                                   */
/*      BML_SUCCESS                                                          */
/* NOTES                                                                     */
/*      Before all of other functions of BML is called, BML_Init() should be */
/*      called.                                                              */
/*                                                                           */
/*****************************************************************************/
INT32
BML_Init(VOID)
{
    BMLPacket   stPacket; 
    UINT32      nResult;

    BMLP_LOG_PRINT((TEXT("[BMLP: IN] ++BML_Init()\r\n")));

    do {
        /* BML Init */
        stPacket.nVol       = 0;
        stPacket.nCtrlCode  = PS_HAL_BML_INIT;
        stPacket.nVbn       = 0;            // Not used
        stPacket.nVsn       = 0;            // Not used
        stPacket.nNumOfScts = 0;            // Not used
        stPacket.nOpFlag    = 0;
        stPacket.pMBuf      = NULL;
        stPacket.pSBuf      = NULL;
        stPacket.pstMEBArg	= 0;			// by kathy
    	stPacket.pSGLBuf = 0;				/* added for XSR v1.5.x */
    
        KernelIoControl(IOCTL_POCKETSTOREII_CMD,  /* Io Control Code */
                        &stPacket,              /* Input buffer (Additional Control Code) */
                        sizeof(BMLPacket),       /* Size of Input buffer */
                        NULL,                   /* Output buffer */
                        0,                      /* Size of Output buffer */
                        &nResult);              /* Error Return */
    
        if ((nResult != BML_SUCCESS) && (nResult != BML_ALREADY_INITIALIZED))
        {
            BMLP_ERR_PRINT((TEXT("[BMLP:ERR]  BML_Init() failure. ERR Code=%x\r\n"), nResult));

            break;
        }

    } while(0);

    BMLP_LOG_PRINT((TEXT("[BMLP:OUT] --BML_Init()\r\n")));

    return (INT32)nResult;
    
}

/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*		BML_Format                                                           */
/* DESCRIPTION                                                               */
/*      This function formats the volume                                     */
/* PARAMETERS                                                                */
/*		nVol       [IN]                                                      */
/*			  volume number                                                  */
/*		pstPartI   [IN]                                                      */
/*			  pointer of XSRPartI data structure, which contains partition   */
/*            information                                                    */
/*      nFlag      [IN]                                                      */
/*            BML_INIT_FORMAT means formatting volume initially              */
/*            BML_REPARTITION means changing partition information of volume */
/* RETURN VALUES                                                             */
/*		BML_SUCCESS                                                          */
/*            BML_Format is completed.                                       */
/*      BML_INVALID_PARAM                                                    */
/*            invalid input parameters (volume number or invalid PI)         */
/*		BML_CRITICAL_ERROR                                                   */
/*            critical error occurs                                          */
/*      BML_UNFORMATTED                                                      */
/*            Reservoir is unformatted or Reservoir is broken                */
/*      BML_MAKE_RSVR_ERROR                                                  */
/*            Making Reservoir is failed                                     */
/* NOTES                                                                     */
/*      Before BML_Format() is called, BML_Init() should be called.          */
/*      When this function is called, AC power must be connected.            */
/*                                                                           */
/*****************************************************************************/
INT32
BML_Format(UINT32 nVol, XSRPartI *pstPartI, UINT32 nFlag)
{
    BMLPacket   stPacket; 
    UINT32      nResult;

    BMLP_LOG_PRINT((TEXT("[BMLP: IN] ++BML_Format()\r\n")));

    do {
        /* BML_Format */
        stPacket.nVol       = nVol;
        stPacket.nCtrlCode  = PS_HAL_BML_FORMAT;
        stPacket.nVbn       = 0;            // Not used
        stPacket.nVsn       = 0;            // Not used
        stPacket.nNumOfScts = 0;            // Not used
        stPacket.nOpFlag    = nFlag;
        stPacket.pMBuf      = NULL;
        stPacket.pSBuf      = NULL;
        stPacket.pstMEBArg	= 0;			// by kathy
    	stPacket.pSGLBuf = 0;				/* added for XSR v1.5.x */
    
        KernelIoControl(IOCTL_POCKETSTOREII_CMD,  /* Io Control Code */
                        &stPacket,              /* Input buffer (Additional Control Code) */
                        sizeof(BMLPacket),       /* Size of Input buffer */
                        pstPartI,               /* Output buffer */
                        sizeof(XSRPartI),       /* Size of Output buffer */
                        &nResult);              /* Error Return */
    
        if (nResult != BML_SUCCESS)
        {
            BMLP_ERR_PRINT((TEXT("[BMLP:ERR]  BML_Format() failure. ERR Code=%x\r\n"), nResult));
    
            break;
        }

    } while(0);

    BMLP_LOG_PRINT((TEXT("[BMLP:OUT] --BML_Format()\r\n")));

    return (INT32)nResult;
}


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*		BML_Open                                                             */
/* DESCRIPTION                                                               */
/*      This function opens the volume.                                      */
/* PARAMETERS                                                                */
/*		nVol       [IN]                                                      */
/*            volume number                                                  */
/* RETURN VALUES                                                             */

⌨️ 快捷键说明

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