www.pudn.com > efs.rar > fs_ftl_cache_i.h
#ifndef __FTL_CACHE_I_H__
#define __FTL_CACHE_I_H__
/******************************************************************************
* fs_ftl_cache_i.h
*
* This file declares the internal data and functions used by the FTL cache.
*
* 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_cache_i.h#4 $
$DateTime: 2006/10/10 12:20:07 $
$Author: davidb $
when who what, where, why
-------- --- ----------------------------------------------------------
2006-09-28 yg Changed age field to uint32.
2006-09-16 yg Fixed compilation issue for non FTL enabled builds.
2006-08-31 dlb Fix RCS header.
2006-07-21 yg Initial file for FTL cache layer
=============================================================================*/
/*
* SECTOR : Is a 512 byte page unit.
* Page : Is the smallest writable unit of the flash device (can be 2k).
*
*/
#include "fs_ftl_cache.h"
#include "fs_ftl_i.h"
#ifdef FEATURE_EFS_FTL
/* This is in order to support 2k page device */
#define MAX_SECTORS_PER_DEV_PAGE 4
/* 2k page device has 64 pages per block */
#define MAX_DEV_PAGES_PER_BLOCK 64
#define MAX_SECTORS_PER_BLOCK (MAX_DEV_PAGES_PER_BLOCK \
* MAX_SECTORS_PER_DEV_PAGE)
/* This could be something const or relative size of the total cache size */
#define MAX_ADDITIONAL_SECTOR_CACHE_COUNT 32
#define FTL_CACHE_PAGE_COUNT (MAX_ADDITIONAL_SECTOR_CACHE_COUNT \
+ MAX_SECTORS_PER_BLOCK)
#define MAX_CACHE_BLOCKS 4
#define INVALID_BLOCK 0xFFFF
/* How many maximum buffers FTL can handle. Since count is not passed
* and the length is determined by the invalid identifier, we need
* atlest 1 more than what FTL can really handle */
#define MAX_FTL_BUFFER_LIST (256 + 1)
typedef struct __cached_page_type
{
struct __cached_page_type * next;
uint32 sector_num;
uint8 dirty;
uint8 attrib;
uint16 dummy;
uint8 buffer [DEFAULT_MS_PAGE_SIZE];
}
cached_page_type;
typedef struct
{
uint16 block_number;
uint16 sector_count;
uint32 dirty;
uint32 age;
cached_page_type * cached_pages;
}
block_cache_type;
#define INVALID_CACHE_PAGE ((cached_page_type *)0)
#define INVALID_BLOCK_CACHE ((block_cache_type *)0)
#define CACHED_PAGE_IS_VALID(x) ((x) != INVALID_CACHE_PAGE)
#define CACHED_PAGE_IS_NOT_VALID(x) ((x) == INVALID_CACHE_PAGE)
#define BLOCK_CACHE_IS_VALID(x) ((x) != INVALID_BLOCK_CACHE)
#define BLOCK_CACHE_IS_NOT_VALID(x) ((x) == INVALID_BLOCK_CACHE)
/******************************************************************************
*
* Local private function prototypes
*
******************************************************************************/
static
cached_page_type * lookup_sector_in_cache (uint32 sector);
static
block_cache_type * lookup_block_in_cache (uint32 block);
static
cached_page_type * lookup_sector_in_cache_list (uint32 sector,
cached_page_type * cache_list);
static
cached_page_type * get_free_cache_page (void);
static
cached_page_type * insert_page_into_list (cached_page_type * src_page_list,
cached_page_type * dest_page_list);
static
block_cache_type * alloc_cached_block (void);
static
int flush_block_cache (block_cache_type * blk_cache);
static
int add_page_to_cache (cached_page_type * new_cached_page);
static
uint32 cache_sync_oldest_block (void);
static
boolean compare_less_than (uint32 x, uint32 y);
#endif /* FEATURE_EFS_FTL */
#endif /* __FTL_CACHE_I_H_ */