xilffs: Modified the xilffs according to MISRAC 2012 compliant.
This patch modifies the xilffs library according to MISRAC 2012 compliant and cache related changes were removed in previous upgrade and the changes are done again to correct it. Signed-off-by: P L Sai Krishna <lakshmis@xilinx.com>
This commit is contained in:
parent
0044befaca
commit
b263d0ea45
5 changed files with 1733 additions and 1038 deletions
|
@ -69,6 +69,7 @@
|
|||
* WP/CD. CR# 810655.
|
||||
* Make changes for prototypes of disk_read and
|
||||
* disk_write according to latest version.
|
||||
* 12/15/14 Modified the code according to MISRAC 2012 Compliant.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,6 +77,7 @@
|
|||
*
|
||||
******************************************************************************/
|
||||
#include "diskio.h"
|
||||
#include "ff.h"
|
||||
#include "xparameters.h"
|
||||
#include "xil_types.h"
|
||||
|
||||
|
@ -86,11 +88,11 @@
|
|||
#include "xil_printf.h"
|
||||
|
||||
#define SD_DEVICE_ID XPAR_XSDPS_0_DEVICE_ID
|
||||
#define HIGH_SPEED_SUPPORT 0x01
|
||||
#define WIDTH_4_BIT_SUPPORT 0x4
|
||||
#define SD_CLK_25_MHZ 25000000
|
||||
#define SD_CLK_26_MHZ 26000000
|
||||
#define SD_CLK_52_MHZ 52000000
|
||||
#define HIGH_SPEED_SUPPORT 0x01U
|
||||
#define WIDTH_4_BIT_SUPPORT 0x4U
|
||||
#define SD_CLK_25_MHZ 25000000U
|
||||
#define SD_CLK_26_MHZ 26000000U
|
||||
#define SD_CLK_52_MHZ 52000000U
|
||||
#define EXT_CSD_DEVICE_TYPE_BYTE 196
|
||||
#define EXT_CSD_4_BIT_WIDTH_BYTE 183
|
||||
#define EXT_CSD_HIGH_SPEED_BYTE 185
|
||||
|
@ -113,10 +115,10 @@ static XSdPs SdInstance;
|
|||
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
u8 ExtCsd[512];
|
||||
static u8 ExtCsd[512];
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
u8 ExtCsd[512] __attribute__ ((aligned(32)));
|
||||
static u8 ExtCsd[512] __attribute__ ((aligned(32)));
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
@ -129,7 +131,7 @@ u8 ExtCsd[512] __attribute__ ((aligned(32)));
|
|||
* Gets the status of the disk.
|
||||
* In case of SD, it checks whether card is present or not.
|
||||
*
|
||||
* @param drv - Drive number
|
||||
* @param pdrv - Drive number
|
||||
*
|
||||
* @return
|
||||
* 0 Status ok
|
||||
|
@ -142,23 +144,23 @@ u8 ExtCsd[512] __attribute__ ((aligned(32)));
|
|||
*
|
||||
******************************************************************************/
|
||||
DSTATUS disk_status (
|
||||
BYTE drv /* Drive number (0) */
|
||||
BYTE pdrv /* Drive number (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS s = Stat;
|
||||
u32 StatusReg;
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
StatusReg = XSdPs_GetPresentStatusReg(XPAR_XSDPS_0_BASEADDR);
|
||||
StatusReg = XSdPs_GetPresentStatusReg((u32)XPAR_XSDPS_0_BASEADDR);
|
||||
#if XPAR_XSDPS_0_HAS_CD
|
||||
if ((StatusReg & XSDPS_PSR_CARD_INSRT_MASK) == 0) {
|
||||
if ((StatusReg & XSDPS_PSR_CARD_INSRT_MASK) == 0U) {
|
||||
s = STA_NODISK | STA_NOINIT;
|
||||
goto Label;
|
||||
}
|
||||
#endif
|
||||
s &= ~STA_NODISK;
|
||||
#if XPAR_XSDPS_0_HAS_WP
|
||||
if ((StatusReg & XSDPS_PSR_WPS_PL_MASK) == 0){
|
||||
if ((StatusReg & XSDPS_PSR_WPS_PL_MASK) == 0U){
|
||||
s |= STA_PROTECT;
|
||||
goto Label;
|
||||
}
|
||||
|
@ -182,7 +184,7 @@ Label:
|
|||
* This function also selects additional settings such as bus width,
|
||||
* speed and block size.
|
||||
*
|
||||
* @param drv - Drive number
|
||||
* @param pdrv - Drive number
|
||||
*
|
||||
* @return s - which contains an OR of the following information
|
||||
* STA_NODISK Disk is not present
|
||||
|
@ -194,19 +196,19 @@ Label:
|
|||
*
|
||||
******************************************************************************/
|
||||
DSTATUS disk_initialize (
|
||||
BYTE drv /* Physical drive number (0) */
|
||||
BYTE pdrv /* Physical drive number (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS s;
|
||||
int Status;
|
||||
s32 Status;
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
u8 SCR[8];
|
||||
u8 ReadBuff[64];
|
||||
u8 SCR[8] = {0U};
|
||||
u8 ReadBuff[64] = {0U};
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
u8 SCR[8] __attribute__ ((aligned(32)));
|
||||
u8 ReadBuff[64] __attribute__ ((aligned(32)));
|
||||
u8 SCR[8] __attribute__ ((aligned(32))) = {0U};
|
||||
u8 ReadBuff[64] __attribute__ ((aligned(32))) = {0U};
|
||||
#endif
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
|
@ -216,15 +218,15 @@ DSTATUS disk_initialize (
|
|||
/*
|
||||
* Check if card is in the socket
|
||||
*/
|
||||
s = disk_status(drv);
|
||||
if (s & STA_NODISK) {
|
||||
s = disk_status(pdrv);
|
||||
if ((s & STA_NODISK) != 0U) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the host controller
|
||||
*/
|
||||
SdConfig = XSdPs_LookupConfig(SD_DEVICE_ID);
|
||||
SdConfig = XSdPs_LookupConfig((u16)SD_DEVICE_ID);
|
||||
if (NULL == SdConfig) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
|
@ -269,7 +271,7 @@ DSTATUS disk_initialize (
|
|||
return s;
|
||||
}
|
||||
|
||||
if(ReadBuff[13] & HIGH_SPEED_SUPPORT){
|
||||
if((ReadBuff[13] & HIGH_SPEED_SUPPORT) != 0U){
|
||||
Status = XSdPs_Change_BusSpeed(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
|
@ -283,7 +285,7 @@ DSTATUS disk_initialize (
|
|||
return s;
|
||||
}
|
||||
|
||||
if (SCR[1] & WIDTH_4_BIT_SUPPORT) {
|
||||
if ((SCR[1] & WIDTH_4_BIT_SUPPORT) != 0U) {
|
||||
Status = XSdPs_Change_BusWidth(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
|
@ -291,7 +293,7 @@ DSTATUS disk_initialize (
|
|||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_SetBlkSize(&SdInstance, XSDPS_BLK_SIZE_512_MASK);
|
||||
Status = XSdPs_SetBlkSize(&SdInstance, (u16)XSDPS_BLK_SIZE_512_MASK);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
|
@ -383,7 +385,7 @@ DSTATUS disk_initialize (
|
|||
* Reads the drive
|
||||
* In case of SD, it reads the SD card using ADMA2 in polled mode.
|
||||
*
|
||||
* @param drv - Drive number
|
||||
* @param pdrv - Drive number
|
||||
* @param *buff - Pointer to the data buffer to store read data
|
||||
* @param sector - Start sector number
|
||||
* @param count - Sector count
|
||||
|
@ -397,7 +399,7 @@ DSTATUS disk_initialize (
|
|||
*
|
||||
******************************************************************************/
|
||||
DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
BYTE pdrv, /* Physical drive number (0) */
|
||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
UINT count /* Sector count (1..128) */
|
||||
|
@ -405,18 +407,24 @@ DRESULT disk_read (
|
|||
{
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
DSTATUS s;
|
||||
int Status;
|
||||
s32 Status;
|
||||
DWORD LocSector = sector;
|
||||
|
||||
s = disk_status(pdrv);
|
||||
|
||||
s = disk_status(drv);
|
||||
|
||||
if (s & STA_NOINIT) return RES_NOTRDY;
|
||||
if (!count) return RES_PARERR;
|
||||
if ((s & STA_NOINIT) != 0U) {
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
if (count == 0U) {
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
/* Convert LBA to byte address if needed */
|
||||
if (!(SdInstance.HCS)) sector *= XSDPS_BLK_SIZE_512_MASK;
|
||||
if ((SdInstance.HCS) == 0U) {
|
||||
LocSector *= (DWORD)XSDPS_BLK_SIZE_512_MASK;
|
||||
}
|
||||
|
||||
Status = XSdPs_ReadPolled(&SdInstance, sector, count, buff);
|
||||
Status = XSdPs_ReadPolled(&SdInstance, (u32)LocSector, count, buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
@ -430,28 +438,30 @@ DRESULT disk_read (
|
|||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
BYTE ctrl, /* Control code */
|
||||
BYTE pdrv, /* Physical drive number (0) */
|
||||
BYTE cmd, /* Control code */
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
DRESULT res;
|
||||
|
||||
if (disk_status(drv) & STA_NOINIT) /* Check if card is in the socket */
|
||||
return RES_NOTRDY;
|
||||
void *LocBuff = buff;
|
||||
if ((disk_status(pdrv) & STA_NOINIT) != 0U) { /* Check if card is in the socket */
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
|
||||
res = RES_ERROR;
|
||||
switch (ctrl) {
|
||||
case CTRL_SYNC : /* Make sure that no pending write process */
|
||||
switch (cmd) {
|
||||
case (BYTE)CTRL_SYNC : /* Make sure that no pending write process */
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
case (BYTE)GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
res = RES_ERROR;
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
*(DWORD*)buff = 128;
|
||||
case (BYTE)GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
(*((DWORD *)((void *)LocBuff))) = ((DWORD)128);
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
|
@ -461,8 +471,9 @@ DRESULT disk_ioctl (
|
|||
}
|
||||
|
||||
return res;
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -480,7 +491,7 @@ DRESULT disk_ioctl (
|
|||
|
||||
DWORD get_fattime (void)
|
||||
{
|
||||
return ((DWORD)(2010 - 1980) << 25) /* Fixed to Jan. 1, 2010 */
|
||||
return ((DWORD)(2010U - 1980U) << 25U) /* Fixed to Jan. 1, 2010 */
|
||||
| ((DWORD)1 << 21)
|
||||
| ((DWORD)1 << 16)
|
||||
| ((DWORD)0 << 11)
|
||||
|
@ -494,7 +505,7 @@ DWORD get_fattime (void)
|
|||
* Reads the drive
|
||||
* In case of SD, it reads the SD card using ADMA2 in polled mode.
|
||||
*
|
||||
* @param drv - Drive number
|
||||
* @param pdrv - Drive number
|
||||
* @param *buff - Pointer to the data to be written
|
||||
* @param sector - Sector address
|
||||
* @param count - Sector count
|
||||
|
@ -508,25 +519,32 @@ DWORD get_fattime (void)
|
|||
*
|
||||
******************************************************************************/
|
||||
DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive nmuber (0..) */
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector address (LBA) */
|
||||
UINT count /* Number of sectors to write (1..128) */
|
||||
)
|
||||
{
|
||||
DSTATUS s;
|
||||
int Status;
|
||||
s32 Status;
|
||||
DWORD LocSector = sector;
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
s = disk_status(drv);
|
||||
s = disk_status(pdrv);
|
||||
|
||||
if (s & STA_NOINIT) return RES_NOTRDY;
|
||||
if (!count) return RES_PARERR;
|
||||
if ((s & STA_NOINIT) != 0U) {
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
if (count == 0U) {
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
/* Convert LBA to byte address if needed */
|
||||
if (!(SdInstance.HCS)) sector *= XSDPS_BLK_SIZE_512_MASK;
|
||||
if ((SdInstance.HCS) == 0U) {
|
||||
LocSector *= (DWORD)XSDPS_BLK_SIZE_512_MASK;
|
||||
}
|
||||
|
||||
Status = XSdPs_WritePolled(&SdInstance, sector, count, buff);
|
||||
Status = XSdPs_WritePolled(&SdInstance, (u32)LocSector, count, buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,18 +2,18 @@
|
|||
/ Low level disk interface modlue include file (C)ChaN, 2013 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
#ifndef DISKIO_DEFINED
|
||||
#define DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
#define USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
#include "xil_types.h"
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
@ -31,7 +31,6 @@ typedef enum {
|
|||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
|
@ -41,37 +40,37 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
|||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
#define STA_NOINIT 0x01U /* Drive not initialized */
|
||||
#define STA_NODISK 0x02U /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04U /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
|
||||
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
|
||||
#define CTRL_SYNC 0U /* Flush disk cache (for write functions) */
|
||||
#define GET_SECTOR_COUNT 1U /* Get media size (for only f_mkfs()) */
|
||||
#define GET_SECTOR_SIZE 2U /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
|
||||
#define GET_BLOCK_SIZE 3U /* Get erase block size (for only f_mkfs()) */
|
||||
#define CTRL_ERASE_SECTOR 4U /* Force erased a block of sectors (for only _USE_ERASE) */
|
||||
|
||||
/* Generic command (not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||
#define CTRL_POWER 5U /* Get/Set power status */
|
||||
#define CTRL_LOCK 6U /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7U /* Eject media */
|
||||
#define CTRL_FORMAT 8U /* Create physical format on the media */
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
#define MMC_GET_TYPE 10 /* Get card type */
|
||||
#define MMC_GET_CSD 11 /* Get CSD */
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
#define MMC_GET_TYPE 10U /* Get card type */
|
||||
#define MMC_GET_CSD 11U /* Get CSD */
|
||||
#define MMC_GET_CID 12U /* Get CID */
|
||||
#define MMC_GET_OCR 13U /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14U /* Get SD status */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
#define ATA_GET_REV 20U /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21U /* Get model name */
|
||||
#define ATA_GET_SN 22U /* Get serial number */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,17 +14,18 @@
|
|||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 8051 /* Revision ID */
|
||||
#ifndef FAT_FS
|
||||
#define FAT_FS 8051 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "xil_types.h"
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if _FATFS != _FFCONF
|
||||
#if FAT_FS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
@ -42,8 +43,8 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
|||
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
||||
|
||||
#else /* Single partition configuration */
|
||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
|
||||
#define LD2PD(vol) (BYTE)((vol)) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0U /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -57,15 +58,15 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
|||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#define T(x) L ## x
|
||||
#define TEXT(x) L ## x
|
||||
#endif
|
||||
|
||||
#else /* ANSI/OEM string */
|
||||
#ifndef _INC_TCHAR
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#define T(x) (x)
|
||||
#define TEXT(x) (x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -103,7 +104,13 @@ typedef struct {
|
|||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
BYTE win[_MAX_SS];
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
BYTE win[_MAX_SS] __attribute__ ((aligned(32))); /* Disk access window for Directory, FAT (and Data on tiny cfg) */
|
||||
#endif
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
@ -131,7 +138,13 @@ typedef struct {
|
|||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File private data read/write window */
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
BYTE buf[_MAX_SS]; /* File data read/write buffer */
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
BYTE buf[_MAX_SS] __attribute__ ((aligned(32))); /* File data read/write buffer */
|
||||
#endif
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
@ -178,7 +191,7 @@ typedef struct {
|
|||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_OK = 0U, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive cannot work */
|
||||
|
@ -209,37 +222,67 @@ FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a f
|
|||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
#if _USE_FORWARD
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
#endif
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
#if _FS_MINIMIZE <= 2
|
||||
#if _FS_MINIMIZE <= 1
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
#if _FS_MINIMIZE == 0
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
#if !_FS_READONLY
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfsys);
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
DWORD clust2sect (FATFS* fs, DWORD clst);
|
||||
DWORD get_fat ( FATFS* fs, DWORD clst);
|
||||
FRESULT put_fat (FATFS* fs, DWORD clst, DWORD val);
|
||||
#if _FS_RPATH >= 1
|
||||
#if _VOLUMES >= 2
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
#endif
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
#if _FS_RPATH >= 2
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
#endif
|
||||
#endif
|
||||
#if _USE_LABEL
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
#if !_FS_READONLY
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
#endif
|
||||
#endif
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
#if _USE_MKFS && !_FS_READONLY
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
#if _MULTI_PARTITION
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
#endif
|
||||
#endif
|
||||
#if _USE_STRFUNC
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
#if !_FS_READONLY
|
||||
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 */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
#define file_size(fp) ((fp)->fsize)
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
|
@ -283,40 +326,40 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
|||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA_READ 0x01U
|
||||
#define FA_OPEN_EXISTING 0x00U
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#define FA__DIRTY 0x40
|
||||
#define FA_WRITE 0x02U
|
||||
#define FA_CREATE_NEW 0x04U
|
||||
#define FA_CREATE_ALWAYS 0x08U
|
||||
#define FA_OPEN_ALWAYS 0x10U
|
||||
#define FA__WRITTEN 0x20U
|
||||
#define FA__DIRTY 0x40U
|
||||
#endif
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
#define FS_FAT12 1U
|
||||
#define FS_FAT16 2U
|
||||
#define FS_FAT32 3U
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
#define AM_RDO 0x01U /* Read only */
|
||||
#define AM_HID 0x02U /* Hidden */
|
||||
#define AM_SYS 0x04U /* System */
|
||||
#define AM_VOL 0x08U /* Volume label */
|
||||
#define AM_LFN 0x0FU /* LFN entry */
|
||||
#define AM_DIR 0x10U /* Directory */
|
||||
#define AM_ARC 0x20U /* Archive */
|
||||
#define AM_MASK 0x3FU /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Fast seek feature */
|
||||
#define CREATE_LINKMAP 0xFFFFFFFF
|
||||
#define CREATE_LINKMAP 0xFFFFFFFFU
|
||||
|
||||
|
||||
|
||||
|
@ -324,19 +367,19 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
|||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_WORD(ptr) (*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#define ST_WORD(ptr,val) (*(WORD*)(BYTE*)(ptr))=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) (*(DWORD*)(BYTE*)(ptr))=(DWORD)(val)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#define LD_WORD(ptr) (((WORD)*((BYTE*)(ptr)+1U)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3U)<<24)|((DWORD)*((BYTE*)(ptr)+2U)<<16)|((WORD)*((BYTE*)(ptr)+1U)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) (*((WORD*)((void *)(ptr))))=((WORD)(val)); (*((WORD *)((ptr)+1U)))=(((WORD)(val))>>8)
|
||||
#define ST_DWORD(ptr,val) (*((DWORD*)((void *)(ptr))))=((DWORD)(val)); (*((DWORD*)(void *)((ptr)+1U)))=((DWORD)((DWORD)(val)>>8)); (*((DWORD*)(void *)((ptr)+2U)))=((DWORD)((DWORD)(val)>>16)); (*((DWORD*)(void *)((ptr)+3U)))=((DWORD)((DWORD)(val)>>24))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
#endif /* FAT_FS */
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
/ FatFs supports only BMP. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0 /* 0 to 2 */
|
||||
#define _FS_RPATH 0U /* 0 to 2 */
|
||||
/* The _FS_RPATH option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
|
@ -133,7 +133,7 @@
|
|||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
#define _VOLUMES 1U
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
|
@ -152,8 +152,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
#define _MIN_SS 512U
|
||||
#define _MAX_SS 512U
|
||||
/* These options configure the range of sector size to be supported. (512, 1024, 2048 or
|
||||
/ 4096) Always set both 512 for most systems, all memory card and harddisk. But a larger
|
||||
/ value may be required for on-board flash memory and some type of optical media.
|
||||
|
|
Loading…
Add table
Reference in a new issue