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