Source code of Windows XP (NT5)
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.

509 lines
23 KiB

  1. /*
  2. * $Log: V:/Flite/archives/TrueFFS5/Src/MTDSA.H_V $
  3. *
  4. * Rev 1.22 Apr 15 2002 08:31:12 oris
  5. * Added USE_TFFS_COPY compilation flag.
  6. * This flag is used by bios driver a Boot SDK in order to improove performance.
  7. *
  8. * Rev 1.21 Apr 15 2002 07:38:02 oris
  9. * Moved system types from flBase.h
  10. * Moved compilation flag validations for TrueFFS to flchkdfs.h
  11. *
  12. * Rev 1.20 Feb 19 2002 21:00:48 oris
  13. * Added include of "flchkfds.h"
  14. *
  15. * Rev 1.19 Jan 28 2002 21:26:14 oris
  16. * Removed the use of back-slashes in macro definitions.
  17. *
  18. * Rev 1.18 Jan 17 2002 23:03:38 oris
  19. * Commented out all compilation flags.
  20. * Replaced USE_FUNC with FL_NO_USE_FUNC so that memory access routines uses routines by default.
  21. * MTD_NO_READ_BBT_CODE was separated to MTD_READ_BBT and MTD_RECONSTRUCT_BBT
  22. * Added windows CE predefined system customization.
  23. * Changed FAR_LEVEL default - always 0 unless DOS
  24. * Join delay routine with matching OS definition.
  25. * If NULL pointers are not defined (or DOS OS) defined NULL as ((void FAR0*)0)
  26. *
  27. * Rev 1.17 Nov 29 2001 20:54:12 oris
  28. * CURRECT_OS was changed to CURRENT_OS
  29. * Added default FAR_LEVEL for VxWorks
  30. *
  31. * Rev 1.16 Sep 15 2001 23:47:42 oris
  32. * Changed BIG_ENDIAN to FL_BIG_ENDIAN
  33. *
  34. * Rev 1.15 Jul 29 2001 16:41:18 oris
  35. * Added CUR_NO_OS definition
  36. * Remove USE_STD_FUNC defintion when using big_endian. since memcpy function can cause memory access problems (buffers are copied from the end).
  37. *
  38. * Rev 1.14 Jul 15 2001 21:08:02 oris
  39. * Changed DFORMAT_PRINT syntax to be similar to DEBUG_PRINT.
  40. *
  41. * Rev 1.13 Jul 13 2001 01:07:28 oris
  42. * Bug fix - Use different memory H file include for vxWorks and DOS for memory handling (memcpy, memset and memcmp)/.
  43. * Added DFORMAT_PRINT macro.
  44. * Changed default configuration.
  45. *
  46. * Rev 1.12 Jun 17 2001 22:30:12 oris
  47. * Comment NO_??? defintions.
  48. *
  49. * Rev 1.11 Jun 17 2001 18:57:04 oris
  50. * Improved documentation and remove warnings.
  51. *
  52. * Rev 1.10 Jun 17 2001 08:17:42 oris
  53. * Removed warnings.
  54. *
  55. * Rev 1.9 May 21 2001 18:24:14 oris
  56. * Removed BDK_IMAGE_TO_FILE as a default definition.
  57. * Change physicalToPointer macro when FAR_LEVEL = 0.
  58. *
  59. * Rev 1.8 May 21 2001 16:11:14 oris
  60. * Added USE_STD_FUNC defintion.
  61. * Added memcpy memset and memcmp as defaults for tffscpy tffsset and tffscmp.
  62. * Removed naming conventions.
  63. * Removed DRIVES definition.
  64. *
  65. * Rev 1.7 May 20 2001 14:36:14 oris
  66. * Reorganized header file.
  67. *
  68. * Rev 1.6 May 16 2001 21:21:00 oris
  69. * Restored the SOCKETS and BINARY_PARTITIONS definitions.
  70. *
  71. * Rev 1.5 May 09 2001 00:32:56 oris
  72. * Changed IPL_CODE to NO_IPL_CODE , READ_BBT_CODE to NO_READ_BBT_CODE.
  73. * Moved BINARY_PARTITIONS and SOCKETS to docbdk.h.
  74. * Removed the DOC2000_FAMILY and DOCPLUS_FAMILY.
  75. * Uncommented the HW_OTP compilation flag as a default for the BDK.
  76. *
  77. * Rev 1.4 Apr 30 2001 18:03:06 oris
  78. * Added READ_BBT_CODE definition and IPL_CODE defintion.
  79. *
  80. * Rev 1.3 Apr 09 2001 15:03:26 oris
  81. * Changed default settings to no verify write and no checksum calculation.
  82. *
  83. * Rev 1.2 Apr 01 2001 07:53:44 oris
  84. * copywrite notice.
  85. * Alligned left all # directives.
  86. * Added the following compilation flag:
  87. * HW_OTP
  88. * MTD_FOR_EXB
  89. *
  90. * Rev 1.1 Feb 07 2001 17:32:48 oris
  91. * Added SOCKETS defintion for standalone mode
  92. *
  93. * Rev 1.0 Feb 04 2001 12:25:00 oris
  94. * Initial revision.
  95. *
  96. */
  97. /***********************************************************************************/
  98. /* M-Systems Confidential */
  99. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
  100. /* All Rights Reserved */
  101. /***********************************************************************************/
  102. /* NOTICE OF M-SYSTEMS OEM */
  103. /* SOFTWARE LICENSE AGREEMENT */
  104. /* */
  105. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  106. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  107. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, OR CONTACT M-SYSTEMS */
  108. /* FOR LICENSE ASSISTANCE: E-MAIL = [email protected] */
  109. /***********************************************************************************/
  110. /************************************************************************/
  111. /* TrueFFS and Standalone MTD */
  112. /************************************************************************/
  113. /************************************************************************/
  114. /* File Header */
  115. /* ----------- */
  116. /* Name : mtdsa.h */
  117. /* */
  118. /* Description : This file contains neccesary definition and */
  119. /* customization */
  120. /* for the MTD standalone mode. It also contains the */
  121. /* compilation flag determining the mode of operation */
  122. /* either */
  123. /* TrueFFS or MTD standalone */
  124. /* */
  125. /* Warning : TrueFFS application must keep the MTD_STANDALONE */
  126. /* definition */
  127. /* commented. */
  128. /* */
  129. /************************************************************************/
  130. #ifndef MTD_SA_H
  131. #define MTD_SA_H
  132. /************************************************************************/
  133. /* Uncomment the following line when using the MTD in standalone mode */
  134. /************************************************************************/
  135. /* #define MTD_STANDALONE */
  136. /************************************************************************/
  137. /* The rest of the file is for the BDK standalone package only */
  138. /************************************************************************/
  139. #ifdef MTD_STANDALONE
  140. /************************************************************************/
  141. /* */
  142. /* Binary Development Kit Stand Alone Customization Area */
  143. /* */
  144. /************************************************************************/
  145. /************************************************************************/
  146. /* Section 1. */
  147. /* */
  148. /* Customize the features to be compiled in your standalone */
  149. /* application. Each required feature will add to your final executable */
  150. /* code. */
  151. /* */
  152. /* Simply uncomment the required feature directive. */
  153. /* */
  154. /************************************************************************/
  155. /* #define ACCESS_BDK_IMAGE */ /* Compile the binary read routines */
  156. /* #define UPDATE_BDK_IMAGE */ /* Compile the binary write routines */
  157. /* #define ERASE_BDK_IMAGE */ /* Compile the binary erase routine */
  158. /* #define CREATE_BDK_IMAGE */ /* Compile the binary create routine */
  159. /* #define PROTECT_BDK_IMAGE */ /* Compile the binary protection routines */
  160. /* #define HW_OTP */ /* Compile the binary OTP routines */
  161. /* #define EDC_MODE */ /* Use the EDC\ECC mechanizm */
  162. /* #define BDK_IMAGE_TO_FILE */ /* Compile the files related routines */
  163. /* #define BDK_CHECK_SUM */ /* Calculate checksum on read operation */
  164. /* #define BDK_VERIFY_WRITE */ /* Read and compare after every write */
  165. /* #define FL_NO_USE_FUNC */ /* Do not use function for register access */
  166. /* #define D2TST */ /* Exports the EDC syndrome with the global */
  167. /* variable saveSyndromForDumping */
  168. /* #define FL_BIG_ENDIAN */ /* Used for big endian architectures */
  169. /* #define NO_IPL_CODE */ /* Do not compile code for IPL read and write */
  170. /* #define MTD_READ_BBT */ /* Compile the read BBT routine code */
  171. /* #define MTD_RECONSTRUCT_BBT *//* Compile code to scan virgin cards for BBT */
  172. /* #define DEBUG */ /* Include debug messages */
  173. /* #define USE_STD_FUNC */ /* Use standard 'C' memcpy\memset and memcmp */
  174. /* This define must be commented out when */
  175. /* working with big endian archtechtures. The */
  176. /* problem is that some implementations of */
  177. /* memcpy, copy the data from the end of the */
  178. /* buffer, therefore bad implementation for */
  179. /* DiskOnChip memory windows access routines */
  180. /* #define USE_TFFS_COPY */ /* Use tffscpy/tffsset for DiskOnChip access */
  181. /************************************************************************/
  182. /* General Customized constants */
  183. /* The total number of Binary partitions on the DiskOnChip */
  184. /************************************************************************/
  185. #define BINARY_PARTITIONS 3
  186. #define SOCKETS 1 /* Currently the only option */
  187. /************************************************************************/
  188. /* Section 2. */
  189. /* */
  190. /* Includes OS/CPU-specific resources and customization */
  191. /* */
  192. /* 1) Uncomment relevant CURRENT_OS directive below for predefined */
  193. /* customization for majore OS'es. */
  194. /* 2) Define the far level of your application's pointers. */
  195. /* 3) Customize pointer arithmetic routines. */
  196. /* 4) Customize debug messages routine. */
  197. /* 5) Default calling convention. */
  198. /* 6) NULL constant. */
  199. /* 7) Signed/unsigned char. */
  200. /* 8) CPU target. */
  201. /* */
  202. /************************************************************************/
  203. #define CUR_NO_OS 0 /* Do not include any OS resources */
  204. #define CUR_OS_PSOS 1 /* Include PSOS resources */
  205. #define CUR_OS_DOS 2 /* Include DOS resources */
  206. #define CUR_OS_VX_WORKS 3 /* Include VX_WORKS resources */
  207. #define CUR_OS_WINCE 4 /* Include Windows CE resources */
  208. /* #define CURRENT_OS CUR_OS_PSOS */ /* uncomment for pSOS */
  209. /* #define CURRENT_OS CUR_OS_VX_WORKS */ /* uncomment for VxWorks */
  210. /* #define CURRENT_OS CUR_OS_DOS */ /* uncomment for DOS */
  211. /* #define CURRENT_OS CUR_OS_WINCE */ /* uncomment for WINCE */
  212. /* #define CURRENT_OS CUR_NO_OS */ /* uncomment for NO OS */
  213. /************************************************************************/
  214. /* Far pointers */
  215. /* */
  216. /* Specify here which pointers can be far, if any. */
  217. /* Far pointers are usually relevant only to 80x86 architectures. */
  218. /* */
  219. /* Specify FAR_LEVEL: */
  220. /* 0 - If using a flat memory model or having no far pointers. */
  221. /* 1 - If only the DiskOnChip window may be far */
  222. /* 2 - If only the DiskOnChip window and RAM window may be far. */
  223. /* 3 - If DiskOnChip window, RAM window and pointer(s) */
  224. /* transferred to the entry-point function may be far */
  225. /************************************************************************/
  226. #if (CURRENT_OS==CUR_OS_DOS)
  227. #define FAR_LEVEL 2
  228. #else
  229. #define FAR_LEVEL 0
  230. #endif /* CURRENT_OS == CUR_OS_DOS */
  231. /************************************************************************/
  232. /* Pointer arithmetic */
  233. /* */
  234. /* The following macros define machine- and compiler-dependent macros */
  235. /* for handling pointers to physical bdkWindow addresses. The */
  236. /* definitions below are for PC real-mode Borland-C. */
  237. /* */
  238. /* 'physicalToPointer' translates a physical flat address to a (far) */
  239. /* pointer. Note that if when your processor uses virtual memory, the */
  240. /* code should map the physical address to virtual memory, and return a */
  241. /* pointer to that memory (the size parameter tells how much memory */
  242. /* should be mapped). */
  243. /* */
  244. /* 'addToFarPointer' adds an increment to a pointer and returns a new */
  245. /* pointer. The increment may be as large as your window size. The code */
  246. /* below assumes that the increment is larger than 64 KB and so */
  247. /* performs huge pointer arithmetic. */
  248. /* */
  249. /* 'freePointer' frees an allocated pointer. This is useful in */
  250. /* architectures using virtual memory. */
  251. /* */
  252. /* The example bellow is relevant for DOS OS */
  253. /************************************************************************/
  254. #if FAR_LEVEL > 0
  255. #define physicalToPointer(physical,size,driveNo) \
  256. MK_FP((int) ((physical) >> 4),(int) (physical) & 0xF)
  257. #define pointerToPhysical(ptr) \
  258. (((unsigned long) FP_SEG(ptr) << 4) + FP_OFF(ptr))
  259. #define freePointer(ptr,size) 1
  260. #define addToFarPointer(base,increment) \
  261. MK_FP(FP_SEG(base) + \
  262. ((unsigned short) ((FP_OFF(base) + (unsigned long)(increment)) >> 16) << 12), \
  263. FP_OFF(base) + (int) (increment))
  264. #else
  265. #define physicalToPointer(physical,size,driveNo) ((void *) (physical))
  266. #define pointerToPhysical(ptr) ((unsigned long)(ptr))
  267. #define addToFarPointer(base,increment) ((void *) ((unsigned char *) (base) + (increment)))
  268. #define freePointer(ptr,size) 1
  269. #endif
  270. /************************************************************************/
  271. /* Debug mode */
  272. /* */
  273. /* Uncomment the following lines if you want debug messages to be */
  274. /* printed out. Messages will be printed at initialization key points, */
  275. /* and when low-level errors occur. */
  276. /* You may choose to use 'printf' or provide your own routine. */
  277. /************************************************************************/
  278. #if DBG
  279. #include <stdio.h>
  280. #define DEBUG_PRINT(p) printf p
  281. #define DFORMAT_PRINT(p) printf p
  282. #else
  283. #define DEBUG_PRINT(str)
  284. #define DFORMAT_PRINT(str)
  285. #endif
  286. /************************************************************************/
  287. /* Default calling convention */
  288. /* */
  289. /* C compilers usually use the C calling convention to routines (cdecl),*/
  290. /* but often can also use the pascal calling convention, which is */
  291. /* somewhat more economical in code size. Some compilers also have */
  292. /* specialized calling conventions which may be suitable. Use compiler */
  293. /* switches or insert a #pragma here to select your favorite calling */
  294. /* convention. */
  295. /************************************************************************/
  296. #if (CURRENT_OS == CUR_OS_DOS)
  297. #pragma option -p /* Default pascal calling convention */
  298. #endif /* CURRENT_OS == CUR_OS_DOS */
  299. /************************************************************************/
  300. /* NULL constant */
  301. /* */
  302. /* Some compilers require a different definition for the NULL pointer */
  303. /************************************************************************/
  304. #if (CURRENT_OS == CUR_OS_DOS)
  305. #include <_null.h>
  306. #else
  307. #ifndef NULL
  308. #define NULL ((void FAR0*)0)
  309. #endif /* NULL */
  310. #endif /* CURRENT_OS == CUR_OS_DOS */
  311. /************************************************************************/
  312. /* signed/unsigned char */
  313. /* */
  314. /* It is assumed that 'char' is signed. If this is not your compiler */
  315. /* default, use compiler switches, or insert a #pragma here to define */
  316. /* this. */
  317. /************************************************************************/
  318. #if (CURRENT_OS == CUR_OS_DOS)
  319. #pragma option -K- /* default char is signed */
  320. #endif /* CURRENT_OS == CUR_OS_DOS */
  321. /************************************************************************/
  322. /* CPU target */
  323. /* */
  324. /* Use compiler switches or insert a #pragma here to select the CPU */
  325. /* type you are targeting. */
  326. /* */
  327. /* If the target is an Intel 80386 or above, also uncomment the */
  328. /* CPU_i386 definition. */
  329. /************************************************************************/
  330. #if (CURRENT_OS == CUR_OS_DOS)
  331. #pragma option -3 /* Select 80386 CPU */
  332. #endif /* CURRENT_OS == CUR_OS_DOS */
  333. /***********************************************************************/
  334. /* End of Customization Area */
  335. /***********************************************************************/
  336. /* Replacement for various TrueFFS definitions */
  337. #define SECTOR_SIZE_BITS 9 /* defines the log2 of a sector size (512) */
  338. #define MTDS 2 /* Maximum number of registred MTDS */
  339. /***********************************************************************/
  340. /* Check for missing defines dependencies Do not customized */
  341. /***********************************************************************/
  342. /* 1) Update routines require the functionalities of the read routine. */
  343. /* 2) Removal of the binary read or write routines does not remove the */
  344. /* flash read and write routines. In order to save on the TEXT code */
  345. /***********************************************************************/
  346. #ifdef UPDATE_BDK_IMAGE
  347. #ifndef ACCESS_BDK_IMAGE
  348. #define ACCESS_BDK_IMAGE
  349. #endif /* !ACCESS_BDK_IMAGE */
  350. #endif /* UPDATE_BDK_IMAGE */
  351. /***********************************************************************/
  352. /* Custom the MTD definitions to meet the above definitions */
  353. /***********************************************************************/
  354. /* 1) EDC_MODE -> ~ NO_EDC_MODE */
  355. /* 2) BDK_VERIFY_WRITE -> VERIFY_WRITE */
  356. /* 3) USE_FUNC_FOR_ACCESS -> ~ FL_NO_USE_FUNC */
  357. /* 4) UPDATE_BDK_IMAGE -> ~ FL_READ_ONLY */
  358. /* 5) ~DOCPLUS_FAMILY -> ~ PROTECT_BDK_IMAGE */
  359. /* 6) PROTECT_BDK_IMAGE -> HW_PROTECTION */
  360. /* 7) DOS -> CUR_OS */
  361. /* 8) FL_BIG_ENDIAN -> ~ USE_STD_FUNC */
  362. /* 9) MTD_NO_READ_BBT_CODE -> ~ MTD_READ_BBT + ~ MTD_RECONSTRUCT_BBT */
  363. /***********************************************************************/
  364. #ifdef EDC_MODE
  365. #ifdef NO_EDC_MODE
  366. #undef NO_EDC_MODE
  367. #endif /* NO_EDC_MODE */
  368. #else /* EDC_MODE */
  369. #define NO_EDC_MODE
  370. #endif /* EDC_MODE */
  371. #ifdef BDK_VERIFY_WRITE
  372. #define VERIFY_WRITE
  373. #endif /* BDK_VERIFY_WRITE */
  374. #ifdef USE_FUNC_FOR_ACCESS
  375. #undef FL_NO_USE_FUNC
  376. #endif /* USE_FUNC_FOR_ACCESS */
  377. #ifndef UPDATE_BDK_IMAGE
  378. #define FL_READ_ONLY
  379. #endif /* UPDATE_BDK_IMAGE */
  380. #if (defined(PROTECT_BDK_IMAGE) && !defined(HW_PROTECTION))
  381. #define HW_PROTECTION
  382. #endif /* PRTOECTION_BDK_IMAGE */
  383. #if (defined(FL_BIG_ENDIAN) && defined(USE_STD_FUNC))
  384. #undef USE_STD_FUNC
  385. #endif /* FL_BIG_ENDIAN */
  386. #ifdef MTD_NO_READ_BBT_CODE
  387. #undef MTD_READ_BBT
  388. #undef MTD_RECONSTRUCT_BBT
  389. #endif /* MTD_NO_READ_BBT_CODE */
  390. /*********************************/
  391. /* Include specific OS resources */
  392. /*********************************/
  393. #if (CURRECT_OS == CUR_OS_WINCE)
  394. #include <windows.h>
  395. #include "pkfuncs.h"
  396. #include <memory.h>
  397. #include <stdio.h>
  398. #endif /*CUR_OS_WINCE*/
  399. #if (CURRENT_OS == CUR_OS_VX_WORKS)
  400. /* OS-specific includes */
  401. #include <vxWorks.h>
  402. #include <tickLib.h>
  403. #include <sysLib.h>
  404. #ifdef USE_STD_FUNC
  405. #include "memLib.h"
  406. #endif /* USE_STD_FUNC */
  407. #define VXW_DELAY /* uncomment for VxWorks delay */
  408. #endif /* CURRENT_OS == CUR_OS_VX_WORKS */
  409. #if (CURRENT_OS == CUR_OS_PSOS)
  410. /* OS-specific includes */
  411. #include <psos.h>
  412. #include <bspfuncs.h>
  413. #include "sys_conf.h"
  414. #ifdef USE_STD_FUNC
  415. #include "memLib.h"
  416. #endif /* USE_STD_FUNC */
  417. #define PSS_DELAY /* uncomment for pSOS delay */
  418. #endif /* CURRENT_OS == CUR_PSOS */
  419. #if (CURRENT_OS == CUR_OS_DOS)
  420. /* OS-specific includes */
  421. #include <dos.h>
  422. #ifdef USE_STD_FUNC
  423. #include "mem.h"
  424. #endif /* USE_STD_FUNC */
  425. #define DOS_DELAY /* uncomment for DOS delay */
  426. #endif /* CURRENT_OS == CUR_OS_DOS */
  427. /*******************************************/
  428. /* Declare memcpy, memset, memcmp routines */
  429. /*******************************************/
  430. #ifdef USE_STD_FUNC
  431. #if FAR_LEVEL > 0
  432. #define tffscpy _fmemcpy
  433. #define tffscmp _fmemcmp
  434. #define tffsset _fmemset
  435. #else
  436. #define tffscpy memcpy
  437. #define tffscmp memcmp
  438. #define tffsset memset
  439. #endif /* FAR_LEVEL */
  440. #endif /* USE_STD_FUNC */
  441. #endif /* MTD_STANDALONE */
  442. #endif /* MTD_SA_H */