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

📄 defs.c

📁 电子盘DEMO板程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************/
/*                                                                            */
/*  Copyright (C), 1995-2006, msystems Ltd. All rights reserved.              */
/*                                                                            */
/*  Redistribution and use in source and binary forms, with or without        */
/*  modification, are permitted provided that the following conditions are    */
/*  met:                                                                      */
/*  1. Redistributions of source code must retain the above copyright notice, */
/*     this list of conditions and the following disclaimer.                  */
/*  2. Redistributions in binary form must reproduce the above copyright      */
/*     notice, this list of conditions and the following disclaimer in the    */
/*     documentation and/or other materials provided with the distribution.   */
/*  3. Neither the name of msystems nor the names of its contributors may be  */
/*     used to endorse or promote products derived from this software without */
/*     specific prior written permission.                                     */
/*                                                                            */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR             */
/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      */
/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     */
/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  */
/*  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/*  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      */
/*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
/*                                                                            */
/******************************************************************************/
/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/DocDriver/TrueFFS BD/src/defs.c-arc  $
 * 
 *    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];
FLByte    flHandleConversionTable[FL_SOCKETS][FL_MAX_TL_PARTITIONS];
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 for :
	*  flUse8Bit,flUseNFTLCache
	*/
	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];
}


/*----------------------------------------------------------------------*/
/*                  f l I d e n t i f y F l a s h                       */

⌨️ 快捷键说明

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