fx_api.h 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538
  1. /***************************************************************************
  2. * Copyright (c) 2024 Microsoft Corporation
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the MIT License which is available at
  6. * https://opensource.org/licenses/MIT.
  7. *
  8. * SPDX-License-Identifier: MIT
  9. **************************************************************************/
  10. /**************************************************************************/
  11. /**************************************************************************/
  12. /** */
  13. /** FileX Component */
  14. /** */
  15. /** Application Interface */
  16. /** */
  17. /**************************************************************************/
  18. /**************************************************************************/
  19. /**************************************************************************/
  20. /* */
  21. /* APPLICATION INTERFACE DEFINITION RELEASE */
  22. /* */
  23. /* fx_api.h PORTABLE C */
  24. /* 6.4.0 */
  25. /* AUTHOR */
  26. /* */
  27. /* William E. Lamie, Microsoft Corporation */
  28. /* */
  29. /* DESCRIPTION */
  30. /* */
  31. /* This file defines the basic Application Interface (API) to the */
  32. /* high-performance FileX FAT compatible embedded file system. */
  33. /* All service prototypes and data structure definitions are defined */
  34. /* in this file. */
  35. /* */
  36. /* RELEASE HISTORY */
  37. /* */
  38. /* DATE NAME DESCRIPTION */
  39. /* */
  40. /* 05-19-2020 William E. Lamie Initial Version 6.0 */
  41. /* 09-30-2020 William E. Lamie Modified comment(s), and */
  42. /* updated product constants, */
  43. /* and added conditionals to */
  44. /* disable few declarations */
  45. /* for code size reduction, */
  46. /* resulting in version 6.1 */
  47. /* 11-09-2020 William E. Lamie Modified comment(s), */
  48. /* resulting in version 6.1.2 */
  49. /* 12-31-2020 William E. Lamie Modified comment(s), and */
  50. /* updated product constants, */
  51. /* resulting in version 6.1.3 */
  52. /* 03-02-2021 William E. Lamie Modified comment(s), and */
  53. /* added standalone support, */
  54. /* resulting in version 6.1.5 */
  55. /* 04-02-2021 William E. Lamie Modified comment(s), and */
  56. /* updated product constants, */
  57. /* resulting in version 6.1.6 */
  58. /* 06-02-2021 William E. Lamie Modified comment(s), and */
  59. /* updated product constants, */
  60. /* resulting in version 6.1.7 */
  61. /* 08-02-2021 William E. Lamie Modified comment(s), and */
  62. /* updated product constants, */
  63. /* resulting in version 6.1.8 */
  64. /* 01-31-2022 Bhupendra Naphade Modified comment(s), fixed */
  65. /* errors without cache, */
  66. /* resulting in version 6.1.10 */
  67. /* 04-25-2022 William E. Lamie Modified comment(s), and */
  68. /* updated product constants, */
  69. /* resulting in version 6.1.11 */
  70. /* 07-29-2022 William E. Lamie Modified comment(s), and */
  71. /* updated product constants, */
  72. /* resulting in version 6.1.12 */
  73. /* 10-31-2022 Xiuwen Cai Modified comment(s), and */
  74. /* updated product constants, */
  75. /* resulting in version 6.2.0 */
  76. /* 03-08-2023 Xiuwen Cai Modified comment(s), and */
  77. /* updated product constants, */
  78. /* resulting in version 6.2.1 */
  79. /* 10-31-2023 Xiuwen Cai Modified comment(s), and */
  80. /* updated product constants, */
  81. /* resulting in version 6.3.0 */
  82. /* 12-31-2023 Xiuwen Cai Modified comment(s), and */
  83. /* updated product constants, */
  84. /* resulting in version 6.4.0 */
  85. /* */
  86. /**************************************************************************/
  87. #ifndef FX_API_H
  88. #define FX_API_H
  89. /* Determine if a C++ compiler is being used. If so, ensure that standard
  90. C is used to process the API information. */
  91. #ifdef __cplusplus
  92. /* Yes, C++ compiler is present. Use standard C. */
  93. extern "C" {
  94. #endif
  95. /* Disable warning of parameter not used. */
  96. #ifndef FX_PARAMETER_NOT_USED
  97. #define FX_PARAMETER_NOT_USED(p) ((void)(p))
  98. #endif /* FX_PARAMETER_NOT_USED */
  99. /* Disable ThreadX error checking for internal FileX source code. */
  100. #ifdef FX_SOURCE_CODE
  101. #ifndef TX_DISABLE_ERROR_CHECKING
  102. #define TX_DISABLE_ERROR_CHECKING
  103. #endif
  104. #endif
  105. /* Include the FileX port-specific file. */
  106. #include "fx_port.h"
  107. /* Define compiler library include files */
  108. #ifdef FX_STANDALONE_ENABLE
  109. #include "string.h"
  110. #endif
  111. /* Define the major/minor version information that can be used by the application
  112. and the FileX source as well. */
  113. #define AZURE_RTOS_FILEX
  114. #define FILEX_MAJOR_VERSION 6
  115. #define FILEX_MINOR_VERSION 4
  116. #define FILEX_PATCH_VERSION 0
  117. /* Define the following symbols for backward compatibility */
  118. #define EL_PRODUCT_FILEX
  119. #ifdef FX_STANDALONE_ENABLE
  120. /* FileX will be used without Azure RTOS ThreadX */
  121. #ifndef FX_SINGLE_THREAD
  122. #define FX_SINGLE_THREAD
  123. #endif /* !FX_SINGLE_THREAD */
  124. /* FileX will be used with local path logic disabled */
  125. #ifndef FX_NO_LOCAL_PATH
  126. #define FX_NO_LOCAL_PATH
  127. #endif /* !FX_NO_LOCAL_PATH */
  128. /* FileX is built without update to the time parameters. */
  129. #ifndef FX_NO_TIMER
  130. #define FX_NO_TIMER
  131. #endif /* !FX_NO_TIMER */
  132. #endif
  133. /* Override the interrupt protection provided in FileX port files to simply use ThreadX protection,
  134. which is often in-line assembly. */
  135. #ifndef FX_LEGACY_INTERRUPT_PROTECTION
  136. #undef FX_INT_SAVE_AREA
  137. #undef FX_DISABLE_INTS
  138. #undef FX_RESTORE_INTS
  139. #define FX_INT_SAVE_AREA TX_INTERRUPT_SAVE_AREA
  140. #define FX_DISABLE_INTS TX_DISABLE
  141. #define FX_RESTORE_INTS TX_RESTORE
  142. #endif
  143. /* Define the update rate of the system timer. These values may also be defined at the command
  144. line when compiling the fx_system_initialize.c module in the FileX library build. Alternatively, they can
  145. be modified in this file. Note: the update rate must be an even number of seconds greater
  146. than or equal to 2, which is the minimal update rate for FAT time. */
  147. #ifndef FX_UPDATE_RATE_IN_SECONDS
  148. #define FX_UPDATE_RATE_IN_SECONDS 10 /* Update time at 10 second intervals */
  149. #endif
  150. #ifndef FX_UPDATE_RATE_IN_TICKS
  151. #define FX_UPDATE_RATE_IN_TICKS 1000 /* Same update rate, but in ticks */
  152. #endif
  153. /* Determine if fault tolerance is selected. If so, turn on the old fault tolerant options -
  154. if they are not defined already. */
  155. #ifdef FX_ENABLE_FAULT_TOLERANT
  156. #ifndef FX_FAULT_TOLERANT_DATA
  157. #define FX_FAULT_TOLERANT_DATA
  158. #endif
  159. #ifndef FX_FAULT_TOLERANT
  160. #define FX_FAULT_TOLERANT
  161. #endif
  162. #endif
  163. /* Determine if cache is disabled. If so, disable direct read sector cache. */
  164. #ifdef FX_DISABLE_CACHE
  165. #ifndef FX_DISABLE_DIRECT_DATA_READ_CACHE_FILL
  166. #define FX_DISABLE_DIRECT_DATA_READ_CACHE_FILL
  167. #endif
  168. #endif
  169. /* Determine if local paths are enabled and if the local path setup code has not been defined.
  170. If so, define the default local path setup code for files that reference the local path. */
  171. #ifndef FX_NO_LOCAL_PATH
  172. #ifndef FX_LOCAL_PATH_SETUP
  173. #ifndef FX_SINGLE_THREAD
  174. #define FX_LOCAL_PATH_SETUP extern TX_THREAD *_tx_thread_current_ptr;
  175. #else
  176. #define FX_NO_LOCAL_PATH
  177. #endif
  178. #endif
  179. #endif
  180. /* Determine if tracing is enabled. */
  181. #if defined(TX_ENABLE_EVENT_TRACE) && !defined(FX_STANDALONE_ENABLE)
  182. /* Trace is enabled. Remap calls so that interrupts can be disabled around the actual event logging. */
  183. #include "tx_trace.h"
  184. /* Define the object types in FileX, if not defined. */
  185. #ifndef FX_TRACE_OBJECT_TYPE_MEDIA
  186. #define FX_TRACE_OBJECT_TYPE_MEDIA 9 /* P1 = FAT cache size, P2 = sector cache size */
  187. #define FX_TRACE_OBJECT_TYPE_FILE 10 /* none */
  188. #endif
  189. /* Define event filters that can be used to selectively disable certain events or groups of events. */
  190. #define FX_TRACE_ALL_EVENTS 0x00007800 /* All FileX events */
  191. #define FX_TRACE_INTERNAL_EVENTS 0x00000800 /* FileX internal events */
  192. #define FX_TRACE_MEDIA_EVENTS 0x00001000 /* FileX media events */
  193. #define FX_TRACE_DIRECTORY_EVENTS 0x00002000 /* FileX directory events */
  194. #define FX_TRACE_FILE_EVENTS 0x00004000 /* FileX file events */
  195. /* Define the trace events in FileX, if not defined. */
  196. /* Define FileX Trace Events, along with a brief description of the additional information fields,
  197. where I1 -> Information Field 1, I2 -> Information Field 2, etc. */
  198. /* Define the FileX internal events first. */
  199. #ifndef FX_TRACE_INTERNAL_LOG_SECTOR_CACHE_MISS
  200. #define FX_TRACE_INTERNAL_LOG_SECTOR_CACHE_MISS 201 /* I1 = media ptr, I2 = sector, I3 = total misses, I4 = cache size */
  201. #define FX_TRACE_INTERNAL_DIR_CACHE_MISS 202 /* I1 = media ptr, I2 = total misses */
  202. #define FX_TRACE_INTERNAL_MEDIA_FLUSH 203 /* I1 = media ptr, I2 = dirty sectors */
  203. #define FX_TRACE_INTERNAL_DIR_ENTRY_READ 204 /* I1 = media ptr */
  204. #define FX_TRACE_INTERNAL_DIR_ENTRY_WRITE 205 /* I1 = media ptr */
  205. #define FX_TRACE_INTERNAL_IO_DRIVER_READ 206 /* I1 = media ptr, I2 = sector, I3 = number of sectors, I4 = buffer */
  206. #define FX_TRACE_INTERNAL_IO_DRIVER_WRITE 207 /* I1 = media ptr, I2 = sector, I3 = number of sectors, I4 = buffer */
  207. #define FX_TRACE_INTERNAL_IO_DRIVER_FLUSH 208 /* I1 = media ptr */
  208. #define FX_TRACE_INTERNAL_IO_DRIVER_ABORT 209 /* I1 = media ptr */
  209. #define FX_TRACE_INTERNAL_IO_DRIVER_INIT 210 /* I1 = media ptr */
  210. #define FX_TRACE_INTERNAL_IO_DRIVER_BOOT_READ 211 /* I1 = media ptr, I2 = buffer */
  211. #define FX_TRACE_INTERNAL_IO_DRIVER_RELEASE_SECTORS 212 /* I1 = media ptr, I2 = sector, I3 = number of sectors */
  212. #define FX_TRACE_INTERNAL_IO_DRIVER_BOOT_WRITE 213 /* I1 = media ptr, I2 = buffer */
  213. #define FX_TRACE_INTERNAL_IO_DRIVER_UNINIT 214 /* I1 = media ptr */
  214. /* Define the FileX API events. */
  215. #define FX_TRACE_DIRECTORY_ATTRIBUTES_READ 220 /* I1 = media ptr, I2 = directory name, I3 = attributes */
  216. #define FX_TRACE_DIRECTORY_ATTRIBUTES_SET 221 /* I1 = media ptr, I2 = directory name, I3 = attributes */
  217. #define FX_TRACE_DIRECTORY_CREATE 222 /* I1 = media ptr, I2 = directory name */
  218. #define FX_TRACE_DIRECTORY_DEFAULT_GET 223 /* I1 = media ptr, I2 = return path name */
  219. #define FX_TRACE_DIRECTORY_DEFAULT_SET 224 /* I1 = media ptr, I2 = new path name */
  220. #define FX_TRACE_DIRECTORY_DELETE 225 /* I1 = media ptr, I2 = directory name */
  221. #define FX_TRACE_DIRECTORY_FIRST_ENTRY_FIND 226 /* I1 = media ptr, I2 = directory name */
  222. #define FX_TRACE_DIRECTORY_FIRST_FULL_ENTRY_FIND 227 /* I1 = media ptr, I2 = directory name */
  223. #define FX_TRACE_DIRECTORY_INFORMATION_GET 228 /* I1 = media ptr, I2 = directory name */
  224. #define FX_TRACE_DIRECTORY_LOCAL_PATH_CLEAR 229 /* I1 = media ptr */
  225. #define FX_TRACE_DIRECTORY_LOCAL_PATH_GET 230 /* I1 = media ptr, I2 = return path name */
  226. #define FX_TRACE_DIRECTORY_LOCAL_PATH_RESTORE 231 /* I1 = media ptr, I2 = local path ptr */
  227. #define FX_TRACE_DIRECTORY_LOCAL_PATH_SET 232 /* I1 = media ptr, I2 = local path ptr, I3 = new path name */
  228. #define FX_TRACE_DIRECTORY_LONG_NAME_GET 233 /* I1 = media ptr, I2 = short file name, I3 = long file name */
  229. #define FX_TRACE_DIRECTORY_NAME_TEST 234 /* I1 = media ptr, I2 = directory name */
  230. #define FX_TRACE_DIRECTORY_NEXT_ENTRY_FIND 235 /* I1 = media ptr, I2 = directory name */
  231. #define FX_TRACE_DIRECTORY_NEXT_FULL_ENTRY_FIND 236 /* I1 = media ptr, I2 = directory name */
  232. #define FX_TRACE_DIRECTORY_RENAME 237 /* I1 = media ptr, I2 = old directory name, I3 = new directory name */
  233. #define FX_TRACE_DIRECTORY_SHORT_NAME_GET 238 /* I1 = media ptr, I2 = long file name, I3 = short file name */
  234. #define FX_TRACE_FILE_ALLOCATE 239 /* I1 = file ptr, I2 = size I3 = previous size, I4 = new size */
  235. #define FX_TRACE_FILE_ATTRIBUTES_READ 240 /* I1 = media ptr, I2 = file name, I3 = attributes */
  236. #define FX_TRACE_FILE_ATTRIBUTES_SET 241 /* I1 = media ptr, I2 = file name, I3 = attributes */
  237. #define FX_TRACE_FILE_BEST_EFFORT_ALLOCATE 242 /* I1 = file ptr, I2 = size, I3 = actual_size_allocated */
  238. #define FX_TRACE_FILE_CLOSE 243 /* I1 = file ptr, I3 = file size */
  239. #define FX_TRACE_FILE_CREATE 244 /* I1 = media ptr, I2 = file name */
  240. #define FX_TRACE_FILE_DATE_TIME_SET 245 /* I1 = media ptr, I2 = file name, I3 = year, I4 = month */
  241. #define FX_TRACE_FILE_DELETE 246 /* I1 = media ptr, I2 = file name */
  242. #define FX_TRACE_FILE_OPEN 247 /* I1 = media ptr, I2 = file ptr, I3 = file name, I4 = open type */
  243. #define FX_TRACE_FILE_READ 248 /* I1 = file ptr, I2 = buffer ptr, I3 = request size I4 = actual size */
  244. #define FX_TRACE_FILE_RELATIVE_SEEK 249 /* I1 = file ptr, I2 = byte offset, I3 = seek from, I4 = previous offset */
  245. #define FX_TRACE_FILE_RENAME 250 /* I1 = media ptr, I2 = old file name, I3 = new file name */
  246. #define FX_TRACE_FILE_SEEK 251 /* I1 = file ptr, I2 = byte offset, I3 = previous offset */
  247. #define FX_TRACE_FILE_TRUNCATE 252 /* I1 = file ptr, I2 = size, I3 = previous size, I4 = new size */
  248. #define FX_TRACE_FILE_TRUNCATE_RELEASE 253 /* I1 = file ptr, I2 = size, I3 = previous size, I4 = new size */
  249. #define FX_TRACE_FILE_WRITE 254 /* I1 = file ptr, I2 = buffer ptr, I3 = size, I4 = bytes written */
  250. #define FX_TRACE_MEDIA_ABORT 255 /* I1 = media ptr */
  251. #define FX_TRACE_MEDIA_CACHE_INVALIDATE 256 /* I1 = media ptr */
  252. #define FX_TRACE_MEDIA_CHECK 257 /* I1 = media ptr, I2 = scratch memory, I3 = scratch memory size, I4 =errors*/
  253. #define FX_TRACE_MEDIA_CLOSE 258 /* I1 = media ptr */
  254. #define FX_TRACE_MEDIA_FLUSH 259 /* I1 = media ptr */
  255. #define FX_TRACE_MEDIA_FORMAT 260 /* I1 = media ptr, I2 = root entries, I3 = sectors, I4 = sectors per cluster*/
  256. #define FX_TRACE_MEDIA_OPEN 261 /* I1 = media ptr, I2 = media driver, I3 = memory ptr, I4 = memory size */
  257. #define FX_TRACE_MEDIA_READ 262 /* I1 = media ptr, I2 = logical sector, I3 = buffer ptr, I4 = bytes read */
  258. #define FX_TRACE_MEDIA_SPACE_AVAILABLE 263 /* I1 = media ptr, I2 = available bytes ptr, I3 = available clusters */
  259. #define FX_TRACE_MEDIA_VOLUME_GET 264 /* I1 = media ptr, I2 = volume name, I3 = volume source */
  260. #define FX_TRACE_MEDIA_VOLUME_SET 265 /* I1 = media ptr, I2 = volume name */
  261. #define FX_TRACE_MEDIA_WRITE 266 /* I1 = media ptr, I2 = logical_sector, I3 = buffer_ptr, I4 = byte written */
  262. #define FX_TRACE_SYSTEM_DATE_GET 267 /* I1 = year, I2 = month, I3 = day */
  263. #define FX_TRACE_SYSTEM_DATE_SET 268 /* I1 = year, I2 = month, I3 = day */
  264. #define FX_TRACE_SYSTEM_INITIALIZE 269 /* None */
  265. #define FX_TRACE_SYSTEM_TIME_GET 270 /* I1 = hour, I2 = minute, I3 = second */
  266. #define FX_TRACE_SYSTEM_TIME_SET 271 /* I1 = hour, I2 = minute, I3 = second */
  267. #define FX_TRACE_UNICODE_DIRECTORY_CREATE 272 /* I1 = media ptr, I2 = source unicode, I3 = source length, I4 = short_name */
  268. #define FX_TRACE_UNICODE_DIRECTORY_RENAME 273 /* I1 = media ptr, I2 = source unicode, I3 = source length, I4 = new_name */
  269. #define FX_TRACE_UNICODE_FILE_CREATE 274 /* I1 = media ptr, I2 = source unicode, I3 = source length, I4 = short name */
  270. #define FX_TRACE_UNICODE_FILE_RENAME 275 /* I1 = media ptr, I2 = source unicode, I3 = source length, I4 = new name */
  271. #define FX_TRACE_UNICODE_LENGTH_GET 276 /* I1 = unicode name, I2 = length */
  272. #define FX_TRACE_UNICODE_NAME_GET 277 /* I1 = media ptr, I2 = source short name, I3 = unicode name, I4 = length */
  273. #define FX_TRACE_UNICODE_SHORT_NAME_GET 278 /* I1 = media ptr, I2 = source unicode name, I3 = length, I4 = short name */
  274. #endif
  275. /* Map the trace macros to internal FileX versions so we can get interrupt protection. */
  276. #ifdef FX_SOURCE_CODE
  277. #define FX_TRACE_OBJECT_REGISTER(t, p, n, a, b) _fx_trace_object_register(t, (VOID *)p, (CHAR *)n, (ULONG)a, (ULONG)b);
  278. #define FX_TRACE_OBJECT_UNREGISTER(o) _fx_trace_object_unregister((VOID *)o);
  279. #define FX_TRACE_IN_LINE_INSERT(i, a, b, c, d, f, g, h) _fx_trace_event_insert((ULONG)i, (ULONG)a, (ULONG)b, (ULONG)c, (ULONG)d, (ULONG)f, g, h);
  280. #define FX_TRACE_EVENT_UPDATE(e, t, i, a, b, c, d) _fx_trace_event_update((TX_TRACE_BUFFER_ENTRY *)e, (ULONG)t, (ULONG)i, (ULONG)a, (ULONG)b, (ULONG)c, (ULONG)d);
  281. /* Define FileX trace prototypes. */
  282. VOID _fx_trace_object_register(UCHAR object_type, VOID *object_ptr, CHAR *object_name, ULONG parameter_1, ULONG parameter_2);
  283. VOID _fx_trace_object_unregister(VOID *object_ptr);
  284. VOID _fx_trace_event_insert(ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4, ULONG filter, TX_TRACE_BUFFER_ENTRY **current_event, ULONG *current_timestamp);
  285. VOID _fx_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4);
  286. #endif
  287. #else
  288. #define FX_TRACE_OBJECT_REGISTER(t, p, n, a, b)
  289. #define FX_TRACE_OBJECT_UNREGISTER(o)
  290. #define FX_TRACE_IN_LINE_INSERT(i, a, b, c, d, f, g, h)
  291. #define FX_TRACE_EVENT_UPDATE(e, t, i, a, b, c, d)
  292. #endif
  293. /* Define basic constants for FileX. */
  294. #define FX_MEDIA_ID ((ULONG)0x4D454449)
  295. #define FX_MEDIA_CLOSED_ID ((ULONG)0x4D454443)
  296. #define FX_MEDIA_ABORTED_ID ((ULONG)0x4D454441)
  297. #define FX_FILE_ID ((ULONG)0x46494C45)
  298. #define FX_FILE_CLOSED_ID ((ULONG)0x46494C43)
  299. #define FX_FILE_ABORTED_ID ((ULONG)0x46494C41)
  300. /* The maximum path includes the entire path and the file name. */
  301. #ifndef FX_MAXIMUM_PATH
  302. #define FX_MAXIMUM_PATH 256
  303. #endif
  304. /* Define directory entry name sizes. Directory entries are found in the
  305. root directory and in directory files (sub-directories). Each directory
  306. entry has a short file name which is a fixed maximum of 13 characters and
  307. and optional 255 character long file name. */
  308. #ifndef FX_MAX_LONG_NAME_LEN
  309. #define FX_MAX_LONG_NAME_LEN 256 /* Minimum value is 13, Maximum value is 256. */
  310. #endif
  311. #define FX_MAX_SHORT_NAME_LEN 13 /* Only allowed value is 13. */
  312. #ifndef FX_MAX_LAST_NAME_LEN
  313. #define FX_MAX_LAST_NAME_LEN 256 /* Should be as large or larger than FX_MAX_LONG_NAME_LEN. */
  314. #endif
  315. /* Define constants related to the logical sector cache. These constants represent the maximum
  316. number of logical sectors that can be cached. The actual number of logical sectors in the
  317. cache is determined by the amount of memory supplied to fx_media_open for the FX_MEDIA
  318. instance. */
  319. #ifndef FX_MAX_SECTOR_CACHE
  320. #define FX_MAX_SECTOR_CACHE 256 /* Maximum size of logical sector cache,
  321. minimum value of 2 all other values must
  322. be a power of 2. */
  323. #endif
  324. /* Define the mask for the hash index into the logical sector cache. If the logical sector cache
  325. determined by the amount of memory supplied by the application to fx_media_open is larger than
  326. FX_SECTOR_CACHE_HASH_ENABLE (usually 16) and can satisfy FX_MAX_SECTOR_CACHE sectors, the cache
  327. is divided into 4 entry pieces (FX_SECTOR_CACHE_DEPTH) that are indexed by the formula:
  328. index = (cluster & media_ptr -> fx_media_sector_cache_hash_mask) * FX_SECTOR_CACHE_LEVELS
  329. The FX_SECTOR_CACHE_DEPTH define must not be changed unless the logical sector read/write
  330. code is also changed. */
  331. #define FX_SECTOR_CACHE_HASH_ENABLE 16
  332. #define FX_SECTOR_CACHE_DEPTH 4
  333. #ifndef FX_FAT_MAP_SIZE
  334. #define FX_FAT_MAP_SIZE 128 /* Minimum 1, maximum any. This represents how many 32-bit words used for the written FAT sector bit map. */
  335. #endif
  336. #ifndef FX_MAX_FAT_CACHE
  337. #define FX_MAX_FAT_CACHE 16 /* Minimum value is 8, all values must be a power of 2. */
  338. #endif
  339. /* Define the size of fault tolerant cache, which is used when freeing FAT chain. */
  340. #ifndef FX_FAULT_TOLERANT_CACHE_SIZE
  341. #define FX_FAULT_TOLERANT_CACHE_SIZE 1024
  342. #endif /* FX_FAULT_TOLERANT_CACHE_SIZE */
  343. /* Define the mask for the hash index into the FAT table. The FAT cache is divided into 4 entry pieces
  344. that are indexed by the formula:
  345. index = (cluster & FX_FAT_CACHE_HASH_MASK) * FX_FAT_CACHE_LEVELS
  346. The FX_FAT_CACHE_DEPTH define must not be changed unless the FAT entry read/write code is also changed. */
  347. #define FX_FAT_CACHE_DEPTH 4
  348. #define FX_FAT_CACHE_HASH_MASK ((FX_MAX_FAT_CACHE / FX_FAT_CACHE_DEPTH) - 1)
  349. /* FileX API input parameters and general constants. */
  350. #define FX_TRUE 1
  351. #define FX_FALSE 0
  352. #define FX_NULL 0
  353. #define FX_OPEN_FOR_READ 0
  354. #define FX_OPEN_FOR_WRITE 1
  355. #define FX_OPEN_FOR_READ_FAST 2
  356. #define FX_12_BIT_FAT_SIZE 4086
  357. #define FX_16_BIT_FAT_SIZE 65525
  358. #define FX_MAX_12BIT_CLUST 0x0FF0
  359. #define FX_SIGN_EXTEND 0xF000
  360. #define FX_12BIT_SIZE 3 /* 2 FAT entries per 3 bytes */
  361. #define FX_FAT_ENTRY_START 2
  362. #define FX_DIR_ENTRY_SIZE 32
  363. #define FX_DIR_NAME_SIZE 8
  364. #define FX_DIR_EXT_SIZE 3
  365. #define FX_DIR_RESERVED 8
  366. #define FX_DIR_ENTRY_FREE 0xE5
  367. #define FX_DIR_ENTRY_DONE 0x00
  368. #define FX_READ_ONLY 0x01
  369. #define FX_HIDDEN 0x02
  370. #define FX_SYSTEM 0x04
  371. #define FX_VOLUME 0x08
  372. #define FX_DIRECTORY 0x10
  373. #define FX_ARCHIVE 0x20
  374. #define FX_LONG_NAME (FX_READ_ONLY | FX_HIDDEN | FX_SYSTEM | FX_VOLUME)
  375. #define FX_LONG_NAME_ENTRY_LEN 13
  376. /* Define FAT FAT entry values. */
  377. #define FX_FREE_CLUSTER 0x0000
  378. #define FX_NOT_USED 0x0001
  379. #define FX_RESERVED_1 0xFFF0
  380. #define FX_RESERVED_2 0xFFF6
  381. #define FX_BAD_CLUSTER 0xFFF7
  382. #define FX_LAST_CLUSTER_1 0xFFF8
  383. #define FX_LAST_CLUSTER_2 0xFFFF
  384. #define FX_RESERVED_1_32 0x0FFFFFF0
  385. #define FX_RESERVED_2_32 0x0FFFFFF6
  386. #define FX_BAD_CLUSTER_32 0x0FFFFFF7
  387. #define FX_LAST_CLUSTER_1_32 0x0FFFFFF8
  388. #define FX_LAST_CLUSTER_2_32 0x0FFFFFFF
  389. /* Define time/date FAT constants. */
  390. #define FX_YEAR_SHIFT 9
  391. #define FX_MONTH_SHIFT 5
  392. #define FX_HOUR_SHIFT 11
  393. #define FX_MINUTE_SHIFT 5
  394. #define FX_YEAR_MASK 0x7F
  395. #define FX_MONTH_MASK 0x0F
  396. #define FX_DAY_MASK 0x1F
  397. #define FX_HOUR_MASK 0x1F
  398. #define FX_MINUTE_MASK 0x3F
  399. #define FX_SECOND_MASK 0x1F
  400. #define FX_BASE_YEAR 1980
  401. #define FX_MAXIMUM_YEAR 2107
  402. #define FX_MAXIMUM_MONTH 12
  403. #define FX_MAXIMUM_HOUR 23
  404. #define FX_MAXIMUM_MINUTE 59
  405. #define FX_MAXIMUM_SECOND 59
  406. #define FX_INITIAL_DATE 0x4A21 /* 01-01-2017 */
  407. #define FX_INITIAL_TIME 0x0000 /* 12:00 am */
  408. /* FileX API return values. */
  409. #define FX_SUCCESS 0x00
  410. #define FX_BOOT_ERROR 0x01
  411. #define FX_MEDIA_INVALID 0x02
  412. #define FX_FAT_READ_ERROR 0x03
  413. #define FX_NOT_FOUND 0x04
  414. #define FX_NOT_A_FILE 0x05
  415. #define FX_ACCESS_ERROR 0x06
  416. #define FX_NOT_OPEN 0x07
  417. #define FX_FILE_CORRUPT 0x08
  418. #define FX_END_OF_FILE 0x09
  419. #define FX_NO_MORE_SPACE 0x0A
  420. #define FX_ALREADY_CREATED 0x0B
  421. #define FX_INVALID_NAME 0x0C
  422. #define FX_INVALID_PATH 0x0D
  423. #define FX_NOT_DIRECTORY 0x0E
  424. #define FX_NO_MORE_ENTRIES 0x0F
  425. #define FX_DIR_NOT_EMPTY 0x10
  426. #define FX_MEDIA_NOT_OPEN 0x11
  427. #define FX_INVALID_YEAR 0x12
  428. #define FX_INVALID_MONTH 0x13
  429. #define FX_INVALID_DAY 0x14
  430. #define FX_INVALID_HOUR 0x15
  431. #define FX_INVALID_MINUTE 0x16
  432. #define FX_INVALID_SECOND 0x17
  433. #define FX_PTR_ERROR 0x18
  434. #define FX_INVALID_ATTR 0x19
  435. #define FX_CALLER_ERROR 0x20
  436. #define FX_BUFFER_ERROR 0x21
  437. #define FX_NOT_IMPLEMENTED 0x22
  438. #define FX_WRITE_PROTECT 0x23
  439. #define FX_INVALID_OPTION 0x24
  440. #define FX_SECTOR_INVALID 0x89
  441. #define FX_IO_ERROR 0x90
  442. #define FX_NOT_ENOUGH_MEMORY 0x91
  443. #define FX_ERROR_FIXED 0x92
  444. #define FX_ERROR_NOT_FIXED 0x93
  445. #define FX_NOT_AVAILABLE 0x94
  446. #define FX_INVALID_CHECKSUM 0x95
  447. #define FX_READ_CONTINUE 0x96
  448. #define FX_INVALID_STATE 0x97
  449. /* FileX driver interface constants. */
  450. #define FX_DRIVER_READ 0
  451. #define FX_DRIVER_WRITE 1
  452. #define FX_DRIVER_FLUSH 2
  453. #define FX_DRIVER_ABORT 3
  454. #define FX_DRIVER_INIT 4
  455. #define FX_DRIVER_BOOT_READ 5
  456. #define FX_DRIVER_RELEASE_SECTORS 6
  457. #define FX_DRIVER_BOOT_WRITE 7
  458. #define FX_DRIVER_UNINIT 8
  459. /* Define relative seek constants. */
  460. #define FX_SEEK_BEGIN 0
  461. #define FX_SEEK_END 1
  462. #define FX_SEEK_FORWARD 2
  463. #define FX_SEEK_BACK 3
  464. /* Define types for logical sectors. This information is passed to the driver
  465. as additional information. */
  466. #define FX_UNKNOWN_SECTOR 0
  467. #define FX_BOOT_SECTOR 1
  468. #define FX_FAT_SECTOR 2
  469. #define FX_DIRECTORY_SECTOR 3
  470. #define FX_DATA_SECTOR 4
  471. /* Define media diagnostic constants. */
  472. #define FX_FAT_CHAIN_ERROR 0x01
  473. #define FX_DIRECTORY_ERROR 0x02
  474. #define FX_LOST_CLUSTER_ERROR 0x04
  475. #define FX_FILE_SIZE_ERROR 0x08
  476. /* Define boot record offset constants. */
  477. #define FX_JUMP_INSTR 0x000
  478. #define FX_OEM_NAME 0x003
  479. #define FX_BYTES_SECTOR 0x00B
  480. #define FX_SECTORS_CLUSTER 0x00D
  481. #define FX_RESERVED_SECTORS 0x00E
  482. #define FX_NUMBER_OF_FATS 0x010
  483. #define FX_ROOT_DIR_ENTRIES 0x011
  484. #define FX_SECTORS 0x013
  485. #define FX_MEDIA_TYPE 0x015
  486. #define FX_SECTORS_PER_FAT 0x016
  487. #define FX_SECTORS_PER_TRK 0x018
  488. #define FX_HEADS 0x01A
  489. #define FX_HIDDEN_SECTORS 0x01C
  490. #define FX_HUGE_SECTORS 0x020
  491. #define FX_DRIVE_NUMBER 0x024
  492. #define FX_RESERVED 0x025
  493. #define FX_BOOT_SIG 0x026
  494. #define FX_BOOT_SIG_32 0x042
  495. #define FX_VOLUME_ID 0x027
  496. #define FX_VOLUME_ID_32 0x043
  497. #define FX_VOLUME_LABEL 0x02B
  498. #define FX_VOLUME_LABEL_32 0x047
  499. #define FX_FILE_SYSTEM_TYPE 0x036
  500. #define FX_SIG_OFFSET 0x1FE
  501. #define FX_ROOT_CLUSTER_32 0x02C
  502. #define FX_SECTORS_PER_FAT_32 0x024
  503. #define FX_SIG_BYTE_1 0x55
  504. #define FX_SIG_BYTE_2 0xAA
  505. /* If not-defined, default port-specific processing extensions to white space. */
  506. #ifndef FX_FILE_OPEN_EXTENSION
  507. #define FX_FILE_OPEN_EXTENSION
  508. #endif
  509. #ifndef FX_DIRECTORY_ENTRY_READ_EXTENSION
  510. #define FX_DIRECTORY_ENTRY_READ_EXTENSION
  511. #endif
  512. #ifndef FX_DIRECTORY_ENTRY_WRITE_EXTENSION
  513. #define FX_DIRECTORY_ENTRY_WRITE_EXTENSION
  514. #endif
  515. #ifndef FX_UTILITY_FAT_ENTRY_READ_EXTENSION
  516. #define FX_UTILITY_FAT_ENTRY_READ_EXTENSION
  517. #endif
  518. #ifndef FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION
  519. #define FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION
  520. #endif
  521. #ifndef FX_UTILITY_LOGICAL_SECTOR_FLUSH_EXTENSION
  522. #define FX_UTILITY_LOGICAL_SECTOR_FLUSH_EXTENSION
  523. #endif
  524. #ifndef FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION
  525. #define FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION
  526. #endif
  527. #ifndef FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION_1
  528. #define FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION_1
  529. #endif
  530. #ifndef FX_UTILITY_LOGICAL_SECTOR_WRITE_EXTENSION
  531. #define FX_UTILITY_LOGICAL_SECTOR_WRITE_EXTENSION
  532. #endif
  533. /* Define the control block definitions for all system objects. */
  534. /* Define a single entry in the FAT cache. The FAT cache is used to reduce the
  535. number of times the actual FAT sectors need to be accessed, thereby improving
  536. performance. */
  537. typedef struct FX_FAT_CACHE_ENTRY_STRUCT
  538. {
  539. ULONG fx_fat_cache_entry_cluster;
  540. ULONG fx_fat_cache_entry_value;
  541. ULONG fx_fat_cache_entry_dirty;
  542. } FX_FAT_CACHE_ENTRY;
  543. /* Define the directory entry structure that contains information about a specific
  544. directory entry. */
  545. typedef struct FX_DIR_ENTRY_STRUCT
  546. {
  547. CHAR *fx_dir_entry_name;
  548. CHAR fx_dir_entry_short_name[FX_MAX_SHORT_NAME_LEN]; /* Short file name, if LFN is present */
  549. UINT fx_dir_entry_long_name_present; /* 0 (default) => LFN not present; 1 => LFN present */
  550. UINT fx_dir_entry_long_name_shorted; /* LFN too large, file name was made shorter */
  551. UCHAR fx_dir_entry_attributes; /* Directory entry attributes */
  552. UCHAR fx_dir_entry_reserved; /* NT reserved, write 0 at create, otherwise ignore */
  553. UCHAR fx_dir_entry_created_time_ms; /* Create time in milliseconds, always write 0 */
  554. UINT fx_dir_entry_created_time; /* Created time */
  555. UINT fx_dir_entry_created_date; /* Created date */
  556. UINT fx_dir_entry_last_accessed_date; /* Last accessed date */
  557. UINT fx_dir_entry_time; /* Modified time */
  558. UINT fx_dir_entry_date; /* Modified cluster */
  559. ULONG fx_dir_entry_cluster; /* File/directory's starting cluster */
  560. ULONG64 fx_dir_entry_file_size; /* Size of the file in bytes */
  561. ULONG64 fx_dir_entry_log_sector; /* Logical sector of this directory entry */
  562. ULONG fx_dir_entry_byte_offset; /* Offset in logical sector of this directory entry */
  563. ULONG fx_dir_entry_number; /* Index into the directory */
  564. ULONG fx_dir_entry_last_search_cluster; /* Last cluster searched */
  565. ULONG fx_dir_entry_last_search_relative_cluster; /* Last relative cluster searched */
  566. ULONG64 fx_dir_entry_last_search_log_sector; /* Last logical sector searched */
  567. ULONG fx_dir_entry_last_search_byte_offset; /* Last offset in logical sector searched */
  568. ULONG64 fx_dir_entry_next_log_sector;
  569. } FX_DIR_ENTRY;
  570. typedef FX_DIR_ENTRY *FX_DIR_ENTRY_PTR;
  571. /* Define the path data structure. This structure will contain
  572. the current path and the information for performing directory
  573. entry operations. */
  574. typedef struct FX_PATH_STRUCT
  575. {
  576. /* Define the path information. */
  577. FX_DIR_ENTRY fx_path_directory;
  578. CHAR fx_path_string[FX_MAXIMUM_PATH];
  579. CHAR fx_path_name_buffer[FX_MAX_LONG_NAME_LEN];
  580. ULONG fx_path_current_entry;
  581. } FX_PATH;
  582. typedef FX_PATH FX_LOCAL_PATH;
  583. /* Define the cache control data structure. There are FX_MAX_SECTOR_CACHE
  584. of these structures defined inside the FX_MEDIA structure. Each entry
  585. maintains a cache representation of a media sector. */
  586. typedef struct FX_CACHED_SECTOR_STRUCT
  587. {
  588. /* Define the buffer pointer associated with this cache entry. */
  589. UCHAR *fx_cached_sector_memory_buffer;
  590. /* Define the sector number that is cached. */
  591. ULONG64 fx_cached_sector;
  592. /* Define the flag that indicates whether or not the cached sector
  593. has been modified and needs to be written to the media. */
  594. UCHAR fx_cached_sector_buffer_dirty;
  595. /* Define the valid flag that indicates whether or not this entry is
  596. still valid. */
  597. UCHAR fx_cached_sector_valid;
  598. /* Define the sector type, which indicates what type of sector is present. */
  599. UCHAR fx_cached_sector_type;
  600. /* Define a reserved byte, reserved for future use. */
  601. UCHAR fx_cached_sector_reserved;
  602. /* Define the next cached sector pointer. This is used to implement
  603. the "last used" algorithm when looking for cache entry to swap out to
  604. the physical media. */
  605. struct FX_CACHED_SECTOR_STRUCT
  606. *fx_cached_sector_next_used;
  607. } FX_CACHED_SECTOR;
  608. /* Determine if the media control block has an extension defined. If not,
  609. define the extension to whitespace. */
  610. #ifndef FX_MEDIA_MODULE_EXTENSION
  611. #define FX_MEDIA_MODULE_EXTENSION
  612. #endif
  613. /* Define the media control block. All information about each open
  614. media device are maintained in by the FX_MEDIA data type. */
  615. typedef struct FX_MEDIA_STRUCT
  616. {
  617. /* Define the media ID used for error checking. */
  618. ULONG fx_media_id;
  619. /* Define the media's name. */
  620. CHAR *fx_media_name;
  621. /* Remember the memory buffer area. */
  622. UCHAR *fx_media_memory_buffer;
  623. ULONG fx_media_memory_size;
  624. #ifdef FX_DISABLE_CACHE
  625. ULONG64 fx_media_memory_buffer_sector;
  626. #else
  627. /* Define the flag that indicates whether the logical cache utilizes
  628. a hash function or is a linear search. If set, the logical cache
  629. is accessed via a hash function on the requested sector. */
  630. UINT fx_media_sector_cache_hashed;
  631. /* Define the number of sectors that can actually be cached based on the
  632. user supplied buffer at media open time. */
  633. ULONG fx_media_sector_cache_size;
  634. /* Define the end of the cache area. This is used to determine
  635. if the I/O is for the internal memory of the media. */
  636. UCHAR *fx_media_sector_cache_end;
  637. /* Define the list head of the cached sector entries. This
  638. pointer points to the most recently used cache sector. */
  639. struct FX_CACHED_SECTOR_STRUCT
  640. *fx_media_sector_cache_list_ptr;
  641. /* Define the bit map that represents the hashed cache sectors that are
  642. valid. This bit map will help optimize the invalidation of the hashed
  643. sector cache. */
  644. ULONG fx_media_sector_cache_hashed_sector_valid;
  645. /* Define the outstanding dirty sector counter. This is used to optimize
  646. the searching of sectors to flush to the media. */
  647. ULONG fx_media_sector_cache_dirty_count;
  648. #endif /* FX_DISABLE_CACHE */
  649. /* Define the basic information about the associated media. */
  650. UINT fx_media_bytes_per_sector;
  651. UINT fx_media_sectors_per_track;
  652. UINT fx_media_heads;
  653. ULONG64 fx_media_total_sectors;
  654. ULONG fx_media_total_clusters;
  655. UINT fx_media_reserved_sectors;
  656. UINT fx_media_root_sector_start;
  657. UINT fx_media_root_sectors;
  658. UINT fx_media_data_sector_start;
  659. UINT fx_media_sectors_per_cluster;
  660. UINT fx_media_sectors_per_FAT;
  661. UINT fx_media_number_of_FATs;
  662. UINT fx_media_12_bit_FAT;
  663. UINT fx_media_32_bit_FAT;
  664. ULONG fx_media_FAT32_additional_info_sector;
  665. UINT fx_media_FAT32_additional_info_last_available;
  666. #ifdef FX_DRIVER_USE_64BIT_LBA
  667. ULONG64 fx_media_hidden_sectors;
  668. #else
  669. ULONG fx_media_hidden_sectors;
  670. #endif
  671. ULONG fx_media_root_cluster_32;
  672. UINT fx_media_root_directory_entries;
  673. ULONG fx_media_available_clusters;
  674. ULONG fx_media_cluster_search_start;
  675. /* Define the information pertinent to the I/O driver interface. */
  676. VOID *fx_media_driver_info;
  677. UINT fx_media_driver_request;
  678. UINT fx_media_driver_status;
  679. UCHAR *fx_media_driver_buffer;
  680. #ifdef FX_DRIVER_USE_64BIT_LBA
  681. ULONG64 fx_media_driver_logical_sector;
  682. #else
  683. ULONG fx_media_driver_logical_sector;
  684. #endif
  685. ULONG fx_media_driver_sectors;
  686. ULONG fx_media_driver_physical_sector;
  687. UINT fx_media_driver_physical_track;
  688. UINT fx_media_driver_physical_head;
  689. UINT fx_media_driver_write_protect; /* The driver sets this to FX_TRUE when media is write protected. */
  690. UINT fx_media_driver_free_sector_update; /* The driver sets this to FX_TRUE when it needs to know freed clusters. */
  691. UINT fx_media_driver_system_write;
  692. UINT fx_media_driver_data_sector_read;
  693. UINT fx_media_driver_sector_type;
  694. /* Define the driver entry point. */
  695. VOID (*fx_media_driver_entry)(struct FX_MEDIA_STRUCT *);
  696. /* Define notify function called when media is open. */
  697. VOID (*fx_media_open_notify)(struct FX_MEDIA_STRUCT *);
  698. /* Define notify function called when media is closed. */
  699. VOID (*fx_media_close_notify)(struct FX_MEDIA_STRUCT *);
  700. /* Define the head pointer for the open files of this media. */
  701. struct FX_FILE_STRUCT
  702. *fx_media_opened_file_list;
  703. /* Define the counter for keeping track of how many open files are
  704. present. */
  705. ULONG fx_media_opened_file_count;
  706. /* Define the next and previous link pointers for the open media list. */
  707. struct FX_MEDIA_STRUCT
  708. *fx_media_opened_next,
  709. *fx_media_opened_previous;
  710. #ifndef FX_MEDIA_STATISTICS_DISABLE
  711. /* Define various statistics for this media instance. This information
  712. should be useful in performance tuning and optimizing the application. */
  713. ULONG fx_media_directory_attributes_reads;
  714. ULONG fx_media_directory_attributes_sets;
  715. ULONG fx_media_directory_creates;
  716. ULONG fx_media_directory_default_gets;
  717. ULONG fx_media_directory_default_sets;
  718. ULONG fx_media_directory_deletes;
  719. ULONG fx_media_directory_first_entry_finds;
  720. ULONG fx_media_directory_first_full_entry_finds;
  721. ULONG fx_media_directory_information_gets;
  722. ULONG fx_media_directory_local_path_clears;
  723. ULONG fx_media_directory_local_path_gets;
  724. ULONG fx_media_directory_local_path_restores;
  725. ULONG fx_media_directory_local_path_sets;
  726. ULONG fx_media_directory_name_tests;
  727. ULONG fx_media_directory_next_entry_finds;
  728. ULONG fx_media_directory_next_full_entry_finds;
  729. ULONG fx_media_directory_renames;
  730. ULONG fx_media_file_allocates;
  731. ULONG fx_media_file_attributes_reads;
  732. ULONG fx_media_file_attributes_sets;
  733. ULONG fx_media_file_best_effort_allocates;
  734. ULONG fx_media_file_closes;
  735. ULONG fx_media_file_creates;
  736. ULONG fx_media_file_deletes;
  737. ULONG fx_media_file_opens;
  738. ULONG fx_media_file_reads;
  739. ULONG fx_media_file_relative_seeks;
  740. ULONG fx_media_file_renames;
  741. ULONG fx_media_file_seeks;
  742. ULONG fx_media_file_truncates;
  743. ULONG fx_media_file_truncate_releases;
  744. ULONG fx_media_file_writes;
  745. ULONG fx_media_aborts;
  746. ULONG fx_media_flushes;
  747. ULONG fx_media_reads;
  748. ULONG fx_media_writes;
  749. ULONG fx_media_directory_entry_reads;
  750. ULONG fx_media_directory_entry_writes;
  751. ULONG fx_media_directory_searches;
  752. ULONG fx_media_directory_free_searches;
  753. ULONG fx_media_fat_entry_reads;
  754. ULONG fx_media_fat_entry_writes;
  755. ULONG fx_media_fat_entry_cache_read_hits;
  756. ULONG fx_media_fat_entry_cache_read_misses;
  757. ULONG fx_media_fat_entry_cache_write_hits;
  758. ULONG fx_media_fat_entry_cache_write_misses;
  759. ULONG fx_media_fat_cache_flushes;
  760. ULONG fx_media_fat_sector_reads;
  761. ULONG fx_media_fat_sector_writes;
  762. ULONG fx_media_logical_sector_reads;
  763. ULONG fx_media_logical_sector_writes;
  764. ULONG fx_media_logical_sector_cache_read_hits;
  765. ULONG fx_media_logical_sector_cache_read_misses;
  766. ULONG fx_media_driver_read_requests;
  767. ULONG fx_media_driver_write_requests;
  768. ULONG fx_media_driver_boot_read_requests;
  769. ULONG fx_media_driver_boot_write_requests;
  770. ULONG fx_media_driver_release_sectors_requests;
  771. ULONG fx_media_driver_flush_requests;
  772. #ifndef FX_MEDIA_DISABLE_SEARCH_CACHE
  773. ULONG fx_media_directory_search_cache_hits;
  774. #endif
  775. #endif
  776. /* Define the media's protection object, which is a ThreadX mutex.
  777. Only one thread is allowed to access any media or associated files
  778. at a time. If FX_SINGLE_THREAD is defined, the FileX services are
  779. going to be called from only one thread, hence the protection is
  780. not needed. */
  781. #ifndef FX_SINGLE_THREAD
  782. TX_MUTEX fx_media_protect;
  783. #endif
  784. #ifndef FX_MEDIA_DISABLE_SEARCH_CACHE
  785. /* Define the information used to remember the last directory entry found through
  786. searching or walking the directory via directory entry next. This information
  787. will be used to eliminate multiple searches for the same directory entry if
  788. the accesses are done sequentially. */
  789. UINT fx_media_last_found_directory_valid;
  790. FX_DIR_ENTRY fx_media_last_found_directory;
  791. FX_DIR_ENTRY fx_media_last_found_entry;
  792. CHAR fx_media_last_found_file_name[FX_MAX_LONG_NAME_LEN];
  793. CHAR fx_media_last_found_name[FX_MAX_LAST_NAME_LEN];
  794. #endif
  795. /* Define the current directory information for the media. */
  796. FX_PATH fx_media_default_path;
  797. /* Define FAT entry cache and the variable used to index the cache. */
  798. FX_FAT_CACHE_ENTRY fx_media_fat_cache[FX_MAX_FAT_CACHE];
  799. /* Define the FAT secondary update map. This will be used on flush and
  800. close to update sectors of any secondary FATs in the media. */
  801. UCHAR fx_media_fat_secondary_update_map[FX_FAT_MAP_SIZE];
  802. /* Define a variable for the application's use. */
  803. ALIGN_TYPE fx_media_reserved_for_user;
  804. /* Define an area to allocate long file names so that local storage on
  805. calling thread's stack is not used for long file names. This helps
  806. reduce the amount of thread stack space needed when using FileX. */
  807. CHAR fx_media_name_buffer[4*FX_MAX_LONG_NAME_LEN];
  808. #ifdef FX_RENAME_PATH_INHERIT
  809. /* Define the file and directory rename buffer that will be used to prepend
  810. paths when necessary to the target file name. */
  811. CHAR fx_media_rename_buffer[FX_MAXIMUM_PATH];
  812. #endif
  813. #ifndef FX_DISABLE_CACHE
  814. /* Define the sector cache control structures for this media. */
  815. struct FX_CACHED_SECTOR_STRUCT
  816. fx_media_sector_cache[FX_MAX_SECTOR_CACHE];
  817. /* Define the sector cache hash mask so that the hash algorithm can be used with
  818. any power of 2 number of cache sectors. */
  819. ULONG fx_media_sector_cache_hash_mask;
  820. #endif /* FX_DISABLE_CACHE */
  821. /* Define a variable to disable burst cache. This is used by the underlying
  822. driver. */
  823. ULONG fx_media_disable_burst_cache;
  824. #ifdef FX_ENABLE_FAULT_TOLERANT
  825. /* Fault tolerant information */
  826. /* Indicate whether fault tolerant is enabled. */
  827. UCHAR fx_media_fault_tolerant_enabled;
  828. /* State of fault tolerant operation. */
  829. UCHAR fx_media_fault_tolerant_state;
  830. /* Transaction recursive count. */
  831. USHORT fx_media_fault_tolerant_transaction_count;
  832. /* Start cluster of log. */
  833. ULONG fx_media_fault_tolerant_start_cluster;
  834. /* Count of consecutive clusters of log. */
  835. ULONG fx_media_fault_tolerant_clusters;
  836. /* Count of total logs. */
  837. ULONG fx_media_fault_tolerant_total_logs;
  838. /* Pointer to the memory buffer area used for fault tolerant operations. */
  839. UCHAR *fx_media_fault_tolerant_memory_buffer;
  840. /* Size of memory buffer area used for fault tolerant operations. */
  841. ULONG fx_media_fault_tolerant_memory_buffer_size;
  842. /* Size of log file. */
  843. ULONG fx_media_fault_tolerant_file_size;
  844. /* Memory space used during the release of FAT list. */
  845. ULONG fx_media_fault_tolerant_cache[FX_FAULT_TOLERANT_CACHE_SIZE >> 2];
  846. /* Sector number of cached FAT entries. */
  847. ULONG fx_media_fault_tolerant_cached_FAT_sector;
  848. #endif /* FX_ENABLE_FAULT_TOLERANT */
  849. /* Reserved value of FAT table. */
  850. ULONG fx_media_fat_reserved;
  851. /* Last value of FAT table. */
  852. ULONG fx_media_fat_last;
  853. /* Media geometry structure */
  854. UCHAR fx_media_FAT_type;
  855. /* Define the module port extension in the media control block. This
  856. is typically defined to whitespace in fx_port.h. */
  857. FX_MEDIA_MODULE_EXTENSION
  858. } FX_MEDIA;
  859. typedef FX_MEDIA * FX_MEDIA_PTR;
  860. /* Determine if the file control block has an extension defined. If not,
  861. define the extension to whitespace. */
  862. #ifndef FX_FILE_MODULE_EXTENSION
  863. #define FX_FILE_MODULE_EXTENSION
  864. #endif
  865. /* Define the FileX file control block. All information about open
  866. files are found in this data type. */
  867. typedef struct FX_FILE_STRUCT
  868. {
  869. /* Define the file ID used for error checking. */
  870. ULONG fx_file_id;
  871. /* Define the file's name. */
  872. CHAR *fx_file_name;
  873. /* Define the open mode request. */
  874. ULONG fx_file_open_mode;
  875. /* Define the file modified field. */
  876. UCHAR fx_file_modified;
  877. /* Define the data storage parameters. */
  878. ULONG fx_file_total_clusters;
  879. ULONG fx_file_first_physical_cluster;
  880. ULONG fx_file_consecutive_cluster;
  881. ULONG fx_file_last_physical_cluster;
  882. ULONG fx_file_current_physical_cluster;
  883. ULONG64 fx_file_current_logical_sector;
  884. ULONG fx_file_current_logical_offset;
  885. ULONG fx_file_current_relative_cluster;
  886. ULONG fx_file_current_relative_sector;
  887. ULONG64 fx_file_current_file_offset;
  888. ULONG64 fx_file_current_file_size;
  889. ULONG64 fx_file_current_available_size;
  890. #ifdef FX_ENABLE_FAULT_TOLERANT
  891. ULONG64 fx_file_maximum_size_used;
  892. #endif /* FX_ENABLE_FAULT_TOLERANT */
  893. /* Remember the media that is associated with this file. */
  894. FX_MEDIA *fx_file_media_ptr;
  895. /* Define the pointers necessary to maintain the open file on
  896. the list of open files. */
  897. struct FX_FILE_STRUCT
  898. *fx_file_opened_next,
  899. *fx_file_opened_previous;
  900. /* Define the complete directory entry structure. */
  901. FX_DIR_ENTRY fx_file_dir_entry;
  902. CHAR fx_file_name_buffer[FX_MAX_LONG_NAME_LEN];
  903. /* Define a variable for the application's use */
  904. ULONG fx_file_disable_burst_cache;
  905. /* Define a notify function called when file is written to. */
  906. VOID (*fx_file_write_notify)(struct FX_FILE_STRUCT *);
  907. /* Define the module port extension in the file control block. This
  908. is typically defined to whitespace in fx_port.h. */
  909. FX_FILE_MODULE_EXTENSION
  910. } FX_FILE;
  911. typedef FX_FILE *FX_FILE_PTR;
  912. /* Define the FileX API mappings based on the error checking
  913. selected by the user. Note: this section is only applicable to
  914. application source code, hence the conditional that turns off this
  915. stuff when the include file is processed by the FileX source. */
  916. #ifndef FX_SOURCE_CODE
  917. #ifdef FX_DISABLE_ONE_LINE_FUNCTION
  918. #define fx_file_seek(f, b) fx_file_extended_seek(f, (ULONG64)b)
  919. #define fx_file_allocate(f, s) fx_file_extended_allocate(f, (ULONG64)s);
  920. #define fx_file_truncate(f, s) fx_file_extended_truncate(f, (ULONG64)s);
  921. #define fx_file_relative_seek(f, b, sf) fx_file_extended_relative_seek(f, (ULONG64)b, sf);
  922. #define fx_file_truncate_release(f, s) fx_file_extended_truncate_release(f, (ULONG64)s);
  923. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  924. /* Determine if error checking is desired. If so, map API functions
  925. to the appropriate error checking front-ends. Otherwise, map API
  926. functions to the core functions that actually perform the work.
  927. Note: error checking is enabled by default. */
  928. #ifdef FX_DISABLE_ERROR_CHECKING
  929. /* Services without error checking. */
  930. #define fx_directory_attributes_read _fx_directory_attributes_read
  931. #define fx_directory_attributes_set _fx_directory_attributes_set
  932. #define fx_directory_create _fx_directory_create
  933. #define fx_directory_default_get _fx_directory_default_get
  934. #define fx_directory_default_get_copy _fx_directory_default_get_copy
  935. #define fx_directory_default_set _fx_directory_default_set
  936. #define fx_directory_delete _fx_directory_delete
  937. #define fx_directory_first_entry_find _fx_directory_first_entry_find
  938. #define fx_directory_first_full_entry_find _fx_directory_first_full_entry_find
  939. #define fx_directory_information_get _fx_directory_information_get
  940. #define fx_directory_local_path_clear _fx_directory_local_path_clear
  941. #define fx_directory_local_path_get _fx_directory_local_path_get
  942. #define fx_directory_local_path_get_copy _fx_directory_local_path_get_copy
  943. #define fx_directory_local_path_restore _fx_directory_local_path_restore
  944. #define fx_directory_local_path_set _fx_directory_local_path_set
  945. #define fx_directory_long_name_get _fx_directory_long_name_get
  946. #define fx_directory_long_name_get_extended _fx_directory_long_name_get_extended
  947. #define fx_directory_name_test _fx_directory_name_test
  948. #define fx_directory_next_entry_find _fx_directory_next_entry_find
  949. #define fx_directory_next_full_entry_find _fx_directory_next_full_entry_find
  950. #define fx_directory_rename _fx_directory_rename
  951. #define fx_directory_short_name_get _fx_directory_short_name_get
  952. #define fx_directory_short_name_get_extended _fx_directory_short_name_get_extended
  953. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  954. #define fx_file_allocate _fx_file_allocate
  955. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  956. #define fx_file_attributes_read _fx_file_attributes_read
  957. #define fx_file_attributes_set _fx_file_attributes_set
  958. #define fx_file_best_effort_allocate _fx_file_best_effort_allocate
  959. #define fx_file_close _fx_file_close
  960. #define fx_file_create _fx_file_create
  961. #define fx_file_date_time_set _fx_file_date_time_set
  962. #define fx_file_delete _fx_file_delete
  963. #define fx_file_open _fx_file_open
  964. #define fx_file_read _fx_file_read
  965. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  966. #define fx_file_relative_seek _fx_file_relative_seek
  967. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  968. #define fx_file_rename _fx_file_rename
  969. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  970. #define fx_file_seek _fx_file_seek
  971. #define fx_file_truncate _fx_file_truncate
  972. #define fx_file_truncate_release _fx_file_truncate_release
  973. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  974. #define fx_file_write _fx_file_write
  975. #define fx_file_write_notify_set _fx_file_write_notify_set
  976. #define fx_file_extended_allocate _fx_file_extended_allocate
  977. #define fx_file_extended_best_effort_allocate _fx_file_extended_best_effort_allocate
  978. #define fx_file_extended_relative_seek _fx_file_extended_relative_seek
  979. #define fx_file_extended_seek _fx_file_extended_seek
  980. #define fx_file_extended_truncate _fx_file_extended_truncate
  981. #define fx_file_extended_truncate_release _fx_file_extended_truncate_release
  982. #define fx_media_abort _fx_media_abort
  983. #define fx_media_cache_invalidate _fx_media_cache_invalidate
  984. #define fx_media_check _fx_media_check
  985. #define fx_media_close _fx_media_close
  986. #define fx_media_flush _fx_media_flush
  987. #define fx_media_format _fx_media_format
  988. #define fx_media_open _fx_media_open
  989. #define fx_media_read _fx_media_read
  990. #define fx_media_space_available _fx_media_space_available
  991. #define fx_media_volume_get _fx_media_volume_get
  992. #define fx_media_volume_get_extended _fx_media_volume_get_extended
  993. #define fx_media_volume_set _fx_media_volume_set
  994. #define fx_media_write _fx_media_write
  995. #define fx_media_open_notify_set _fx_media_open_notify_set
  996. #define fx_media_close_notify_set _fx_media_close_notify_set
  997. #define fx_media_extended_space_available _fx_media_extended_space_available
  998. #define fx_unicode_directory_create _fx_unicode_directory_create
  999. #define fx_unicode_directory_rename _fx_unicode_directory_rename
  1000. #define fx_unicode_file_create _fx_unicode_file_create
  1001. #define fx_unicode_file_rename _fx_unicode_file_rename
  1002. #define fx_unicode_length_get _fx_unicode_length_get
  1003. #define fx_unicode_length_get_extended _fx_unicode_length_get_extended
  1004. #define fx_unicode_name_get _fx_unicode_name_get
  1005. #define fx_unicode_name_get_extended _fx_unicode_name_get_extended
  1006. #define fx_unicode_short_name_get _fx_unicode_short_name_get
  1007. #define fx_unicode_short_name_get_extended _fx_unicode_short_name_get_extended
  1008. #define fx_system_date_get _fx_system_date_get
  1009. #define fx_system_date_set _fx_system_date_set
  1010. #define fx_system_time_get _fx_system_time_get
  1011. #define fx_system_time_set _fx_system_time_set
  1012. #define fx_system_initialize _fx_system_initialize
  1013. #ifdef FX_ENABLE_FAULT_TOLERANT
  1014. #define fx_fault_tolerant_enable _fx_fault_tolerant_enable
  1015. #endif /* FX_ENABLE_FAULT_TOLERANT */
  1016. #else
  1017. /* Services with error checking. */
  1018. #define fx_directory_attributes_read _fxe_directory_attributes_read
  1019. #define fx_directory_attributes_set _fxe_directory_attributes_set
  1020. #define fx_directory_create _fxe_directory_create
  1021. #define fx_directory_default_get _fxe_directory_default_get
  1022. #define fx_directory_default_get_copy _fxe_directory_default_get_copy
  1023. #define fx_directory_default_set _fxe_directory_default_set
  1024. #define fx_directory_delete _fxe_directory_delete
  1025. #define fx_directory_first_entry_find _fxe_directory_first_entry_find
  1026. #define fx_directory_first_full_entry_find _fxe_directory_first_full_entry_find
  1027. #define fx_directory_information_get _fxe_directory_information_get
  1028. #define fx_directory_local_path_clear _fxe_directory_local_path_clear
  1029. #define fx_directory_local_path_get _fxe_directory_local_path_get
  1030. #define fx_directory_local_path_get_copy _fxe_directory_local_path_get_copy
  1031. #define fx_directory_local_path_restore _fxe_directory_local_path_restore
  1032. #define fx_directory_local_path_set(m, l, n) _fxe_directory_local_path_set(m, l, n, sizeof(FX_LOCAL_PATH))
  1033. #define fx_directory_long_name_get _fxe_directory_long_name_get
  1034. #define fx_directory_long_name_get_extended _fxe_directory_long_name_get_extended
  1035. #define fx_directory_name_test _fxe_directory_name_test
  1036. #define fx_directory_next_entry_find _fxe_directory_next_entry_find
  1037. #define fx_directory_next_full_entry_find _fxe_directory_next_full_entry_find
  1038. #define fx_directory_rename _fxe_directory_rename
  1039. #define fx_directory_short_name_get _fxe_directory_short_name_get
  1040. #define fx_directory_short_name_get_extended _fxe_directory_short_name_get_extended
  1041. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1042. #define fx_file_allocate _fxe_file_allocate
  1043. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  1044. #define fx_file_attributes_read _fxe_file_attributes_read
  1045. #define fx_file_attributes_set _fxe_file_attributes_set
  1046. #define fx_file_best_effort_allocate _fxe_file_best_effort_allocate
  1047. #define fx_file_close _fxe_file_close
  1048. #define fx_file_create _fxe_file_create
  1049. #define fx_file_date_time_set _fxe_file_date_time_set
  1050. #define fx_file_delete _fxe_file_delete
  1051. #define fx_file_open(m, f, n, t) _fxe_file_open(m, f, n, t, sizeof(FX_FILE))
  1052. #define fx_file_read _fxe_file_read
  1053. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1054. #define fx_file_relative_seek _fxe_file_relative_seek
  1055. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  1056. #define fx_file_rename _fxe_file_rename
  1057. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1058. #define fx_file_seek _fxe_file_seek
  1059. #define fx_file_truncate _fxe_file_truncate
  1060. #define fx_file_truncate_release _fxe_file_truncate_release
  1061. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  1062. #define fx_file_write _fxe_file_write
  1063. #define fx_file_write_notify_set _fxe_file_write_notify_set
  1064. #define fx_file_extended_allocate _fxe_file_extended_allocate
  1065. #define fx_file_extended_best_effort_allocate _fxe_file_extended_best_effort_allocate
  1066. #define fx_file_extended_relative_seek _fxe_file_extended_relative_seek
  1067. #define fx_file_extended_seek _fxe_file_extended_seek
  1068. #define fx_file_extended_truncate _fxe_file_extended_truncate
  1069. #define fx_file_extended_truncate_release _fxe_file_extended_truncate_release
  1070. #define fx_media_abort _fxe_media_abort
  1071. #define fx_media_cache_invalidate _fxe_media_cache_invalidate
  1072. #define fx_media_check _fxe_media_check
  1073. #define fx_media_close _fxe_media_close
  1074. #define fx_media_flush _fxe_media_flush
  1075. #define fx_media_format _fxe_media_format
  1076. #define fx_media_open(m, n, d, i, p, s) _fxe_media_open(m, n, d, i, p, s, sizeof(FX_MEDIA))
  1077. #define fx_media_read _fxe_media_read
  1078. #define fx_media_space_available _fxe_media_space_available
  1079. #define fx_media_volume_get _fxe_media_volume_get
  1080. #define fx_media_volume_get_extended _fxe_media_volume_get_extended
  1081. #define fx_media_volume_set _fxe_media_volume_set
  1082. #define fx_media_write _fxe_media_write
  1083. #define fx_media_open_notify_set _fxe_media_open_notify_set
  1084. #define fx_media_close_notify_set _fxe_media_close_notify_set
  1085. #define fx_media_extended_space_available _fxe_media_extended_space_available
  1086. #define fx_unicode_directory_create _fxe_unicode_directory_create
  1087. #define fx_unicode_directory_rename _fxe_unicode_directory_rename
  1088. #define fx_unicode_file_create _fxe_unicode_file_create
  1089. #define fx_unicode_file_rename _fxe_unicode_file_rename
  1090. #define fx_unicode_length_get _fx_unicode_length_get
  1091. #define fx_unicode_length_get_extended _fx_unicode_length_get_extended
  1092. #define fx_unicode_name_get _fxe_unicode_name_get
  1093. #define fx_unicode_name_get_extended _fxe_unicode_name_get_extended
  1094. #define fx_unicode_short_name_get _fxe_unicode_short_name_get
  1095. #define fx_unicode_short_name_get_extended _fxe_unicode_short_name_get_extended
  1096. #define fx_system_date_get _fxe_system_date_get
  1097. #define fx_system_date_set _fxe_system_date_set
  1098. #define fx_system_time_get _fxe_system_time_get
  1099. #define fx_system_time_set _fxe_system_time_set
  1100. #define fx_system_initialize _fx_system_initialize
  1101. #ifdef FX_ENABLE_FAULT_TOLERANT
  1102. #define fx_fault_tolerant_enable _fxe_fault_tolerant_enable
  1103. #endif /* FX_ENABLE_FAULT_TOLERANT */
  1104. #endif
  1105. /* Define the function prototypes of the FileX API. */
  1106. UINT fx_directory_attributes_read(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes_ptr);
  1107. UINT fx_directory_attributes_set(FX_MEDIA *media_ptr, CHAR *directory_name, UINT attributes);
  1108. UINT fx_directory_create(FX_MEDIA *media_ptr, CHAR *directory_name);
  1109. UINT fx_directory_default_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
  1110. UINT fx_directory_default_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
  1111. UINT fx_directory_default_set(FX_MEDIA *media_ptr, CHAR *new_path_name);
  1112. UINT fx_directory_delete(FX_MEDIA *media_ptr, CHAR *directory_name);
  1113. UINT fx_directory_first_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
  1114. UINT fx_directory_first_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
  1115. ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
  1116. UINT fx_directory_information_get(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes, ULONG *size,
  1117. UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
  1118. UINT fx_directory_local_path_clear(FX_MEDIA *media_ptr);
  1119. UINT fx_directory_local_path_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
  1120. UINT fx_directory_local_path_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
  1121. UINT fx_directory_local_path_restore(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr);
  1122. #ifdef FX_DISABLE_ERROR_CHECKING
  1123. UINT _fx_directory_local_path_set(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr, CHAR *new_path_name);
  1124. #else
  1125. UINT _fxe_directory_local_path_set(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr, CHAR *new_path_name, UINT local_path_control_block_size);
  1126. #endif
  1127. UINT fx_directory_long_name_get(FX_MEDIA *media_ptr, CHAR *short_file_name, CHAR *long_file_name);
  1128. UINT fx_directory_long_name_get_extended(FX_MEDIA* media_ptr, CHAR* short_file_name, CHAR* long_file_name, UINT long_file_name_buffer_length);
  1129. UINT fx_directory_name_test(FX_MEDIA *media_ptr, CHAR *directory_name);
  1130. UINT fx_directory_next_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
  1131. UINT fx_directory_next_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
  1132. ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
  1133. UINT fx_directory_rename(FX_MEDIA *media_ptr, CHAR *old_directory_name, CHAR *new_directory_name);
  1134. UINT fx_directory_short_name_get(FX_MEDIA *media_ptr, CHAR *long_file_name, CHAR *short_file_name);
  1135. UINT fx_directory_short_name_get_extended(FX_MEDIA* media_ptr, CHAR* long_file_name, CHAR* short_file_name, UINT short_file_name_length);
  1136. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1137. UINT fx_file_allocate(FX_FILE *file_ptr, ULONG size);
  1138. #endif /* FX_DISABLE_ONE_LINE_FUNCTION*/
  1139. UINT fx_file_attributes_read(FX_MEDIA *media_ptr, CHAR *file_name, UINT *attributes_ptr);
  1140. UINT fx_file_attributes_set(FX_MEDIA *media_ptr, CHAR *file_name, UINT attributes);
  1141. UINT fx_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated);
  1142. UINT fx_file_close(FX_FILE *file_ptr);
  1143. UINT fx_file_create(FX_MEDIA *media_ptr, CHAR *file_name);
  1144. UINT fx_file_date_time_set(FX_MEDIA *media_ptr, CHAR *file_name,
  1145. UINT year, UINT month, UINT day, UINT hour, UINT minute, UINT second);
  1146. UINT fx_file_delete(FX_MEDIA *media_ptr, CHAR *file_name);
  1147. #ifdef FX_DISABLE_ERROR_CHECKING
  1148. UINT _fx_file_open(FX_MEDIA *media_ptr, FX_FILE *file_ptr, CHAR *file_name,
  1149. UINT open_type);
  1150. #else
  1151. UINT _fxe_file_open(FX_MEDIA *media_ptr, FX_FILE *file_ptr, CHAR *file_name,
  1152. UINT open_type, UINT file_control_block_size);
  1153. #endif
  1154. UINT fx_file_read(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG request_size, ULONG *actual_size);
  1155. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1156. UINT fx_file_relative_seek(FX_FILE *file_ptr, ULONG byte_offset, UINT seek_from);
  1157. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  1158. UINT fx_file_rename(FX_MEDIA *media_ptr, CHAR *old_file_name, CHAR *new_file_name);
  1159. #ifndef FX_DISABLE_ONE_LINE_FUNCTION
  1160. UINT fx_file_seek(FX_FILE *file_ptr, ULONG byte_offset);
  1161. UINT fx_file_truncate(FX_FILE *file_ptr, ULONG size);
  1162. UINT fx_file_truncate_release(FX_FILE *file_ptr, ULONG size);
  1163. #endif /* FX_DISABLE_ONE_LINE_FUNCTION */
  1164. UINT fx_file_write(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG size);
  1165. UINT fx_file_write_notify_set(FX_FILE *file_ptr, VOID (*file_write_notify)(FX_FILE *));
  1166. UINT fx_file_extended_allocate(FX_FILE *file_ptr, ULONG64 size);
  1167. UINT fx_file_extended_best_effort_allocate(FX_FILE *file_ptr, ULONG64 size, ULONG64 *actual_size_allocated);
  1168. UINT fx_file_extended_relative_seek(FX_FILE *file_ptr, ULONG64 byte_offset, UINT seek_from);
  1169. UINT fx_file_extended_seek(FX_FILE *file_ptr, ULONG64 byte_offset);
  1170. UINT fx_file_extended_truncate(FX_FILE *file_ptr, ULONG64 size);
  1171. UINT fx_file_extended_truncate_release(FX_FILE *file_ptr, ULONG64 size);
  1172. UINT fx_media_abort(FX_MEDIA *media_ptr);
  1173. UINT fx_media_cache_invalidate(FX_MEDIA *media_ptr);
  1174. UINT fx_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected);
  1175. UINT fx_media_close(FX_MEDIA *media_ptr);
  1176. UINT fx_media_flush(FX_MEDIA *media_ptr);
  1177. UINT fx_media_format(FX_MEDIA *media_ptr, VOID (*driver)(FX_MEDIA *media), VOID *driver_info_ptr, UCHAR *memory_ptr, UINT memory_size,
  1178. CHAR *volume_name, UINT number_of_fats, UINT directory_entries, UINT hidden_sectors,
  1179. ULONG total_sectors, UINT bytes_per_sector, UINT sectors_per_cluster,
  1180. UINT heads, UINT sectors_per_track);
  1181. #ifdef FX_DISABLE_ERROR_CHECKING
  1182. UINT _fx_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
  1183. VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
  1184. VOID *memory_ptr, ULONG memory_size);
  1185. #else
  1186. UINT _fxe_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
  1187. VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
  1188. VOID *memory_ptr, ULONG memory_size, UINT media_control_block_size);
  1189. #endif
  1190. UINT fx_media_read(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
  1191. UINT fx_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr);
  1192. UINT fx_media_volume_get(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_source);
  1193. UINT fx_media_volume_get_extended(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_name_buffer_length, UINT volume_source);
  1194. UINT fx_media_volume_set(FX_MEDIA *media_ptr, CHAR *volume_name);
  1195. UINT fx_media_write(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
  1196. UINT fx_media_open_notify_set(FX_MEDIA *media_ptr, VOID (*media_open_notify)(FX_MEDIA *));
  1197. UINT fx_media_close_notify_set(FX_MEDIA *media_ptr, VOID (*media_close_notify)(FX_MEDIA *));
  1198. UINT fx_media_extended_space_available(FX_MEDIA *media_ptr, ULONG64 *available_bytes_ptr);
  1199. UINT fx_system_date_get(UINT *year, UINT *month, UINT *day);
  1200. UINT fx_system_date_set(UINT year, UINT month, UINT day);
  1201. VOID fx_system_initialize(VOID);
  1202. UINT fx_system_time_get(UINT *hour, UINT *minute, UINT *second);
  1203. UINT fx_system_time_set(UINT hour, UINT minute, UINT second);
  1204. UINT fx_unicode_directory_create(FX_MEDIA *media_ptr,
  1205. UCHAR *source_unicode_name, ULONG source_unicode_length,
  1206. CHAR *short_name);
  1207. UINT fx_unicode_directory_rename(FX_MEDIA *media_ptr,
  1208. UCHAR *old_unicode_name, ULONG old_unicode_length,
  1209. UCHAR *new_unicode_name, ULONG new_unicode_length,
  1210. CHAR *new_short_name);
  1211. UINT fx_unicode_file_create(FX_MEDIA *media_ptr,
  1212. UCHAR *source_unicode_name, ULONG source_unicode_length,
  1213. CHAR *short_name);
  1214. UINT fx_unicode_file_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
  1215. UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name);
  1216. ULONG fx_unicode_length_get(UCHAR *unicode_name);
  1217. ULONG fx_unicode_length_get_extended(UCHAR *unicode_name, UINT buffer_length);
  1218. UINT fx_unicode_name_get(FX_MEDIA *media_ptr, CHAR *source_short_name,
  1219. UCHAR *destination_unicode_name, ULONG *destination_unicode_length);
  1220. UINT fx_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name,
  1221. UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length);
  1222. UINT fx_unicode_short_name_get(FX_MEDIA *media_ptr,
  1223. UCHAR *source_unicode_name, ULONG source_unicode_length,
  1224. CHAR *destination_short_name);
  1225. UINT fx_unicode_short_name_get_extended(FX_MEDIA *media_ptr,
  1226. UCHAR *source_unicode_name, ULONG source_unicode_length,
  1227. CHAR *destination_short_name, ULONG short_name_buffer_length);
  1228. #ifdef FX_ENABLE_FAULT_TOLERANT
  1229. UINT fx_fault_tolerant_enable(FX_MEDIA *media_ptr, VOID *memory_buffer, UINT memory_size);
  1230. #endif /* FX_ENABLE_FAULT_TOLERANT */
  1231. /* Define prototype for utility services commonly used by FileX I/O Drivers. This eliminates the
  1232. need to include internal FileX component files in I/O drivers. */
  1233. UINT _fx_utility_16_unsigned_read(UCHAR *source_ptr);
  1234. VOID _fx_utility_16_unsigned_write(UCHAR *dest_ptr, UINT value);
  1235. ULONG _fx_utility_32_unsigned_read(UCHAR *source_ptr);
  1236. VOID _fx_utility_32_unsigned_write(UCHAR *dest_ptr, ULONG value);
  1237. ULONG64 _fx_utility_64_unsigned_read(UCHAR *source_ptr);
  1238. VOID _fx_utility_64_unsigned_write(UCHAR *dest_ptr, ULONG64 value);
  1239. VOID _fx_utility_memory_copy(UCHAR *source_ptr, UCHAR *dest_ptr, ULONG size);
  1240. VOID _fx_utility_memory_set(UCHAR *dest_ptr, UCHAR value, ULONG size);
  1241. #endif
  1242. /* Determine if a C++ compiler is being used. If so, complete the standard
  1243. C conditional started above. */
  1244. #ifdef __cplusplus
  1245. }
  1246. #endif
  1247. #endif