📄 mdocplus.c
字号:
* Removed warrnings.
*
* Rev 1.13 Apr 24 2001 17:11:14 oris
* Bug fix - Wrong data when reading 2 bytes from data area.
* Removed compilation problems when USE_FUNC is defined.
* Bug fix - read\write operation with the EDC flags ignored the EXTRA flag.
* Bug fix - ipl and otp routines causes exception in MTD_STANDALONE mode.
* Rebuild OTP routine.
*
* Rev 1.12 Apr 18 2001 21:24:54 oris
* Bug fix - bad status code when writting in interleave - 1 fails, because changeInterleave routine is called while in access error.
* Bug fix - removed download operation after write IPL.
* Bug fix - Fixed casting problem in flash type identification.
* Bug fix - Bad status code in doc2erase.
* Bug fix - OTP area written\ read in interleave - 1
* Bug fix - bad endian handling in OTP routines.
* Moved forced download routine from under the MTD_STANDALONE compilation flag.
* Removed warrnings.
*
* Rev 1.11 Apr 18 2001 11:17:30 oris
* Bug fix in getUniqueId routine.
*
* Rev 1.10 Apr 18 2001 09:27:38 oris
* Removed warrnings.
*
* Rev 1.9 Apr 16 2001 21:46:58 oris
* Bug fix - aliasing mechanism fixed.
*
* Rev 1.8 Apr 16 2001 13:54:34 oris
* Removed warrnings.
* Bug fix - uninitialized buffer in read operation from uneven address.
* Bug fix - report hw protection fault on write and erase operations.
*
* Rev 1.7 Apr 12 2001 06:52:06 oris
* Added setFloor in chkAsicMode in order to make sure floor does not change.
* Added powerDown routine and registration.
* Added download routine registration.
* Added support for reading and writing uneven address or length.
* Removed warrnings.
* Bug fix for memory lick in readBBT.
* Changed several routines to static.
*
* Rev 1.6 Apr 10 2001 23:55:30 oris
* Bug fix - in readbbt routine buffer was not incremented correctly.
*
* Rev 1.5 Apr 10 2001 16:43:14 oris
* Added multiple floor support for readbbt routine.
* Added call for docSocketInit which initializes the socket routines.
* Added validity check after flMap call in order to support pccard premoutn routine.
*
* Rev 1.4 Apr 09 2001 19:02:34 oris
* Removed unused variables.
* Bug fix on erase operation to more then 1 unit.
* Comment forced download in device identification routine.
*
*/
/*********************************************************************/
/* */
/* FAT-FTL Lite Software Development Kit */
/* Copyright (C) M-Systems Ltd. 1995-2001 */
/* */
/*********************************************************************/
/*********************************************************************
* *
* DESCRIPTION: basic mtd functions for MDOC32 *
* interleave 1 *
* page organization : *
* 512 bytes data sector 0, *
* 6 bytes ecc sector 0, *
* 2 bytes sector 0 flag, *
* 8 bytes unit data sector 0, *
* interleave 2 *
* page organization : *
* 512 bytes data sector 0, *
* 6 bytes ecc sector 0, *
* 2 bytes sector 0 flag, *
* 2 bytes sector 1 flags, *
* 512 bytes data sector 1 , *
* 6 bytes ecc sector 1, *
* 8 bytes unit data sector 0, *
* 8 bytes unit data sector 1 *
* *
* AUTHOR: arie tamam *
* *
* HISTORY: created november 14 2000 *
* *
*********************************************************************/
/*********************************************************************/
/* | Physical address of interleave - 2 page */
/* Area -----------------------------------------------------*/
/* | First Sector | Second Sector */
/*-------------------------------------------------------------------*/
/* Extra: | 512-519, 1040-1047 | 1034-1039, 520-521, 1048-1055 */
/* Sector data | 0-511 | 522-1033 */
/* Sector flags | 518-519 | 520-521 */
/* Unit data | 1040-1047 | 1048-1055 */
/* Edc | 512-517 | 1034-1039 */
/*********************************************************************/
/* Note: The address is given as a page offset 0-n where n is the */
/* number of bytes the area has fo a sector (16 for extra , 2 for */
/* sector flags, 8 for unit data and 512 for sector data). The */
/* second sector address is given in a simmilar fation + 512. */
/* Note: Extra area is exported in the floowing order: */
/* sector data , edc , sector flags , unit data. */
/*********************************************************************/
/* Area A : 0 - 511 | Area B : 512 - 1023 | Area C : 1024 - 1055 */
/*********************************************************************/
/*********************************************************************/
/* Area | Physical address of interleave - 1 page */
/*-------------------------------------------------------------------*/
/* Extra: | 512 - 517 , 518 - 519 , 520 - 527 */
/* Sector data | 0 - 511 */
/* Edc | 512 - 517 */
/* Sector flags | 518 - 519 */
/* Unit data | 520 - 527 */
/*********************************************************************/
/* Note: The address is given as a page offset 0-n where n is the */
/* number of bytes the area has for a sector (16 for extra , 2 for */
/* sector flags, 8 for unit data and 512 for sector data). */
/* Note: Extra area is exported in the floowing order: */
/* sector data , edc , sector flags , unit data. */
/*********************************************************************/
/* Area A : 0 - 255 | Area B : 256 - 511 | Area C : 512 - 528 */
/*********************************************************************/
/** include files **/
#include "mdocplus.h"
#include "reedsol.h"
#ifdef HW_PROTECTION
#include "protectp.h"
#endif /* HW_PROTECTION */
/* Yield CPU time in msecs */
#ifndef YIELD_CPU
#define YIELD_CPU 10
#endif /* YIELD_CPU */
/* maximum waiting time in msecs */
#define MAX_WAIT 30
extern NFDC21Vars docMtdVars[SOCKETS];
#ifdef FL_PLANT_BBT_FOR_TESTING
extern FLStatus informOfOperation(FLFlash * flash, dword start, dword length , byte bType);
#endif /* FL_PLANT_BBT_FOR_TESTING */
/* When the MTD is used as a standalone package some of the routine */
/* are replaced with the following macroes */
#ifdef MTD_STANDALONE
#define flReadBackBufferOf(a) &(globalReadBack[a][0])
#define flSocketNoOf(socket) 0 /* currently we support only a single device */
#define flMap(socket,address) addToFarPointer(socket->base, address & (socket->size - 1));
#endif /* MTD_STANDALONE */
#ifndef FL_NO_USE_FUNC
/*----------------------------------------------------------------------*/
/* c h o o s e D e f a u l t I F _ C F G */
/* */
/* Choose the default IF_CFG to use before is can actually be detected */
/* */
/* Parameters: */
/* busConfig : Socket access discriptor */
/* */
/* Returns: */
/* Suspected IF_CFG configuration (either 8 or 16). */
/*----------------------------------------------------------------------*/
static byte chooseDefaultIF_CFG(dword busConfig)
{
if(( busConfig & FL_BUS_HAS_8BIT_ACCESS )&&
((busConfig & FL_XX_ADDR_SHIFT_MASK) == FL_NO_ADDR_SHIFT) )
{
/* Assume if_cfg was set to 0. Interleave is irelevant */
return 8;
}
/* Assume if_cfg was set to 1. Interleave is irelevant */
return 16;
}
/*----------------------------------------------------------------------*/
/* s e t D O C P l u s B u s T y p e */
/* */
/* Check validity and set the proper memory access routines for MTD. */
/* */
/* Parameters: */
/* flash : Pointer identifying drive */
/* busConfig : Socket access discriptor */
/* interleave : Interleave factor (1,2) */
/* if_cfg : if_cfg state: */
/* 8 - 8 bit */
/* 16 - 16 bit */
/* */
/* Returns: */
/* TRUE if routines are available and fit the DiskOnChip */
/* configuration otherwise FALSE. */
/* */
/* The variable pointer to by busConfig is added TrueFFS private */
/* MTD descriptors. */
/*----------------------------------------------------------------------*/
static FLBoolean setDOCPlusBusType(FLFlash * flash,
dword busConfig,
byte interleave,
byte if_cfg)
{
switch(interleave)
{
case 1: /* No interleave */
busConfig |= FL_8BIT_FLASH_ACCESS;
break;
case 2: /* 2 flashes are interleaved */
busConfig |= FL_16BIT_FLASH_ACCESS;
break;
default:
DEBUG_PRINT(("ERROR: No such interleave factor (setDOCPlusBusType).\r\n"));
return FALSE;
}
switch(if_cfg)
{
case 8: /* No interleave */
busConfig |= FL_8BIT_DOC_ACCESS;
break;
case 16: /* 2 flashes are interleaved */
busConfig |= FL_16BIT_DOC_ACCESS;
break;
default:
DEBUG_PRINT(("ERROR: Invalid if_cfg value (setDOCPlusBusType).\r\n"));
return FALSE;
}
if(setBusTypeOfFlash(flash, busConfig) != flOK)
return FALSE;
return TRUE;
}
#endif /* FL_NO_USE_FUNC */
#ifndef NO_EDC_MODE
/*哪哪哪哪哪哪哪哪哪哪哪哪哪
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -