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.

454 lines
18 KiB

  1. /*
  2. * $Log: V:/Flite/archives/TrueFFS5/Src/FLFORMAT.H_V $
  3. *
  4. * Rev 1.9 Apr 15 2002 07:36:52 oris
  5. * Bug fix - Standard format was changed
  6. * - includes only 1 Disk partitions and not 2.
  7. * - leave 2 spare units in case power failure occurs while writing into the last unit.
  8. *
  9. * Rev 1.8 Feb 19 2002 20:59:52 oris
  10. * Changed default spare units to 2
  11. *
  12. * Rev 1.7 Jan 21 2002 20:44:44 oris
  13. * Changed comments.
  14. *
  15. * Rev 1.6 Sep 15 2001 23:46:24 oris
  16. * Changed progress callback routine to support up to 64K units.
  17. *
  18. * Rev 1.5 Jun 17 2001 08:18:54 oris
  19. * Changed exbFlag field to word
  20. * Added typedef FLStatus (*FLProgressCallback)(int totalUnitsToFormat, int totalUnitsFormattedSoFar);
  21. *
  22. * Rev 1.4 Apr 16 2001 13:42:22 oris
  23. * Removed warrnings by changing some of the fields types.
  24. *
  25. * Rev 1.3 Apr 01 2001 07:54:42 oris
  26. * copywrite notice.
  27. * Spelling mistake "changable".
  28. * Compression parameters were changed in order to prevent floating point math.
  29. *
  30. * Rev 1.2 Feb 18 2001 12:03:32 oris
  31. * Added TL_OLD_FORMAT defintion.
  32. *
  33. * Rev 1.1 Feb 13 2001 01:44:40 oris
  34. * Moved the TL_FORMAT_COMPRESSION and TL_FORMAT_FAT defintion from blockdev.h
  35. *
  36. * Rev 1.0 Feb 02 2001 13:57:58 oris
  37. * Initial revision.
  38. *
  39. */
  40. /***********************************************************************************/
  41. /* M-Systems Confidential */
  42. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
  43. /* All Rights Reserved */
  44. /***********************************************************************************/
  45. /* NOTICE OF M-SYSTEMS OEM */
  46. /* SOFTWARE LICENSE AGREEMENT */
  47. /* */
  48. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  49. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  50. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
  51. /* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
  52. /* E-MAIL = [email protected] */
  53. /***********************************************************************************/
  54. /*****************************************************************************
  55. * File Header *
  56. * ----------- *
  57. * Name : flformat.h *
  58. * *
  59. * Description : This file contains data strucutres passed to the format *
  60. * routines. *
  61. * *
  62. * Note : If dos format is also needed include dosformt.h instead *
  63. * *
  64. *****************************************************************************/
  65. #ifndef FORMAT_H
  66. #define FORMAT_H
  67. #include "flbase.h"
  68. /*********************************************/
  69. /* Formatting parameter structure definition */
  70. /*********************************************/
  71. /*----------------------------------------------*/
  72. /* User BDTL Partition Format Parameters record */
  73. /*----------------------------------------------*/
  74. typedef struct {
  75. dword length;
  76. /* The size of the usable storage space. The size will be
  77. rounded upwards to a multiplication of a block size.
  78. The size of the last partition will calculated automatically,
  79. but if the requested size is greater then the remaining space
  80. an error code will be returned,. Requesting zero size for any
  81. partition but the last will generate an flBadParameters status. */
  82. unsigned noOfSpareUnits;
  83. /* BDTL needs at least one spare erase unit in order to function
  84. as a read/write media. It is possible to specify more than one
  85. spare unit, which takes more media space. The advantage of
  86. specifying more than one spare unit is that if one of the flash
  87. erase units becomes bad and inerasable in the future, then one
  88. of the spare units can replace it. In that case, a second spare
  89. unit enables TrueFFS to continue its read/write functionality,
  90. whereas if no second spare unit is available the media goes into
  91. read-only mode. The standard value used is 1 */
  92. byte flags;
  93. #define TL_FORMAT_COMPRESSION 1 /* Add ZIP format on the media */
  94. #define TL_FORMAT_FAT 2 /* Add FAT format on the media */
  95. #define TL_OLD_FORMAT 4 /* Format with 1 sector per cluster */
  96. byte volumeId[4]; /* DOS partition identification number */
  97. byte FAR1 * volumeLabel; /*DOS partition label string. If NULL, no label */
  98. byte noOfFATcopies;
  99. /* It is customary to format DOS media with two FAT copies. The
  100. first copy is always used, but more copies make it possible
  101. to recover if the FAT becomes corrupted (a rare occurrence).
  102. On the other hand, this slows down performance and uses media
  103. space. The standard value used is 2. */
  104. #ifdef HW_PROTECTION
  105. byte protectionKey[8]; /* The key for the protection*/
  106. byte protectionType;
  107. /* PROTECTABLE - Can recieve protection */
  108. /* READ_PROTECTED - Protect against read operations */
  109. /* WRITE_PROTECTED - Protect against write operations */
  110. /* LOCK_ENABLED - Enables the hardware lock signal */
  111. /* PROTECTABLE - This partition can be protected */
  112. /* CHANGEABLE_PROTECTION - protection type can be changed */
  113. #endif /* HW_PROTECTION */
  114. #ifdef COMPRESSION
  115. word ratioDenominator;
  116. word ratioNominator;
  117. #endif /* COMPRESSION */
  118. /* The ratio between the real media size and the virtual size
  119. reported to the file system when compression is active. */
  120. } BDTLPartitionFormatParams;
  121. /*------------------------------------------------*/
  122. /* User binary Partition Format Parameters record */
  123. /*------------------------------------------------*/
  124. typedef struct {
  125. dword length; /* Required number of good blocks in the partition.*/
  126. byte sign[4]; /* signature of the binary partition to format.
  127. The signature 0xFFFF FFFF is not a valid signature */
  128. byte signOffset;
  129. /* offset of the signature. This value should always be 8, but it
  130. can also accept 0 for backwards compatibility reasons. Note that
  131. if the offset is 0 EDC\ECC is neutralized */
  132. #ifdef HW_PROTECTION
  133. byte protectionKey[8]; /* The key for the protection*/
  134. byte protectionType;
  135. /* PROTECTABLE - Can recieve protection */
  136. /* READ_PROTECTED - Protect against read operations */
  137. /* WRITE_PROTECTED - Protect against write operations */
  138. /* LOCK_ENABLED - Enables the hardware lock signal */
  139. /* PROTECTABLE - This partition can be protected */
  140. /* CHANGEABLE_PROTECTION - protection type can be changed */
  141. #endif /* HW_PROTECTION */
  142. } BinaryPartitionFormatParams;
  143. /*-----------------------------------------------------------------*/
  144. /* User Format Parameters record for flFormatPhysicalDrive routine */
  145. /*-----------------------------------------------------------------*/
  146. typedef FLStatus (*FLProgressCallback)(word totalUnitsToFormat, word totalUnitsFormattedSoFar);
  147. typedef struct {
  148. /*****************************/
  149. /* Device formatting section */
  150. /*****************************/
  151. byte percentUse;
  152. /* BDTL performance depends on how full the flash media is,
  153. becoming slower as the media becomes closer to 100% full.
  154. It is possible to avoid the worst-case performance
  155. (at 100% full) by formatting the media to less than 100%
  156. capacity, thus guaranteeing free space at all times. This
  157. of course sacrifices some capacity. The standard value
  158. used is 98 */
  159. byte noOfBDTLPartitions;
  160. /* Indicates the number of BDTL partitions (1 to 4). 0 will
  161. cause a single STD_BDTL_PARAMS BDTL partition */
  162. byte noOfBinaryPartitions;
  163. /* Indicates the number of binary partitions (up to 3). 0 will
  164. cause formatting with no binary partition. This value is ignored
  165. unless the TL_BINARY_FORMAT flag is set in the irFlags f the ioreq */
  166. BDTLPartitionFormatParams FAR2* BDTLPartitionInfo;
  167. /* BDTL partition information array */
  168. BinaryPartitionFormatParams FAR2* binaryPartitionInfo;
  169. /* Binary partition information array*/
  170. /***********************************/
  171. /* Special format features section */
  172. /***********************************/
  173. #ifdef WRITE_EXB_IMAGE
  174. void FAR1 * exbBuffer;
  175. /* A buffer containing the EXB file. Optionaly this file can
  176. contain only the first 512 bytes of the file while the rest
  177. will be sent using consequitive calls to flPlaceExbByBuffer */
  178. dword exbBufferLen; /* Size of the given EXB buffer */
  179. dword exbLen; /* The specific size to leave for the EXB */
  180. word exbWindow; /* Set explicit DiskOnChip window base */
  181. word exbFlags; /* For the flags list see doc2exb.h */
  182. #endif /* WRITE_EXB_IMAGE */
  183. byte cascadedDeviceNo; /* Not used */
  184. byte noOfCascadedDevices; /* Not used */
  185. FLProgressCallback progressCallback;
  186. /* Progress callback routine, will be called if not NULL.
  187. The callback routine is called after erasing each unit,
  188. and its parameters are the total number of erase units
  189. to format and the number erased so far.
  190. The callback routine returns a Status value. A value of
  191. OK (0) allows formatting to continue. Any other value
  192. will abort the formatting with the returned status code. */
  193. /* Note the following section is not used by for DiskOnChips */
  194. /*************************************************************/
  195. dword vmAddressingLimit;
  196. /* A part of the FTL Virtual Map always resides in RAM. The
  197. RAM part is the one that is used to address the part of
  198. the media below the VM addressing limit. Reading and
  199. writing to this part is usually faster to some degree.
  200. The downside is that the bigger the limit, the more RAM
  201. size is required.
  202. To get the extra RAM requirement in bytes, divide the
  203. limit by 128 or by 256, depending on whether you
  204. specified in #2.9 more than 32 or not, respectively.
  205. The minimum VM limit is 0.
  206. The standard value to use is 0x10000 (first 64 KBytes) */
  207. word embeddedCISlength;
  208. /* Length in bytes of CIS to embed after the unit header */
  209. byte FAR1 * embeddedCIS;
  210. /* The unit header is structured as a beginning of a PCMCIA
  211. 'tuple' chain (a CIS). The unit header contains a
  212. data-organization tuple, which points past the end of the
  213. unit header to a location which usually just contains
  214. hex FF's which mark an 'end-of-tuple-chain'. Optionally,
  215. it is possible to embed an entire CIS chain at this
  216. location. If so, 'embeddedCISlength' marks the length in
  217. bytes */
  218. } FormatParams2;
  219. /*----------------------------------------------------------*/
  220. /* User Format Parameters record for flFormatVolume routine */
  221. /*----------------------------------------------------------*/
  222. typedef struct {
  223. /* FTL formatting section */
  224. long int bootImageLen;
  225. /* Space to reserve for a boot-image at the start of the
  226. medium. The FLite volume will begin at the next higher
  227. erase unit boundary */
  228. unsigned percentUse;
  229. /* FTL performance depends on how full the Flash media is,
  230. getting slower when the media is close to 100%. It is
  231. possible to avoid the worst consequences of this effect by
  232. formatting the media to less than 100% capacity, so
  233. guaranteeing some free space at all times. This of course
  234. sacrifices some capcity.
  235. The standard value to use is 98 */
  236. unsigned noOfSpareUnits;
  237. /* BDTL partitions needs at least one spare erase unit to function as
  238. a read/write media. That unit is normally taken from the transfer
  239. units specified by the percentUsed field, but it is possible to
  240. specify additional units (which takes more media space). This
  241. ensures that if all the transfer units become bad and inerasable,
  242. the spare unit enables TrueFFS to continue its read/write
  243. functionality. Conversely, if no spare units are available the
  244. media may switch into read-only mode. The standard value used is 1 */
  245. dword vmAddressingLimit;
  246. /* A part of the FTL Virtual Map always resides in RAM. The
  247. RAM part is the one that is used to address the part of
  248. the media below the VM addressing limit. Reading and
  249. writing to this part is usually faster to some degree.
  250. The downside is that the bigger the limit, the more RAM
  251. size is required.
  252. To get the extra RAM requirement in bytes, divide the
  253. limit by 128 or by 256, depending on whether you
  254. specified in #2.9 more than 32 or not, respectively.
  255. The minimum VM limit is 0.
  256. The standard value to use is 0x10000 (first 64 KBytes) */
  257. FLProgressCallback progressCallback;
  258. /* Progress callback routine, will be called if not NULL.
  259. The callback routine is called after erasing each unit,
  260. and its parameters are the total number of erase units
  261. to format and the number erased so far.
  262. The callback routine returns a Status value. A value of
  263. OK (0) allows formatting to continue. Any other value
  264. will abort the formatting with the returned status code. */
  265. /* DOS formatting section */
  266. char volumeId[4];
  267. /* Volume identification number */
  268. char FAR1 * volumeLabel;
  269. /* Volume label string. If NULL, no label */
  270. unsigned noOfFATcopies;
  271. /* It is customary to format DOS media with 2 FAT copies.
  272. The first copy is always used, but more copies make it
  273. possible to recover if the FAT becomes corrupted (a
  274. rare occurrence). On the other hand, this slows down
  275. performance and uses media space.
  276. The standard value to use is 2 */
  277. unsigned embeddedCISlength;
  278. /* Length in bytes of CIS to embed after the unit header */
  279. char FAR1 * embeddedCIS;
  280. /* The unit header is structured as a beginning of a PCMCIA
  281. 'tuple' chain (a CIS). The unit header contains a
  282. data-organization tuple, which points past the end of the
  283. unit header to a location which usually just contains
  284. hex FF's which mark an 'end-of-tuple-chain'. Optionally,
  285. it is possible to embed an entire CIS chain at this
  286. location. If so, 'embeddedCISlength' marks the length in
  287. bytes */
  288. } FormatParams;
  289. /*----------------------------------------------------------*/
  290. /* Format Parameters record passed to the translation layer */
  291. /*----------------------------------------------------------*/
  292. typedef struct {
  293. /* Global device info */
  294. Sdword bootImageLen;
  295. byte percentUse;
  296. byte noOfBDTLPartitions;
  297. byte noOfBinaryPartitions;
  298. BDTLPartitionFormatParams FAR2* BDTLPartitionInfo;
  299. BinaryPartitionFormatParams FAR2* binaryPartitionInfo;
  300. byte flags;
  301. /* First volume info */
  302. #ifdef HW_PROTECTION
  303. byte protectionKey[8];
  304. byte protectionType;
  305. #endif /* HW_PROTECTION */
  306. #ifdef COMPRESSION
  307. word ratioDenominator;
  308. word ratioNominator;
  309. #endif /* COMPRESSION */
  310. byte noOfSpareUnits;
  311. byte volumeId[4];
  312. byte FAR1 * volumeLabel;
  313. byte noOfFATcopies;
  314. /* Special features */
  315. #ifdef WRITE_EXB_IMAGE
  316. Sdword exbLen;
  317. #endif /* WRITE_EXB_IMAGE */
  318. byte cascadedDeviceNo;
  319. byte noOfCascadedDevices;
  320. FLProgressCallback progressCallback;
  321. dword osakVersion;
  322. /* None DiskOnChip parameters */
  323. dword vmAddressingLimit;
  324. word embeddedCISlength;
  325. byte FAR1 * embeddedCIS;
  326. } TLFormatParams;
  327. #define BINARY_SIGNATURE_NAME 4
  328. #define BINARY_SIGNATURE_LEN 8
  329. #define SIGN_SPL "����"
  330. /* Standard initializer for BDTLPartitionFormatParams structure */
  331. #ifdef HW_PROTECTION
  332. #ifdef COMPRESSION
  333. #define STD_BDTL_PARAMS {0,2,TL_FORMAT_FAT,{0,0,0,0},NULL,2,{0,0,0,0,0,0,0,0},0,0,2}
  334. #else
  335. #define STD_BDTL_PARAMS {0,2,TL_FORMAT_FAT,{0,0,0,0},NULL,2,{0,0,0,0,0,0,0,0},0}
  336. #endif /* COMPRESSION */
  337. #else
  338. #ifdef COMPRESSION
  339. #define STD_BDTL_PARAMS {0,2,TL_FORMAT_FAT,{0,0,0,0},NULL,2,0,2}
  340. #else
  341. #define STD_BDTL_PARAMS {0,2,TL_FORMAT_FAT,{0,0,0,0},NULL,2}
  342. #endif /* COMPRESSION */
  343. #endif /* HW_PROTECTION */
  344. /* Standard initializer for BinaryPartitionFormatParams structure */
  345. #ifdef HW_PROTECTION
  346. #define STD_BINARY_PARAMS {0,{'B','I','P','O'},8,{0,0,0,0,0,0,0,0},0}
  347. #else
  348. #define STD_BINARY_PARAMS {0,{'B','I','P','O'},8}
  349. #endif /* HW_PROTECTION */
  350. /* Standard initializer for FormatParams2 structure */
  351. #ifdef WRITE_EXB_IMAGE
  352. #define STD_FORMAT_PARAMS2 {98,1,0,NULL,NULL,NULL,0,0,0,0,0,0,NULL,0x10000l,0,NULL}
  353. #else
  354. #define STD_FORMAT_PARAMS2 {98,1,0,NULL,NULL,0,0,NULL,0x10000l,0,NULL}
  355. #endif /* WRITE_EXB_IMAGE */
  356. /* Standard initializer for FormatParams structure */
  357. #define STD_FORMAT_PARAMS {-1, 98, 2, 0x10000l, NULL, {0,0,0,0}, NULL, 2, 0, NULL}
  358. #endif /* FORMAT_H */