Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
16 KiB

  1. /*
  2. * $Log: V:/Flite/archives/TrueFFS5/Src/DOCBDK.H_V $
  3. *
  4. * Rev 1.13 Apr 15 2002 07:35:48 oris
  5. * Moved bdkCall to blockdev.h
  6. * Added include for flreq.h and flfuncno.h when BDK_ACCESS is defined.
  7. *
  8. * Rev 1.12 Feb 19 2002 20:58:56 oris
  9. * Removed flflash.h include directive.
  10. * Moved bdkCall prototype to blockdev.
  11. *
  12. * Rev 1.11 Nov 08 2001 10:45:10 oris
  13. * Moved BDK module ifdef statement in order to allow the use of basic definitions.
  14. *
  15. * Rev 1.10 Oct 18 2001 22:17:12 oris
  16. * Added number of blocks per floor in the bdkVol structure.
  17. *
  18. * Rev 1.9 Oct 10 2001 19:48:28 oris
  19. * More afficient way to store the Binary module internal structure (bdkVol).
  20. *
  21. * Rev 1.8 May 20 2001 14:35:00 oris
  22. * Removed mtdsa.h include file.
  23. *
  24. * Rev 1.7 May 17 2001 16:51:08 oris
  25. * Removed warnings.
  26. *
  27. * Rev 1.6 May 16 2001 21:17:12 oris
  28. * Added OTP routines declaration.
  29. * Removed redefinitions of SOCKETS and BINARY_PARTITIONS.
  30. * Changed variable types to TrueFFS standard types.
  31. * Added EXTRA_SIZE definition and removed SYNDROM_BYTES.
  32. *
  33. * Rev 1.5 May 09 2001 00:32:14 oris
  34. * Removed the DOC2000_FAMILY and DOCPLUS_FAMILY defintion and replaced it with NO_DOC2000_FAMILY_SUPPORT, NO_DOCPLUS_FAMILY_SUPPORT, NO_NFTL_SUPPORT and NO_INFTL_SUPPORT.
  35. * Added BINARY_PARTITIONS and SOCKETS defintions.
  36. *
  37. * Rev 1.4 Apr 30 2001 17:59:38 oris
  38. * Changed bdkSetBootPartitonNo, bdkGetProtectionType, bdkSetProtection prototypes
  39. *
  40. * Rev 1.3 Apr 16 2001 13:32:02 oris
  41. * Removed warrnings.
  42. *
  43. * Rev 1.2 Apr 09 2001 15:06:18 oris
  44. * End with an empty line.
  45. *
  46. * Rev 1.1 Apr 01 2001 07:50:38 oris
  47. * Updated copywrite notice.
  48. * Removed nested comments.
  49. * Changed #include "base2400.h" to "mdocplus.h"
  50. * Fix for Big endien compilation problems - changed LEmin to LEulong
  51. * Changed MULTIPLIER_OFFSET define.
  52. * Changed protectionType to word instead of unsigned.
  53. * Added extern prototype of bdkVol pointer.
  54. *
  55. * Rev 1.0 Feb 02 2001 13:24:56 oris
  56. * Initial revision.
  57. */
  58. /***************************************************************************/
  59. /* M-Systems Confidential */
  60. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
  61. /* All Rights Reserved */
  62. /***************************************************************************/
  63. /* NOTICE OF M-SYSTEMS OEM */
  64. /* SOFTWARE LICENSE AGREEMENT */
  65. /* */
  66. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  67. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  68. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
  69. /* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
  70. /* E-MAIL = [email protected] */
  71. /***************************************************************************/
  72. /************************************************************************/
  73. /* Caution: The BDK_ACCESS compilation flag is for M-SYSTEMS internal */
  74. /* use ONLY. This flag is used by M-SYSTEMS drivers and */
  75. /* therfore it is SHOULD NOT be used by this package */
  76. /************************************************************************/
  77. /*****************************************************************************
  78. * File Header *
  79. * ----------- *
  80. * Name : docbdk.h *
  81. * *
  82. * Description : This file contains the binary partition defintions , data *
  83. * structures and function prototypes. *
  84. * *
  85. * Note : The file exports 2 interfaces each under its own compilation flag: *
  86. * *
  87. * BDK package - Standalone package that exports routines for binary *
  88. * partitions handling(MTD_STANDALONE compilation flag). *
  89. * OSAK module - Separated module of the OSAK package that exports a *
  90. * common entry point to the same routines. (BDK_ACCESS *
  91. * compilation flag). *
  92. * *
  93. * Warning : Do not use this file with the BDK_ACCESS compilation flag unless *
  94. * you own the full OSAK package. *
  95. *****************************************************************************/
  96. #ifndef _DOC_BDK_H_
  97. #define _DOC_BDK_H_
  98. /*---------------------------------------------------------------------*/
  99. /* Include the proper header files. */
  100. /*---------------------------------------------------------------------*/
  101. #include "nanddefs.h" /* The MTD for the doc2000 and millennium DiskOnChips */
  102. #ifdef BDK_ACCESS
  103. #include "flfuncno.h"
  104. #include "flreq.h"
  105. #endif /* BDK_ACCESS */
  106. /*---------------------------------------------------------------------
  107. *
  108. * Binary Development Kit Stand Alone Customization Area
  109. *
  110. *---------------------------------------------------------------------*/
  111. /*---------------------------------------------------------------------*/
  112. /* Boundries of the memory location to look for the DiskOnChip */
  113. /*---------------------------------------------------------------------*/
  114. #define DOC_LOW_ADDRESS 0xC8000L
  115. #define DOC_HIGH_ADDRESS 0xE0000L
  116. /*----------------------- Mtd selection -------------------------------
  117. *
  118. * Uncomment the following uneeded MTD or TL to reduce code size.
  119. *
  120. *---------------------------------------------------------------------*/
  121. /* DiskOnChip2000, DiskOnChip Millennium and DiskOnChip 2000 Tsop devices */
  122. /* #define NO_DOC2000_FAMILY_SUPPORT */
  123. /* DiskOnChip Millennium plus device */
  124. /* #define NO_DOCPLUS_FAMILY_SUPPORT */
  125. /* NFTL format - DiskOnChip2000 and DiskOnChip Millennium */
  126. /* #define NO_NFTL_SUPPORT */
  127. /* INFTL format - DiskOnChip2000 Tsop and DiskOnChip Millennium Plus */
  128. /* #define NO_INFTL_SUPPORT */
  129. /*---------------------------------------------------------------------
  130. *
  131. * End of Binary Development Kit Stand Alone Customization Area
  132. *
  133. *---------------------------------------------------------------------*/
  134. /*---------------------------------------------------------------------*/
  135. /* general constant */
  136. /*---------------------------------------------------------------------*/
  137. #define MAX_BINARY_PARTITIONS_PER_DRIVE 3
  138. #define SIGNATURE_LEN 8
  139. #define BDK_SIGNATURE_NAME 4
  140. #define SIGNATURE_NUM 4
  141. #define MBYTE 0x100000L
  142. #define KBYTE 0x400
  143. #define BLOCK 0x200
  144. #define BDK_SIGN_OFFSET 8
  145. #define ANAND_LEN 5
  146. #define BDK_COMPLETE_IMAGE_UPDATE 16
  147. #define BDK_PARTIAL_IMAGE_UPDATE 0
  148. #define BDK_MIN(a,b) ((a) < (b) ? (a) : (b))
  149. #define MULTIPLIER_OFFSET 5
  150. #define BDK_INVALID_VOLUME_HANDLE 0xff
  151. #define BDK_HEADERS_SPACING (SECTOR_SIZE * 4)
  152. #define BDK_UNIT_BAD 0
  153. #define BDK_NO_OF_MEDIA_HEADERS 2
  154. #define BDK_FIELDS_BEFORE_HEADER 9 /* number of LEmin fieldsr to skip
  155. to reach the volume records */
  156. #define BDK_HEADER_FIELDS 35 /* number of LEmin fields used for
  157. volumes infromation record */
  158. #define BDK_BINARY_FLAG 0x20000000L /* flag representing a binary volume
  159. in the volume information record */
  160. /* BDK specific flag area */
  161. #define ERASE_BEFORE_WRITE 8
  162. #define EXTRA_SIZE 16
  163. /*---------------------------------------------------------------------*/
  164. /* The maximum number of binary partitions */
  165. /*---------------------------------------------------------------------*/
  166. #ifndef BINARY_PARTITIONS
  167. #define BINARY_PARTITIONS SOCKETS /* for backwards compatibility */
  168. #endif /* BINARY_PARITITON */
  169. /*-------------------------- BDK Global Status Values --------------------*/
  170. #define BDK_S_INIT 0 /* uninitialized binary partition record */
  171. #define BDK_S_DOC_FOUND 0x01 /* DiskOnChip device was found */
  172. #define BDK_S_HEADER_FOUND 0X04 /* Partition information was found */
  173. #define BDK_S_INFO_FOUND 0x08 /* Sub partition information was found */
  174. /*------------------------------------------------------------------------*/
  175. #if defined(BDK_ACCESS) || defined(MTD_STANDALONE)
  176. /*------------------------------------------------------------------------*/
  177. /* Global binary partition data structures */
  178. /*------------------------------------------------------------------------*/
  179. typedef struct {
  180. byte bdkGlobalStatus; /* BDK global status variable */
  181. byte bdkEDC; /* ECC mode flag */
  182. byte bdkSignOffset; /* BDK signature offset ( 0 or 8) */
  183. byte bdkSavedSignOffset; /* signature offset of last access */
  184. word bdkSavedStartUnit; /* starting unit of last access */
  185. word startPartitionBlock, endPartitionBlock; /* partition boundries */
  186. word startImageBlock, endImageBlock; /* sub partition boundries */
  187. word curReadImageBlock; /* current block number to read from */
  188. word blockPerFloor; /* Blocks per floor */
  189. byte signBuffer[SIGNATURE_LEN]; /* signature of binary sub partition */
  190. dword bootImageSize; /* available sub binary partition size */
  191. dword realBootImageSize; /* size used by an image on the sub partition */
  192. dword actualReadLen; /* length needed to be read */
  193. dword bdkDocWindow; /* DiskOnChip window start address */
  194. CardAddress curReadImageAddress; /* current address to read from */
  195. #ifdef UPDATE_BDK_IMAGE
  196. CardAddress curUpdateImageAddress; /* current address to write to */
  197. dword actualUpdateLen; /* length needed to be write */
  198. word curUpdateImageBlock; /* current block number to write to */
  199. byte updateImageFlag;/* BDK_COMPLETE_IMAGE_UPDATE \ ERASE_BEFORE_WRITE */
  200. #endif /* UPDATE_BDK_IMAGE */
  201. #ifdef PROTECT_BDK_IMAGE
  202. byte protectionArea; /* protection area no protecting the volume */
  203. word protectionType; /* PROTECTABLE , CHANGEABLE_PROTECTION */
  204. #endif /* PROTECT_BDK_IMAGE */
  205. byte erasableBlockBits; /* number of bits used to represen a block */
  206. FLFlash * flash; /* flash record representing the media */
  207. } BDKVol;
  208. /*------------------------------------------------------------------------*/
  209. /* Extern variables for low level operations. */
  210. /*------------------------------------------------------------------------*/
  211. extern BDKVol* bdkVol;
  212. /*------------------------------------------------------------------------*/
  213. /* OSAK Routines argument packet */
  214. /*------------------------------------------------------------------------*/
  215. #ifdef BDK_ACCESS
  216. typedef struct {
  217. byte oldSign[BDK_SIGNATURE_NAME];
  218. byte newSign[BDK_SIGNATURE_NAME];
  219. byte signOffset;
  220. dword startingBlock;
  221. dword length;
  222. byte flags;
  223. byte FAR1 *bdkBuffer;
  224. } BDKStruct;
  225. #endif /* BDK_ACCESS */
  226. /*------------------------------------------------------------------------*/
  227. /* Diffrent records used by the media header */
  228. /*------------------------------------------------------------------------*/
  229. typedef struct {
  230. LEulong virtualSize; /* Virtual size exported by the trasnaltion layer */
  231. LEulong firstUnit; /* First erasable block of the partition */
  232. LEulong lastUnit; /* Last erasable block of the partition */
  233. LEulong flags; /* PROTECTABLE , BDK_BINARY_FLAG */
  234. LEulong not_used1;
  235. LEulong not_used2;
  236. LEulong protectionArea; /* protection area no' */
  237. } VolumeRecord;
  238. /************************ Function Prototype Begin ************************/
  239. #ifdef MTD_STANDALONE
  240. /*************************/
  241. /* BDK specific routines */
  242. /*************************/
  243. void bdkExit (void);
  244. void bdkSetDocWindow (CardAddress docWindow);
  245. FLStatus bdkSetBootPartitionNo (byte partitionNo);
  246. FLStatus bdkFindDiskOnChip (CardAddress FAR2 *docAddress,
  247. dword FAR2 *docSize );
  248. FLStatus bdkCheckSignOffset (byte FAR2 *signature );
  249. FLStatus bdkCopyBootArea (byte FAR1 *startAddress,
  250. word startUnit,
  251. dword areaLen,
  252. byte FAR2 *checkSum,
  253. byte FAR2 *signature);
  254. /**************************************************/
  255. /* common functions which are exported by the BDK */
  256. /**************************************************/
  257. FLStatus bdkGetBootPartitionInfo (word startUnit,
  258. dword FAR2 *partitionSize,
  259. dword FAR2 *realPartitionSize,
  260. dword FAR2 *unitSize,
  261. byte FAR2 *signature);
  262. FLStatus bdkCopyBootAreaInit (word startUnit,
  263. dword areaLen,
  264. byte FAR2 *signature);
  265. FLStatus bdkCopyBootAreaBlock (byte FAR1 *buf ,
  266. word bufferLen,
  267. byte FAR2 *checkSum);
  268. #ifdef BDK_IMAGE_TO_FILE
  269. FLStatus bdkCopyBootAreaFile ( char FAR2 *fname,
  270. word startUnit,
  271. dword areaLen,
  272. byte FAR2 *checkSum,
  273. byte FAR2 *signature );
  274. #endif /* BDK_IMAGE_TO_FILE */
  275. #ifdef UPDATE_BDK_IMAGE
  276. FLStatus bdkUpdateBootAreaInit (word startUnit,
  277. dword areaLen,
  278. byte updateFlag,
  279. byte FAR2 *signature );
  280. FLStatus bdkUpdateBootAreaBlock (byte FAR1 *buf ,
  281. word bufferLen );
  282. #ifdef ERASE_BDK_IMAGE
  283. FLStatus bdkEraseBootArea (word startUnit,
  284. word noOfBlocks,
  285. byte FAR2 * signature);
  286. #endif /* ERASE_BDK_IMAGE */
  287. #ifdef CREATE_BDK_IMAGE
  288. FLStatus bdkCreateBootArea (word noOfBlocks,
  289. byte FAR2 * oldSign,
  290. byte FAR2 * newSign);
  291. #endif /* CREATE_BDK_IMAGE */
  292. #ifdef HW_OTP
  293. FLStatus bdkGetUniqueID(byte FAR1* buf);
  294. FLStatus bdkReadOtp(word offset,byte FAR1 * buffer,word length);
  295. FLStatus bdkWriteAndLockOtp(const byte FAR1 * buffer,word length);
  296. FLStatus bdkGetOtpSize(dword FAR2* sectionSize, dword FAR2* usedSize,
  297. word FAR2* locked);
  298. #endif /* HW_OTP */
  299. #ifdef BDK_IMAGE_TO_FILE
  300. FLStatus bdkUpdateBootAreaFile(char FAR2 *fname, word startUnit,
  301. dword areaLen, byte FAR2 *signature);
  302. #endif /* BDK_IMAGE_TO_FILE */
  303. #endif /* UPDATE_BDK_IMAGE */
  304. #ifdef PROTECT_BDK_IMAGE
  305. FLStatus bdkGetProtectionType (word * protectionType);
  306. FLStatus bdkSetProtectionType (word newType);
  307. FLStatus bdkInsertKey (byte FAR1* key);
  308. FLStatus bdkRemoveKey (void);
  309. FLStatus bdkLockEnable (byte enable);
  310. FLStatus bdkChangeKey (byte FAR1* key);
  311. #endif /* PROTECT_BDK_IMAGE */
  312. #else /* MTD_STANDALONE */
  313. extern FLStatus bdkCall(FLFunctionNo functionNo,
  314. IOreq FAR2 *ioreq, FLFlash* flash);
  315. #endif /* MTD_STANDALONE */
  316. /********************/
  317. /* common functions */
  318. /********************/
  319. void bdkInit( void );
  320. /************************ Function Prototype End **************************/
  321. #endif /* BDK_ACCESS || MTD_STANDALONE */
  322. #endif /* _DOC_BDK_H_ */