Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FAT file system

FAT file system driver that provides an interface for accessing a FAT file system located on a memory device.

Supports FAT12, FAT16 and FAT32.

Modules

 

Data Structures

struct  Fs_clusterlist_cache
 Structure to store the cluster list cache. More...
 
struct  Fs_management
 Structure to save the variables frequently used by file system mounted. More...
 
struct  Fs_management_entry
 Structure to save the frequently variables of file system mounted. More...
 
struct  Fs_management_fast
 Structure to save the variables very frequently used by file system mounted. More...
 
union  Fs_rootdir
 Union to define a root directory. More...
 
struct  Fs_sector_cache
 Structure to store the information about sector cache (=last sector read or write on disk) More...
 
struct  Fs_segment
 Structure to define a segment. More...
 
struct  st_fs_cluster
 Structure to store cluster information. More...
 

Macros

#define _GLOBEXT_   extern
 
#define FS_BUF_SECTOR_EMPTY   0xFF
 Signal that sector cache is not valid. More...
 
#define FS_MBR_OFFSET_PART_ENTRY(num)   ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num)))
 Position (unit byte) in the MBR of a partition entry. More...
 
#define Is_fat12   (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat)
 
#define Is_fat16   (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat)
 
#define Is_fat32   (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat)
 
#define Is_unicode   (g_b_unicode)
 

Functions

bool fat_format (uint8_t u8_fat_type)
 This function formats the drive. More...
 
uint8_t fat_get_nbpartition (void)
 This function returns the number of partition present on selected drive. More...
 
bool fat_mount (void)
 This function mounts a partition. More...
 
bool fat_serialnumber (bool b_action, uint8_t _MEM_TYPE_SLOW_ *a_u8_sn)
 This function reads or writes a serial number. More...
 

Variables

_GLOBEXT_ _MEM_TYPE_FAST_
Fs_cluster 
fs_g_cluster
 To take time in functions: fat_getfreespace, fat_cluster_list, fat_cluster_val, fat_checkcluster. More...
 
_GLOBEXT_ _MEM_TYPE_FAST_
Fs_segment 
fs_g_seg
 Variable frequently used by many function (optimization, no parameter in function) More...
 
_GLOBEXT_ bool g_b_no_check_disk
 Variables to enable/disable the disk check before each action on disk. More...
 
_GLOBEXT_ bool g_b_string_length
 Variables to select LENGTH string mode (initialised in nav_reset()) More...
 
_GLOBEXT_ bool g_b_unicode
 Variables to select string format (initialised in nav_reset()) More...
 

Macro to access at fields in BPB sector (only used in fat_mount() function)

The name prefixed by "BPB_" are defined in "Hardware White Paper FAT"

#define LOW_16_BPB_BytsPerSec   fs_g_sector[11]
 
#define HIGH_16_BPB_BytsPerSec   fs_g_sector[12]
 
#define U8_BPB_SecPerClus   fs_g_sector[13]
 
#define LOW_16_BPB_RootEntCnt   fs_g_sector[17]
 
#define HIGH_16_BPB_RootEntCnt   fs_g_sector[18]
 
#define LOW_16_BPB_FATSz16   fs_g_sector[22]
 
#define HIGH_16_BPB_FATSz16   fs_g_sector[23]
 
#define LOW0_32_BPB_FATSz32   fs_g_sector[36]
 
#define LOW1_32_BPB_FATSz32   fs_g_sector[37]
 
#define LOW2_32_BPB_FATSz32   fs_g_sector[38]
 
#define LOW3_32_BPB_FATSz32   fs_g_sector[39]
 
#define LOW_16_BPB_TotSec16   fs_g_sector[19]
 
#define HIGH_16_BPB_TotSec16   fs_g_sector[20]
 
#define LOW0_32_BPB_TotSec32   fs_g_sector[32]
 
#define LOW1_32_BPB_TotSec32   fs_g_sector[33]
 
#define LOW2_32_BPB_TotSec32   fs_g_sector[34]
 
#define LOW3_32_BPB_TotSec32   fs_g_sector[35]
 
#define LOW_16_BPB_ResvSecCnt   fs_g_sector[14]
 
#define HIGH_16_BPB_ResvSecCnt   fs_g_sector[15]
 
#define U8_BPB_NumFATs   fs_g_sector[16]
 
#define LOW0_32_BPB_RootClus   fs_g_sector[44]
 
#define LOW1_32_BPB_RootClus   fs_g_sector[45]
 
#define LOW2_32_BPB_RootClus   fs_g_sector[46]
 
#define LOW3_32_BPB_RootClus   fs_g_sector[47]
 
#define LOW_16_BPB_FSInfo   fs_g_sector[48]
 
#define HIGH_16_BPB_FSInfo   fs_g_sector[49]
 

Constants used to sign a MBR or PBR sectors

#define FS_BR_SIGNATURE_LOW   0x55
 
#define FS_BR_SIGNATURE_HIGH   0xAA
 

Constants used in MBR sector

#define FS_PART_BOOTABLE   0x80
 
#define FS_PART_NO_BOOTABLE   0x00
 
#define FS_PART_TYPE_FAT12   0x01
 
#define FS_PART_TYPE_FAT16_INF32M   0x04
 
#define FS_PART_TYPE_FAT16_SUP32M   0x06
 
#define FS_PART_TYPE_FAT16_SUP32M_BIS   0x0E
 
#define FS_PART_TYPE_FAT32   0x0B
 
#define FS_PART_TYPE_FAT32_BIS   0x0C
 
#define FS_PART_REMOVE_MEDIA   0xF0
 
#define FS_PART_NO_REMOVE_MEDIA   0xF8
 
#define FS_PART_HARD_DISK   0x81
 
#define FS_BOOT_SIGN   0x29
 

Maximum of FAT cluster

#define FS_FAT12_MAX_CLUSTERS   4085
 
#define FS_FAT16_MAX_CLUSTERS   65525
 

Constants used in the first byte of file entry

#define FS_ENTRY_END   0x00
 
#define FS_ENTRY_DEL   0xE5
 
#define FS_ENTRY_LFN_LAST   0x40
 

Constantes used to manage the file entry

#define FS_SIZE_FILE_ENTRY   32
 
#define FS_SHIFT_B_TO_FILE_ENTRY   5
 
#define FS_SIZE_LFN_ENTRY   13
 
#define FS_SIZE_SFNAME   11
 
#define FS_SIZE_SFNAME_WITHOUT_EXT   8
 
#define FS_SIZE_SFNAME_EXT_ONLY   3
 

LIMITATIONS OF FILE SYSTEM

#define FS_NB_FAT   2
 

The unit sector of 512B is many used in file System stack

#define FS_512B   512
 
#define FS_512B_MASK   (512-1)
 
#define FS_512B_SHIFT_BIT   9
 
#define FS_SIZE_OF_SECTOR   FS_512B
 
#define FS_MASK_SIZE_OF_SECTOR   FS_512B_MASK
 
#define FS_SHIFT_B_TO_SECTOR   FS_512B_SHIFT_BIT
 
#define FS_CACHE_SIZE   512
 

Status of the fat_checkcluster() function

#define FS_CLUS_OK   0
 
#define FS_CLUS_BAD   1
 
#define FS_CLUS_END   2
 

Options of the fat_cluster_list() function

#define FS_CLUST_ACT_SEG   0x01
 
#define FS_CLUST_ACT_ONE   0x02
 
#define FS_CLUST_ACT_CLR   0x03
 

Options of the fat_cluster_val() function

#define FS_CLUST_VAL_READ   false
 
#define FS_CLUST_VAL_WRITE   true
 
#define FS_CLUST_VAL_EOL   0x0FFFFFFF
 

Main structures

typedef struct st_fs_cluster Fs_cluster
 Structure to store cluster information. More...
 

FAT type ID, used in "Fs_management_fast.u8_type_fat"

#define FS_TYPE_FAT_UNM   0
 Partition not mounted. More...
 
#define FS_TYPE_FAT_12   1
 
#define FS_TYPE_FAT_16   2
 
#define FS_TYPE_FAT_32   3
 

Value used in "Fs_management_fast.u16_entry_pos_sel_file"

#define FS_NO_SEL   0xFFFF
 Signal that a file entry isn't selected. More...
 
#define FS_END_FIND   0xFFFE
 Signal that a file entry is the last file entry accessible by system. More...
 

Macro to check the file open mode

#define Fat_file_is_open()   (fs_g_nav_entry.u8_open_mode !=0 )
 
#define Fat_file_isnot_open()   (fs_g_nav_entry.u8_open_mode ==0 )
 
#define Fat_file_close()   (fs_g_nav_entry.u8_open_mode =0 )
 

Variables initialized in drive_mount()

_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_management 
fs_g_nav
 
_GLOBEXT_ _MEM_TYPE_FAST_
Fs_management_fast 
fs_g_nav_fast
 
_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_management_entry 
fs_g_nav_entry
 

Variables used to manage the sector cache

typedef uint8_t _MEM_TYPE_SLOW_PTR_CACHE
 
_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t fs_g_sector [FS_CACHE_SIZE]
 Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf()) More...
 
_GLOBEXT_ _MEM_TYPE_SLOW_
Fs_sector_cache 
fs_g_sectorcache
 
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector
 Store the address of future cache (unit 512B) More...
 

Functions to verify navigator state

}@

bool fat_check_device (void)
 This function checks device state. More...
 
bool fat_check_mount (void)
 This function checks if the partition is mounted. More...
 
bool fat_check_noopen (void)
 This function checks if a file is not opened on current navigator. More...
 
bool fat_check_open (void)
 This function checks if a file is opened on current navigator. More...
 
bool fat_check_select (void)
 This function checks if a file is selected on current navigator. More...
 
bool fat_check_mount_noopen (void)
 This function checks if the partition is mounted and no file is opened. More...
 
bool fat_check_mount_select_noopen (void)
 This function checks if the partition is mounted and if no file is opened and a file is selected. More...
 
bool fat_check_mount_select_open (void)
 This function checks if the partition is mounted and if a file is opened. More...
 
bool fat_check_mount_select (void)
 This function checks if the partition is mounted and if a file is selected. More...
 
bool fat_check_is_file (void)
 This function checks if the selected file entry is a file and not a directory. More...
 

Functions to compute free space on a partition

uint32_t fat_getfreespace (void)
 This function returns the space free in the partition. More...
 
uint8_t fat_getfreespace_percent (void)
 This function returns the space free in percent. More...
 
bool fat_write_fat32_FSInfo (uint32_t u32_nb_free_cluster)
 
uint32_t fat_read_fat32_FSInfo (void)
 

Functions to manage the cluster list

bool fat_cluster_list (uint8_t opt_action, bool b_for_file)
 This function gets or clears a cluster list. More...
 
void fat_cache_clusterlist_reset (void)
 This function resets the cluster list caches. More...
 
bool fat_cluster_val (bool b_mode)
 This function returns or modifies a cluster value in FAT. More...
 
bool fat_cluster_readnext (void)
 This function is optimized to read a continue cluster list on FAT16 and FAT32. More...
 
uint8_t fat_checkcluster (void)
 This function checks the cluster value. More...
 
bool fat_allocfreespace (void)
 
void fat_clear_info_fat_mod (void)
 
bool fat_clear_cluster (void)
 
bool fat_update_fat2 (void)
 

Functions to read or to write a file or a directory

bool fat_read_file (uint8_t mode)
 This function gets or clears a cluster list at the current position in the selected file. More...
 
bool fat_write_file (uint8_t mode, uint32_t u32_nb_sector_write)
 
bool fat_read_dir (void)
 This function fill the internal cache with a sector from current directory. More...
 
bool fat_initialize_dir (void)
 

Functions to manage the entry field (fat.c)

bool fat_entry_check (bool b_type)
 This function checks the entry. More...
 
bool fat_entry_checkext (FS_STRING sz_filter)
 This function checks the file extension. More...
 
void fat_get_entry_info (void)
 This function reads information about selected file. More...
 
bool fat_entry_is_dir (void)
 This function checks if the entry file is a directory. More...
 
void fat_clear_entry_info_and_ptr (void)
 This function resets the selection pointers. More...
 
void fat_write_entry_file (void)
 
bool fat_entry_shortname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode)
 This function returns or compares the short name entry. More...
 
bool fat_entry_longname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode, bool b_match_case)
 This function returns or compares the long name entry. More...
 
bool fat_check_eof_name (uint16_t character)
 Check end of name. More...
 
PTR_CACHE fat_get_ptr_entry (void)
 This function returns a cache pointer on the current entry. More...
 

Functions to manage the entry field (fat_unusual.c)

bool fat_create_entry_file_name (FS_STRING sz_name)
 
void fat_get_date (FS_STRING sz_date, bool type_date)
 This function reads the information about a date. More...
 
void fat_set_date (const FS_STRING sz_date, bool type_date)
 
bool fat_delete_file (bool b_cluster_list)
 
bool fat_entry_label (bool b_action, FS_STRING sz_label)
 

Functions to manage the cache

bool fat_cache_read_sector (bool b_load)
 This function loads a memory sector in internal cache sector. More...
 
void fat_cache_reset (void)
 This function resets the sector cache. More...
 
void fat_cache_clear (void)
 
void fat_cache_mark_sector_as_dirty (void)
 
bool fat_cache_flush (void)
 This function flushes the sector cache on the memory if necessary. More...
 

Functions to control access disk

#define fat_check_nav_access_disk(b)   (true)
 
#define fat_check_nav_access_file(b)   (true)
 

Functions to manage navigator switch

#define fat_invert_nav   ( arg ) (arg++)
 
#define fat_copy_nav   ( arg ) (arg++)
 

#define _GLOBEXT_   extern
//! - File system vocabulary :
//! MBR : Master Boot Record (constains four PE)
//! PE  : Partition Entry (constains a location informations about PBR)
//! PBR : Partition Boot Record
//! BPB : BIOS Parameter Block (see Hardware White Paper FAT)
//! PBR = BPB
//! FAT : File Allocation Table
//! 
#define fat_check_nav_access_disk (   b)    (true)
#define fat_check_nav_access_file (   b)    (true)

Referenced by file_open().

#define fat_copy_nav   ( arg ) (arg++)

Referenced by nav_copy().

#define Fat_file_close ( )    (fs_g_nav_entry.u8_open_mode =0 )
#define Fat_file_is_open ( )    (fs_g_nav_entry.u8_open_mode !=0 )

Referenced by fat_check_noopen().

#define Fat_file_isnot_open ( )    (fs_g_nav_entry.u8_open_mode ==0 )

Referenced by fat_check_open().

#define fat_invert_nav   ( arg ) (arg++)

Referenced by nav_select().

#define FS_512B   512
#define FS_512B_MASK   (512-1)
#define FS_512B_SHIFT_BIT   9
#define FS_BOOT_SIGN   0x29
#define FS_BR_SIGNATURE_HIGH   0xAA

Referenced by fat_mount().

#define FS_BR_SIGNATURE_LOW   0x55

Referenced by fat_mount().

#define FS_BUF_SECTOR_EMPTY   0xFF

Signal that sector cache is not valid.

Referenced by fat_cache_reset().

#define FS_CACHE_SIZE   512
#define FS_CLUS_BAD   1
#define FS_CLUS_END   2
#define FS_CLUS_OK   0

Referenced by fat_checkcluster().

#define FS_CLUST_ACT_CLR   0x03

Referenced by fat_cluster_list(), and fat_read_file().

#define FS_CLUST_ACT_ONE   0x02
#define FS_CLUST_ACT_SEG   0x01
#define FS_CLUST_VAL_EOL   0x0FFFFFFF

Referenced by fat_cluster_list().

#define FS_CLUST_VAL_READ   false
#define FS_CLUST_VAL_WRITE   true

Referenced by fat_cluster_list().

#define FS_END_FIND   0xFFFE

Signal that a file entry is the last file entry accessible by system.

Referenced by nav_filelist_set().

#define FS_ENTRY_DEL   0xE5
#define FS_ENTRY_END   0x00
#define FS_ENTRY_LFN_LAST   0x40

Referenced by fat_entry_longname().

#define FS_FAT12_MAX_CLUSTERS   4085

Referenced by fat_mount().

#define FS_FAT16_MAX_CLUSTERS   65525

Referenced by fat_mount().

#define FS_MASK_SIZE_OF_SECTOR   FS_512B_MASK
#define FS_MBR_OFFSET_PART_ENTRY (   num)    ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num)))

Position (unit byte) in the MBR of a partition entry.

Referenced by fat_mount().

#define FS_NB_FAT   2

Referenced by fat_mount().

#define FS_PART_BOOTABLE   0x80

Referenced by fat_mount().

#define FS_PART_HARD_DISK   0x81
#define FS_PART_NO_BOOTABLE   0x00

Referenced by fat_mount().

#define FS_PART_NO_REMOVE_MEDIA   0xF8
#define FS_PART_REMOVE_MEDIA   0xF0
#define FS_PART_TYPE_FAT12   0x01

Referenced by fat_mount().

#define FS_PART_TYPE_FAT16_INF32M   0x04

Referenced by fat_mount().

#define FS_PART_TYPE_FAT16_SUP32M   0x06

Referenced by fat_mount().

#define FS_PART_TYPE_FAT16_SUP32M_BIS   0x0E

Referenced by fat_mount().

#define FS_PART_TYPE_FAT32   0x0B

Referenced by fat_mount().

#define FS_PART_TYPE_FAT32_BIS   0x0C

Referenced by fat_mount().

#define FS_SHIFT_B_TO_FILE_ENTRY   5

Referenced by fat_read_dir().

#define FS_SHIFT_B_TO_SECTOR   FS_512B_SHIFT_BIT

Referenced by main(), prv_df(), and ushell_cmd_free_space().

#define FS_SIZE_FILE_ENTRY   32
#define FS_SIZE_LFN_ENTRY   13

Referenced by nav_file_name().

#define FS_SIZE_SFNAME   11

Referenced by fat_entry_shortname().

#define FS_SIZE_SFNAME_EXT_ONLY   3
#define FS_SIZE_SFNAME_WITHOUT_EXT   8

Referenced by fat_entry_shortname().

#define FS_TYPE_FAT_12   1

Referenced by fat_mount(), main(), and ushell_cmd_ls().

#define FS_TYPE_FAT_16   2

Referenced by fat_mount(), main(), and ushell_cmd_ls().

#define FS_TYPE_FAT_32   3

Referenced by fat_mount(), main(), and ushell_cmd_ls().

#define HIGH_16_BPB_BytsPerSec   fs_g_sector[12]

Referenced by fat_mount().

#define HIGH_16_BPB_FATSz16   fs_g_sector[23]

Referenced by fat_mount().

#define HIGH_16_BPB_FSInfo   fs_g_sector[49]
#define HIGH_16_BPB_ResvSecCnt   fs_g_sector[15]

Referenced by fat_mount().

#define HIGH_16_BPB_RootEntCnt   fs_g_sector[18]

Referenced by fat_mount().

#define HIGH_16_BPB_TotSec16   fs_g_sector[20]

Referenced by fat_mount().

#define Is_fat16   (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat)
#define LOW0_32_BPB_FATSz32   fs_g_sector[36]

Referenced by fat_mount().

#define LOW0_32_BPB_RootClus   fs_g_sector[44]

Referenced by fat_mount().

#define LOW0_32_BPB_TotSec32   fs_g_sector[32]

Referenced by fat_mount().

#define LOW1_32_BPB_FATSz32   fs_g_sector[37]

Referenced by fat_mount().

#define LOW1_32_BPB_RootClus   fs_g_sector[45]

Referenced by fat_mount().

#define LOW1_32_BPB_TotSec32   fs_g_sector[33]

Referenced by fat_mount().

#define LOW2_32_BPB_FATSz32   fs_g_sector[38]

Referenced by fat_mount().

#define LOW2_32_BPB_RootClus   fs_g_sector[46]

Referenced by fat_mount().

#define LOW2_32_BPB_TotSec32   fs_g_sector[34]

Referenced by fat_mount().

#define LOW3_32_BPB_FATSz32   fs_g_sector[39]

Referenced by fat_mount().

#define LOW3_32_BPB_RootClus   fs_g_sector[47]

Referenced by fat_mount().

#define LOW3_32_BPB_TotSec32   fs_g_sector[35]

Referenced by fat_mount().

#define LOW_16_BPB_BytsPerSec   fs_g_sector[11]
#define LOW_16_BPB_FATSz16   fs_g_sector[22]

Referenced by fat_mount().

#define LOW_16_BPB_FSInfo   fs_g_sector[48]

Referenced by fat_mount().

#define LOW_16_BPB_ResvSecCnt   fs_g_sector[14]

Referenced by fat_mount().

#define LOW_16_BPB_RootEntCnt   fs_g_sector[17]

Referenced by fat_mount().

#define LOW_16_BPB_TotSec16   fs_g_sector[19]

Referenced by fat_mount().

#define U8_BPB_NumFATs   fs_g_sector[16]
#define U8_BPB_SecPerClus   fs_g_sector[13]

Referenced by fat_mount().

typedef struct st_fs_cluster Fs_cluster

Structure to store cluster information.

typedef uint8_t _MEM_TYPE_SLOW_* PTR_CACHE

bool fat_allocfreespace ( void  )
void fat_cache_clear ( void  )
void fat_cache_clusterlist_reset ( void  )
bool fat_cache_flush ( void  )

This function flushes the sector cache on the memory if necessary.

Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References CTRL_GOOD, FS_ERR_HW, fs_g_sector, fs_g_sectorcache, fs_g_status, FS_LUN_WP, mem_wr_protect(), ram_2_memory(), Fs_sector_cache::u32_addr, Fs_sector_cache::u8_dirty, and Fs_sector_cache::u8_lun.

Referenced by e_supervisor_switch_to_maintenance_mode(), fat_cache_read_sector(), file_close(), nav_exit(), ushell_cmd_perform_access(), ushell_cmd_perform_extaccess(), and x_supervisor_SemaphoreGive().

void fat_cache_mark_sector_as_dirty ( void  )

Referenced by fat_cluster_val().

bool fat_cache_read_sector ( bool  b_load)

This function loads a memory sector in internal cache sector.

@param     b_load   true,  load the cache with the memory sector corresponding <br>
                    false, Don't change the sector cache but change the memory address of cache <br>

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variable used
//! IN :
//!   fs_g_nav.u8_lun      drive number to read
//!   fs_gu32_addrsector   address to read (unit sector)
//! 

References CTRL_GOOD, fat_cache_flush(), fat_cache_reset(), FS_ERR_HW, fs_g_nav, fs_g_sector, fs_g_sectorcache, fs_g_status, fs_gu32_addrsector, memory_2_ram(), Fs_sector_cache::u32_addr, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.

Referenced by fat_cluster_readnext(), fat_cluster_val(), fat_getfreespace_percent(), fat_mount(), fat_read_dir(), and fat_read_file().

bool fat_check_eof_name ( uint16_t  character)

Check end of name.

Parameters
charactervalue of character to check
Returns
true, it is a character to signal a end of name (0,'\','/')
false, otherwise

Referenced by fat_entry_longname().

bool fat_check_is_file ( void  )

This function checks if the selected file entry is a file and not a directory.

Returns
true It is a file and not a directory
false otherwise

References Fat_is_not_a_file, FS_ERR_NO_FILE, and fs_g_status.

Referenced by file_ispresent(), and file_open().

bool fat_check_mount ( void  )
bool fat_check_mount_noopen ( void  )

This function checks if the partition is mounted and no file is opened.

Returns
true partition mounted and no file is opened
false otherwise

References fat_check_mount(), and fat_check_noopen().

Referenced by nav_dir_gotoparent(), nav_dir_is_root(), nav_dir_name(), nav_filelist_reset(), nav_filelist_set(), nav_filterlist_gotoparent(), and nav_getcwd().

bool fat_check_mount_select ( void  )

This function checks if the partition is mounted and if a file is selected.

Returns
true partition mounted and a file is selected
false otherwise

References fat_check_mount(), and fat_check_select().

Referenced by file_ispresent(), nav_file_checkext(), nav_file_dateget(), nav_file_isreadonly(), and nav_file_name().

bool fat_check_mount_select_noopen ( void  )

This function checks if the partition is mounted and if no file is opened and a file is selected.

Returns
true partition mounted and no file is opened and a file is selected
false otherwise

References fat_check_mount(), fat_check_noopen(), and fat_check_select().

Referenced by file_open(), nav_dir_cd(), and nav_filelist_validpos().

bool fat_check_mount_select_open ( void  )

This function checks if the partition is mounted and if a file is opened.

Returns
true partition mounted and a file is opened
false otherwise

References fat_check_mount(), fat_check_open(), and fat_check_select().

Referenced by file_bof(), file_close(), file_eof(), file_getpos(), file_read(), file_read_buf(), file_seek(), output(), and play_wav().

bool fat_check_noopen ( void  )
bool fat_check_open ( void  )

This function checks if a file is opened on current navigator.

Returns
true a file is opened
false otherwise

References Fat_file_isnot_open, FS_ERR_FILE_NO_OPEN, and fs_g_status.

Referenced by fat_check_mount_select_open().

bool fat_check_select ( void  )

This function checks if a file is selected on current navigator.

Returns
true a file is selected
false otherwise

References FS_ERR_NO_FILE_SEL, fs_g_nav_fast, fs_g_status, FS_NO_SEL, and Fs_management_fast::u16_entry_pos_sel_file.

Referenced by fat_check_mount_select(), fat_check_mount_select_noopen(), fat_check_mount_select_open(), and nav_getcwd().

uint8_t fat_checkcluster ( void  )

This function checks the cluster value.

@return    value status <br>
           FS_CLUS_OK        Value correct <br>
           FS_CLUS_BAD       Value bad <br>
           FS_CLUS_END       It is a end of list <br>
//! Global variable used
//! IN :
//!   fs_g_cluster.u32_val       value to check
//! 

References FS_CLUS_BAD, FS_CLUS_END, FS_CLUS_OK, fs_g_cluster, Is_fat12, Is_fat16, Is_fat32, and st_fs_cluster::u32_val.

Referenced by fat_cluster_list().

bool fat_clear_cluster ( void  )
void fat_clear_info_fat_mod ( void  )

Referenced by fat_cluster_list().

bool fat_cluster_list ( uint8_t  opt_action,
bool  b_for_file 
)

This function gets or clears a cluster list.

@param     b_for_file        If true then it is a file cluster list else a directory cluster list  <br>
@param     opt_action        Choose action on the cluster list <br>
           FS_CLUST_ACT_SEG  Get continue memory segment corresponding at cluster list <br>
           FS_CLUST_ACT_ONE  Get only one memory sector (512B) corresponding at cluster list <br>
           FS_CLUST_ACT_CLR  Clear the cluster list <br>

@return  false in case of error, see global value "fs_g_status" for more detail
@return  true otherwise
//! Global variables used
//! IN :
//!   fs_g_seg.u32_addr          The first cluster of the cluster list
//!   fs_g_seg.u32_size_or_pos   Start position in the cluster list (unit 512B)
//! OUT:
//!   fs_g_seg.u32_addr          The memory segment address corresponding at the beginning of cluster list (only for action FS_CLUST_ACT_SEG & FS_CLUST_ACT_ONE)
//!   fs_g_seg.u32_size_or_pos   The memory segment size corresponding at cluster list read or cleared (unit 512B)
//! 

References _MEM_TYPE_FAST_, fat_cache_clusterlist_reset(), fat_cache_clusterlist_update_finish(), fat_cache_clusterlist_update_read(), fat_checkcluster(), fat_clear_info_fat_mod(), fat_cluster_readnext(), fat_cluster_val(), fat_update_fat2(), fat_write_fat32_FSInfo(), FS_CLUS_BAD, FS_CLUS_END, FS_CLUST_ACT_CLR, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_CLUST_VAL_EOL, FS_CLUST_VAL_READ, FS_CLUST_VAL_WRITE, FS_ERR_FS, FS_ERR_OUT_LIST, fs_g_cache_clusterlist, fs_g_cluster, fs_g_nav, fs_g_seg, fs_g_status, fs_g_u8_current_cache, Is_fat12, Is_fat16, Is_fat32, LSB0, MSB0, Fs_management::rootdir, Fs_rootdir::seg, Fs_rootdir::u16_pos, Fs_rootdir::u16_size, Fs_segment::u32_addr, Fs_rootdir::u32_cluster, Fs_management::u32_offset_data, st_fs_cluster::u32_pos, Fs_management::u32_ptr_fat, Fs_segment::u32_size_or_pos, Fs_clusterlist_cache::u32_start, st_fs_cluster::u32_val, and Fs_management::u8_BPB_SecPerClus.

Referenced by fat_read_dir(), and fat_read_file().

bool fat_cluster_readnext ( void  )

This function is optimized to read a continue cluster list on FAT16 and FAT32.

Read global value "fs_g_status" in case of error :
         FS_ERR_HW            Hardware driver error
         FS_LUN_WP            Drive is read only

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variables used
//! IN :
//!   fs_g_u16_pos_fat        previous cluster position in FAT
//! OUT:
//!   fs_g_u16_pos_fat        read cluster position in FAT
//!   fs_g_cluster.u32_val    value of cluster read
//! 

References fat_cache_read_sector(), FS_CACHE_SIZE, fs_g_cluster, fs_g_sector, fs_gu32_addrsector, Is_fat32, LSB0, LSB1, LSB2, LSB3, and st_fs_cluster::u32_val.

Referenced by fat_cluster_list(), and fat_getfreespace().

bool fat_cluster_val ( bool  b_mode)

This function returns or modifies a cluster value in FAT.

@param     b_mode   false, to read a cluster value <br>
                    true,  to write a cluster value

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variables used
//! IN :
//!   fs_g_cluster.u32_pos    cluster number to read or write
//!   fs_g_cluster.u32_val    value to write
//! OUT:
//!   fs_g_cluster.u32_val    value ready
//!   fs_g_u16_pos_fat        position in FAT of the cluster to read or write
//!                           value init in case of the fat_cluster_readnext() routine is used after
//! 

References _MEM_TYPE_FAST_, fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), FS_CACHE_SIZE, FS_ERR_COMMAND, fs_g_cluster, fs_g_nav, fs_g_sector, fs_g_status, fs_g_u16_pos_fat, fs_gu32_addrsector, Is_fat12, Is_fat16, Is_fat32, LSB0, LSB1, LSB2, LSB3, MSB, st_fs_cluster::u32_pos, Fs_management::u32_ptr_fat, and st_fs_cluster::u32_val.

Referenced by fat_cluster_list(), fat_getfreespace(), and fat_getfreespace_percent().

bool fat_create_entry_file_name ( FS_STRING  sz_name)
bool fat_delete_file ( bool  b_cluster_list)
bool fat_entry_check ( bool  b_type)

This function checks the entry.

@param     b_type   entry type to compare (FS_FILE or FS_DIR)

@return    true,    the entry is a short entry and correspond to b_type
@return    false,   otherwise
//! Global variable used
//! IN :
//!   fs_g_sector       The directory sector corresponding at the current position
//!   fs_g_nav_fast.u16_entry_pos_sel_file    Position in directory of the entry file (unit entry)
//! 

References fat_get_ptr_entry(), FS_ATTR_DIRECTORY, FS_ATTR_VOLUME_ID, FS_DIR, FS_ENTRY_DEL, FS_ENTRY_END, FS_ERR_ENTRY_BAD, FS_ERR_ENTRY_EMPTY, FS_FILE, and fs_g_status.

Referenced by nav_filelist_set().

bool fat_entry_checkext ( FS_STRING  sz_filter)

This function checks the file extension.

@param     sz_filter      extension filter is a ASCII string (ex: "mp3,w*" )

@return    true, the file name have a good extension
@return    false, otherwise
//! Global variable used
//! IN :
//!   fs_g_sector       The directory sector corresponding at the current position
//!   fs_g_nav_fast.u16_entry_pos_sel_file    Position in directory of the entry file (unit entry)
//! 

References fat_get_ptr_entry().

Referenced by nav_file_checkext().

bool fat_entry_is_dir ( void  )

This function checks if the entry file is a directory.

Returns
true, this entry is a directory
false, otherwise

References FS_ATTR_DIRECTORY, FS_ERR_NO_DIR, fs_g_nav_entry, fs_g_status, and Fs_management_entry::u8_attr.

Referenced by nav_dir_cd(), nav_file_isdir(), and nav_setcwd().

bool fat_entry_label ( bool  b_action,
FS_STRING  sz_label 
)

Referenced by nav_partition_label().

bool fat_entry_longname ( FS_STRING  sz_name,
uint8_t  u8_size_max,
bool  b_mode,
bool  b_match_case 
)

This function returns or compares the long name entry.

@param     b_mode         action mode: <br>
                          FS_NAME_GET       to get the long name of selected file <br>
                          FS_NAME_CHECK     to compare the long name of selected file <br>
@param     sz_name        if FS_NAME_GET    then buffer to store the long name file (ASCII or UNICODE ) <br>
                          if FS_NAME_CHECK  then name to compare with long name (ASCII or UNICODE),
                                            it must be terminate by NULL or '*' value <br>

@param     b_match_case   false, ignore the case (only used in "FS_NAME_CHECK" action mode)
@param     u8_size_max    buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode)

@return    false is not the end of long name, or in case of error, see global value "fs_g_status" for more detail
@return    true, the name is correct or read is finish
//! Global variable used
//! IN :
//!   fs_g_sector       The directory sector corresponding at the current position
//!   fs_g_nav_fast.u16_entry_pos_sel_file    Position in directory of the entry file (unit entry)
//! 

References fat_check_eof_name(), fat_get_ptr_entry(), FS_ATTR_LFN_ENTRY, FS_ENTRY_DEL, FS_ENTRY_END, FS_ENTRY_LFN_LAST, FS_ERR_ENTRY_BAD, FS_ERR_NAME_INCORRECT, fs_g_status, FS_NAME_GET, FS_NO_LAST_LFN_ENTRY, FS_SIZE_FILE_ENTRY, g_b_string_length, Is_unicode, LSB, and MSB.

Referenced by nav_file_name().

bool fat_entry_shortname ( FS_STRING  sz_name,
uint8_t  u8_size_max,
bool  b_mode 
)

This function returns or compares the short name entry.

@param     b_mode         action mode: <br>
                          FS_NAME_GET       to get the short name of selected file <br>
                          FS_NAME_CHECK     to compare the short name of selected file <br>
@param     sz_name        if FS_NAME_GET    then buffer to store the short name file (ASCII or UNICODE ) <br>
                          if FS_NAME_CHECK  then name to compare with short name (ASCII or UNICODE),
                                            it must be terminate by NULL or '*' value <br>
@param     u8_size_max    buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode)

@return    false, in case of error, see global value "fs_g_status" for more detail
@return    true, the name is correct or read OK
//! Global variable used
//! IN :
//!   fs_g_sector       The directory sector corresponding at the current position
//!   fs_g_nav_fast.u16_entry_pos_sel_file    Position in directory of the entry file (unit entry)
//! 

References fat_get_ptr_entry(), FS_ERR_NAME_INCORRECT, fs_g_status, FS_NAME_GET, FS_SIZE_SFNAME, FS_SIZE_SFNAME_WITHOUT_EXT, g_b_string_length, Is_unicode, and MSB.

Referenced by nav_file_name().

bool fat_format ( uint8_t  u8_fat_type)

This function formats the drive.

void fat_get_date ( FS_STRING  sz_date,
bool  type_date 
)

This function reads the information about a date.

Parameters
type_datechoose the date type (FS_DATE_LAST_WRITE or FS_DATE_CREATION)
sz_datetable to store the date
storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond

References fat_get_ptr_entry(), fat_translatedate_number_to_ascii(), and FS_DATE_LAST_WRITE.

Referenced by nav_file_dateget().

void fat_get_entry_info ( void  )

This function reads information about selected file.

//! Global variable used
//! IN :
//!   fs_g_sector       The directory sector corresponding at the current position
//!   fs_g_nav_fast.u16_entry_pos_sel_file    Position in directory of the entry file (unit entry)
//! OUT:
//!   fs_g_nav_entry. u32_cluster, u8_attr, u32_size
//! 

References fat_get_ptr_entry(), fs_g_nav_entry, LSB0, LSB1, LSB2, LSB3, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.

Referenced by nav_dir_gotoparent(), nav_filelist_set(), nav_filterlist_gotoparent(), and navauto_mov_explorer_updir().

uint8_t fat_get_nbpartition ( void  )

This function returns the number of partition present on selected drive.

This function returns the number of partition present on selected drive.

Returns
u8_number number of partition
PTR_CACHE fat_get_ptr_entry ( void  )

This function returns a cache pointer on the current entry.

Returns
a pointer on the internal cache

References FS_512B_MASK, fs_g_nav_fast, fs_g_sector, FS_SIZE_FILE_ENTRY, and Fs_management_fast::u16_entry_pos_sel_file.

Referenced by fat_entry_check(), fat_entry_checkext(), fat_entry_longname(), fat_entry_shortname(), fat_get_date(), and fat_get_entry_info().

uint32_t fat_getfreespace ( void  )
uint8_t fat_getfreespace_percent ( void  )

This function returns the space free in percent.

@return    percent of free space (1 to 100)
           if 0, then error or full
//! More speed than fat_getfreespace() routine but error delta 1%
//! 

References fat_cache_read_sector(), fat_cluster_val(), fat_getfreespace(), fat_read_fat32_FSInfo(), FS_CLUST_VAL_READ, fs_g_cluster, fs_g_nav, fs_g_sector, fs_gu32_addrsector, Is_fat12, Is_fat16, Is_fat32, Fs_management::u32_CountofCluster, Fs_management::u32_fat_size, st_fs_cluster::u32_pos, and Fs_management::u8_BPB_SecPerClus.

Referenced by nav_partition_freespace_percent().

bool fat_initialize_dir ( void  )
bool fat_mount ( void  )

This function mounts a partition.

This function mounts a partition.

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variables used
//! IN :
//!   fs_g_nav.u8_lun            Indicate the drive to mount
//!   fs_g_nav.u8_partition      Indicate the partition to mount (if FS_MULTI_PARTITION =  true )
//! OUT:
//!   fs_g_nav                   update structure
//! If the FS_MULTI_PARTITION option is disabled
//! then the mount routine selects the first partition supported by file system. <br>
//! 

References fat_cache_read_sector(), fat_check_device(), fat_clear_entry_info_and_ptr(), FS_512B, FS_BR_SIGNATURE_HIGH, FS_BR_SIGNATURE_LOW, FS_ERR_NO_FORMAT, FS_ERR_NO_PART, FS_ERR_NO_SUPPORT_PART, FS_FAT12_MAX_CLUSTERS, FS_FAT16_MAX_CLUSTERS, fs_g_nav, fs_g_nav_fast, fs_g_sector, fs_g_status, fs_gu32_addrsector, FS_MBR_OFFSET_PART_ENTRY, FS_NB_FAT, FS_PART_BOOTABLE, FS_PART_NO_BOOTABLE, FS_PART_TYPE_FAT12, FS_PART_TYPE_FAT16_INF32M, FS_PART_TYPE_FAT16_SUP32M, FS_PART_TYPE_FAT16_SUP32M_BIS, FS_PART_TYPE_FAT32, FS_PART_TYPE_FAT32_BIS, FS_SIZE_FILE_ENTRY, FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32, FS_TYPE_FAT_UNM, HIGH_16_BPB_BytsPerSec, HIGH_16_BPB_FATSz16, HIGH_16_BPB_ResvSecCnt, HIGH_16_BPB_RootEntCnt, HIGH_16_BPB_TotSec16, LOW0_32_BPB_FATSz32, LOW0_32_BPB_RootClus, LOW0_32_BPB_TotSec32, LOW1_32_BPB_FATSz32, LOW1_32_BPB_RootClus, LOW1_32_BPB_TotSec32, LOW2_32_BPB_FATSz32, LOW2_32_BPB_RootClus, LOW2_32_BPB_TotSec32, LOW3_32_BPB_FATSz32, LOW3_32_BPB_RootClus, LOW3_32_BPB_TotSec32, LOW_16_BPB_FATSz16, LOW_16_BPB_FSInfo, LOW_16_BPB_ResvSecCnt, LOW_16_BPB_RootEntCnt, LOW_16_BPB_TotSec16, LSB, LSB0, LSB1, LSB2, LSB3, mem_sector_size(), MSB, Fs_management::rootdir, Fs_rootdir::seg, Fs_management::u16_offset_FSInfo, Fs_rootdir::u16_pos, Fs_rootdir::u16_size, Fs_rootdir::u32_cluster, Fs_management::u32_cluster_sel_dir, Fs_management::u32_CountofCluster, Fs_management::u32_fat_size, Fs_management::u32_offset_data, Fs_management::u32_ptr_fat, U8_BPB_SecPerClus, Fs_management::u8_BPB_SecPerClus, Fs_management::u8_lun, Fs_management::u8_partition, and Fs_management_fast::u8_type_fat.

Referenced by fat_check_mount(), and nav_partition_mount().

bool fat_read_dir ( void  )

This function fill the internal cache with a sector from current directory.

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variable used
//! IN :
//!   fs_g_nav.u32_cluster_sel_dir           First cluster of current directory
//!   fs_g_nav_fast.u16_entry_pos_sel_file   Position in directory (unit entry)
//! 

References fat_cache_read_sector(), fat_cluster_list(), FS_512B_SHIFT_BIT, FS_CLUST_ACT_ONE, fs_g_nav, fs_g_nav_fast, fs_g_sectorcache, fs_g_seg, fs_gu32_addrsector, FS_SHIFT_B_TO_FILE_ENTRY, Fs_management_fast::u16_entry_pos_sel_file, Fs_segment::u32_addr, Fs_management::u32_cluster_sel_dir, Fs_sector_cache::u32_clusterlist_pos, Fs_sector_cache::u32_clusterlist_start, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.

Referenced by file_close(), nav_dir_gotoparent(), nav_file_checkext(), nav_file_dateget(), nav_file_name(), nav_filelist_set(), nav_filterlist_gotoparent(), nav_partition_label(), and navauto_mov_explorer_updir().

uint32_t fat_read_fat32_FSInfo ( void  )
bool fat_read_file ( uint8_t  mode)

This function gets or clears a cluster list at the current position in the selected file.

@param     mode              Choose action <br>
           FS_CLUST_ACT_SEG  Get memory segment corresponding at the position in selected file <br>
           FS_CLUST_ACT_ONE  Store in internal cache the sector corresponding at the position in selected file <br>
           FS_CLUST_ACT_CLR  Clear the cluster list corresponding at the position in selected file <br>

@return    false in case of error, see global value "fs_g_status" for more detail
@return    true otherwise
//! Global variable used
//! IN :
//!   fs_g_nav_entry.u32_cluster       First cluster of selected file
//!   fs_g_nav_entry.u32_pos_in_file   Position in file (unit byte)
//! 

References fat_cache_read_sector(), fat_cluster_list(), FS_512B_MASK, FS_512B_SHIFT_BIT, FS_CLUST_ACT_CLR, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_ERR_OUT_LIST, fs_g_nav, fs_g_nav_entry, fs_g_sectorcache, fs_g_seg, fs_g_status, fs_gu32_addrsector, Fs_segment::u32_addr, Fs_management_entry::u32_cluster, Fs_sector_cache::u32_clusterlist_pos, Fs_sector_cache::u32_clusterlist_start, Fs_management_entry::u32_pos_in_file, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.

Referenced by file_getc(), file_read(), and file_read_buf().

bool fat_serialnumber ( bool  b_action,
uint8_t _MEM_TYPE_SLOW_ a_u8_sn 
)

This function reads or writes a serial number.

Referenced by nav_partition_serialnumber().

void fat_set_date ( const FS_STRING  sz_date,
bool  type_date 
)
bool fat_update_fat2 ( void  )

Referenced by fat_cluster_list().

void fat_write_entry_file ( void  )

Referenced by file_close().

bool fat_write_fat32_FSInfo ( uint32_t  u32_nb_free_cluster)
bool fat_write_file ( uint8_t  mode,
uint32_t  u32_nb_sector_write 
)

Referenced by ai_usb_ms_audio_ctrl_resume(), ai_usb_ms_specific_restore_navigator(), ai_usb_ms_specific_save_navigator(), fat_cache_clusterlist_update_finish(), fat_cache_clusterlist_update_read(), fat_cache_read_sector(), fat_check_device(), fat_clear_entry_info_and_ptr(), fat_cluster_list(), fat_cluster_val(), fat_getfreespace(), fat_getfreespace_percent(), fat_mount(), fat_read_dir(), fat_read_file(), file_load_segment_value(), file_open(), file_read(), file_read_buf(), nav_dir_cd(), nav_dir_gotoparent(), nav_dir_is_root(), nav_dir_name(), nav_drive_get(), nav_drive_getname(), nav_drive_set(), nav_file_isreadonly(), nav_filelist_eol(), nav_filelist_exist(), nav_filelist_first(), nav_filelist_get(), nav_filelist_nb(), nav_filelist_set(), nav_filelist_single_disable(), nav_filelist_single_enable(), nav_filterflat_cd(), nav_filterflat_get(), nav_filterflat_gotoparent(), nav_filterflat_mount(), nav_filterflat_next(), nav_filterflat_previous(), nav_filterflat_reset(), nav_filterflat_root(), nav_filterlist_cd(), nav_filterlist_get(), nav_filterlist_goto(), nav_filterlist_gotoindex(), nav_filterlist_gotoparent(), nav_filterlist_mount(), nav_filterlist_nb_ex(), nav_filterlist_next(), nav_filterlist_previous(), nav_filterlist_reset(), nav_filterlist_root(), nav_filterlist_setfilter(), nav_flat_cd(), nav_flat_get(), nav_flat_gotoparent(), nav_flat_mount(), nav_flat_next(), nav_flat_previous(), nav_flat_reset(), nav_flat_root(), nav_getindex(), nav_gotoindex(), nav_partition_cluster_size(), nav_partition_mount(), nav_partition_set(), nav_partition_space(), nav_reset(), navauto_mov_explorer_enterdir(), and navauto_mov_explorer_updir().

_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector
_GLOBEXT_ bool g_b_no_check_disk

Variables to enable/disable the disk check before each action on disk.

Referenced by fat_check_device(), nav_checkdisk_disable(), nav_checkdisk_enable(), and nav_reset().

_GLOBEXT_ bool g_b_unicode

Variables to select string format (initialised in nav_reset())

Referenced by nav_reset(), and nav_string_ascii().