www.pudn.com > efs.rar > fs_device.h
#ifndef __FS_DEVICE_H__
#define __FS_DEVICE_H__
/**********************************************************************
* fs_device.h
*
* File System Device interface.
*
* This module implements a device-independent view of the low-level file
* system devices. This interface hides all of the implementation details
* and device differences between the diverse device types.
*
* Copyright (C) 2002, 2004, 2004, 2005, 2006, Qualcomm, Inc.
*
**********************************************************************/
/*===========================================================================
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_device.h#8 $ $DateTime: 2006/11/13 09:22:31 $ $Author: davidb $
when who what, where, why
-------- --- ----------------------------------------------------------
2006-11-09 dlb Add dealloc counter.
2006-09-20 dlb Lint fixes.
2006-09-12 dlb Change some queries to unsigned values.
2006-09-11 dlb Add wrappers for all flash functions.
2006-06-26 yg Memory reduction effort
2006-01-27 dlb Add wrappers for write styles on old drivers.
2005-10-21 dlb Mark unsigned constants as such.
2004-10-15 dlb Update copyright line.
2004-04-26 drh Remove support for old non-uniform flash drivers
2004-02-20 drh Add support for Uniform Flash Drivers
2003-06-15 gr Added a function pointer for mark_block_bad.
2003-04-04 bgc Added FS_DEVICE_BUSY and function pointers for
begin_erase, suspend, resume, and erase_status.
2002-09-05 gr Changed signature of is_erased to accept a page id rather
than a block id.
2002-08-19 drh Added is_erased to fs_device_data structure
2002-08-08 drh Added total_page_size to fs_device_data structure
2002-06-13 dlb Created
===========================================================================*/
#include "comdef.h"
#include "customer.h"
#include "flash.h"
#ifdef FEATURE_EFS_PROBE_NAND
#define FEATURE_EFS_EFS2_ON_NAND
#else
#define FEATURE_EFS_EFS2_ON_NOR
#endif
#ifdef FS_UNIT_TEST
#error code not present
#endif
#define INVALID_PAGE_ID 0xFFFFFFFFU
#define INVALID_BLOCK_ID 0xFFFFFFFFU
#define INVALID_CLUSTER_ID 0xFFFFFFFFU
/* Encapsulate the get_write_style feature and types, so that the code will
* continue to work with older drivers. We assume that all older drivers
* (for NOR) are simple devices. The driver will define
* HAVE_FLASH_WRITE_STYLE to indicate that the query is present, and this
* driver might support other write styles. */
#ifdef HAVE_FLASH_WRITE_STYLE
#define FS_GET_WRITE_STYLE(dev) \
((dev)->get_write_style (dev))
#else /* not HAVE_FLASH_WRITE_STYLE */
/* Enough of the types to allow things to build. */
typedef word fs_device_write_style_t;
/* And the definitions used in this file. The only value that must match
* is FS_DEVICE_WRITES_SIMPLE, because that is the one returned by the
* constant "query". The others are defined to vary different values to
* make it clear if they ever show up. */
#define FS_DEVICE_WRITES_SIMPLE 0
#define FS_DEVICE_WRITES_PAIRED_BITS 0x18ea928b
#define FS_GET_WRITE_STYLE(dev) FS_DEVICE_WRITES_SIMPLE
#endif /* not HAVE_FLASH_WRITE_STYLE */
#ifdef FEATURE_FS_BENCHMARK
#include "fs_benchmark.h"
#endif
/* TODO: These are simple thin wrappers. Eventually, we want to capture
* which calls are allowed to fail, and die with a more meaningful message
* if the others fail. */
/* Types of flash categorizations. */
enum fs_flashop_category {
FS_FOP_SUPER,
FS_FOP_USER,
FS_FOP_LOG,
FS_FOP_DATA_GC_MOVE,
FS_FOP_DATA_GC_RECOVERY,
FS_FOP_USER_RECOVERY,
FS_FOP_PTABLE_GC_MOVE,
FS_FOP_PTABLE,
FS_FOP_FACTORY_RECOVERY,
FS_FOP_UNKNOWN,
NUM_FS_FLASHOP_CATEGORIES,
};
/* Types of buffer operations. */
enum fs_bufop_category {
FS_BOP_DB,
FS_BOP_FS,
FS_BOP_ALLOC_TREE,
FS_BOP_ALLOC_MAP,
FS_BOP_UNKNOWN,
NUM_FS_BUFOP_CATEGORIES,
};
int fs_flash_write_page (fs_device_t dev, page_id page, void *data,
enum fs_flashop_category category);
int fs_flash_erase_block (fs_device_t dev, block_id block,
enum fs_flashop_category category);
int fs_flash_read_page (fs_device_t dev, page_id page, void *data,
enum fs_flashop_category category);
void fs_flash_buffer_fill (enum fs_bufop_category category);
uint32 fs_flash_block_size (fs_device_t dev);
uint32 fs_flash_page_size (fs_device_t dev);
uint32 fs_flash_block_count (fs_device_t dev);
int fs_flash_bad_block_check (fs_device_t dev, block_id block);
int fs_flash_is_erased (fs_device_t dev, page_id page);
int fs_flash_mark_block_bad (fs_device_t dev, block_id block);
int fs_flash_resume_erase (fs_device_t dev);
int fs_flash_erase_status (fs_device_t dev);
int fs_flash_suspend_erase (fs_device_t dev);
int fs_flash_begin_erase_block (fs_device_t dev, block_id block);
int fs_flash_partial_write (fs_device_t dev, page_id page,
void *data, int offset, int length);
void *fs_flash_read_pointer (fs_device_t dev, page_id page);
/* Accessing the counters. */
#ifdef FEATURE_FS_BENCHMARK
#define fs_flash_write_page_counter fs_counter.flash_write_page_counter
#define fs_flash_read_page_counter fs_counter.flash_read_page_counter
#define fs_flash_erase_block_counter fs_counter.flash_erase_block_counter
#else
extern uint32 fs_flash_write_page_counter;
extern uint32 fs_flash_read_page_counter;
extern uint32 fs_flash_erase_block_counter;
#endif
extern uint32 fs_flash_pcache_miss_counter;
extern uint32 fs_flash_pcache_hit_counter;
extern uint32 fs_flash_buffer_miss_counter;
extern uint32 fs_flash_buffer_hit_counter;
extern uint32 fs_flash_dealloc_counter;
#ifdef FS_UNIT_TEST
#error code not present
#endif
/* How many statistics do we keep? */
unsigned fs_flash_number_stats (void);
/* Return the current statistics in slot
* (0 <= slot < fs_flash_number_stats()) */
struct stat_result fs_flash_get_stat (unsigned slot);
#endif /* __FS_DEVICE_H__ */