fmd_stub.cpp

来自「SAMSUNG S3C6410 CPU BSP for winmobile6」· C++ 代码 · 共 188 行

CPP
188
字号
/*
 * fmd_stub.cpp
 */
 
#include <fmd.h>

#include <XSR.h>

#define SpinForever()   while (1)

#define PSFTL_SAM_BUF_FACTOR        0   /* 0 < FACTOR < 100                          */

PVOID  FMD_Init(LPCTSTR lpActiveReg, PPCI_REG_INFO pRegIn, PPCI_REG_INFO pRegOut)
{
	STLInfo stSTLInfo;
	INT32 nErr;
    	  
	RETAILMSG(1, (L"++STL_Init\r\n"));
	
	if(STL_Init()!=STL_SUCCESS) {
	    RETAILMSG(1, (L"FMD_Init : STL_Init is failed.\r\n"));
	    SpinForever();
	}

	RETAILMSG(1, (L"++STL_Open\r\n"));
	
	stSTLInfo.nTotalLogScts = 0;
	stSTLInfo.nLogSctsPerUnit = 0;
	stSTLInfo.nSamBufFactor = PSFTL_SAM_BUF_FACTOR;
	stSTLInfo.bASyncMode = FALSE32;

	nErr = STL_Open(0,PARTITION_ID_COPIEDOS,&stSTLInfo);
	
#if 1  // sequence for formatting OS region
    if (nErr == STL_SUCCESS)
    {
        RETAILMSG(1, (L"stSTLInfo.nTotalLogScts   =%d\r\n", stSTLInfo.nTotalLogScts));
        RETAILMSG(1, (L"stSTLInfo.nLogSctsPerUnit =%d\r\n", stSTLInfo.nLogSctsPerUnit));
        RETAILMSG(1, (L"stSTLInfo.nSamBufFactor   =%d\r\n", stSTLInfo.nSamBufFactor));
    }
    else if (nErr == STL_INVALID_PARAM)
    {
        RETAILMSG(1, (L"invalid STL parameter\r\n"));
    }
    else if (nErr == STL_UNFORMATTED)
    {
        RETAILMSG(1, (L"FTL unformatted\r\n"));
    }
    else if (nErr == STL_PARTITION_ALREADY_OPENED)
    {
        RETAILMSG(1, (L"STL_Open(PATITION=%d) is already opened\r\n", PARTITION_ID_COPIEDOS));
    }       
    else if (nErr == STL_CRITICAL_ERROR)
    {
        RETAILMSG(1, (L"STL_Open occurs Critical Error\r\n"));
    }
    else
    {
        RETAILMSG(1, (L"STL_Open unknown error\r\n"));
    }    
#else
	if(nErr==STL_UNFORMATTED) {
	    STLConfig   stSTLCfg;

		/* STL Cfg setting for STL Format */
		stSTLCfg.nFillFactor    = 100;   /* LogSctsPerUnit : UsableSctsPerUnit        */
		                                              /* Percentage, Full Usage Fill Factor = 100  */
	    stSTLCfg.nSnapshots     = 1;  /* Number of Snapshot : 1 or 4               */
		stSTLCfg.nNumOfRsvUnits = 2;      /* Reserved Units, should be >= 2            */
		stSTLCfg.nBlksPerUnit   = 1;  /* Maximum sectors per Unit is 256           */
		
		/* STL_Format */
		RETAILMSG(1,(L"[FMD_Init:INF]  STL_Format Start\r\n"));

		nErr = STL_Format(0,
							PARTITION_ID_COPIEDOS,
		                    &stSTLCfg,
		                    0);
		
		if (nErr != STL_SUCCESS)
		{
		    RETAILMSG(1,(L"[FMD_Init:ERR]  STL_Format Error = 0x%x\r\n", nErr));
		    while(1);
		}
		else RETAILMSG(1,(L"[FMD_Init:INF]  STL_Format ok\r\n"));		

		RETAILMSG(1, (L"++STL_Open\r\n"));
		nErr = STL_Open(0,PARTITION_ID_COPIEDOS,&stSTLInfo);
	}

	if(nErr!=STL_SUCCESS && nErr!=STL_PARTITION_ALREADY_OPENED) {
	    RETAILMSG(1, (L"[FMD_Init::ERR] STL_Open is failed.(nErr:0x%x)\r\n", nErr));
	}   
#endif

	RETAILMSG(1, (L"--STL_Open\r\n"));
 	
	return((PVOID) 1);
}

BOOL  FMD_GetInfo(PFlashInfo pFlashInfo)
{
	if (pFlashInfo == NULL)
		return(FALSE);
	
	pFlashInfo->flashType = NAND;
    pFlashInfo->dwNumBlocks = 0;
    pFlashInfo->dwBytesPerBlock = 0;
    pFlashInfo->wSectorsPerBlock = 64;
    pFlashInfo->wDataBytesPerSector = (512 << 2);
    return(TRUE);
}

ULONG nCount=0;
BOOL  FMD_ReadSector (SECTOR_ADDR startSectorAddr, LPBYTE pSectorBuff, PSectorInfo pSectorInfoBuff, DWORD dwNumSectors)
{
	//RETAILMSG(1, (L"FMD_ReadSector: %x, %x, %x, %x\r\n", startSectorAddr, pSectorBuff, pSectorInfoBuff, dwNumSectors));
	if ((nCount %0x100) == 0 )
	{
		RETAILMSG(1,(L"."));
	}
		nCount++;

	
	if ((pSectorBuff == NULL) || (pSectorInfoBuff != NULL)){
		RETAILMSG(1, (L"FMD_ReadSector : pSetorBuff null or pSectorInfoBuff not null\r\n"));
		return(FALSE);
	}
	
	STL_Read(0, PARTITION_ID_COPIEDOS, (startSectorAddr << 2), (dwNumSectors << 2), pSectorBuff);
	return(TRUE);
}

BOOL  FMD_WriteSector(SECTOR_ADDR startSectorAddr, LPBYTE pSectorBuff, PSectorInfo pSectorInfoBuff, DWORD dwNumSectors)
{
    if ((pSectorBuff == NULL) || (pSectorInfoBuff != NULL)){
		RETAILMSG(1, (L"FMD_WriteSector : pSetorBuff null or pSectorInfoBuff not null\r\n"));
		return(FALSE);
	}
	
	STL_Write(0, PARTITION_ID_COPIEDOS, (startSectorAddr << 2), (dwNumSectors << 2), pSectorBuff);
	return(TRUE);
}


BOOL  FMD_Deinit(PVOID)
{
	STL_Close(0,PARTITION_ID_COPIEDOS);
	// XSR deinit
	return(TRUE);
}

BOOL  FMD_EraseBlock(BLOCK_ID blockID)
{
	return(TRUE);
}

#if 0
BOOL  FMD_GetInfoEx(PFlashInfoEx pFlashInfo, PDWORD pdwNumRegions)
{
	return(FALSE);
}

DWORD FMD_GetBlockStatus(BLOCK_ID blockID)
{
	return(0);
}

BOOL FMD_SetBlockStatus(BLOCK_ID blockID, DWORD dwStatus)
{
	return(FALSE);
}

void  FMD_PowerUp(VOID)
{
}

VOID  FMD_PowerDown(VOID)
{
}

BOOL  FMD_OEMIoControl(DWORD dwIoControlCode, PBYTE pInBuf, DWORD nInBufSize, 
                       PBYTE pOutBuf, DWORD nOutBufSize, PDWORD pBytesReturned)
{
	return(FALSE);
}
#endif

⌨️ 快捷键说明

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