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

📄 defs.c

📁 H3 M-system NAND flash driver in Linux OS, M-DOC driver
💻 C
字号:
/****************************************************************************** *                                                                            * * Project: DOC Driver for Linux 2.4 Block device driver for mDOC H3  family  * * of devices under Linux kernel 2.4.                                         * *                                                                            * *   Version: 1.0                                                             * *   Email questions to: oemsupport@sandisk.com                               * *   Copyright (C) SanDisk IL Ltd. 1995 - 2007                                * *   SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel             * *                                                                            * ****************************************************************************** *                                                                            * * This program is free software; you can redistribute it and/or modify it    * * under the terms of the GNU General Public License as published by the Free * * Software Foundation; either version 2 of the License, or any later version.* * This program is distributed in the hope that it will be useful, but WITHOUT* * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      * * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  * * more details, which is set forth in the readme.txt file.                   * * You should have received a copy of the GNU General Public License along    * * with this program; if not, write to the Free Software Foundation, Inc., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                    * *                                                                            * * This License does not grant you any right to use the trademarks, service   * * marks or logos of SanDisk IL Ltd. or SanDisk Corporation.                  * * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its * * licensors, hereby reserves all intellectual property rights in the program,* * except for the rights expressly granted in this License.                   * *                                                                            * ******************************************************************************//*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/DocDriver/TrueFFS BD/src/defs.c-arc  $
 * 
 *    Rev 1.7   Oct 29 2006 11:27:26   Yaniv.Iarovici
 * Removed unusable variable - 'readBackBuffer'.
 * 
 *    Rev 1.6   Oct 29 2006 10:59:40   Yaniv.Iarovici
 * Removed unused variable - 'volBuffers'.
 * 
 *    Rev 1.5   Oct 09 2006 14:05:12   yaniv.iarovici
 * Removed legacy devices related code and definitions
 * 
 *    Rev 1.4   Oct 05 2006 11:00:18   yaniv.iarovici
 * Fixed compilation warnings.
 * 
 *    Rev 1.3   Sep 13 2006 10:43:00   yaniv.iarovici
 * Fix compilation warnings
 * 
 *    Rev 1.2   Sep 11 2006 13:45:12   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.1   Aug 22 2006 13:22:20   Yaniv.Iarovici
 * Remove decleration fo 'void flInitGlobalVars(void)'
 * 
 *    Rev 1.0   Aug 08 2006 15:47:24   Polina.Marimont
 * Initial revision.
 */


#include "flcustom.h"
#include "flchkdef.h"
#include "flsystyp.h"
#include "blockdev.h"
#include "bddefs.h"

#ifdef __cplusplus
extern "C" {
#endif

/*============================================================================*/
/*==== from blockdev.c */
/********************* Global variables Start **************************/

Volume    vols[FL_VOLUMES];
static    FLBoolean initDone = FALSE;           /* Initialization not done yet   */
static    FLBoolean initGlobalVarsDone = FALSE; /* Initialization of environment */
                                                /* and access type variables not */
                                                /* done yet.                     */
unsigned  noOfDrives;
/* 
 * bus configuration
 * DiskOnChip minimal bus width
 */
#ifndef FL_NO_USE_FUNC
FLDword flBusConfig[FL_SOCKETS];
#endif /* FL_NO_USE_FUNC */
/*----------------------------------------------------------------------*/
/*                          f l I n i t                                 */
/*                                                                      */
/* Initializes the FLite system, sockets and timers.                    */
/*                                                                      */
/* Calling this function is optional. If it is not called,              */
/* initialization will be done automatically .                          */
/* This function is provided for those applications who want to         */
/* explicitly initialize the system and get an initialization status.   */
/*                                                                      */
/* Calling flInit after initialization was done has no effect.          */
/*                                                                      */
/* Parameters:                                                          */
/*      None                                                            */
/*                                                                      */
/* Returns:                                                             */
/*      FLStatus        : 0 on success, otherwise failed                */
/*----------------------------------------------------------------------*/

FLStatus _flInit(void)
{
    unsigned volNo;
    Volume * pVol = vols;

	if (initDone) 
		return flOK;


	flInitGlobalVars();

#ifdef FL_ENVIRONMENT_VARS

	/* Call users initialization routine
	*/
	flSetEnvVar();

#endif /* FL_ENVIRONMENT_VARS */

   /*
    * 1) Mark all the volumes as not used and free to be allocated.
    * 2) Clear password in order to make it invalid.
    */
   
    tffsset(vols,0,sizeof(vols));

    for (volNo = 0,pVol = vols; volNo < FL_VOLUMES; volNo++,pVol++)
    {       
      /* The actual number of sockets is not yet known and will be retrieved by
       * flRegisterComponents routine by the socket components. For now supply
       * each of the possible sockets with its buffer and socket number.
       */
       if ( volNo < FL_SOCKETS)
       {
          pVol->socket = flSocketOf(volNo);
          pVol->flash  = flFlashOf((FLByte)volNo);
          tffsset(pVol->socket,0,sizeof(FLSocket));          
          pVol->socket->volNo = volNo;         
       }
       else
       {
           pVol->flash = NULL;
       }
       pVol->volExecInProgress = NULL;
    }


#ifdef FL_BACKGROUND
    flCreateBackground();
#endif
    noOfDrives  = 0;
    noOfSockets = 0;
	return flOK;
}/*_flInit*/


/*----------------------------------------------------------------------*/
/*                     f l I n i t G l o b a l V a r s                  */
/*                                                                      */
/* Initializes the FLite system, environment and access type variables. */
/*                                                                      */
/* Parameters:                                                          */
/*      None                                                            */
/*                                                                      */
/* Returns:                                                             */
/*      None                                                            */
/*----------------------------------------------------------------------*/

void flInitGlobalVars(void)
{
   FLFlash * flash;
   int i,j;

   if(initGlobalVarsDone == TRUE)
     return;

   /* Do not initialize variables on next call */
   initGlobalVarsDone     = TRUE;
   initDone               = FALSE;

   /*
    * Set default values to per socket/volume variables
    */

   for(i=0; i< FL_SOCKETS; i++)
   {
      flash = flFlashOf((FLByte)i);
      /* tffsset is not yet initialized */
      for(j=0;j<(int)sizeof(FLFlash);j++)
      {
         ((FLByte  *)flash)[j] = 0;
      }  
#ifndef FL_NO_USE_FUNC
      flBusConfig[i] = FL_DEFAULT_BUS_MODE(i);
#endif /* FL_NO_USE_FUNC */

  }
}/*flInitGlobalVars*/

/*============================================================================*/

/*============================================================================*/
/*==== from flflash.c */
static FLFlash flashes[FL_SOCKETS];


/************************************************************************/
/************************************************************************/
/***                                                                  ***/
/***                E X P O R T E D    R O U T I N E S                ***/
/***                                                                  ***/
/************************************************************************/
/************************************************************************/

/*----------------------------------------------------------------------*/
/*                           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 &flashes[volNo];
}

/*============================================================================*/
#ifdef __cplusplus
}
#endif



/*============================================================================*/
/*=== from bdstub.c */
#include "dochstub.h"
/*----------------------------------------------------------------------*/
/* Function name	: lockForIO*/
/* Description	    : */
/* Return type		: FLStatus */
/* Argument         : FLByte socket*/
/* Argument         : FLByte partition*/
/* Argument         : FLBoolean onOff*/
/*----------------------------------------------------------------------*/
FLStatus lockForIO(FLByte socket, FLByte partition, FLBoolean onOff)  
{
    
#if (FS_SOCKETS < FL_SOCKETS) || (FS_MAX_TL_PARTITIONS < FL_MAX_TL_PARTITIONS)
    /* then caller's check is not good enough */
    if ((socket >= FL_SOCKETS) || (partition >= FL_MAX_TL_PARTITIONS)) 
        return flBadDriveHandle;
#endif

    checkStatus(dochSetBusy(socket, onOff, partition)); /* take DOCH mutex */
    return flOK;
}/*lockForIO()*/
/*============================================================================*/


/*============================================================================*/
/*=== from flsocket.c */
FLByte noOfSockets;        /* No. of drives actually registered */

static FLSocket sockets[FL_SOCKETS];


/*----------------------------------------------------------------------*/
/*                        f l S o c k e t O f                           */
/*                                                                      */
/* Gets the socket connected to a volume no.                            */
/*                                                                      */
/* Parameters:                                                          */
/*        volNo                : Volume no. for which to get socket     */
/*                                                                      */
/* Returns:                                                             */
/*         socket of volume no.                                         */
/*----------------------------------------------------------------------*/

FLSocket *flSocketOf(unsigned volNo)
{
  return &sockets[volNo];
}

/*----------------------------------------------------------------------*/
/*                       u d a t e S o c k e t P a r a m e t e r s      */
/*                                                                      */
/* Pass socket parameters to the socket interface layer.                */
/* This function should be called after the socket parameters (like     */
/* size and base) are known. If these parameters are known at           */
/* registration time then there is no need to use this function, and    */
/* the parameters can be passed to the registration routine.            */
/* The structure passed in irData is specific for each socket interface.*/
/*                                                                      */
/* Note : When using DiskOnChip this routine returns the socekt         */
/*        parameters instead of initializing them.                      */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*  params  : Record returning (or sending) the flsocket record         */
/*                                                                      */
/* Returns:                                                             */
/*        FLStatus         : 0 on success                               */
/*----------------------------------------------------------------------*/
FLStatus updateSocketParameters(FLSocket * pVol, void FAR1 *params)
{
  if (pVol->updateSocketParams)
    pVol->updateSocketParams(pVol, params);

  return flOK;
}

/*============================================================================*/

/*end of file*/



⌨️ 快捷键说明

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