www.pudn.com > efs.rar > fs_ftl.h


#ifndef __FTL_H__
#define __FTL_H__
/******************************************************************************
 * fs_ftl.h
 *
 * This file declares the interface for the NAND Flash Translation Layer to
 *   present the NAND flash as logical sectors.
 *
 * Copyright (C) 2006 Qualcomm, Inc.  All Rights Reserved
 *
 *****************************************************************************/

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

                        EDIT HISTORY FOR MODULE

  This section contains comments describing changes made to the module.
  Notice that changes are listed in reverse chronological order.

  $Header: //depot/asic/MSMSHARED/services/efs/MSM_EFS.01.02/fs_ftl.h#3 $
  $DateTime: 2006/09/05 15:33:55 $
  $Author: davidb $

when         who     what, where, why
--------     ---     ----------------------------------------------------------
2006-09-01   yg      Fixed compilation issue for non FTL enabled builds.
2006-08-28   yg      Changed function name for 2K page dev & cache support.
2006-05-28   sh      Cosmetic changes
2006-05-21   yg      Cleanup
2006-04-10   yg      Initial file for FTL layer
=============================================================================*/

#include "comdef.h"
#include "flash_nand.h"

#ifdef FEATURE_EFS_FTL

/* Set these values to what the maximum size the software has to support */
#define MAX_BLOCK_COUNT          4096
#define MAX_DATA_PAGE_SIZE       2048
#define SPARE_AREA_SIZE            16

/* Return codes for FTL module */
#define FTL_SUCCESS                     0
#define FTL_FAILURE                   (-1)

/* This structure defines the interface that need to be used while flushing
 * cached pages, where the pages might not be contiguous, so FTL can really
 * look through the list to check if any page is available in the cache.
 * The list should be sorted by sector_num since a moving pointer will be
 * used for checking, so no real search is performed.
 */
typedef struct
{
  uint32    sector_num;
  byte*     data_ptr;
}
cached_buffer_list_type;

/* Check if we have the needed flash driver support included */
#if !defined(HAVE_FLASH_COPY_PAGE) || !defined(HAVE_FLASH_RW_SPARE_UDATA_BYTES)
#error Required updated flash driver features are missing...
#endif

/******************************************************************************
FUNCTION      ftl_raw_init

DESCRIPTION   Initialize the FTL layer

RETURN VALUE
              0 : Success
     Error code : Failure
******************************************************************************/
int ftl_raw_init (void);

/******************************************************************************
FUNCTION      ftl_raw_read

DESCRIPTION   Read specified number of sectors from mentioned sector onwards.

PARAMETERS
          drive_num : Currently not used by the FTL layer.
          sector    : Starting Sector number to read from (page number in flash
                        terminology).
          buffer    : buffer where read data has to be placed.
          count     : Number of sectors to read starting from mentioned sector.

RETURN VALUE
              0 : Success
     Error code : Failure
******************************************************************************/
int ftl_raw_read (uint16 drive_num, uint32 sector, byte* buffer, uint16 count);

/******************************************************************************
FUNCTION      ftl_raw_write

DESCRIPTION   Write multiple logical sectors starting from the specified one.

PARAMETERS
          drive_num : Currently not used by the FTL layer.
          sector    : Starting Sector number to write to (page number in flash
                        terminology).
          buffer    : buffer where new data to be written is passed.
          count     : Number of sectors to wrote starting from mentioned sector

RETURN VALUE  Success / Failure
******************************************************************************/
int ftl_raw_write (uint16 drive_num, uint32 sector,
                   cached_buffer_list_type* buffer, uint16 count);

/******************************************************************************
FUNCTION      ftl_get_raw_dev_params

DESCRIPTION   Get physical flash device parameters.

RETURN VALUE  0
******************************************************************************/
int ftl_get_raw_dev_params (uint32 * pblock_count, uint32 * ppg_per_block,
                           uint16 * pg_size, uint32 *psector_cnt);

#endif /* FEATURE_EFS_FTL */
#endif /* __FTL_H__ */