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

📄 docsoc.c

📁 M-System DOC(Disk on a Chip) Flash芯片的诊断工具, 可以从Flash芯片中获取特定的数据信息, 用于判断芯片当前的状态.
💻 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/socket/docsoc.c-arc  $
 * 
 *    Rev 1.2   Apr 27 2003 14:13:28   Oris
 * Changed vol to pVol
 * 
 *    Rev 1.1   Apr 13 2003 20:29:24   OriS
 * Fixed compilation error for BDK
 * 
 *    Rev 1.0   Apr 09 2003 12:15:54   OriS
 * Initial revision.
 *
 */

#include "nanddefs.h"
#ifndef MTD_STANDALONE
#include "flsocket.h"
#endif /* MTD_STANDALONE */

/************************************************************************/
/*                                                                        */
/* Beginning of controller-customizable code                                */
/*                                                                        */
/* The function prototypes and interfaces in this section are standard        */
/* and are used in this form by the non-customizable code. However, the */
/* function implementations are specific to the 82365SL controller.        */
/*                                                                        */
/* You should replace the function bodies here with the implementation        */
/* that is appropriate for your controller.                                */
/*                                                                        */
/* All the functions in this section have no parameters. This is        */
/* because the parameters needed for an operation may be themselves        */
/* dependent on the controller. Instead, you should use the value in         */
/* the 'vol' structure as parameters.                                   */
/* If you need socket-state variables specific to your implementation,        */
/* it is recommended to add them to the 'vol' structure rather than     */
/* define them as separate static variables.                                */
/*                                                                        */
/************************************************************************/


/************************************************************************/
/* c a r d D e t e c t e d                                                */
/*                                                                        */
/* Detect if a card is present (inserted)                                */
/*                                                                        */
/* Parameters:                                                                */
/*        vol : Pointer identifying drive                                        */
/*                                                                        */
/* Returns:                                                                */
/*        0 = card not present, other = card present                        */
/************************************************************************/

static FLBoolean cardDetected(FLSocket * pVol)
{
  return TRUE;
}


/************************************************************************/
/* V c c O n                                                            */
/*                                                                      */
/* Turns on Vcc (3.3/5 Volts). Vcc must be known to be good on exit.    */
/* This routine also makes sure the device is not in DPD mode           */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*                                                                      */
/************************************************************************/

#ifndef MTD_STANDALONE
static void VccOn(FLSocket * pVol)
{/* Ori */
   if((pVol->DPDState == PowerOff) && (pVol->flash != NULL))
      if(((FLFlash *)(pVol->flash))->enterDeepPowerDownMode != NULL)
      {
	 ((FLFlash *)pVol->flash)->enterDeepPowerDownMode((FLFlash *)pVol->flash,EXIT_DEEP_POWER_DOWN);
	 pVol->DPDState = PowerOn;
      }
}
#endif /* MTD_STANDALONE */


/************************************************************************/
/* V c c O f f                                                                */
/*                                                                        */
/* Turns off Vcc.                                                        */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/************************************************************************/

static void VccOff(FLSocket * pVol)
{
}


#ifdef SOCKET_12_VOLTS

/************************************************************************/
/* V p p O n                                                                */
/*                                                                        */
/* Turns on Vpp (12 Volts. Vpp must be known to be good on exit.)        */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/* Returns:                                                                */
/*        FLStatus        : 0 on success, failed otherwise                */
/************************************************************************/

static FLStatus VppOn(FLSocket * pVol)
{
  return flOK;
}

/************************************************************************/
/* V p p O f f                                                                */
/*                                                                        */
/* Turns off Vpp.                                                        */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/************************************************************************/

static void VppOff(FLSocket * pVol)
{
}

#endif        /* SOCKET_12_VOLTS */

/************************************************************************/
/* i n i t S o c k e t                                                        */
/*                                                                        */
/* Perform all necessary initializations of the socket or controller        */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/* Returns:                                                                */
/*        FLStatus                : 0 on success, failed otherwise        */
/************************************************************************/

static FLStatus initSocket(FLSocket * pVol)
{
  return flOK;
}


/************************************************************************/
/* s e t W i n d o w                                                        */
/*                                                                        */
/* Sets in hardware all current window parameters: Base address, size,        */
/* speed and bus width.                                                 */
/* The requested settings are given in the 'vol.window' structure.      */
/*                                                                        */
/* If it is not possible to set the window size requested in                */
/* 'vol.window.size', the window size should be set to a larger value,  */
/* if possible. In any case, 'vol.window.size' should contain the       */
/* actual window size (in 4 KB units) on exit.                                */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/************************************************************************/

static void setWindow(FLSocket * pVol)
{
}


/************************************************************************/
/* s e t M a p p i n g C o n t e x t                                        */
/*                                                                        */
/* Sets the window mapping register to a card address.                        */
/*                                                                        */
/* The window should be set to the value of 'vol.window.currentPage',        */
/* which is the card address divided by 4 KB. An address over 128KB,        */
/* (page over 32K) specifies an attribute-space address.                */
/*                                                                        */
/* The page to map is guaranteed to be on a full window-size boundary.        */
/*                                                                        */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                        */
/*        page                : page to map                                        */
/*                                                                      */
/************************************************************************/

static void setMappingContext(FLSocket * pVol, unsigned page)
{
}


/************************************************************************/
/* g e t A n d C l e a r C a r d C h a n g e I n d i c a t o r                */
/*                                                                        */
/* Returns the hardware card-change indicator and clears it if set.        */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/* Returns:                                                                */
/*        0 = Card not changed, other = card changed                        */
/************************************************************************/

static FLBoolean getAndClearCardChangeIndicator(FLSocket * pVol)
{
  /* Note: On the 365, the indicator is turned off by the act of reading */
  return FALSE;
}



/************************************************************************/
/* w r i t e P r o t e c t e d                                                */
/*                                                                        */
/* Returns the write-protect state of the media                         */
/*                                                                        */
/* Parameters:                                                                */
/*        vol                : Pointer identifying drive                        */
/*                                                                        */
/* Returns:                                                                */
/*        0 = not write-protected, other = write-protected                */
/************************************************************************/

static FLBoolean writeProtected(FLSocket * pVol)
{
  return FALSE;
}

#ifdef EXIT

/************************************************************************/
/* f r e e S o c k e t                                                        */
/*                                                                        */
/* Free resources that were allocated for this socket.                        */
/* This function is called when TrueFFS exits.                                */
/*                                                                        */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                        */
/*                                                                      */
/************************************************************************/

static void freeSocket(FLSocket * pVol)
{
   freePointer(pVol->window.base,pVol->window.size);
}

#endif  /* EXIT */

void docSocketInit(FLSocket * pVol)
{
    pVol->cardDetected = cardDetected;
    pVol->VccOn        = VccOn;
    pVol->VccOff       = VccOff;
#ifdef SOCKET_12_VOLTS
    pVol->VppOn        = VppOn;
    pVol->VppOff       = VppOff;
#endif
    pVol->initSocket   = initSocket;
    pVol->setWindow    = setWindow;
    pVol->setMappingContext  = setMappingContext;
    pVol->getAndClearCardChangeIndicator = getAndClearCardChangeIndicator;
    pVol->writeProtected     = writeProtected;
    pVol->updateSocketParams = NULL /* updateSocketParameters */;
#ifdef EXIT
    pVol->freeSocket = freeSocket;
#endif
}

⌨️ 快捷键说明

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