📄 flflash.c
字号:
/***********************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003 */
/* All Rights Reserved */
/***********************************************************************************/
/* NOTICE OF M-SYSTEMS OEM */
/* SOFTWARE LICENSE AGREEMENT */
/* */
/* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
/* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
/* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
/* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
/* E-MAIL = info@m-sys.com */
/***********************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/core/flflash.c-arc $
*
* Rev 1.4 Sep 01 2003 19:08:02 oris
* - changed MTDS definition to FL_MTDS
*
* Rev 1.3 Jun 16 2003 01:18:16 oris
* Added TFFS_DLL_API prefix.
*
* Rev 1.2 Apr 27 2003 14:13:14 Oris
* Removed default initialization of mediaType to prevent identification of wrong MTD module.
*
* Rev 1.1 Apr 27 2003 09:01:34 Oris
* Improoved RAM_MTD support.
*
* Rev 1.0 Apr 09 2003 12:16:04 OriS
* Initial revision.
*
*/
#include "flflash.h"
#include "docsys.h"
/* MTD registration information */
int noOfMTDs = 0;
MTDidentifyRoutine mtdTable[FL_MTDS];
static FLFlash vols[SOCKETS];
FLStatus dataErrorObject;
/*----------------------------------------------------------------------*/
/* f l F l a s h O f */
/* */
/* Gets the flash connected to a volume no. */
/* */
/* Parameters: */
/* volNo : Volume no. for which to get flash */
/* */
/* Returns: */
/* flash of volume no. */
/*----------------------------------------------------------------------*/
TFFS_DLL_API FLFlash * NAMING_CONVENTION flFlashOf(FLByte volNo)
{
return &vols[volNo];
}
/*----------------------------------------------------------------------*/
/* f l I d e n t i f y F l a s h */
/* */
/* Identify the current Flash medium and select an MTD for it */
/* */
/* Parameters: */
/* socket : Socket of flash */
/* vol : New volume pointer */
/* */
/* Returns: */
/* FLStatus : 0 = Flash was identified */
/* other = identification failed */
/*----------------------------------------------------------------------*/
FLStatus flIdentifyFlash(FLSocket *socket, FLFlash vol)
{
FLStatus status = flUnknownMedia;
int iMTD;
/* Prevent reidentifing flash media */
if(vol.wasIdentified == TRUE)
return flOK;
/* Setup default parameters for old MTD's that do not support new properties */
#ifndef RAM_MTD
vol.type = NOT_FLASH;
vol.interleaving = 1;
vol.maxEraseCycles = 100000L; /* Defaul for NOR */
vol.maxBadPercentage = 2;
vol.if_cfg = 8;
vol.noOfFloors = 1;
vol.noOfPlanes = 1;
vol.noOfSectorsPerPage = 1;
vol.sharedSectors = 1;
vol.noOfChips = 1;
#endif /* RAM_MTD */
vol.socket = socket;
#ifndef FIXED_MEDIA
/* Check that we have a media */
flResetCardChanged(vol.socket); /* we're mounting anyway */
checkStatus(flMediaCheck(vol.socket));
#endif
/* Attempt all MTD's */
for (iMTD = 0; (iMTD < noOfMTDs) && (status != flOK) &&
(status != flBadDownload); iMTD++)
status = mtdTable[iMTD](&vol);
switch(status)
{
case flOK:
vol.wasIdentified = TRUE; /* No need to identify the media again */
if(vol.erasableBlockSizeBits == 0)
for(iMTD = vol.erasableBlockSize ; iMTD > 1 ; vol.erasableBlockSizeBits++,iMTD >>=1);
if(vol.unitsInFirstFloor == 0)
vol.unitsInFirstFloor = (FLWord)(vol.mediaSize / vol.noOfChips) *
(FLWord)(vol.noOfChips / vol.noOfFloors);
if(vol.noOfBanks == 0)
vol.noOfBanks = vol.noOfChips;
return flOK;
case flBadDownload:
DBG_PRINT_ERR(FLZONE_BLKDEV,"ERROR - Flash media reported bad download error.\r\n");
return flBadDownload;
default: /* No MTD recognition */
DBG_PRINT_ERR(FLZONE_BLKDEV,"ERROR - Did not identify flash media.\r\n");
return flUnknownMedia;
}
/*6.0 mtd must report erasable unit size bits */
}
/*----------------------------------------------------------------------*/
/* f l D i s m o u n t F l a s h */
/* */
/* Dismount MTD from current socket. */
/* This routine is used to free memory used by the MTD */
/* */
/* Parameters: */
/* vol : New volume pointer */
/* */
/* Returns: */
/* FLStatus : flOK */
/*----------------------------------------------------------------------*/
FLStatus flDismountFlash(FLFlash vol)
{
/* Prevent dismounting of the flash media twice */
if(vol.wasIdentified == FALSE)
return flOK;
vol.wasIdentified = FALSE;
/* Call MTD dismount routine if one exists */
if(vol.dismount != NULL)
return vol.dismount(&vol);
return flOK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -