提交 544ba90a 编写于 作者: O openharmony_ci 提交者: Gitee

!24 三方库FatFs升级至r0.14a版本

Merge pull request !24 from Far/r014a
......@@ -3,8 +3,8 @@
"Name" : "FatFs",
"License" : "BSD 3-Clause License",
"License File" : "LICENSE.txt",
"Version Number" : "R0.13c",
"Owner" : "jianghan2@huawei.com",
"Version Number" : "R0.14a",
"Owner" : "yesiyuan2@huawei.com",
"Upstream URL" : "http://elm-chan.org/fsw/ff/00index_e.html",
"Description" : "FatFs is a generic FAT/exFAT filesystem module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, RX and etc. Also Petit FatFs module for tiny microcontrollers is available here."
}
......
FatFs Module Source Files R0.13c
FatFs Module Source Files R0.14a
FILES
......
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */
/* Low level disk I/O module SKELETON for FatFs (C)ChaN, 2019 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */
/* storage control modules to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/
#include "diskio.h"
#include "ff.h" /* Obtains integer types */
#include "diskio.h" /* Declarations of disk functions */
#ifndef __LITEOS_M__
#include "string.h"
#include "disk.h"
......@@ -80,7 +81,7 @@ DSTATUS disk_initialize (
DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
QWORD sector, /* Start sector in LBA */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to read */
)
{
......@@ -105,7 +106,7 @@ DRESULT disk_read (
DRESULT disk_read_readdir (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
QWORD sector, /* Start sector in LBA */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to read */
)
{
......@@ -122,7 +123,7 @@ DRESULT disk_read_readdir (
#ifndef __LITEOS_M__
DRESULT disk_raw_read (int id, void *buff, QWORD sector, UINT32 count)
DRESULT disk_raw_read (int id, void *buff, LBA_t sector, UINT32 count)
{
int result;
......@@ -146,7 +147,7 @@ DRESULT disk_raw_read (int id, void *buff, QWORD sector, UINT32 count)
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
QWORD sector, /* Start sector in LBA */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to write */
)
{
......
......@@ -30,20 +30,23 @@ typedef enum {
RES_PARERR /* 4: Invalid Parameter */
} DRESULT;
/*---------------------------------------*/
/* Prototypes for disk control functions */
DSTATUS disk_initialize (BYTE pdrv);
DSTATUS disk_status (BYTE pdrv);
DRESULT disk_read (BYTE pdrv, BYTE* buff, QWORD sector, UINT count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, QWORD sector, UINT count);
DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
#ifndef __LITEOS_M__
DRESULT disk_read_readdir (BYTE pdrv, BYTE* buff, QWORD sector, UINT count);
DRESULT disk_raw_read (int id, void* buff, QWORD sector, UINT32 count);
DRESULT disk_raw_write (int id, void* buff, QWORD sector, UINT32 count);
DRESULT disk_read_readdir (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
DRESULT disk_raw_read (int id, void* buff, LBA_t sector, UINT32 count);
DRESULT disk_raw_write (int id, void* buff, LBA_t sector, UINT32 count);
#endif
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
#ifdef __LITEOS_M__
DRESULT disk_read_readdir (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
DWORD get_fattime (void);
#endif
......
此差异已折叠。
/*----------------------------------------------------------------------------/
/ FatFs - Generic FAT Filesystem module R0.13c /
/ FatFs - Generic FAT Filesystem module R0.14a /
/-----------------------------------------------------------------------------/
/
/ Copyright (C) 2018, ChaN, all right reserved.
/ Copyright (C) 2020, ChaN, all right reserved.
/
/ FatFs module is an open source software. Redistribution and use of FatFs in
/ source and binary forms, with or without modification, are permitted provided
......@@ -15,17 +15,18 @@
/ and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/---------------------------------------------------------------------------*/
/
/----------------------------------------------------------------------------*/
#ifndef FF_DEFINED
#define FF_DEFINED 86604 /* Revision ID */
#define FF_DEFINED 80196 /* Revision ID */
#ifdef __cplusplus
extern "C" {
#endif
#include <dirent.h>
#include <sys/types.h>
#include "integer.h" /* Basic integer types */
#include "ffconf.h" /* FatFs configuration options */
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
......@@ -99,7 +100,7 @@ typedef struct {
QWORD ps; /* Partition start sector */
QWORD pc; /* Partition sector count */
} PARTITION;
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
#define LD2DI(vol) (VolToPart[vol].di) /* Get physical disk id */
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
......@@ -171,6 +172,7 @@ typedef char TCHAR;
/* Type of file size variables */
typedef DWORD FSIZE_t;
typedef QWORD LBA_t;
/* DIR offset in fs win */
#define DIR_Name 0 /* Short file name (11-byte) */
......@@ -238,11 +240,11 @@ typedef struct {
#endif
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
DWORD fsize; /* Sectors per FAT */
QWORD volbase; /* Volume base sector */
QWORD fatbase; /* FAT base sector */
QWORD dirbase; /* Root directory base sector/cluster */
QWORD database; /* Data base sector */
QWORD winsect; /* Current sector appearing in the win[] */
LBA_t volbase; /* Volume base sector */
LBA_t fatbase; /* FAT base sector */
LBA_t dirbase; /* Root directory base sector/cluster */
LBA_t database; /* Data base sector */
LBA_t winsect; /* Current sector appearing in the win[] */
BYTE* win; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
......@@ -290,9 +292,9 @@ typedef struct {
BYTE err; /* Abort flag (error code) */
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
QWORD sect; /* Sector number appearing in buf[] (0:invalid) */
LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */
#if !FF_FS_READONLY
QWORD dir_sect; /* Sector number containing the directory entry */
LBA_t dir_sect; /* Sector number containing the directory entry */
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
#endif
#if FF_USE_FASTSEEK
......@@ -314,7 +316,7 @@ struct __dirstream {
FFOBJID obj; /* Object identifier */
DWORD dptr; /* Current read/write offset */
DWORD clust; /* Current cluster */
QWORD sect; /* Current sector (0:Read operation has terminated) */
LBA_t sect; /* Current sector (0:Read operation has terminated) */
BYTE* dir; /* Pointer to the directory item in the win[] */
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
#if FF_USE_LFN
......@@ -354,6 +356,16 @@ typedef struct {
} FAT_ENTRY;
#endif
/* Format parameter structure (MKFS_PARM) */
typedef struct {
BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
BYTE n_fat; /* Number of FATs */
UINT align; /* Data area alignment (sector) */
UINT n_root; /* Number of root directory entries */
int n_sect; /* Cluster size (sector) */
} MKFS_PARM;
typedef struct {
DIR f_dir;
FILINFO fno;
......@@ -447,9 +459,9 @@ FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
FRESULT f_expand (FIL* fp, FSIZE_t offset, FSIZE_t fsz, int opt); /* Allocate a contiguous block to the file */
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
FRESULT f_mkfs (const TCHAR* path, BYTE opt, int sector, void* work, UINT len); /* Create a FAT volume */
FRESULT f_fdisk (BYTE pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */
FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
FRESULT f_setcp (WORD cp); /* Set current code page */
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
......@@ -466,7 +478,7 @@ FRESULT fat_count_free_entries(DWORD *nclst, FATFS *fs);
void get_fileinfo (DIR* dp, FILINFO* fno);
DWORD get_fat (FFOBJID *obj, DWORD clst);
FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val);
FRESULT find_volume (const TCHAR **path, FATFS **rfs, BYTE mode);
FRESULT mount_volume (const TCHAR **path, FATFS **rfs, BYTE mode);
QWORD clst2sect (FATFS* fs, DWORD clst );
DWORD ld_clust(FATFS *fs, const BYTE *dir);
void st_clust(FATFS *fs, BYTE *dir, DWORD cl);
......@@ -476,7 +488,7 @@ void st_dword (BYTE *ptr, DWORD val);
void st_word (BYTE *ptr, WORD val);
FRESULT create_name (DIR *dp, const TCHAR **path);
int lock_fs (FATFS *fs);
BYTE check_fs(FATFS *fs, QWORD sect);
UINT check_fs(FATFS *fs, QWORD sect);
UINT inc_lock(DIR* dp, int acc);
void unlock_fs (FATFS *fs, FRESULT res);
FRESULT dir_sdi (DIR *dp, DWORD ofs);
......@@ -503,10 +515,7 @@ FRESULT set_volumn_label(FATFS *fs, const TCHAR *label);
#define f_rewind(fp) f_lseek((fp), 0)
#define f_rewinddir(dp) f_readdir((dp), 0)
#define f_rmdir(path) f_unlink(path)
#ifndef EOF
#define EOF (-1)
#endif
#define f_unmount(path) f_mount(0, path, 0)
......@@ -525,7 +534,6 @@ WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
#endif
void* ff_memalloc (UINT msize); /* Allocate memory block */
void ff_memfree (void* mblock); /* Free memory block */
#ifndef __LITEOS_M__
......
......@@ -18,7 +18,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define FFCONF_DEF 86604 /* Revision ID */
#define FFCONF_DEF 80196 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function Configurations
......@@ -144,17 +144,19 @@ enum STORAGE {
/* The FF_USE_LFN switches the support for LFN (long file name).
/
/ 0: Disable LFN. FF_MAX_LFN has no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ To enable the LFN, Unicode handling functions (option/unicode.c) must be added
/ to the project. The working buffer occupies (FF_MAX_LFN + 1) * 2 bytes.
/ FF_MAX_LFN can be in range from 12 to 255.
/ It should be set 255 to support full featured LFN operations.
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
/ be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN
/ specification.
/ When use stack for the working buffer, take care on stack overflow. When use heap
/ memory for the working buffer, memory management functions, ff_memalloc() and
/ ff_memfree(), must be added to the project. */
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
#ifndef __LITEOS_M__
#define FF_LFN_UNICODE 0
......@@ -273,18 +275,6 @@ enum STORAGE {
/ disk_ioctl() function. */
#define FF_FS_NOFSINFO 0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
/
/ bit0=0: Use free cluster count in the FSINFO if available.
/ bit0=1: Do not trust free cluster count in the FSINFO.
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
*/
/*---------------------------------------------------------------------------/
/ System Configurations
......@@ -300,7 +290,7 @@ enum STORAGE {
#define FF_FS_NORTC 0
#define FF_NORTC_MON 1
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2018
#define FF_NORTC_YEAR 2020
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
......@@ -308,7 +298,19 @@ enum STORAGE {
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
/ These options have no effect at read-only configuration (FF_FS_READONLY = 1). */
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
#define FF_FS_NOFSINFO 0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
/
/ bit0=0: Use free cluster count in the FSINFO if available.
/ bit0=1: Do not trust free cluster count in the FSINFO.
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
*/
#ifndef __LITEOS_M__
#define FF_FS_LOCK CONFIG_NFILE_DESCRIPTORS
......
/*------------------------------------------------------------------------*/
/* Unicode handling functions for FatFs R0.13c */
/* Unicode handling functions for FatFs R0.13+ */
/*------------------------------------------------------------------------*/
/* This module will occupy a huge memory in the .const section when the /
/ FatFs is configured for LFN with DBCS. If the system has any Unicode /
......@@ -7,7 +7,7 @@
/ that function to avoid silly memory consumption. /
/-------------------------------------------------------------------------*/
/*
/ Copyright (C) 2018, ChaN, all right reserved.
/ Copyright (C) 2014, ChaN, all right reserved.
/
/ FatFs module is an open source software. Redistribution and use of FatFs in
/ source and binary forms, with or without modification, are permitted provided
......@@ -25,11 +25,7 @@
#include "ff.h"
#if FF_USE_LFN /* This module will be blanked at non-LFN configuration */
#if FF_DEFINED != 86604 /* Revision ID */
#error Wrong include file (ff.h).
#endif
#if FF_USE_LFN /* This module will be blanked if non-LFN configuration */
#define MERGE2(a, b) a ## b
#define CVTBL(tbl, cp) MERGE2(tbl, cp)
......@@ -15245,7 +15241,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
return c;
}
WCHAR ff_oem2uni ( /* Returns Unicode character, zero on error */
WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
WCHAR oem, /* OEM code to be converted */
WORD cp /* Code page for the conversion */
)
......@@ -15312,7 +15308,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
}
WCHAR ff_oem2uni ( /* Returns Unicode character, zero on error */
WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
WCHAR oem, /* OEM code to be converted */
WORD cp /* Code page for the conversion */
)
......@@ -15411,7 +15407,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
}
WCHAR ff_oem2uni ( /* Returns Unicode character, zero on error */
WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
WCHAR oem, /* OEM code to be converted (DBC if >=0x100) */
WORD cp /* Code page for the conversion */
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册