Transition FileX to Eclipse Fundation

This commit is contained in:
TiejunZhou
2024-01-02 07:35:14 +00:00
commit 14884808b5
406 changed files with 143803 additions and 0 deletions
+1539
View File
File diff suppressed because it is too large Load Diff
+122
View File
@@ -0,0 +1,122 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Directory */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_directory.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX Directory component constants, data */
/* definitions, and external references. It is assumed that fx_api.h */
/* (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_DIRECTORY_H
#define FX_DIRECTORY_H
/* Define the external Directory component function prototypes. */
UINT _fx_directory_attributes_read(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes_ptr);
UINT _fx_directory_attributes_set(FX_MEDIA *media_ptr, CHAR *directory_name, UINT attributes);
UINT _fx_directory_create(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fx_directory_default_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
UINT _fx_directory_default_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
UINT _fx_directory_default_set(FX_MEDIA *media_ptr, CHAR *new_path_name);
UINT _fx_directory_delete(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fx_directory_entry_read_FAT(FX_MEDIA *media_ptr, FX_DIR_ENTRY *source_dir, ULONG *entry_ptr,
FX_DIR_ENTRY *destination_ptr);
UINT _fx_directory_first_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fx_directory_first_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fx_directory_information_get(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes, ULONG *size,
UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fx_directory_local_path_clear(FX_MEDIA *media_ptr);
UINT _fx_directory_local_path_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
UINT _fx_directory_local_path_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
UINT _fx_directory_local_path_restore(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr);
UINT _fx_directory_local_path_set(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr, CHAR *new_path_name);
UINT _fx_directory_long_name_get(FX_MEDIA *media_ptr, CHAR *short_file_name, CHAR *long_file_name);
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);
UINT _fx_directory_name_test(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fx_directory_next_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fx_directory_next_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fx_directory_rename(FX_MEDIA *media_ptr, CHAR *old_directory_name, CHAR *new_directory_name);
UINT _fx_directory_short_name_get(FX_MEDIA *media_ptr, CHAR *long_file_name, CHAR *short_file_name);
UINT _fx_directory_short_name_get_extended(FX_MEDIA *media_ptr, CHAR *long_file_name, CHAR *short_file_name, UINT short_file_name_length);
UINT _fxe_directory_attributes_read(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes_ptr);
UINT _fxe_directory_attributes_set(FX_MEDIA *media_ptr, CHAR *directory_name, UINT attributes);
UINT _fxe_directory_create(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fxe_directory_default_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
UINT _fxe_directory_default_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
UINT _fxe_directory_default_set(FX_MEDIA *media_ptr, CHAR *new_path_name);
UINT _fxe_directory_delete(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fxe_directory_first_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fxe_directory_first_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fxe_directory_information_get(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes, ULONG *size,
UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fxe_directory_local_path_clear(FX_MEDIA *media_ptr);
UINT _fxe_directory_local_path_get(FX_MEDIA *media_ptr, CHAR **return_path_name);
UINT _fxe_directory_local_path_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size);
UINT _fxe_directory_local_path_restore(FX_MEDIA *media_ptr, FX_LOCAL_PATH *local_path_ptr);
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);
UINT _fxe_directory_long_name_get(FX_MEDIA *media_ptr, CHAR *short_file_name, CHAR *long_file_name);
UINT _fxe_directory_long_name_get_extended(FX_MEDIA *media_ptr, CHAR *short_file_name, CHAR *long_file_name, UINT long_file_name_buffer_length);
UINT _fxe_directory_name_test(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fxe_directory_next_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name);
UINT _fxe_directory_next_full_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name, UINT *attributes,
ULONG *size, UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second);
UINT _fxe_directory_rename(FX_MEDIA *media_ptr, CHAR *old_directory_name, CHAR *new_directory_name);
UINT _fxe_directory_short_name_get(FX_MEDIA *media_ptr, CHAR *long_file_name, CHAR *short_file_name);
UINT _fxe_directory_short_name_get_extended(FX_MEDIA *media_ptr, CHAR *long_file_name, CHAR *short_file_name, UINT short_file_name_length);
/* Define the internal Directory component function prototypes. */
UINT _fx_directory_entry_read(FX_MEDIA *media_ptr, FX_DIR_ENTRY *source_dir, ULONG *entry, FX_DIR_ENTRY *destination_ptr);
UINT _fx_directory_entry_write(FX_MEDIA *media_ptr, FX_DIR_ENTRY *entry_ptr);
UINT _fx_directory_free_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *directory_ptr, FX_DIR_ENTRY *entry_ptr);
CHAR *_fx_directory_name_extract(CHAR *source_ptr, CHAR *dest_ptr);
UINT _fx_directory_search(FX_MEDIA *media_ptr, CHAR *name_ptr, FX_DIR_ENTRY *entry_ptr, FX_DIR_ENTRY *last_dir_ptr, CHAR **last_name_ptr);
#endif
+407
View File
@@ -0,0 +1,407 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Fault Tolerant */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_fault_tolerant.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX Fault Tolerant component constants, */
/* data definitions, and external references. It is assumed that */
/* fx_api.h (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef _FX_FAULT_TOLERANT_H_
#define _FX_FAULT_TOLERANT_H_
#ifdef FX_ENABLE_FAULT_TOLERANT
#ifndef FX_FAULT_TOLERANT
#error "FX_FAULT_TOLERANT must be defined with FX_ENABLE_FAULT_TOLERANT"
#endif /* FX_FAULT_TOLERANT */
/* Define ID of fault tolerant. */
#define FX_FAULT_TOLERANT_ID 0x46544C52
/* Define fault tolerant version. */
#define FX_FAULT_TOLERANT_VERSION_MAJOR 0x01
#define FX_FAULT_TOLERANT_VERSION_MINOR 0x00
/* Define byte offset in boot sector where the cluster number of the Fault Tolerant Log file is.
Note that this field (byte 116 to 119) is marked as reserved by FAT 12/16/32 specification. */
#ifndef FX_FAULT_TOLERANT_BOOT_INDEX
#define FX_FAULT_TOLERANT_BOOT_INDEX 116
#endif /* FX_FAULT_TOLERANT_BOOT_INDEX */
/* Define the extension invoked when fault tolerant log is recovered or applied during enable API. */
#ifndef FX_FAULT_TOLERANT_ENABLE_EXTENSION
#define FX_FAULT_TOLERANT_ENABLE_EXTENSION
#endif /* FX_FAULT_TOLERANT_ENABLE_EXTENSION */
/* Define the extension invoked when fault tolerant log is applied. */
#ifndef FX_FAULT_TOLERANT_APPLY_LOGS_EXTENSION
#define FX_FAULT_TOLERANT_APPLY_LOGS_EXTENSION
#endif /* FX_FAULT_TOLERANT_APPLY_LOGS_EXTENSION */
/* If not-defined, default port-specific processing extensions to white space. */
#ifndef FX_FAULT_TOLERANT_WRITE_LOG_FILE_EXTENSION
#define FX_FAULT_TOLERANT_WRITE_LOG_FILE_EXTENSION
#endif /* FX_FAULT_TOLERANT_WRITE_LOG_FILE_EXTENSION */
/* Define the maximum size of log file. */
#define FX_FAULT_TOLERANT_MAXIMUM_LOG_FILE_SIZE 3072
/* For backward compatibility, map the symbols deprecated to FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE. */
#ifndef FX_FAULT_TOLERANT_MINIMAL_CLUSTER
#define FX_FAULT_TOLERANT_MINIMAL_CLUSTER FX_FAULT_TOLERANT_MAXIMUM_LOG_FILE_SIZE
#endif /* FX_FAULT_TOLERANT_MINIMAL_CLUSTER */
#ifndef FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE
#define FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE FX_FAULT_TOLERANT_MAXIMUM_LOG_FILE_SIZE
#endif /* FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE */
/* Define the states of the fault tolerant module. */
#define FX_FAULT_TOLERANT_STATE_IDLE 0x00u
#define FX_FAULT_TOLERANT_STATE_STARTED 0x01u
#define FX_FAULT_TOLERANT_STATE_SET_FAT_CHAIN 0x02u
/* Define types of logs. */
#define FX_FAULT_TOLERANT_FAT_LOG_TYPE 1
#define FX_FAULT_TOLERANT_DIR_LOG_TYPE 2
#define FX_FAULT_TOLERANT_BITMAP_LOG_TYPE 3
/* Define operations of FAT chain. */
#define FX_FAULT_TOLERANT_FAT_CHAIN_RECOVER 0 /* Recover new FAT chain. */
#define FX_FAULT_TOLERANT_FAT_CHAIN_CLEANUP 1 /* Cleanup old FAT chain. */
/* Define flags for FAT chain log. */
#define FX_FAULT_TOLERANT_FLAG_FAT_CHAIN_VALID 0x01
#define FX_FAULT_TOLERANT_FLAG_BITMAP_USED 0x02
/* Define size of each section in log file. */
#define FX_FAULT_TOLERANT_LOG_HEADER_SIZE sizeof(FX_FAULT_TOLERANT_LOG_HEADER)
#define FX_FAULT_TOLERANT_FAT_CHAIN_SIZE sizeof(FX_FAULT_TOLERANT_FAT_CHAIN)
#define FX_FAULT_TOLERANT_LOG_CONTENT_HEADER_SIZE sizeof(FX_FAULT_TOLERANT_LOG_CONTENT)
/* Define offset of each section in log file. */
#define FX_FAULT_TOLERANT_FAT_CHAIN_OFFSET (FX_FAULT_TOLERANT_LOG_HEADER_SIZE)
#define FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET (FX_FAULT_TOLERANT_LOG_HEADER_SIZE + FX_FAULT_TOLERANT_FAT_CHAIN_SIZE)
/* Define size of log entries. */
/* The total size of DIR log entry is variable. 16 is the fixed size of DIR log entry. */
#define FX_FAULT_TOLERANT_FAT_LOG_ENTRY_SIZE sizeof(FX_FAULT_TOLERANT_FAT_LOG)
#define FX_FAULT_TOLERANT_BITMAP_LOG_ENTRY_SIZE sizeof(FX_FAULT_TOLERANT_BITMAP_LOG)
#define FX_FAULT_TOLERANT_DIR_LOG_ENTRY_SIZE sizeof(FX_FAULT_TOLERANT_DIR_LOG)
#ifdef FX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION
#define FX_FAULT_TOLERANT_TRANSACTION_FAIL _fx_fault_tolerant_transaction_fail
#else
/* Define transaction fail for fault tolerant. */
#define FX_FAULT_TOLERANT_TRANSACTION_FAIL(m) \
if ((m) -> fx_media_fault_tolerant_enabled == FX_TRUE) \
{ \
(m) -> fx_media_fault_tolerant_transaction_count--; \
if ((m) -> fx_media_fault_tolerant_transaction_count == 0) \
{ \
_fx_fault_tolerant_recover(m); \
_fx_fault_tolerant_reset_log_file(m); \
} \
}
#endif /* FX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION */
/* Log file format
* The entire log file fits into one cluster.
*
* 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + ID +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Total Log Size (in Bytes) + Header Checksum + Log Header
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + version major + version minor + reserved +
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Checksum of FAT chain + Flag | Reserved +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Insertion Point - Front +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Head cluster of newly created FAT chain +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FAT Chain
* + Head cluster of original FAT chain +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Insertion Point - Back +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + Next Deletion Point +
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + checksum of log content + count of log entries +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + (log 0) . +
* + . +
* + . +
* + . +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + (log 1) . +
* + . + Log Entries
* + . +
* + . +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + ... +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + (log N) . +
* + . +
* + . +
* + . +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
*
* Log Header
*
* * ID: It is fixed value FX_FAULT_TOLERANT_ID.
* * Total Size: Total size (in bytes) of the log file, including Log Header, FAT Chain and Log Entries
* * Header Checksum: It is the checksum of all data in log header.
* * Version Major: The major version number.
* * Version Minor: The minor version number.
* * Reserved: Reserved for future use.
*
* FAT Chain
*
* * Checksum of FAT chain: It is the checksum of all data in the FAT Chain section.
* * Flag: 8 bits. The 1-6 bits are not used (from left to right).
* bit 7: When set, bitmap is used in old FAT chain.
* bit 8: When set, FAT chain is valid.
* * Reserved: Reserved for future use.
* * Insertion Point - Front: The cluster where the newly created chain is attached to
* * Head cluster of new FAT chain. It is the head cluster of new FAT chain.
* * Head cluster of oritinal FAT chain. It is the head cluster of the original FAT chain,
* which will be removed.
* * Inswertion Point - Back: The original cluster right after the newly created chain is inserted.
* * Next Deletion Point: next session of cluster to delete. It is used during deleting FAT chain.
* The deltion is carried out in stages for perofmrance reasons. When delting a FAT chain, the
* Next Deletion Point is chosen, and the chain between head and the Next Deletion Point is deleted.
*
* Log Entries:
*
* * Checksum of log entries: It is the checksum of all data in Log Entries
* * Counter of log entries: It is the counter of all log entries in Log content.
* * log 0 ... log N: Log entries. The formats are described below.
*/
/* Defined structure of log header.
*/
typedef struct FX_FAULT_TOLERANT_LOG_HEADER_STRUCT
{
ULONG fx_fault_tolerant_log_header_id;
USHORT fx_fault_tolerant_log_header_total_size;
USHORT fx_fault_tolerant_log_header_checksum;
UCHAR fx_fault_tolerant_log_header_version_major;
UCHAR fx_fault_tolerant_log_header_version_minor;
USHORT fx_fault_tolerant_log_header_reserved;
} FX_FAULT_TOLERANT_LOG_HEADER;
/* Define structure of FAT chain. */
typedef struct FX_FAULT_TOLERANT_FAT_CHAIN_STRUCT
{
USHORT fx_fault_tolerant_FAT_chain_checksumm;
UCHAR fx_fault_tolerant_FAT_chain_flag;
UCHAR fx_fault_tolerant_FAT_chain_reserved;
ULONG fx_fault_tolerant_FAT_chain_insertion_front;
ULONG fx_fault_tolerant_FAT_chain_head_new;
ULONG fx_fault_tolerant_FAT_chain_head_original;
ULONG fx_fault_tolerant_FAT_chain_insertion_back;
ULONG fx_fault_tolerant_FAT_chain_next_deletion;
} FX_FAULT_TOLERANT_FAT_CHAIN;
/* Define structure of Log content. */
typedef struct FX_FAULT_TOLERANT_LOG_CONTENT_STRUCT
{
USHORT fx_fault_tolerant_log_content_checksum;
USHORT fx_fault_tolerant_log_content_count;
} FX_FAULT_TOLERANT_LOG_CONTENT;
/* 3 types of log entries are defined. */
/* FAT log format
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + type + size +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + cluster +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + value +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Description:
*
* Type: FX_FAULT_TOLERANT_FAT_LOG.
* Size: The size of this log entry.
* Cluster: The cluster number in FAT.
* Value: The value of cluster in FAT.
*
*/
typedef struct FX_FAULT_TOLERANT_FAT_LOG_STRUCT
{
USHORT fx_fault_tolerant_FAT_log_type;
USHORT fx_fault_tolerant_FAT_log_size;
ULONG fx_fault_tolerant_FAT_log_cluster;
ULONG fx_fault_tolerant_FAT_log_value;
} FX_FAULT_TOLERANT_FAT_LOG;
/* DIR log format
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + type + size +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + sector offset +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + log sector +
* + +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + log data +
* + . +
* + . +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Fields description,
*
* Type: FX_FAULT_TOLERANT_DIRECTORY_LOG
* Size: The size of this log entry.
* Sector Offset: The offset in original sector this DIR is trying to write to.
* Log Sector: The original sector this DIR is trying to write to.
* Log Data: Content of DIR entries.
*
*/
typedef struct FX_FAULT_TOLERANT_DIR_LOG_STRUCT
{
USHORT fx_fault_tolerant_dir_log_type;
USHORT fx_fault_tolerant_dir_log_size;
ULONG fx_fault_tolerant_dir_log_offset;
ULONG64 fx_fault_tolerant_dir_log_sector;
} FX_FAULT_TOLERANT_DIR_LOG;
/* Bitmap log format
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + type + size +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + cluster +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* + value +
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Description,
*
* Type: FX_FAULT_TOLERANT_BITMAP_LOG.
* Size: The size of this log entry.
* Cluster: The cluster number in FAT.
* Value: The value of cluster in FAT.
*/
typedef struct FX_FAULT_TOLERANT_BITMAP_LOG_STRUCT
{
USHORT fx_fault_tolerant_bitmap_log_type;
USHORT fx_fault_tolerant_bitmap_log_size;
ULONG fx_fault_tolerant_bitmap_log_cluster;
ULONG fx_fault_tolerant_bitmap_log_value;
} FX_FAULT_TOLERANT_BITMAP_LOG;
/* This function checks whether or not the log file exists, and creates the log file if it does not exist. */
UINT _fx_fault_tolerant_enable(FX_MEDIA *media_ptr, VOID *memory_buffer, UINT memory_size);
UINT _fxe_fault_tolerant_enable(FX_MEDIA *media_ptr, VOID *memory_buffer, UINT memory_size);
/* This function resets statistics and marks the start of a transaction. */
UINT _fx_fault_tolerant_transaction_start(FX_MEDIA *media_ptr);
/* This function marks the end of a transaction and completes the log file.
* Then it applies all data in the log file to the file system.
* Finally it resets the log header section. */
UINT _fx_fault_tolerant_transaction_end(FX_MEDIA *media_ptr);
/* This function resets the log file. */
UINT _fx_fault_tolerant_reset_log_file(FX_MEDIA *media_ptr);
/* This function applies the log file to the file system. */
UINT _fx_fault_tolerant_apply_logs(FX_MEDIA *media_ptr);
/* This function recovers FAT chain. */
UINT _fx_fault_tolerant_recover(FX_MEDIA *media_ptr);
/* This function adds a FAT log entry. */
UINT _fx_fault_tolerant_add_FAT_log(FX_MEDIA *media_ptr, ULONG cluster, ULONG value);
/* This function adds a directory log entry. */
UINT _fx_fault_tolerant_add_dir_log(FX_MEDIA *media_ptr, ULONG64 logical_sector, ULONG offset,
UCHAR *data, ULONG data_size);
/* This function sets the FAT chain. */
UINT _fx_fault_tolerant_set_FAT_chain(FX_MEDIA *media_ptr, UINT use_bitmap, ULONG insertion_front,
ULONG new_head_cluster, ULONG original_head_cluster, ULONG insertion_back);
/* This function reads a FAT entry from log file. If it doesn't exist in log file, return and read from FAT entry directly. */
UINT _fx_fault_tolerant_read_FAT(FX_MEDIA *media_ptr, ULONG cluster, ULONG *value, ULONG log_type);
/* This function reads directory sector from log file. */
UINT _fx_fault_tolerant_read_directory_sector(FX_MEDIA *media_ptr, ULONG64 logical_sector,
VOID *buffer_ptr, ULONG64 sectors);
/* This function calculates the checksum of the log header. */
USHORT _fx_fault_tolerant_calculate_checksum(UCHAR *data, UINT len);
/* This function cleans up FAT chain. */
UINT _fx_fault_tolerant_cleanup_FAT_chain(FX_MEDIA *media_ptr, UINT operation);
/* This function reads log file from file system to memory buffer. */
UINT _fx_fault_tolerant_read_log_file(FX_MEDIA *media_ptr);
/* This function writes data of one sector from memory to log file in file system. */
UINT _fx_fault_tolerant_write_log_file(FX_MEDIA *media_ptr, ULONG relative_sector);
/* This function creates log file. */
UINT _fx_fault_tolerant_create_log_file(FX_MEDIA *media_ptr);
#ifdef FX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION
/* This function cleans up resources created by fault tolerant when transaction fails. */
UINT _fx_fault_tolerant_transaction_fail(FX_MEDIA *media_ptr);
#endif /* FX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION */
#endif /* FX_ENABLE_FAULT_TOLERANT */
#endif /* _FX_FAULT_TOLERANT_H_ */
+125
View File
@@ -0,0 +1,125 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** File */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_file.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX File component constants, data */
/* definitions, and external references. It is assumed that fx_api.h */
/* (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), and */
/* added conditional to */
/* disable one line function, */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_FILE_H
#define FX_FILE_H
/* Define the external File component function prototypes. */
#ifndef FX_DISABLE_ONE_LINE_FUNCTION
UINT _fx_file_allocate(FX_FILE *file_ptr, ULONG size);
#else
#define _fx_file_allocate(f, s) _fx_file_extended_allocate(f, (ULONG64)s);
#endif /* FX_DISABLE_ONE_LINE_FUNCTION */
UINT _fx_file_attributes_read(FX_MEDIA *media_ptr, CHAR *file_name, UINT *attributes_ptr);
UINT _fx_file_attributes_set(FX_MEDIA *media_ptr, CHAR *file_name, UINT attributes);
UINT _fx_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated);
UINT _fx_file_close(FX_FILE *file_ptr);
UINT _fx_file_create(FX_MEDIA *media_ptr, CHAR *file_name);
UINT _fx_file_date_time_set(FX_MEDIA *media_ptr, CHAR *file_name,
UINT year, UINT month, UINT day, UINT hour, UINT minute, UINT second);
UINT _fx_file_delete(FX_MEDIA *media_ptr, CHAR *file_name);
UINT _fx_file_open(FX_MEDIA *media_ptr, FX_FILE *file_ptr, CHAR *file_name,
UINT open_type);
UINT _fx_file_read(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG request_size, ULONG *actual_size);
#ifndef FX_DISABLE_ONE_LINE_FUNCTION
UINT _fx_file_relative_seek(FX_FILE *file_ptr, ULONG byte_offset, UINT seek_from);
#else
#define _fx_file_relative_seek(f, b, sf) _fx_file_extended_relative_seek(f, (ULONG64)b, sf);
#endif /* FX_DISABLE_ONE_LINE_FUNCTION */
UINT _fx_file_rename(FX_MEDIA *media_ptr, CHAR *old_file_name, CHAR *new_file_name);
#ifndef FX_DISABLE_ONE_LINE_FUNCTION
UINT _fx_file_seek(FX_FILE *file_ptr, ULONG byte_offset);
UINT _fx_file_truncate(FX_FILE *file_ptr, ULONG size);
UINT _fx_file_truncate_release(FX_FILE *file_ptr, ULONG size);
#else
#define _fx_file_seek(f, b) _fx_file_extended_seek(f, (ULONG64)b)
#define _fx_file_truncate(f, s) _fx_file_extended_truncate(f, (ULONG64)s);
#define _fx_file_truncate_release(f, s) _fx_file_extended_truncate_release(f, (ULONG64)s);
#endif /* FX_DISABLE_ONE_LINE_FUNCTION */
UINT _fx_file_write(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG size);
UINT _fx_file_write_notify_set(FX_FILE *file_ptr, VOID (*file_write_notify)(FX_FILE *));
UINT _fx_file_extended_allocate(FX_FILE *file_ptr, ULONG64 size);
UINT _fx_file_extended_best_effort_allocate(FX_FILE *file_ptr, ULONG64 size, ULONG64 *actual_size_allocated);
UINT _fx_file_extended_relative_seek(FX_FILE *file_ptr, ULONG64 byte_offset, UINT seek_from);
UINT _fx_file_extended_seek(FX_FILE *file_ptr, ULONG64 byte_offset);
UINT _fx_file_extended_truncate(FX_FILE *file_ptr, ULONG64 size);
UINT _fx_file_extended_truncate_release(FX_FILE *file_ptr, ULONG64 size);
UINT _fxe_file_allocate(FX_FILE *file_ptr, ULONG size);
UINT _fxe_file_attributes_read(FX_MEDIA *media_ptr, CHAR *file_name, UINT *attributes_ptr);
UINT _fxe_file_attributes_set(FX_MEDIA *media_ptr, CHAR *file_name, UINT attributes);
UINT _fxe_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated);
UINT _fxe_file_close(FX_FILE *file_ptr);
UINT _fxe_file_create(FX_MEDIA *media_ptr, CHAR *file_name);
UINT _fxe_file_date_time_set(FX_MEDIA *media_ptr, CHAR *file_name,
UINT year, UINT month, UINT day, UINT hour, UINT minute, UINT second);
UINT _fxe_file_delete(FX_MEDIA *media_ptr, CHAR *file_name);
UINT _fxe_file_open(FX_MEDIA *media_ptr, FX_FILE *file_ptr, CHAR *file_name,
UINT open_type, UINT file_control_block_size);
UINT _fxe_file_read(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG request_size, ULONG *actual_size);
UINT _fxe_file_relative_seek(FX_FILE *file_ptr, ULONG byte_offset, UINT seek_from);
UINT _fxe_file_rename(FX_MEDIA *media_ptr, CHAR *old_file_name, CHAR *new_file_name);
UINT _fxe_file_seek(FX_FILE *file_ptr, ULONG byte_offset);
UINT _fxe_file_truncate(FX_FILE *file_ptr, ULONG size);
UINT _fxe_file_truncate_release(FX_FILE *file_ptr, ULONG size);
UINT _fxe_file_write(FX_FILE *file_ptr, VOID *buffer_ptr, ULONG size);
UINT _fxe_file_write_notify_set(FX_FILE *file_ptr, VOID (*file_write_notify)(FX_FILE *));
UINT _fxe_file_extended_allocate(FX_FILE *file_ptr, ULONG64 size);
UINT _fxe_file_extended_best_effort_allocate(FX_FILE *file_ptr, ULONG64 size, ULONG64 *actual_size_allocated);
UINT _fxe_file_extended_relative_seek(FX_FILE *file_ptr, ULONG64 byte_offset, UINT seek_from);
UINT _fxe_file_extended_seek(FX_FILE *file_ptr, ULONG64 byte_offset);
UINT _fxe_file_extended_truncate(FX_FILE *file_ptr, ULONG64 size);
UINT _fxe_file_extended_truncate_release(FX_FILE *file_ptr, ULONG64 size);
#endif
+109
View File
@@ -0,0 +1,109 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Media */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_media.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX Media component constants, data */
/* definitions, and external references. It is assumed that fx_api.h */
/* (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_MEDIA_H
#define FX_MEDIA_H
/* Define the external Media component function prototypes. */
UINT _fx_media_abort(FX_MEDIA *media_ptr);
UINT _fx_media_cache_invalidate(FX_MEDIA *media_ptr);
UINT _fx_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected);
UINT _fx_media_close(FX_MEDIA *media_ptr);
UINT _fx_media_flush(FX_MEDIA *media_ptr);
UINT _fx_media_format(FX_MEDIA *media_ptr, VOID (*driver)(FX_MEDIA *media), VOID *driver_info_ptr, UCHAR *memory_ptr, UINT memory_size,
CHAR *volume_name, UINT number_of_fats, UINT directory_entries, UINT hidden_sectors,
ULONG total_sectors, UINT bytes_per_sector, UINT sectors_per_cluster,
UINT heads, UINT sectors_per_track);
UINT _fx_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
VOID *memory_ptr, ULONG memory_size);
UINT _fx_media_read(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
UINT _fx_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr);
UINT _fx_media_volume_get(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_source);
UINT _fx_media_volume_get_extended(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_name_buffer_length, UINT volume_source);
UINT _fx_media_volume_set(FX_MEDIA *media_ptr, CHAR *volume_name);
UINT _fx_media_write(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
UINT _fx_media_open_notify_set(FX_MEDIA *media_ptr, VOID (*media_open_notify)(FX_MEDIA *));
UINT _fx_media_close_notify_set(FX_MEDIA *media_ptr, VOID (*media_close_notify)(FX_MEDIA *));
UINT _fx_media_extended_space_available(FX_MEDIA *media_ptr, ULONG64 *available_bytes_ptr);
UINT _fxe_media_abort(FX_MEDIA *media_ptr);
UINT _fxe_media_cache_invalidate(FX_MEDIA *media_ptr);
UINT _fxe_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected);
UINT _fxe_media_close(FX_MEDIA *media_ptr);
UINT _fxe_media_flush(FX_MEDIA *media_ptr);
UINT _fxe_media_format(FX_MEDIA *media_ptr, VOID (*driver)(FX_MEDIA *media), VOID *driver_info_ptr, UCHAR *memory_ptr, UINT memory_size,
CHAR *volume_name, UINT number_of_fats, UINT directory_entries, UINT hidden_sectors,
ULONG total_sectors, UINT bytes_per_sector, UINT sectors_per_cluster,
UINT heads, UINT sectors_per_track);
UINT _fxe_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
VOID (*media_driver)(FX_MEDIA *), VOID *driver_info_ptr,
VOID *memory_ptr, ULONG memory_size, UINT media_control_block_size);
UINT _fxe_media_read(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
UINT _fxe_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr);
UINT _fxe_media_volume_get(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_source);
UINT _fxe_media_volume_get_extended(FX_MEDIA *media_ptr, CHAR *volume_name, UINT volume_name_buffer_length, UINT volume_source);
UINT _fxe_media_volume_set(FX_MEDIA *media_ptr, CHAR *volume_name);
UINT _fxe_media_write(FX_MEDIA *media_ptr, ULONG logical_sector, VOID *buffer_ptr);
UINT _fxe_media_open_notify_set(FX_MEDIA *media_ptr, VOID (*media_open_notify)(FX_MEDIA *));
UINT _fxe_media_close_notify_set(FX_MEDIA *media_ptr, VOID (*media_close_notify)(FX_MEDIA *));
UINT _fxe_media_extended_space_available(FX_MEDIA *media_ptr, ULONG64 *available_bytes_ptr);
/* Define the internal Media component function prototypes. */
ULONG _fx_media_check_FAT_chain_check(FX_MEDIA *media_ptr, ULONG starting_cluster, ULONG *last_valid_cluster, ULONG *total_valid_clusters, UCHAR *logical_fat);
ULONG _fx_media_check_lost_cluster_check(FX_MEDIA *media_ptr, UCHAR *logical_fat, ULONG total_clusters, ULONG error_correction_option);
UINT _fx_media_boot_info_extract(FX_MEDIA *media_ptr);
#endif
+175
View File
@@ -0,0 +1,175 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** System */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_system.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX system constants and global data */
/* definitions, including external references. It is assumed that */
/* fx_api.h (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_SYSTEM_H
#define FX_SYSTEM_H
/* Define System component constants. */
#define FX_TIMER_ID ((ULONG) 0x46585359)
/* Define the external System component function prototypes. */
VOID _fx_system_initialize(VOID);
UINT _fx_system_date_set(UINT year, UINT month, UINT day);
UINT _fx_system_time_set(UINT hour, UINT minute, UINT second);
UINT _fx_system_date_get(UINT *year, UINT *month, UINT *day);
UINT _fx_system_time_get(UINT *hour, UINT *minute, UINT *second);
VOID _fx_system_timer_entry(ULONG id);
UINT _fxe_system_date_set(UINT year, UINT month, UINT day);
UINT _fxe_system_time_set(UINT hour, UINT minute, UINT second);
UINT _fxe_system_date_get(UINT *year, UINT *month, UINT *day);
UINT _fxe_system_time_get(UINT *hour, UINT *minute, UINT *second);
/* System Component data declarations follow. */
/* Determine if the initialization function of this component is including
this file. If so, make the data definitions really happen. Otherwise,
make them extern so other functions in the component can access them. */
#ifdef FX_SYSTEM_INIT
#define SYSTEM_DECLARE
#else
#define SYSTEM_DECLARE extern
#endif
/* Define the head pointer of the opened media list. */
SYSTEM_DECLARE FX_MEDIA *_fx_system_media_opened_ptr;
/* Define the variable that holds the number of open media. */
SYSTEM_DECLARE ULONG _fx_system_media_opened_count;
/* Define the system date variable. */
SYSTEM_DECLARE UINT _fx_system_date;
/* Define the system time variable. */
SYSTEM_DECLARE UINT _fx_system_time;
/* Define the variable that holds the maximum size of the sector cache. */
SYSTEM_DECLARE ULONG _fx_system_media_max_sector_cache;
/* Define the variable that holds the maximum size of the FAT cache. */
SYSTEM_DECLARE ULONG _fx_system_media_max_fat_cache;
/* Define the global FileX build options variables. These variables contain a bit
map representing how the FileX library was built. The following are the bit
field definitions:
_fx_system_build_options_1:
Bit(s) Meaning
31-24 FX_MAX_LONG_NAME_LEN
23-16 FX_MAX_LAST_NAME_LEN
15-11 Reserved
10 FX_NO_TIMER defined
9 FX_SINGLE_THREAD defined
8 FX_DONT_UPDATE_OPEN_FILES defined
7 FX_MEDIA_DISABLE_SEARCH_CACHE defined
6 FX_MEDIA_STATISTICS_DISABLE defined
5 Reserved
4 FX_SINGLE_OPEN_LEGACY defined
3 FX_RENAME_PATH_INHERIT defined
2 FX_NO_LOCAL_PATH defined
1 FX_FAULT_TOLERANT_DATA defined
0 FX_FAULT_TOLERANT defined
_fx_system_build_options_2:
Bit(s) Meaning
31-16 FX_MAX_SECTOR_CACHE
15-8 FX_FAT_MAP_SIZE
7-0 FX_MAX_FAT_CACHE
_fx_system_build_options_3:
Bit(s) Meaning
31-24 Reserved
23-16 FX_UPDATE_RATE_IN_SECONDS
15-0 FX_UPDATE_RATE_IN_TICKS
Note that values greater than the value that can be represented in the build options
bit field are represented as all ones in the bit field. For example, if FX_MAX_LONG_NAME_LEN
is 256, the value in the bits 31-24 of _fx_system_build_options_1 is 0xFF, which is 255
decimal. */
SYSTEM_DECLARE ULONG _fx_system_build_options_1;
SYSTEM_DECLARE ULONG _fx_system_build_options_2;
SYSTEM_DECLARE ULONG _fx_system_build_options_3;
/* Define system timer control block. If accurate date/time stamps on
files is not needed, the define FX_NO_TIMER should be used when
compiling fx_system_initialize.c to eliminate the FileX timer. */
#ifndef FX_NO_TIMER
SYSTEM_DECLARE TX_TIMER _fx_system_timer;
#endif
#endif
+110
View File
@@ -0,0 +1,110 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Unicode */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_unicode.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX Unicode component constants, data */
/* definitions, and external references. It is assumed that fx_api.h */
/* (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_UNICODE_H
#define FX_UNICODE_H
/* Define external data for the Unicode component. */
extern UCHAR _fx_unicode_temp_long_file_name[FX_MAX_LONG_NAME_LEN];
extern UCHAR _fx_unicode_search_name[FX_MAX_LONG_NAME_LEN * 2];
/* Define the external Unicode component function prototypes. */
UINT _fx_unicode_directory_create(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *short_name);
UINT _fx_unicode_directory_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name);
UINT _fx_unicode_file_create(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *short_name);
ULONG _fx_unicode_length_get(UCHAR *unicode_name);
ULONG _fx_unicode_length_get_extended(UCHAR *unicode_name, UINT buffer_length);
UINT _fx_unicode_name_get(FX_MEDIA *media_ptr, CHAR *source_short_name,
UCHAR *destination_unicode_name, ULONG *destination_unicode_length);
UINT _fx_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name,
UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length);
UINT _fx_unicode_file_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name);
UINT _fx_unicode_short_name_get(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *destination_short_name);
UINT _fx_unicode_short_name_get_extended(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *destination_short_name, ULONG short_name_buffer_length);
UINT _fxe_unicode_directory_create(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *short_name);
UINT _fxe_unicode_directory_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name);
UINT _fxe_unicode_file_create(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *short_name);
UINT _fxe_unicode_file_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name);
UINT _fxe_unicode_name_get(FX_MEDIA *media_ptr, CHAR *source_short_name,
UCHAR *destination_unicode_name, ULONG *destination_unicode_length);
UINT _fxe_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name,
UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length);
UINT _fxe_unicode_short_name_get(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *destination_short_name);
UINT _fxe_unicode_short_name_get_extended(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
CHAR *destination_short_name, ULONG short_name_buffer_length);
/* Define the internal Unicode component function prototypes. */
UINT _fx_unicode_directory_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *entry_ptr,
UCHAR *short_name, ULONG short_name_buffer_length,
UCHAR *unicode_name, ULONG *unicode_name_length, ULONG unicode_name_buffer_length);
UINT _fx_unicode_directory_entry_read(FX_MEDIA *media_ptr, FX_DIR_ENTRY *source_dir,
ULONG *entry_ptr, FX_DIR_ENTRY *destination_ptr,
UCHAR *unicode_name, ULONG *unicode_size);
UINT _fx_unicode_directory_entry_change(FX_MEDIA *media_ptr, FX_DIR_ENTRY *entry_ptr, UCHAR *unicode_name, ULONG unicode_name_length);
#endif
+236
View File
@@ -0,0 +1,236 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** User Specific */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* fx_user.h PORTABLE C */
/* 6.1.5 */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file contains user defines for configuring FileX in specific */
/* ways. This file will have an effect only if the application and */
/* FileX library are built with FX_INCLUDE_USER_DEFINE_FILE defined. */
/* Note that all the defines in this file may also be made on the */
/* command line when building FileX library and application objects. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), and */
/* added product constants */
/* to enable code */
/* size optimization, */
/* resulting in version 6.1 */
/* 03-02-2021 William E. Lamie Modified comment(s), and */
/* added standalone support, */
/* resulting in version 6.1.5 */
/* */
/**************************************************************************/
#ifndef FX_USER_H
#define FX_USER_H
/* Define various build options for the FileX port. The application should either make changes
here by commenting or un-commenting the conditional compilation defined OR supply the defines
though the compiler's equivalent of the -D option. */
/* Override various options with default values already assigned in fx_api.h or fx_port.h. Please
also refer to fx_port.h for descriptions on each of these options. */
/* Defines the maximum size of long file names supported by FileX. The default value is 33. The
minimum value is 13 and the maximum value is 256. */
/*#define FX_MAX_LONG_NAME_LEN 256 */
/*#define FX_MAX_LAST_NAME_LEN 256 */ /* Must be as large or larger than FX_MAX_LONG_NAME_LEN */
/* Defines the maximum number of logical sectors that can be cached by FileX. The cache memory
supplied to FileX at fx_media_open determines how many sectors can actually be cached. */
/*#define FX_MAX_SECTOR_CACHE 256 */ /* Minimum value is 2, all other values must be power of 2. */
/* Defines the size in bytes of the bit map used to update the secondary FAT sectors. The larger the value the
less unnecessary secondary FAT sector writes. */
/*#define FX_FAT_MAP_SIZE 128 */ /* Minimum value is 1, no maximum value. */
/* Defines the number of entries in the FAT cache. */
/*#define FX_MAX_FAT_CACHE 16 */ /* Minimum value is 8, all values must be a power of 2. */
/* Defines the number of seconds the time parameters are updated in FileX. */
/*#define FX_UPDATE_RATE_IN_SECONDS 10 */
/* Defines the number of ThreadX timer ticks required to achieve the update rate specified by
FX_UPDATE_RATE_IN_SECONDS defined previously. By default, the ThreadX timer tick is 10ms,
so the default value for this constant is 1000. */
/*#define FX_UPDATE_RATE_IN_TICKS 1000 */
/* Defined, FileX is built without update to the time parameters. */
/*#define FX_NO_TIMER */
/* Defined, FileX does not update already opened files. */
/*#define FX_DONT_UPDATE_OPEN_FILES */
/* Defined, the file search cache optimization is disabled. */
/*#define FX_MEDIA_DISABLE_SEARCH_CACHE */
/* Defined, the direct read sector update of cache is disabled. */
/*#define FX_DISABLE_DIRECT_DATA_READ_CACHE_FILL */
/* Defined, gathering of media statistics is disabled. */
/*#define FX_MEDIA_STATISTICS_DISABLE */
/* Defined, legacy single open logic for the same file is enabled. */
/*#define FX_SINGLE_OPEN_LEGACY */
/* Defined, renaming inherits path information. */
/*#define FX_RENAME_PATH_INHERIT */
/* Defined, local path logic is disabled. */
/*#define FX_NO_LOCAL_PATH */
/* Define FileX internal protection macros. If FX_SINGLE_THREAD is defined,
these protection macros are effectively disabled. However, for multi-thread
uses, the macros are setup to utilize a ThreadX mutex for multiple thread
access control into an open media. */
/* #define FX_SINGLE_THREAD */
/* Defined, Filex will be used in standalone mode (without ThreadX) */
/* #define FX_STANDALONE_ENABLE */
/* Defined, data sector write requests are flushed immediately to the driver. */
/*#define FX_FAULT_TOLERANT_DATA */
/* Defined, system sector write requests (including FAT and directory entry requests)
are flushed immediately to the driver. */
/*#define FX_FAULT_TOLERANT */
/* Defined, enables 64-bits sector addresses used in I/O driver. */
/*#define FX_DRIVER_USE_64BIT_LBA */
/* Defined, enables FileX fault tolerant service. */
/*#define FX_ENABLE_FAULT_TOLERANT */
/* Define byte offset in boot sector where the cluster number of the Fault Tolerant Log file is.
Note that this field (byte 116 to 119) is marked as reserved by FAT 12/16/32 specification. */
/*#define FX_FAULT_TOLERANT_BOOT_INDEX 116 */
/* Below FX_DISABLE_XXX macros can be used for code size optimization required for memory
critical aplications */
/* Defined, error checking is disabled. */
/*#define FX_DISABLE_ERROR_CHECKING */
/* Defined, cache is disabled. */
/*#define FX_DISABLE_CACHE */
/* Defined, file close is disabled. */
/*#define FX_DISABLE_FILE_CLOSE */
/* Defined, fast open is disabled. */
/*#define FX_DISABLE_FAST_OPEN */
/* Defined, force memory operations are disabled. */
/*#define FX_DISABLE_FORCE_MEMORY_OPERATION */
/* Defined, build options is disabled. */
/*#define FX_DISABLE_BUILD_OPTIONS */
/* Defined, one line function is disabled. */
/*#define FX_DISABLE_ONE_LINE_FUNCTION */
/* Defined, FAT entry refresh is disabled. */
/*#define FX_DIABLE_FAT_ENTRY_REFRESH */
/* Defined, consecutive detect is disabled. */
/*#define FX_DISABLE_CONSECUTIVE_DETECT */
#endif
+82
View File
@@ -0,0 +1,82 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** Utility */
/** */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/* */
/* COMPONENT DEFINITION RELEASE */
/* */
/* fx_utility.h PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file defines the FileX Utility component constants, data */
/* definitions, and external references. It is assumed that fx_api.h */
/* (and fx_port.h) have already been included. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
#ifndef FX_UTILITY_H
#define FX_UTILITY_H
/* Define the internal Utility component function prototypes. */
UINT _fx_utility_16_unsigned_read(UCHAR *source_ptr);
VOID _fx_utility_16_unsigned_write(UCHAR *dest_ptr, UINT value);
ULONG _fx_utility_32_unsigned_read(UCHAR *source_ptr);
VOID _fx_utility_32_unsigned_write(UCHAR *dest_ptr, ULONG value);
ULONG64 _fx_utility_64_unsigned_read(UCHAR *source_ptr);
VOID _fx_utility_64_unsigned_write(UCHAR *dest_ptr, ULONG64 value);
VOID _fx_utility_memory_copy(UCHAR *source_ptr, UCHAR *dest_ptr, ULONG size);
VOID _fx_utility_memory_set(UCHAR *dest_ptr, UCHAR value, ULONG size);
FX_CACHED_SECTOR
*_fx_utility_logical_sector_cache_entry_read(FX_MEDIA *media_ptr, ULONG64 logical_sector, FX_CACHED_SECTOR **previous_cache_entry);
UINT _fx_utility_logical_sector_read(FX_MEDIA *media_ptr, ULONG64 logical_sector,
VOID *buffer_ptr, ULONG sectors, UCHAR sector_type);
UINT _fx_utility_logical_sector_write(FX_MEDIA *media_ptr, ULONG64 logical_sector,
VOID *buffer_ptr, ULONG sectors, UCHAR sector_type);
UINT _fx_utility_logical_sector_flush(FX_MEDIA *media_ptr, ULONG64 starting_sector, ULONG64 sectors, UINT invalidate);
UINT _fx_utility_FAT_entry_read(FX_MEDIA *media_ptr, ULONG cluster, ULONG *entry_ptr);
UINT _fx_utility_FAT_entry_write(FX_MEDIA *media_ptr, ULONG cluster, ULONG next_cluster);
UINT _fx_utility_FAT_flush(FX_MEDIA *media_ptr);
UINT _fx_utility_FAT_map_flush(FX_MEDIA *media_ptr);
ULONG _fx_utility_FAT_sector_get(FX_MEDIA *media_ptr, ULONG cluster);
UINT _fx_utility_string_length_get(CHAR *string, UINT max_length);
#endif