flflash.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:9k
源码类别:

VxWorks

开发平台:

C/C++

  1. /*
  2.  * $Log:   P:/user/amir/lite/vcs/flflash.h_v  $
  3.    
  4.       Rev 1.10   03 Nov 1997 16:12:52   danig
  5.    amdCmdRoutine receives FlashPTR
  6.    
  7.       Rev 1.9   28 Jul 1997 14:46:20   danig
  8.    setPowerOnCallback
  9.    
  10.       Rev 1.8   24 Jul 1997 17:55:08   amirban
  11.    FAR to FAR0
  12.    
  13.       Rev 1.7   21 Jul 1997 14:45:26   danig
  14.    No parallelLimit
  15.    
  16.       Rev 1.6   07 Jul 1997 15:23:44   amirban
  17.    Ver 2.0
  18.    
  19.       Rev 1.5   08 Jun 1997 19:19:10   danig
  20.    BIG_PAGE & FULL_PAGE
  21.    
  22.       Rev 1.4   18 May 1997 17:34:14   amirban
  23.    Defined write mode flags
  24.    
  25.       Rev 1.3   18 Aug 1996 13:47:46   amirban
  26.    Comments
  27.    
  28.       Rev 1.2   31 Jul 1996 14:29:34   amirban
  29.    New flash.erase definition
  30.    
  31.       Rev 1.1   04 Jul 1996 18:19:52   amirban
  32.    New flag field
  33.    
  34.       Rev 1.0   20 Mar 1996 13:33:20   amirban
  35.    Initial revision.
  36.  */
  37. /************************************************************************/
  38. /*                                                                      */
  39. /* FAT-FTL Lite Software Development Kit */
  40. /* Copyright (C) M-Systems Ltd. 1995-1996 */
  41. /* */
  42. /************************************************************************/
  43. #ifndef FLFLASH_H
  44. #define FLFLASH_H
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. #include "flsocket.h"
  49. /* Some useful types for mapped Flash locations */
  50. typedef volatile unsigned char FAR0 * FlashPTR;
  51. typedef volatile unsigned short int FAR0 * FlashWPTR;
  52. typedef volatile unsigned long FAR0 * FlashDPTR;
  53. typedef unsigned short FlashType; /* JEDEC id */
  54. #define NOT_FLASH 0
  55. /* page characteristics flags */
  56. #define  BIG_PAGE    0x0100             /* page size > 100H*/
  57. #define  FULL_PAGE  0x0200           /* no partial page programming*/
  58. /* MTD write routine mode flags */
  59. #define OVERWRITE 1 /* Overwriting non-erased area  */
  60. #define EDC 2 /* Activate ECC/EDC */
  61. #define EXTRA 4 /* Read/write spare area */
  62. /*----------------------------------------------------------------------*/
  63. /*          Flash array identification structure */
  64. /* */
  65. /* This structure contains a description of the Flash array and */
  66. /* routine pointers for the map, read, write & erase functions. */
  67. /*  */
  68. /* The structure is initialized by the MTD that identifies the Flash */
  69. /* array.                                                               */
  70. /* On entry to an MTD, the Flash structure contains default routines */
  71. /* for all operations. This routines are sufficient forread-only access */
  72. /* to NOR Flash on a memory-mapped socket. The MTD should override the */
  73. /* default routines with MTD specific ones when appropriate. */
  74. /*----------------------------------------------------------------------*/
  75. /* Flash array identification structure */
  76. typedef struct tFlash FLFlash; /* Forward definition */
  77. struct tFlash {
  78.   FlashType type; /* Flash device type (JEDEC id) */
  79.   long int erasableBlockSize; /* Smallest physically erasable size
  80.    (with interleaving taken in account) */
  81.   long int chipSize; /* chip size */
  82.   int noOfChips; /* no of chips in array */
  83.   int interleaving; /* chip interleaving
  84.    (The interleaving is defined as
  85.    the address difference between
  86.    two consecutive bytes on a chip) */
  87.   unsigned flags; /* Special capabilities & options
  88.    Bits 0-7 may be used by FLite.
  89.    Bits 8-15 are not used bt FLite
  90.    and may be used by MTD's for MTD-
  91.    specific purposes. */
  92.   void * mtdVars; /* Points to MTD private area for
  93.    this socket.
  94.    This field, if used by the MTD, is
  95.    initialized by the MTD identification
  96.    routine */
  97.   FLSocket * socket; /* Socket of this drive */
  98. /* Flag bit values */
  99. #define SUSPEND_FOR_WRITE 1 /* MTD provides suspend for write */
  100. #define NFTL_ENABLED 2 /* Flash can run NFTL */
  101. /*----------------------------------------------------------------------*/
  102. /*                 f l a s h . m a p */
  103. /* */
  104. /* MTD specific map routine */
  105. /*                                                                      */
  106. /* The default routine maps by socket mapping, and is suitable for all  */
  107. /* NOR Flash.                                                           */
  108. /* NAND or other type Flash should use map-through-copy emulation: Read */
  109. /* a block of Flash to an internal buffer and return a pointer to that */
  110. /* buffer. */
  111. /* */
  112. /* Parameters:                                                          */
  113. /* vol : Pointer identifying drive */
  114. /*      address : Card address to map */
  115. /* length : Length to map */
  116. /*                                                                      */
  117. /* Returns:                                                             */
  118. /* Pointer to required card address */
  119. /*----------------------------------------------------------------------*/
  120.   void FAR0 * (*map)(FLFlash *, CardAddress, int);
  121. /*----------------------------------------------------------------------*/
  122. /*                 f l a s h . r e a d */
  123. /* */
  124. /* MTD specific Flash read routine */
  125. /* */
  126. /* The default routine reads by copying from a mapped window, and is */
  127. /* suitable for all NOR Flash. */
  128. /* */
  129. /* Parameters:                                                          */
  130. /* vol : Pointer identifying drive */
  131. /*      address : Card address to read */
  132. /* buffer : Area to read into */
  133. /* length : Length to read */
  134. /*                                                                      */
  135. /*----------------------------------------------------------------------*/
  136.   FLStatus (*read)(FLFlash *, CardAddress, void FAR1 *, int, int);
  137. /*----------------------------------------------------------------------*/
  138. /*                       f l a s h . w r i t e */
  139. /* */
  140. /* MTD specific Flash write routine */
  141. /* */
  142. /* The default routine returns a write-protect error. */
  143. /* */
  144. /* Parameters:                                                          */
  145. /* vol : Pointer identifying drive */
  146. /*      address : Card address to write to */
  147. /*      buffer : Address of data to write */
  148. /* length : Number of bytes to write */
  149. /* modes : See write mode flags definition above */
  150. /*                                                                      */
  151. /* Returns:                                                             */
  152. /* FLStatus : 0 on success, failed otherwise */
  153. /*----------------------------------------------------------------------*/
  154.   FLStatus  (*write)(FLFlash *, CardAddress, const void FAR1 *, int, int);
  155. /*----------------------------------------------------------------------*/
  156. /*                       f l a s h . e r a s e */
  157. /* */
  158. /* Erase one or more contiguous Flash erasable blocks */
  159. /* */
  160. /* The default routine returns a write-protect error. */
  161. /* */
  162. /* Parameters:                                                          */
  163. /* vol : Pointer identifying drive */
  164. /*      firstErasableBlock : Number of first block to erase */
  165. /* numOfErasableBlocks: Number of blocks to erase */
  166. /*                                                                      */
  167. /* Returns:                                                             */
  168. /* FLStatus : 0 on success, failed otherwise */
  169. /*----------------------------------------------------------------------*/
  170.   FLStatus  (*erase)(FLFlash *, int, int);
  171. /*----------------------------------------------------------------------*/
  172. /*        f l a s h . s e t P o w e r O n C a l l b a c k */
  173. /* */
  174. /* Register power on callback routine. Default: no routine is  */
  175. /* registered. */
  176. /* */
  177. /* Parameters:                                                          */
  178. /* vol : Pointer identifying drive */
  179. /*                                                                      */
  180. /*----------------------------------------------------------------------*/
  181.   void  (*setPowerOnCallback)(FLFlash *);
  182. };
  183. /* MTD registration information */
  184. extern int noOfMTDs; /* No. of MTDs actually registered */
  185. typedef FLStatus (*MTDidentifyRoutine) (FLFlash vol);
  186. extern MTDidentifyRoutine mtdTable[];
  187. /* See interface documentation of functions in flash.c */
  188. extern void flIntelIdentify(FLFlash *, 
  189.                             void (*)(FLFlash *, CardAddress, unsigned char, FlashPTR), 
  190.                             CardAddress);
  191. extern FLStatus flIntelSize(FLFlash *, 
  192.                             void (*)(FLFlash *, CardAddress, unsigned char, FlashPTR), 
  193.                             CardAddress);
  194. extern FLStatus flIdentifyFlash(FLSocket *socket, FLFlash *flash);
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif