pam.cpp

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

CPP
242
字号
/*****************************************************************************/
/*                                                                           */
/* PROJECT : ANYSTORE II                                                     */
/* MODULE  : Platform Adaptation Module                                      */
/* NAME    : S3C6410 + OneNAND PAM                                           */
/* FILE    : PAM.cpp                                                         */
/* PURPOSE : Platform Dependent code, Platform Configuration code            */
/*           Implementation                                                  */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*        COPYRIGHT 2003-2005, 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                                                          */
/*                                                                           */
/* - 09/JUN/2003 [Janghwan Kim] : First writing                              */
/* - 08/OCT/2003 [Janghwan Kim] : Remove LFT.h and Add LLD.h                 */
/* - 09/OCT/2003 [Janghwan Kim] : Code Mofification                          */
/*   16/NOV/2004 [MinYoung Kim] : reorganized functions                      */
/*   28/DEC/2004 [JinKyu Kim]   : Reorganization                             */
/*                                                                           */
/*****************************************************************************/

/*****************************************************************************/
/* Note                                                                      */
/*                                                                           */
/*  This code is appliable OneNAND512Mb, OneNAND1GDDP, OneNAND256Mb LLDs to  */
/*  S3C6400 board and OneNAND2G to S3C6410 board.                            */
/*****************************************************************************/

#include <Xsr.h>
#include <OCLD.h>
//#include <oal_memory.h>

/*****************************************************************************/
/* Local Definitions                                                         */
/*****************************************************************************/

/*****************************************************************************/
/* Variables                                                                 */
/*****************************************************************************/

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


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      PAM_Init                                                             */
/* DESCRIPTION                                                               */
/*      This function initializes NAND specific Hardware                     */
/* PARAMETERS                                                                */
/*      None                                                                 */
/* RETURN VALUES                                                             */
/*      None                                                                 */
/* NOTES                                                                     */
/*                                                                           */
/*****************************************************************************/
VOID
PAM_Init(VOID)
{	
}

/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      PAM_RegLFT                                                           */
/* DESCRIPTION                                                               */
/*      This function registers LLD functions with LFT                       */
/* PARAMETERS                                                                */
/*      pstFunc                                                              */
/*          LLD Functino Table                                               */
/* RETURN VALUES                                                             */
/*      None                                                                 */
/* NOTES                                                                     */
/*                                                                           */
/*****************************************************************************/
VOID 
PAM_RegLFT(VOID *pstFunc)
{
	LowFuncTbl *pstLFT;

	pstLFT = (LowFuncTbl*)pstFunc;

    pstLFT[0].Init          = ONLD_Init;
    pstLFT[0].Open          = ONLD_Open;
    pstLFT[0].Close         = ONLD_Close;
    pstLFT[0].Read          = ONLD_Read;
    pstLFT[0].Write         = ONLD_Write;
    pstLFT[0].CopyBack      = ONLD_CopyBack;
    pstLFT[0].Erase         = ONLD_Erase;
    pstLFT[0].GetDevInfo    = ONLD_GetDevInfo;
    pstLFT[0].ChkInitBadBlk = ONLD_ChkInitBadBlk;
    pstLFT[0].FlushOp       = ONLD_FlushOp;
    pstLFT[0].SetRWArea     = ONLD_SetRWArea;
    pstLFT[0].GetPrevOpData = ONLD_GetPrevOpData;
    pstLFT[0].IOCtl         = ONLD_IOCtl;
    
    pstLFT[0].MRead         = ONLD_MRead;
    pstLFT[0].MWrite        = ONLD_MWrite;
    pstLFT[0].MErase        = ONLD_MErase;
    pstLFT[0].EraseVerify   = ONLD_EraseVerify;
}


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      PAM_GetPAParm                                                        */
/* DESCRIPTION                                                               */
/*      This function gets device parameter value                            */
/* PARAMETERS                                                                */
/*      nDev                                                                 */
/*          XSR Platform Parameter                                           */
/* RETURN VALUES                                                             */
/*      None                                                                 */
/* NOTES                                                                     */
/*                                                                           */
/*****************************************************************************/
static XsrVolParm gstParm[XSR_MAX_VOL];

#ifdef __cplusplus
extern "C" {
#endif
	
unsigned int CheckMMU();

#ifdef __cplusplus
}
#endif

VOID*
PAM_GetPAParm(VOID)
{
	unsigned int MMUFlag;
	MMUFlag = CheckMMU();
	
#if 0
	if(MMUFlag&0x01)
	{	//MMU is on.
		gstParm[0].nBaseAddr[0] = ONENANDC0_VIRTADDR; //(UINT32)OALPAtoVA(ONENANDC_BASEADDR,FALSE);
	}
	else {
		gstParm[0].nBaseAddr[0] = ONENANDC0_BASEADDR;
	}
#else
	gstParm[0].nBaseAddr[0] = ONENANDC0_MEM_VIRTADDR;
#endif
	gstParm[0].nBaseAddr[1] = NOT_MAPPED;
	gstParm[0].nBaseAddr[2] = NOT_MAPPED;
	gstParm[0].nBaseAddr[3] = NOT_MAPPED;

	gstParm[0].nEccPol      = HW_ECC;
	gstParm[0].nLSchemePol  = HW_LOCK_SCHEME;
	gstParm[0].bByteAlign   = TRUE32;
	gstParm[0].nDevsInVol   = 1;
	gstParm[0].pExInfo      = NULL;

	gstParm[1].nBaseAddr[0] = NOT_MAPPED;
	gstParm[1].nBaseAddr[1] = NOT_MAPPED;
	gstParm[1].nBaseAddr[2] = NOT_MAPPED;
	gstParm[1].nBaseAddr[3] = NOT_MAPPED;

	gstParm[1].nEccPol      = HW_ECC;
	gstParm[1].nLSchemePol  = HW_LOCK_SCHEME;
	gstParm[1].bByteAlign   = TRUE32;
	gstParm[1].nDevsInVol   = 0;
	gstParm[1].pExInfo      = NULL;

	return (VOID *) gstParm;
}

VOID
PAM_SetMemoryCtl(VOID)
{	
}


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      PAM_Memcpy                                                           */
/* DESCRIPTION                                                               */
/*      This function copies data from source to destination by using OAM or */
/*      System supported function                                            */
/* PARAMETERS                                                                */
/*      pDst        Destination array Pointer to be copied                   */
/*      pSrc        Source data allocated Pointer                            */
/*      nLen        length to be copied                                      */
/* RETURN VALUES                                                             */
/*      None                                                                 */
/* NOTES                                                                     */
/*      This function is called by function that wants to copy source buffer */
/*  to destination buffer.                                                   */
/*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

void memcpy32(VOID *pDst, VOID *pSrc, UINT32 nLen);

#ifdef __cplusplus
}
#endif

VOID
PAM_Memcpy(VOID *pDst, VOID *pSrc, UINT32 nLen)
{
#if defined(PAM_USE_ASMCPY)
#if 0
	if(nLen>=32 && ((UINT32)pDst&0x3)==0 && ((UINT32)pSrc&0x3)==0) {
		memcpy32(pDst, pSrc, nLen);
	}
	else {
	    OAM_Memcpy(pDst, pSrc, nLen);
	}
#else
	memcpy32(pDst, pSrc, nLen);
#endif	
#else
    OAM_Memcpy(pDst, pSrc, nLen);
#endif
}
		

⌨️ 快捷键说明

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