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.

306 lines
9.4 KiB

  1. /*
  2. * $Log: P:/user/amir/lite/vcs/flsystem.h_v $
  3. Rev 1.4 11 Sep 1997 14:14:22 danig
  4. physicalToPointer receives drive no. when FAR == 0
  5. Rev 1.3 04 Sep 1997 13:58:30 danig
  6. DEBUG_PRINT
  7. Rev 1.2 28 Aug 1997 16:39:32 danig
  8. include stdlib.h instead of malloc.h
  9. Rev 1.1 19 Aug 1997 20:05:06 danig
  10. Andray's changes
  11. Rev 1.0 24 Jul 1997 18:13:06 amirban
  12. Initial revision.
  13. */
  14. /************************************************************************/
  15. /* */
  16. /* FAT-FTL Lite Software Development Kit */
  17. /* Copyright (C) M-Systems Ltd. 1995-1996 */
  18. /* */
  19. /************************************************************************/
  20. #ifndef FLSYSTEM_H
  21. #define FLSYSTEM_H
  22. #include <ntddk.h>
  23. #include "flcustom.h"
  24. /* DiskOnChip bus configuration
  25. *
  26. * When FL_NO_USE_FUNC is defined use the defintion bellow to set DiskOnChip
  27. * bus width access (either 8/16/32).
  28. * Please check the manula before deciding to use the FL_NO_USE_FUNC mode.
  29. */
  30. #define DOC_ACCESS_TYPE 8
  31. /*moti
  32. * delay With Yeald CPU disable
  33. *
  34. * Osak utiliezes the flSleep customized routine to yeald the CPU while
  35. * waiting for time consumming operations like flash erase. If the routine
  36. * is not implemented the uncomment the define bellow
  37. */
  38. #define DO_NOT_YEAL_CPU
  39. /*
  40. * signed/unsigned char
  41. *
  42. * It is assumed that 'char' is signed. If this is not your compiler
  43. * default, use compiler switches, or insert a #pragma here to define this.
  44. *
  45. */
  46. /*#pragma option -K-*/ /* default char is signed */
  47. /* CPU target
  48. *
  49. * Use compiler switches or insert a #pragma here to select the CPU type
  50. * you are targeting.
  51. *
  52. * If the target is an Intel 80386 or above, also uncomment the CPU_i386
  53. * definition.
  54. */
  55. /*#pragma option -3*/ /* Select 80386 CPU */
  56. #define CPU_i386
  57. /* NULL constant
  58. *
  59. * Some compilers require a different definition for the NULL pointer
  60. */
  61. /*#include <_null.h>*/
  62. /* Little-endian/big-endian
  63. *
  64. * FAT and translation layers structures use the little-endian (Intel)
  65. * format for integers.
  66. * If your machine uses the big-endian (Motorola) format, uncomment the
  67. * following line.
  68. * Note that even on big-endian machines you may omit the BIG_ENDIAN
  69. * definition for smaller code size and better performance, but your media
  70. * will not be compatible with standard FAT and FTL.
  71. */
  72. /* #define BIG_ENDIAN */
  73. /* Far pointers
  74. *
  75. * Specify here which pointers may be far, if any.
  76. * Far pointers are usually relevant only to 80x86 architectures.
  77. *
  78. * Specify FAR_LEVEL:
  79. * 0 - if using a flat memory model or having no far pointers.
  80. * 1 - if only the socket window may be far
  81. * 2 - if only the socket window and caller's read/write buffers
  82. * may be far.
  83. * 3 - if socket window, caller's read/write buffers and the
  84. * caller's I/O request packet may be far
  85. */
  86. #define FAR_LEVEL 0
  87. /* Memory routines
  88. *
  89. * You need to supply library routines to copy, set and compare blocks of
  90. * memory, internally and to/from callers. The code uses the names 'tffscpy',
  91. * 'tffsset' and 'tffscmp' with parameters as in the standard 'memcpy',
  92. * 'memset' and 'memcmp' C library routines.
  93. */
  94. #include <string.h>
  95. #ifndef ENVIRONMENT_VARS
  96. #if FAR_LEVEL > 0
  97. #define tffscpy _fmemcpy
  98. #define tffscmp _fmemcmp
  99. #define tffsset _fmemset
  100. #else
  101. #define tffscpy memcpy
  102. #define tffscmp memcmp
  103. #define tffsset memset
  104. #endif
  105. #else
  106. #if FAR_LEVEL > 0
  107. #define flcpy _fmemcpy
  108. #define flcmp _fmemcmp
  109. #define flset _fmemset
  110. #else
  111. #define flcmp flmemcmp
  112. #define flset flmemset
  113. #define flcpy flmemcpy
  114. #endif
  115. #endif
  116. /* Pointer arithmetic
  117. *
  118. * The following macros define machine- and compiler-dependent macros for
  119. * handling pointers to physical window addresses. The definitions below are
  120. * for PC real-mode Borland-C.
  121. *
  122. * 'physicalToPointer' translates a physical flat address to a (far) pointer.
  123. * Note that if when your processor uses virtual memory, the code should
  124. * map the physical address to virtual memory, and return a pointer to that
  125. * memory (the size parameter tells how much memory should be mapped).
  126. *
  127. * 'addToFarPointer' adds an increment to a pointer and returns a new
  128. * pointer. The increment may be as large as your window size. The code
  129. * below assumes that the increment may be larger than 64 KB and so performs
  130. * huge pointer arithmetic.
  131. */
  132. #if FAR_LEVEL > 0
  133. #include <dos.h>
  134. #define physicalToPointer(physical,size,drive) \
  135. MK_FP((LONG) ((physical) >> 4),(LONG) (physical) & 0xF)
  136. #define addToFarPointer(base,increment) \
  137. MK_FP(FP_SEG(base) + \
  138. ((USHORT) ((FP_OFF(base) + (increment)) >> 16) << 12), \
  139. FP_OFF(base) + (LONG) (increment))
  140. #else
  141. #include <ntddk.h>
  142. #define freePointer(ptr,size) 1
  143. typedef struct {
  144. ULONG windowSize;
  145. ULONGLONG physWindow;
  146. PVOID winBase;
  147. ULONG interfAlive;
  148. PVOID fdoExtension;
  149. UCHAR nextPartitionNumber;
  150. } NTsocketParams;
  151. //moti extern NTsocketParams *pdriveInfo;
  152. extern NTsocketParams *pdriveInfo;
  153. #define physicalToPointer(physical,size,drive) pdriveInfo[drive & 0x0f].winBase
  154. #define pointerToPhysical(ptr) ((ULONG_PTR)(ptr))
  155. #define addToFarPointer(base,increment) \
  156. ((VOID *) ((UCHAR *) (base) + (increment)))
  157. #endif
  158. /* Default calling convention
  159. *
  160. * C compilers usually use the C calling convention to routines (cdecl), but
  161. * often can also use the pascal calling convention, which is somewhat more
  162. * economical in code size. Some compilers also have specialized calling
  163. * conventions which may be suitable. Use compiler switches or insert a
  164. * #pragma here to select your favorite calling convention.
  165. */
  166. /*#pragma option -p*/ /* Default pascal calling convention */
  167. /* Naming convention for functions that uses non-default convention. */
  168. #define NAMING_CONVENTION /*cdecl*/
  169. #define FL_IOCTL_START 0
  170. /* Mutex type
  171. *
  172. * If you intend to access the FLite API in a multi-tasking environment,
  173. * you may need to implement some resource management and mutual-exclusion
  174. * of FLite with mutex & semaphore services that are available to you. In
  175. * this case, define here the Mutex type you will use, and provide your own
  176. * implementation of the Mutex functions incustom.c
  177. *
  178. * By default, a Mutex is defined as a simple counter, and the Mutex
  179. * functions in custom.c implement locking and unlocking by incrementing
  180. * and decrementing the counter. This will work well on all single-tasking
  181. * environment, as well as on many multi-tasking environments.
  182. */
  183. //typedef LONG FLMutex;
  184. typedef struct _SpinLockMutex{
  185. KSPIN_LOCK Mutex;
  186. KIRQL cIrql;
  187. }SpinLockMutex;
  188. typedef SpinLockMutex FLMutex;
  189. /*#include <dos.h>
  190. #define flStartCriticalSection(FLMutex) disable()
  191. #define flEndCriticalSection(FLMutex) enable()*/
  192. /* Memory allocation
  193. *
  194. * The translation layers (e.g. FTL) need to allocate memory to handle
  195. * Flash media. The size needed depends on the media being handled.
  196. *
  197. * You may choose to use the standard 'malloc' and 'free' to handle such
  198. * memory allocations, provide your own equivalent routines, or you may
  199. * choose not to define any memory allocation routine. In this case, the
  200. * memory will be allocated statically at compile-time on the assumption of
  201. * the largest media configuration you need to support. This is the simplest
  202. * choice, but may cause your RAM requirements to be larger than you
  203. * actually need.
  204. *
  205. * If you define routines other than malloc & free, they should have the
  206. * same parameters and return types as malloc & free. You should either code
  207. * these routines in flcustom.c or include them when you link your application.
  208. */
  209. #ifdef NT5PORT
  210. VOID * myMalloc(ULONG numberOfBytes);
  211. #define MALLOC myMalloc
  212. #define FREE ExFreePool
  213. /* Debug mode
  214. *
  215. * Uncomment the following lines if you want debug messages to be printed
  216. * out. Messages will be printed at initialization key points, and when
  217. * low-level errors occure.
  218. * You may choose to use 'printf' or provide your own routine.
  219. */
  220. #if DBG
  221. #define DEBUG_PRINT(str) DbgPrint(str)
  222. #else
  223. #define DEBUG_PRINT(str)
  224. #endif
  225. VOID startIntervalTimer(VOID);
  226. #define tffsReadByteFlash(r) READ_REGISTER_UCHAR((PUCHAR)r)
  227. #define tffsWriteByteFlash(r,b) WRITE_REGISTER_UCHAR((PUCHAR)r,(UCHAR)b)
  228. #define tffsReadWordFlash(r) READ_REGISTER_USHORT((PUSHORT)r)
  229. #define tffsWriteWordFlash(r,b) WRITE_REGISTER_USHORT((PUSHORT)r,(USHORT)b)
  230. #define tffsReadDwordFlash(r) READ_REGISTER_ULONG((PULONG)r)
  231. #define tffsWriteDwordFlash(r,b) WRITE_REGISTER_ULONG((PULONG)r,(ULONG)b)
  232. #define tffsReadByte(r) READ_REGISTER_UCHAR((PUCHAR)&(r))
  233. #define tffsWriteByte(r,b) WRITE_REGISTER_UCHAR((PUCHAR)&(r),b)
  234. #define tffsReadBuf(d,s,c) READ_REGISTER_BUFFER_UCHAR((PUCHAR)s,d,c)
  235. #define tffsWriteBuf(d,s,c) WRITE_REGISTER_BUFFER_UCHAR((PUCHAR)d,s,c)
  236. extern void PRINTF(
  237. char * Message,
  238. ...
  239. );
  240. #endif /* NT5PORT */
  241. #endif