⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flflash.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * $Log:   V:/Flite/archives/TrueFFS5/Src/FLFLASH.C_V  $
 * 
 *    Rev 1.16   Jul 18 2002 10:54:20   oris
 * Removed warnings
 * 
 *    Rev 1.15   May 02 2002 09:41:28   oris
 * Changed memIntereleaveChanged to memSetGetMode
 * 
 *    Rev 1.14   May 01 2002 19:03:10   oris
 * Added initialization of memInterleaveChanged routine.
 * 
 *    Rev 1.13   Apr 22 2002 13:53:48   oris
 * Bug fix - extra ";" prevents insertion of  user defined access routines.
 * 
 *    Rev 1.12   Apr 15 2002 07:36:38   oris
 * Bug fix - do not initialize access routines in case of user defined routines - as a result docsys must be included.
 * 
 *    Rev 1.11   Jan 28 2002 21:24:38   oris
 * Changed memWinowSize to memWindowSize.
 * 
 *    Rev 1.10   Jan 17 2002 23:09:30   oris
 * Added flFlashOf() routine to allow the use of a single FLFlash record  per socket .
 * Added memory access routines initialization for FLFlash.
 * Bug fix - if M+ device was registered after 8-bit DiskOnChip and the M+  had a bad download problem , the error would not be reported, but only  flUnknown media.
 * 
 *    Rev 1.9   Sep 15 2001 23:46:00   oris
 * Changed erase routine to support up to 64K erase blocks.
 * 
 *    Rev 1.8   Jul 13 2001 01:04:38   oris
 * Added new field initialization in FLFlash record - Max Erase Cycles of the flash.
 * 
 *    Rev 1.7   May 16 2001 21:18:24   oris
 * Removed warnings.
 * 
 *    Rev 1.6   May 02 2001 06:41:26   oris
 * Removed the lastUsableBlock variable.
 * 
 *    Rev 1.5   Apr 24 2001 17:07:52   oris
 * Bug fix - missing NULL initialization for several compilation flags.
 * Added lastUsableBlock field defualt initialization.
 * 
 *    Rev 1.4   Apr 16 2001 13:39:14   oris
 * Bug fix read and write default routines were not initialized.
 * Initialize the firstUsableBlock.
 * Removed warrnings.
 * 
 *    Rev 1.3   Apr 12 2001 06:50:22   oris
 * Added initialization of download routine pointer.
 * 
 *    Rev 1.2   Apr 09 2001 15:09:04   oris
 * End with an empty line.
 * 
 *    Rev 1.1   Apr 01 2001 07:54:08   oris
 * copywrite notice.
 * Changed prototype of :flashRead.
 * Removed interface b initialization (experimental MTD interface for mdocp).
 * Spelling mistake "changableProtectedAreas".
 * Added check for bad download in flash recognition.
 *
 *    Rev 1.0   Feb 04 2001 11:21:16   oris
 * Initial revision.
 *
 */

/***********************************************************************************/
/*                        M-Systems Confidential                                   */
/*           Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001            */
/*                         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                                                    */
/***********************************************************************************/


#include "flflash.h"
#include "docsys.h"

#define    READ_ID            0x90
#define    INTEL_READ_ARRAY        0xff
#define    AMD_READ_ARRAY        0xf0

/* MTD registration information */

int doc_noOfMTDs = 0;

MTDidentifyRoutine doc_mtdTable[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.                        */
/*----------------------------------------------------------------------*/

FLFlash *flFlashOf(unsigned volNo)
{
  return &vols[volNo];
}


/*----------------------------------------------------------------------*/
/*                      f l a s h M a p                */
/*                                    */
/* Default flash map method: Map through socket window.            */
/* This method is applicable for all NOR Flash                */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*      address        : Card address to map                */
/*    length        : Length to map (irrelevant here)        */
/*                                                                      */
/* Returns:                                                             */
/*    Pointer to required card address                */
/*----------------------------------------------------------------------*/

static void FAR0 *flashMap(FLFlash vol, CardAddress address, int length)
{
  return flMap(vol.socket,address);
}


/*----------------------------------------------------------------------*/
/*                      f l a s h R e a d                */
/*                                    */
/* Default flash read method: Read by copying from mapped address    */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*      address        : Card address to read                */
/*    buffer        : Area to read into                */
/*    length        : Length to read                */
/*                                                                      */
/*----------------------------------------------------------------------*/

static FLStatus flashRead(FLFlash vol,
            CardAddress address,
            void FAR1 *buffer,
            dword length,
            word mode)
{
  tffscpy(buffer,vol.map(&vol,address,(word)length),(word)length);

  return flOK;
}



/*----------------------------------------------------------------------*/
/*                   f l a s h N o W r i t e            */
/*                                    */
/* Default flash write method: Write not allowed (read-only mode)    */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*      address        : Card address to write                */
/*    buffer        : Area to write from                */
/*    length        : Length to write                */
/*                                                                      */
/* Returns:                                                             */
/*    Write-protect error                        */
/*----------------------------------------------------------------------*/

static FLStatus flashNoWrite(FLFlash vol,
               CardAddress address,
               const void FAR1 *from,
               dword length,
               word mode)
{
  return flWriteProtect;
}


/*----------------------------------------------------------------------*/
/*                   f l a s h N o E r a s e            */
/*                                    */
/* Default flash erase method: Erase not allowed (read-only mode)    */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*      firstBlock    : No. of first erase block            */
/*    noOfBlocks    : No. of contiguous blocks to erase        */
/*                                                                      */
/* Returns:                                                             */
/*    Write-protect error                        */
/*----------------------------------------------------------------------*/

static FLStatus flashNoErase(FLFlash vol,
               word firstBlock,
               word noOfBlocks)
{
  return flWriteProtect;
}

/*----------------------------------------------------------------------*/
/*                   s e t N o C a l l b a c k            */
/*                                    */
/* Register power on callback routine. Default: no routine is         */
/* registered.                                */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*                                                                      */
/*----------------------------------------------------------------------*/

static void setNoCallback(FLFlash vol)
{
  flSetPowerOnCallback(vol.socket,NULL,NULL);
}

/*----------------------------------------------------------------------*/
/*                   f l I n t e l I d e n t i f y            */
/*                                    */
/* Identify the Flash type and interleaving for Intel-style Flash.    */
/* Sets the value of vol.type (JEDEC id) & vol.interleaving.            */
/*                                    */
/* Parameters:                                                          */
/*    vol        : Pointer identifying drive            */
/*    amdCmdRoutine    : Routine to read-id AMD/Fujitsu style at    */
/*              a specific location. If null, Intel procedure    */
/*              is used.                                      */
/*      idOffset    : Chip offset to use for identification        */
/*                                                                      */
/* Returns:                                                             */
/*    FLStatus    : 0 = OK, otherwise failed (invalid Flash array)*/
/*----------------------------------------------------------------------*/

void flIntelIdentify(FLFlash vol,
                     void (*amdCmdRoutine)(FLFlash vol, CardAddress,
                     unsigned char, FlashPTR),
                     CardAddress idOffset)
{
  int inlv;

  unsigned char vendorId = 0;

⌨️ 快捷键说明

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