Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
b0568922
Commit
b0568922
authored
Nov 12, 2021
by
longpanda
Browse files
1.0.60 release
parent
69b6bb8f
Changes
86
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1179 additions
and
0 deletions
+1179
-0
vtoycli/fat_io_lib/include/fat_filelib.h
vtoycli/fat_io_lib/include/fat_filelib.h
+146
-0
vtoycli/fat_io_lib/include/fat_format.h
vtoycli/fat_io_lib/include/fat_format.h
+15
-0
vtoycli/fat_io_lib/include/fat_list.h
vtoycli/fat_io_lib/include/fat_list.h
+161
-0
vtoycli/fat_io_lib/include/fat_misc.h
vtoycli/fat_io_lib/include/fat_misc.h
+63
-0
vtoycli/fat_io_lib/include/fat_opts.h
vtoycli/fat_io_lib/include/fat_opts.h
+90
-0
vtoycli/fat_io_lib/include/fat_string.h
vtoycli/fat_io_lib/include/fat_string.h
+20
-0
vtoycli/fat_io_lib/include/fat_table.h
vtoycli/fat_io_lib/include/fat_table.h
+20
-0
vtoycli/fat_io_lib/include/fat_types.h
vtoycli/fat_io_lib/include/fat_types.h
+69
-0
vtoycli/fat_io_lib/include/fat_write.h
vtoycli/fat_io_lib/include/fat_write.h
+14
-0
vtoycli/fat_io_lib/lib/libfat_io_32.a
vtoycli/fat_io_lib/lib/libfat_io_32.a
+0
-0
vtoycli/fat_io_lib/lib/libfat_io_64.a
vtoycli/fat_io_lib/lib/libfat_io_64.a
+0
-0
vtoycli/fat_io_lib/lib/libfat_io_aa64.a
vtoycli/fat_io_lib/lib/libfat_io_aa64.a
+0
-0
vtoycli/fat_io_lib/lib/libfat_io_m64e.a
vtoycli/fat_io_lib/lib/libfat_io_m64e.a
+0
-0
vtoycli/fat_io_lib/release/API.txt
vtoycli/fat_io_lib/release/API.txt
+22
-0
vtoycli/fat_io_lib/release/COPYRIGHT.txt
vtoycli/fat_io_lib/release/COPYRIGHT.txt
+345
-0
vtoycli/fat_io_lib/release/Configuration.txt
vtoycli/fat_io_lib/release/Configuration.txt
+53
-0
vtoycli/fat_io_lib/release/History.txt
vtoycli/fat_io_lib/release/History.txt
+24
-0
vtoycli/fat_io_lib/release/License.txt
vtoycli/fat_io_lib/release/License.txt
+10
-0
vtoycli/fat_io_lib/release/Media Access API.txt
vtoycli/fat_io_lib/release/Media Access API.txt
+40
-0
vtoycli/fat_io_lib/release/example.c
vtoycli/fat_io_lib/release/example.c
+87
-0
No files found.
vtoycli/fat_io_lib/include/fat_filelib.h
0 → 100644
View file @
b0568922
#ifndef __FAT_FILELIB_H__
#define __FAT_FILELIB_H__
#include "fat_opts.h"
#include "fat_access.h"
#include "fat_list.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef EOF
#define EOF (-1)
#endif
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct
sFL_FILE
;
struct
cluster_lookup
{
uint32
ClusterIdx
;
uint32
CurrentCluster
;
};
typedef
struct
sFL_FILE
{
uint32
parentcluster
;
uint32
startcluster
;
uint32
bytenum
;
uint32
filelength
;
int
filelength_changed
;
char
path
[
FATFS_MAX_LONG_FILENAME
];
char
filename
[
FATFS_MAX_LONG_FILENAME
];
uint8
shortfilename
[
11
];
#ifdef FAT_CLUSTER_CACHE_ENTRIES
uint32
cluster_cache_idx
[
FAT_CLUSTER_CACHE_ENTRIES
];
uint32
cluster_cache_data
[
FAT_CLUSTER_CACHE_ENTRIES
];
#endif
// Cluster Lookup
struct
cluster_lookup
last_fat_lookup
;
// Read/Write sector buffer
uint8
file_data_sector
[
FAT_SECTOR_SIZE
];
uint32
file_data_address
;
int
file_data_dirty
;
// File fopen flags
uint8
flags
;
#define FILE_READ (1 << 0)
#define FILE_WRITE (1 << 1)
#define FILE_APPEND (1 << 2)
#define FILE_BINARY (1 << 3)
#define FILE_ERASE (1 << 4)
#define FILE_CREATE (1 << 5)
struct
fat_node
list_node
;
}
FL_FILE
;
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
// External
void
fl_init
(
void
);
void
fl_attach_locks
(
void
(
*
lock
)(
void
),
void
(
*
unlock
)(
void
));
int
fl_attach_media
(
fn_diskio_read
rd
,
fn_diskio_write
wr
);
void
fl_shutdown
(
void
);
// Standard API
void
*
fl_fopen
(
const
char
*
path
,
const
char
*
modifiers
);
void
fl_fclose
(
void
*
file
);
int
fl_fflush
(
void
*
file
);
int
fl_fgetc
(
void
*
file
);
char
*
fl_fgets
(
char
*
s
,
int
n
,
void
*
f
);
int
fl_fputc
(
int
c
,
void
*
file
);
int
fl_fputs
(
const
char
*
str
,
void
*
file
);
int
fl_fwrite
(
const
void
*
data
,
int
size
,
int
count
,
void
*
file
);
int
fl_fread
(
void
*
data
,
int
size
,
int
count
,
void
*
file
);
int
fl_fseek
(
void
*
file
,
long
offset
,
int
origin
);
int
fl_fgetpos
(
void
*
file
,
uint32
*
position
);
long
fl_ftell
(
void
*
f
);
int
fl_feof
(
void
*
f
);
int
fl_remove
(
const
char
*
filename
);
// Equivelant dirent.h
typedef
struct
fs_dir_list_status
FL_DIR
;
typedef
struct
fs_dir_ent
fl_dirent
;
FL_DIR
*
fl_opendir
(
const
char
*
path
,
FL_DIR
*
dir
);
int
fl_readdir
(
FL_DIR
*
dirls
,
fl_dirent
*
entry
);
int
fl_closedir
(
FL_DIR
*
dir
);
// Extensions
void
fl_listdirectory
(
const
char
*
path
);
int
fl_createdirectory
(
const
char
*
path
);
int
fl_is_dir
(
const
char
*
path
);
int
fl_format
(
uint32
volume_sectors
,
const
char
*
name
);
// Test hooks
#ifdef FATFS_INC_TEST_HOOKS
struct
fatfs
*
fl_get_fs
(
void
);
#endif
//-----------------------------------------------------------------------------
// Stdio file I/O names
//-----------------------------------------------------------------------------
#ifdef USE_FILELIB_STDIO_COMPAT_NAMES
#define FILE FL_FILE
#define fopen(a,b) fl_fopen(a, b)
#define fclose(a) fl_fclose(a)
#define fflush(a) fl_fflush(a)
#define fgetc(a) fl_fgetc(a)
#define fgets(a,b,c) fl_fgets(a, b, c)
#define fputc(a,b) fl_fputc(a, b)
#define fputs(a,b) fl_fputs(a, b)
#define fwrite(a,b,c,d) fl_fwrite(a, b, c, d)
#define fread(a,b,c,d) fl_fread(a, b, c, d)
#define fseek(a,b,c) fl_fseek(a, b, c)
#define fgetpos(a,b) fl_fgetpos(a, b)
#define ftell(a) fl_ftell(a)
#define feof(a) fl_feof(a)
#define remove(a) fl_remove(a)
#define mkdir(a) fl_createdirectory(a)
#define rmdir(a) 0
#endif
#endif
vtoycli/fat_io_lib/include/fat_format.h
0 → 100644
View file @
b0568922
#ifndef __FAT_FORMAT_H__
#define __FAT_FORMAT_H__
#include "fat_defs.h"
#include "fat_opts.h"
#include "fat_access.h"
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
int
fatfs_format
(
struct
fatfs
*
fs
,
uint32
volume_sectors
,
const
char
*
name
);
int
fatfs_format_fat16
(
struct
fatfs
*
fs
,
uint32
volume_sectors
,
const
char
*
name
);
int
fatfs_format_fat32
(
struct
fatfs
*
fs
,
uint32
volume_sectors
,
const
char
*
name
);
#endif
vtoycli/fat_io_lib/include/fat_list.h
0 → 100644
View file @
b0568922
#ifndef __FAT_LIST_H__
#define __FAT_LIST_H__
#ifndef FAT_ASSERT
#define FAT_ASSERT(x)
#endif
#ifndef FAT_INLINE
#define FAT_INLINE
#endif
//-----------------------------------------------------------------
// Types
//-----------------------------------------------------------------
struct
fat_list
;
struct
fat_node
{
struct
fat_node
*
previous
;
struct
fat_node
*
next
;
};
struct
fat_list
{
struct
fat_node
*
head
;
struct
fat_node
*
tail
;
};
//-----------------------------------------------------------------
// Macros
//-----------------------------------------------------------------
#define fat_list_entry(p, t, m) p ? ((t *)((char *)(p)-(char*)(&((t *)0)->m))) : 0
#define fat_list_next(l, p) (p)->next
#define fat_list_prev(l, p) (p)->previous
#define fat_list_first(l) (l)->head
#define fat_list_last(l) (l)->tail
#define fat_list_for_each(l, p) for ((p) = (l)->head; (p); (p) = (p)->next)
//-----------------------------------------------------------------
// Inline Functions
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// fat_list_init:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_init
(
struct
fat_list
*
list
)
{
FAT_ASSERT
(
list
);
list
->
head
=
list
->
tail
=
0
;
}
//-----------------------------------------------------------------
// fat_list_remove:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_remove
(
struct
fat_list
*
list
,
struct
fat_node
*
node
)
{
FAT_ASSERT
(
list
);
FAT_ASSERT
(
node
);
if
(
!
node
->
previous
)
list
->
head
=
node
->
next
;
else
node
->
previous
->
next
=
node
->
next
;
if
(
!
node
->
next
)
list
->
tail
=
node
->
previous
;
else
node
->
next
->
previous
=
node
->
previous
;
}
//-----------------------------------------------------------------
// fat_list_insert_after:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_insert_after
(
struct
fat_list
*
list
,
struct
fat_node
*
node
,
struct
fat_node
*
new_node
)
{
FAT_ASSERT
(
list
);
FAT_ASSERT
(
node
);
FAT_ASSERT
(
new_node
);
new_node
->
previous
=
node
;
new_node
->
next
=
node
->
next
;
if
(
!
node
->
next
)
list
->
tail
=
new_node
;
else
node
->
next
->
previous
=
new_node
;
node
->
next
=
new_node
;
}
//-----------------------------------------------------------------
// fat_list_insert_before:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_insert_before
(
struct
fat_list
*
list
,
struct
fat_node
*
node
,
struct
fat_node
*
new_node
)
{
FAT_ASSERT
(
list
);
FAT_ASSERT
(
node
);
FAT_ASSERT
(
new_node
);
new_node
->
previous
=
node
->
previous
;
new_node
->
next
=
node
;
if
(
!
node
->
previous
)
list
->
head
=
new_node
;
else
node
->
previous
->
next
=
new_node
;
node
->
previous
=
new_node
;
}
//-----------------------------------------------------------------
// fat_list_insert_first:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_insert_first
(
struct
fat_list
*
list
,
struct
fat_node
*
node
)
{
FAT_ASSERT
(
list
);
FAT_ASSERT
(
node
);
if
(
!
list
->
head
)
{
list
->
head
=
node
;
list
->
tail
=
node
;
node
->
previous
=
0
;
node
->
next
=
0
;
}
else
fat_list_insert_before
(
list
,
list
->
head
,
node
);
}
//-----------------------------------------------------------------
// fat_list_insert_last:
//-----------------------------------------------------------------
static
FAT_INLINE
void
fat_list_insert_last
(
struct
fat_list
*
list
,
struct
fat_node
*
node
)
{
FAT_ASSERT
(
list
);
FAT_ASSERT
(
node
);
if
(
!
list
->
tail
)
fat_list_insert_first
(
list
,
node
);
else
fat_list_insert_after
(
list
,
list
->
tail
,
node
);
}
//-----------------------------------------------------------------
// fat_list_is_empty:
//-----------------------------------------------------------------
static
FAT_INLINE
int
fat_list_is_empty
(
struct
fat_list
*
list
)
{
FAT_ASSERT
(
list
);
return
!
list
->
head
;
}
//-----------------------------------------------------------------
// fat_list_pop_head:
//-----------------------------------------------------------------
static
FAT_INLINE
struct
fat_node
*
fat_list_pop_head
(
struct
fat_list
*
list
)
{
struct
fat_node
*
node
;
FAT_ASSERT
(
list
);
node
=
fat_list_first
(
list
);
if
(
node
)
fat_list_remove
(
list
,
node
);
return
node
;
}
#endif
vtoycli/fat_io_lib/include/fat_misc.h
0 → 100644
View file @
b0568922
#ifndef __FAT_MISC_H__
#define __FAT_MISC_H__
#include "fat_defs.h"
#include "fat_opts.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
#define MAX_LONGFILENAME_ENTRIES 20
#define MAX_LFN_ENTRY_LENGTH 13
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
#define GET_32BIT_WORD(buffer, location) ( ((uint32)buffer[location+3]<<24) + ((uint32)buffer[location+2]<<16) + ((uint32)buffer[location+1]<<8) + (uint32)buffer[location+0] )
#define GET_16BIT_WORD(buffer, location) ( ((uint16)buffer[location+1]<<8) + (uint16)buffer[location+0] )
#define SET_32BIT_WORD(buffer, location, value) { buffer[location+0] = (uint8)((value)&0xFF); \
buffer[location+1] = (uint8)((value>>8)&0xFF); \
buffer[location+2] = (uint8)((value>>16)&0xFF); \
buffer[location+3] = (uint8)((value>>24)&0xFF); }
#define SET_16BIT_WORD(buffer, location, value) { buffer[location+0] = (uint8)((value)&0xFF); \
buffer[location+1] = (uint8)((value>>8)&0xFF); }
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct
lfn_cache
{
#if FATFS_INC_LFN_SUPPORT
// Long File Name Structure (max 260 LFN length)
uint8
String
[
MAX_LONGFILENAME_ENTRIES
][
MAX_LFN_ENTRY_LENGTH
];
uint8
Null
;
#endif
uint8
no_of_strings
;
};
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
void
fatfs_lfn_cache_init
(
struct
lfn_cache
*
lfn
,
int
wipeTable
);
void
fatfs_lfn_cache_entry
(
struct
lfn_cache
*
lfn
,
uint8
*
entryBuffer
);
char
*
fatfs_lfn_cache_get
(
struct
lfn_cache
*
lfn
);
int
fatfs_entry_lfn_text
(
struct
fat_dir_entry
*
entry
);
int
fatfs_entry_lfn_invalid
(
struct
fat_dir_entry
*
entry
);
int
fatfs_entry_lfn_exists
(
struct
lfn_cache
*
lfn
,
struct
fat_dir_entry
*
entry
);
int
fatfs_entry_sfn_only
(
struct
fat_dir_entry
*
entry
);
int
fatfs_entry_is_dir
(
struct
fat_dir_entry
*
entry
);
int
fatfs_entry_is_file
(
struct
fat_dir_entry
*
entry
);
int
fatfs_lfn_entries_required
(
char
*
filename
);
void
fatfs_filename_to_lfn
(
char
*
filename
,
uint8
*
buffer
,
int
entry
,
uint8
sfnChk
);
void
fatfs_sfn_create_entry
(
char
*
shortfilename
,
uint32
size
,
uint32
startCluster
,
struct
fat_dir_entry
*
entry
,
int
dir
);
int
fatfs_lfn_create_sfn
(
char
*
sfn_output
,
char
*
filename
);
int
fatfs_lfn_generate_tail
(
char
*
sfn_output
,
char
*
sfn_input
,
uint32
tailNum
);
void
fatfs_convert_from_fat_time
(
uint16
fat_time
,
int
*
hours
,
int
*
minutes
,
int
*
seconds
);
void
fatfs_convert_from_fat_date
(
uint16
fat_date
,
int
*
day
,
int
*
month
,
int
*
year
);
uint16
fatfs_convert_to_fat_time
(
int
hours
,
int
minutes
,
int
seconds
);
uint16
fatfs_convert_to_fat_date
(
int
day
,
int
month
,
int
year
);
void
fatfs_print_sector
(
uint32
sector
,
uint8
*
data
);
#endif
vtoycli/fat_io_lib/include/fat_opts.h
0 → 100644
View file @
b0568922
#ifndef __FAT_OPTS_H__
#define __FAT_OPTS_H__
#ifdef FATFS_USE_CUSTOM_OPTS_FILE
#include "fat_custom.h"
#endif
//-------------------------------------------------------------
// Configuration
//-------------------------------------------------------------
// Is the processor little endian (1) or big endian (0)
#ifndef FATFS_IS_LITTLE_ENDIAN
#define FATFS_IS_LITTLE_ENDIAN 1
#endif
// Max filename Length
#ifndef FATFS_MAX_LONG_FILENAME
#define FATFS_MAX_LONG_FILENAME 260
#endif
// Max open files (reduce to lower memory requirements)
#ifndef FATFS_MAX_OPEN_FILES
#define FATFS_MAX_OPEN_FILES 2
#endif
// Number of sectors per FAT_BUFFER (min 1)
#ifndef FAT_BUFFER_SECTORS
#define FAT_BUFFER_SECTORS 1
#endif
// Max FAT sectors to buffer (min 1)
// (mem used is FAT_BUFFERS * FAT_BUFFER_SECTORS * FAT_SECTOR_SIZE)
#ifndef FAT_BUFFERS
#define FAT_BUFFERS 1
#endif
// Size of cluster chain cache (can be undefined)
// Mem used = FAT_CLUSTER_CACHE_ENTRIES * 4 * 2
// Improves access speed considerably
//#define FAT_CLUSTER_CACHE_ENTRIES 128
// Include support for writing files (1 / 0)?
#ifndef FATFS_INC_WRITE_SUPPORT
#define FATFS_INC_WRITE_SUPPORT 1
#endif
// Support long filenames (1 / 0)?
// (if not (0) only 8.3 format is supported)
#ifndef FATFS_INC_LFN_SUPPORT
#define FATFS_INC_LFN_SUPPORT 1
#endif
// Support directory listing (1 / 0)?
#ifndef FATFS_DIR_LIST_SUPPORT
#define FATFS_DIR_LIST_SUPPORT 1
#endif
// Support time/date (1 / 0)?
#ifndef FATFS_INC_TIME_DATE_SUPPORT
#define FATFS_INC_TIME_DATE_SUPPORT 0
#endif
// Include support for formatting disks (1 / 0)?
#ifndef FATFS_INC_FORMAT_SUPPORT
#define FATFS_INC_FORMAT_SUPPORT 1
#endif
// Sector size used
#define FAT_SECTOR_SIZE 512
// Printf output (directory listing / debug)
#ifndef FAT_PRINTF
// Don't include stdio, but there is a printf function available
#ifdef FAT_PRINTF_NOINC_STDIO
extern
int
printf
(
const
char
*
ctrl1
,
...
);
#define FAT_PRINTF(a) printf a
// Include stdio to use printf
#else
#include <stdio.h>
#define FAT_PRINTF(a) printf a
#endif
#endif
// Time/Date support requires time.h
#if FATFS_INC_TIME_DATE_SUPPORT
#include <time.h>
#endif
#endif
vtoycli/fat_io_lib/include/fat_string.h
0 → 100644
View file @
b0568922
#ifndef __FILESTRING_H__
#define __FILESTRING_H__
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
int
fatfs_total_path_levels
(
char
*
path
);
int
fatfs_get_substring
(
char
*
Path
,
int
levelreq
,
char
*
output
,
int
max_len
);
int
fatfs_split_path
(
char
*
FullPath
,
char
*
Path
,
int
max_path
,
char
*
FileName
,
int
max_filename
);
int
fatfs_compare_names
(
char
*
strA
,
char
*
strB
);
int
fatfs_string_ends_with_slash
(
char
*
path
);
int
fatfs_get_sfn_display_name
(
char
*
out
,
char
*
in
);
int
fatfs_get_extension
(
char
*
filename
,
char
*
out
,
int
maxlen
);
int
fatfs_create_path_string
(
char
*
path
,
char
*
filename
,
char
*
out
,
int
maxlen
);
#ifndef NULL
#define NULL 0
#endif
#endif
vtoycli/fat_io_lib/include/fat_table.h
0 → 100644
View file @
b0568922
#ifndef __FAT_TABLE_H__
#define __FAT_TABLE_H__
#include "fat_opts.h"
#include "fat_misc.h"
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
void
fatfs_fat_init
(
struct
fatfs
*
fs
);
int
fatfs_fat_purge
(
struct
fatfs
*
fs
);
uint32
fatfs_find_next_cluster
(
struct
fatfs
*
fs
,
uint32
current_cluster
);
void
fatfs_set_fs_info_next_free_cluster
(
struct
fatfs
*
fs
,
uint32
newValue
);
int
fatfs_find_blank_cluster
(
struct
fatfs
*
fs
,
uint32
start_cluster
,
uint32
*
free_cluster
);
int
fatfs_fat_set_cluster
(
struct
fatfs
*
fs
,
uint32
cluster
,
uint32
next_cluster
);
int
fatfs_fat_add_cluster_to_chain
(
struct
fatfs
*
fs
,
uint32
start_cluster
,
uint32
newEntry
);
int
fatfs_free_cluster_chain
(
struct
fatfs
*
fs
,
uint32
start_cluster
);
uint32
fatfs_count_free_clusters
(
struct
fatfs
*
fs
);
#endif
vtoycli/fat_io_lib/include/fat_types.h
0 → 100644
View file @
b0568922
#ifndef __FAT_TYPES_H__
#define __FAT_TYPES_H__
// Detect 64-bit compilation on GCC
#if defined(__GNUC__) && defined(__SIZEOF_LONG__)
#if __SIZEOF_LONG__ == 8
#define FATFS_DEF_UINT32_AS_INT
#endif
#endif
//-------------------------------------------------------------
// System specific types
//-------------------------------------------------------------
#ifndef FATFS_NO_DEF_TYPES
typedef
unsigned
char
uint8
;
typedef
unsigned
short
uint16
;
// If compiling on a 64-bit machine, use int as 32-bits
#ifdef FATFS_DEF_UINT32_AS_INT
typedef
unsigned
int
uint32
;
// Else for 32-bit machines & embedded systems, use long...
#else
typedef
unsigned
long
uint32
;
#endif
#endif
#ifndef NULL
#define NULL 0
#endif
//-------------------------------------------------------------
// Endian Macros
//-------------------------------------------------------------
// FAT is little endian so big endian systems need to swap words
// Little Endian - No swap required
#if FATFS_IS_LITTLE_ENDIAN == 1
#define FAT_HTONS(n) (n)
#define FAT_HTONL(n) (n)
// Big Endian - Swap required
#else
#define FAT_HTONS(n) ((((uint16)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
#define FAT_HTONL(n) (((((uint32)(n) & 0xFF)) << 24) | \
((((uint32)(n) & 0xFF00)) << 8) | \
((((uint32)(n) & 0xFF0000)) >> 8) | \
((((uint32)(n) & 0xFF000000)) >> 24))
#endif
//-------------------------------------------------------------
// Structure Packing Compile Options
//-------------------------------------------------------------
#ifdef __GNUC__
#define STRUCT_PACK
#define STRUCT_PACK_BEGIN
#define STRUCT_PACK_END
#define STRUCT_PACKED __attribute__ ((packed))
#else
// Other compilers may require other methods of packing structures
#define STRUCT_PACK
#define STRUCT_PACK_BEGIN
#define STRUCT_PACK_END
#define STRUCT_PACKED
#endif
#endif
vtoycli/fat_io_lib/include/fat_write.h
0 → 100644
View file @
b0568922
#ifndef __FAT_WRITE_H__
#define __FAT_WRITE_H__
#include "fat_defs.h"
#include "fat_opts.h"
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
int
fatfs_add_file_entry
(
struct
fatfs
*
fs
,
uint32
dirCluster
,
char
*
filename
,
char
*
shortfilename
,
uint32
startCluster
,
uint32
size
,
int
dir
);
int
fatfs_add_free_space
(
struct
fatfs
*
fs
,
uint32
*
startCluster
,
uint32
clusters
);
int
fatfs_allocate_free_space
(
struct
fatfs
*
fs
,
int
newFile
,
uint32
*
startCluster
,
uint32
size
);
#endif
vtoycli/fat_io_lib/lib/libfat_io_32.a
0 → 100644
View file @
b0568922
File added
vtoycli/fat_io_lib/lib/libfat_io_64.a
0 → 100644
View file @
b0568922
File added
vtoycli/fat_io_lib/lib/libfat_io_aa64.a
0 → 100644
View file @
b0568922
File added
vtoycli/fat_io_lib/lib/libfat_io_m64e.a
0 → 100644
View file @
b0568922
File added
vtoycli/fat_io_lib/release/API.txt
0 → 100644
View file @
b0568922
File IO Lib API
-=-=-=-=-=-=-=-=-
void fl_init(void)
Called to initialize FAT IO library.
This should be called prior to any other functions.
void fl_attach_locks(void (*lock)(void), void (*unlock)(void))
[Optional] File system thread safety locking functions.
For thread safe operation, you should provide lock() and unlock() functions.
Note that locking primitive used must support recursive locking, i.e lock() called within an already ‘locked’ region.
int fl_attach_media(fn_diskio_read rd, fn_diskio_write wr)
This function is used to attach system specific disk/media access functions.
This should be done subsequent to calling fl_init() and fl_attach_locks() (if locking required).
void fl_shutdown(void)
Shutdown the FAT IO library. This purges any un-saved data back to disk.
vtoycli/fat_io_lib/release/COPYRIGHT.txt
0 → 100644
View file @
b0568922
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
vtoycli/fat_io_lib/release/Configuration.txt
0 → 100644
View file @
b0568922
File IO Lib Options
-=-=-=-=-=-=-=-=-=-
See defines in fat_opts.h:
FATFS_IS_LITTLE_ENDIAN [1/0]
Which endian is your system? Set to 1 for little endian, 0 for big endian.
FATFS_MAX_LONG_FILENAME [260]
By default, 260 characters (max LFN length). Increase this to support greater path depths.
FATFS_MAX_OPEN_FILES
The more files you wish to have concurrently open, the greater this number should be.
This increases the number of FL_FILE file structures in the library, each of these is around 1K in size (assuming 512 byte sectors).
FAT_BUFFER_SECTORS
Minimum is 1, more increases performance.
This defines how many FAT sectors can be buffered per FAT_BUFFER entry.
FAT_BUFFERS
Minimum is 1, more increases performance.
This defines how many FAT buffer entries are available.
Memory usage is FAT_BUFFERS * FAT_BUFFER_SECTORS * FAT_SECTOR_SIZE
FATFS_INC_WRITE_SUPPORT
Support file write functionality.
FAT_SECTOR_SIZE
Sector size used by buffers. Most likely to be 512 bytes (standard for ATA/IDE).
FAT_PRINTF
A define that allows the File IO library to print to console/stdout.
Provide your own printf function if printf not available.
FAT_CLUSTER_CACHE_ENTRIES
Size of cluster chain cache (can be undefined if not required).
Mem used = FAT_CLUSTER_CACHE_ENTRIES * 4 * 2
Improves access speed considerably.
FATFS_INC_LFN_SUPPORT [1/0]
Enable/Disable support for long filenames.
FATFS_DIR_LIST_SUPPORT [1/0]
Include support for directory listing.
FATFS_INC_TIME_DATE_SUPPORT [1/0]
Use time/date functions provided by time.h to update creation & modification timestamps.
FATFS_INC_FORMAT_SUPPORT
Include support for formatting disks (FAT16 only).
FAT_PRINTF_NOINC_STDIO
Disable use of printf & inclusion of stdio.h
vtoycli/fat_io_lib/release/History.txt
0 → 100644
View file @
b0568922
Revision History
-=-=-=-=-=-=-=-=-
v2.6.11 - Fix compilation with GCC on 64-bit machines
v2.6.10 - Added support for FAT32 format.
V2.6.9 - Added support for time & date handling.
V2.6.8 - Fixed error with FSINFO sector write.
V2.6.7 - Added fgets().
Fixed C warnings, removed dependancy on some string.h functions.
V2.6.6 – Massive read + write performance improvements.
V2.6.5 – Bug fixes for big endian systems.
V2.6.4 – Further bug fixes and performance improvements for write operations.
V2.6.3 – Peformance improvements, FAT16 formatting support. Various bug fixes.
V2.6 - Basic support for FAT16 added (18-04-10).
V2.5 - Code cleaned up. Many bugs fixed. Thread safety functions added.
V2.x - Write support added as well as better stdio like API.
V1.0 - Rewrite of all code to enable multiple files to be opened and provides a
better file API.
Also better string matching, and generally better C code than origonal
version.
V0.1c - Fetch_ID_Max_LBA() function added to retrieve Drive infomation and stoping
the drive reads from addressing a sector that is out of range.
V0.1b - fopen(), fgetc(), fopenDIR() using new software stack for IDE and FAT32
access.
V0.1a - First release (27/12/03); fopen(), fgetc() unbuffered reads.
vtoycli/fat_io_lib/release/License.txt
0 → 100644
View file @
b0568922
FAT File IO Library License
-=-=-=-=-=-=-=-=-=-=-=-=-=-
This versions license: GPL
If you include GPL software in your project, you must release the source code of that project too.
If you would like a version with a more permissive license for use in closed source commercial applications please contact me for details.
Email: admin@ultra-embedded.com
vtoycli/fat_io_lib/release/Media Access API.txt
0 → 100644
View file @
b0568922
Media Access API
-=-=-=-=-=-=-=-=-
int media_read(uint32 sector, uint8 *buffer, uint32 sector_count)
Params:
Sector: 32-bit sector number
Buffer: Target buffer to read n sectors of data into.
Sector_count: Number of sectors to read.
Return:
int, 1 = success, 0 = failure.
Description:
Application/target specific disk/media read function.
Sector number (sectors are usually 512 byte pages) to read.
Media Write API
int media_write(uint32 sector, uint8 *buffer, uint32 sector_count)
Params:
Sector: 32-bit sector number
Buffer: Target buffer to write n sectors of data from.
Sector_count: Number of sectors to write.
Return:
int, 1 = success, 0 = failure.
Description:
Application/target specific disk/media write function.
Sector number (sectors are usually 512 byte pages) to write to.
File IO Library Linkage
Use the following API to attach the media IO functions to the File IO library.
int fl_attach_media(fn_diskio_read rd, fn_diskio_write wr)
vtoycli/fat_io_lib/release/example.c
0 → 100644
View file @
b0568922
#include <stdio.h>
#include "fat_filelib.h"
int
media_init
()
{
// ...
return
1
;
}
int
media_read
(
unsigned
long
sector
,
unsigned
char
*
buffer
,
unsigned
long
sector_count
)
{
unsigned
long
i
;
for
(
i
=
0
;
i
<
sector_count
;
i
++
)
{
// ...
// Add platform specific sector (512 bytes) read code here
//..
sector
++
;
buffer
+=
512
;
}
return
1
;
}
int
media_write
(
unsigned
long
sector
,
unsigned
char
*
buffer
,
unsigned
long
sector_count
)
{
unsigned
long
i
;
for
(
i
=
0
;
i
<
sector_count
;
i
++
)
{
// ...
// Add platform specific sector (512 bytes) write code here
//..
sector
++
;
buffer
+=
512
;
}
return
1
;
}
void
main
()
{
FL_FILE
*
file
;
// Initialise media
media_init
();
// Initialise File IO Library
fl_init
();
// Attach media access functions to library
if
(
fl_attach_media
(
media_read
,
media_write
)
!=
FAT_INIT_OK
)
{
printf
(
"ERROR: Media attach failed
\n
"
);
return
;
}
// List root directory
fl_listdirectory
(
"/"
);
// Create File
file
=
fl_fopen
(
"/file.bin"
,
"w"
);
if
(
file
)
{
// Write some data
unsigned
char
data
[]
=
{
1
,
2
,
3
,
4
};
if
(
fl_fwrite
(
data
,
1
,
sizeof
(
data
),
file
)
!=
sizeof
(
data
))
printf
(
"ERROR: Write file failed
\n
"
);
}
else
printf
(
"ERROR: Create file failed
\n
"
);
// Close file
fl_fclose
(
file
);
// Delete File
if
(
fl_remove
(
"/file.bin"
)
<
0
)
printf
(
"ERROR: Delete file failed
\n
"
);
// List root directory
fl_listdirectory
(
"/"
);
fl_shutdown
();
}
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment