xilffs_v3_1: Added new minor version.
This patch add new minor version v3.1 and deprecates v3.0 Signed-off-by: P L Sai Krishna <lakshmis@xilinx.com>
This commit is contained in:
parent
5c1e76fb33
commit
ca1fb25835
10 changed files with 7034 additions and 0 deletions
54
lib/sw_services/xilffs/data/xilffs.mld
Normal file
54
lib/sw_services/xilffs/data/xilffs.mld
Normal file
|
@ -0,0 +1,54 @@
|
|||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2013 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# Use of the Software is limited solely to applications:
|
||||
# (a) running on a Xilinx device, or
|
||||
# (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# Modification History
|
||||
#
|
||||
# Ver Who Date Changes
|
||||
# ----- ---- -------- -----------------------------------------------
|
||||
# 1.00a hk/sg 10/17/13 First release
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
OPTION psf_version = 2.1;
|
||||
|
||||
BEGIN LIBRARY xilffs
|
||||
OPTION drc = ffs_drc;
|
||||
OPTION copyfiles = all;
|
||||
OPTION REQUIRES_OS = (standalone);
|
||||
OPTION APP_LINKER_FLAGS = "-Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group";
|
||||
OPTION desc = "Generic Fat File System Library";
|
||||
OPTION VERSION = 3.1;
|
||||
OPTION NAME = xilffs;
|
||||
PARAM name = fs_interface, desc = "Enables file system with selected interface. Enter 1 for SD.", type = int, default = 1;
|
||||
PARAM name = enable_mmc, desc = "Enables MMC support if true. If false, SD is enabled.", type = bool, default = false;
|
||||
|
||||
END LIBRARY
|
151
lib/sw_services/xilffs/data/xilffs.tcl
Normal file
151
lib/sw_services/xilffs/data/xilffs.tcl
Normal file
|
@ -0,0 +1,151 @@
|
|||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2013 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# Use of the Software is limited solely to applications:
|
||||
# (a) running on a Xilinx device, or
|
||||
# (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# Modification History
|
||||
#
|
||||
# Ver Who Date Changes
|
||||
# ----- ---- ------- -----------------------------------------------
|
||||
# 1.00a hk/sg 10/17/13 First release
|
||||
# 2.0 hk 12/13/13 Modified to use new TCL API's
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
#---------------------------------------------
|
||||
# FFS_drc - check system configuration and make sure
|
||||
# all components to run ISF are available.
|
||||
#---------------------------------------------
|
||||
|
||||
proc ffs_drc {libhandle} {
|
||||
|
||||
# Check if any IP instances that use FATFS are present
|
||||
set sw_processor [hsi::get_sw_processor]
|
||||
set processor [hsi::get_cells [common::get_property HW_INSTANCE $sw_processor]]
|
||||
|
||||
set ffs_periphs_list [get_ffs_periphs $processor]
|
||||
|
||||
if { [llength $ffs_periphs_list] == 0 } {
|
||||
puts "WARNING : No interface that uses file system is available \n"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
proc get_ffs_periphs {processor} {
|
||||
set periphs_list [hsi::utils::get_proc_slave_periphs $processor]
|
||||
set ffs_periphs_list {}
|
||||
|
||||
global ffs_periphs_name_list
|
||||
set ffs_periphs_name_list {}
|
||||
|
||||
foreach periph $periphs_list {
|
||||
set periphname [common::get_property IP_NAME $periph]
|
||||
# Checks if SD instance is present
|
||||
# This can be expanded to add more instances.
|
||||
if {$periphname == "ps7_sdio" || $periphname == "psu_sd"} {
|
||||
lappend ffs_periphs_list $periph
|
||||
lappend ffs_periphs_name_list $periphname
|
||||
}
|
||||
}
|
||||
|
||||
return $ffs_periphs_list
|
||||
}
|
||||
|
||||
proc generate {libhandle} {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------
|
||||
# post_generate: called after generate called on all libraries
|
||||
#-------
|
||||
proc post_generate {libhandle} {
|
||||
xgen_opts_file $libhandle
|
||||
}
|
||||
|
||||
#-------
|
||||
# execs_generate: called after BSP's, libraries and drivers have been compiled
|
||||
# This procedure builds the libisf.a library
|
||||
#-------
|
||||
proc execs_generate {libhandle} {
|
||||
|
||||
}
|
||||
|
||||
|
||||
proc xgen_opts_file {libhandle} {
|
||||
|
||||
# Open xparameters.h file
|
||||
set file_handle [hsi::utils::open_include_file "xparameters.h"]
|
||||
|
||||
# Generate parameters for "file system with SD" and "MMC support"
|
||||
puts $file_handle "/* Xilinx FAT File System Library (XilFFs) User Settings */"
|
||||
set fs_interface [common::get_property CONFIG.fs_interface $libhandle]
|
||||
set enable_mmc [common::get_property CONFIG.enable_mmc $libhandle]
|
||||
|
||||
# Checking if SD with FATFS is enabled.
|
||||
# This can be expanded to add more interfaces.
|
||||
|
||||
global ffs_periphs_name_list
|
||||
foreach periph $ffs_periphs_name_list {
|
||||
|
||||
if {$periph == "ps7_sdio" || $periph == "psu_sd"} {
|
||||
if {$fs_interface == 1} {
|
||||
puts $file_handle "\#define FILE_SYSTEM_INTERFACE_SD"
|
||||
} else {
|
||||
error "ERROR: Invalid interface selected \n"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# MMC support
|
||||
if {$enable_mmc == true} {
|
||||
puts $file_handle "\#define MMC_CARD"
|
||||
}
|
||||
|
||||
close $file_handle
|
||||
|
||||
# Copy the include files to the include directory
|
||||
set srcdir [file join src include]
|
||||
set dstdir [file join .. .. include]
|
||||
|
||||
# Create dstdir if it does not exist
|
||||
if { ! [file exists $dstdir] } {
|
||||
file mkdir $dstdir
|
||||
}
|
||||
|
||||
# Get list of files in the srcdir
|
||||
set sources [glob -join $srcdir *.h]
|
||||
|
||||
# Copy each of the files in the list to dstdir
|
||||
foreach source $sources {
|
||||
file copy -force $source $dstdir
|
||||
}
|
||||
}
|
223
lib/sw_services/xilffs/examples/xilffs_polled_example.c
Normal file
223
lib/sw_services/xilffs/examples/xilffs_polled_example.c
Normal file
|
@ -0,0 +1,223 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2013 - 2014 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file xilffs_polled_example.c
|
||||
*
|
||||
*
|
||||
* @note This example uses file system with SD to write to and read from
|
||||
* an SD card using ADMA2 in polled mode.
|
||||
*
|
||||
* This example was tested using SD2.0 card and eMMC (using eMMC to SD adaptor).
|
||||
*
|
||||
* None.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- --- -------- -----------------------------------------------
|
||||
* 1.00a hk 10/17/13 First release
|
||||
* 2.2 hk 07/28/14 Make changes to enable use of data cache.
|
||||
*
|
||||
*</pre>
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include "xparameters.h" /* SDK generated parameters */
|
||||
#include "xsdps.h" /* SD device driver */
|
||||
#include "xil_printf.h"
|
||||
#include "ff.h"
|
||||
#include "xil_cache.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
int FfsSdPolledExample(void);
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
static FIL fil; /* File object */
|
||||
static FATFS fatfs;
|
||||
static char FileName[32] = "Test.bin";
|
||||
static char *SD_File;
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
u8 DestinationAddress[10*1024*1024];
|
||||
u8 SourceAddress[10*1024*1024];
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
u8 DestinationAddress[10*1024*1024] __attribute__ ((aligned(32)));
|
||||
u8 SourceAddress[10*1024*1024] __attribute__ ((aligned(32)));
|
||||
#endif
|
||||
|
||||
#define TEST 7
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Main function to call the SD example.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return XST_SUCCESS if successful, otherwise XST_FAILURE.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
|
||||
xil_printf("SD Polled File System Example Test \r\n");
|
||||
|
||||
Status = FfsSdPolledExample();
|
||||
if (Status != XST_SUCCESS) {
|
||||
xil_printf("SD Polled File System Example Test failed \r\n");
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
xil_printf("Successfully ran SD Polled File System Example Test \r\n");
|
||||
|
||||
return XST_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* File system example using SD driver to write to and read from an SD card
|
||||
* in polled mode. This example creates a new file on an
|
||||
* SD card (which is previously formatted with FATFS), write data to the file
|
||||
* and reads the same data back to verify.
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return XST_SUCCESS if successful, otherwise XST_FAILURE.
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
******************************************************************************/
|
||||
int FfsSdPolledExample(void)
|
||||
{
|
||||
FRESULT Res;
|
||||
UINT NumBytesRead;
|
||||
UINT NumBytesWritten;
|
||||
u32 BuffCnt;
|
||||
u32 FileSize = (8*1024*1024);
|
||||
TCHAR *Path = "0:/";
|
||||
|
||||
for(BuffCnt = 0; BuffCnt < FileSize; BuffCnt++){
|
||||
SourceAddress[BuffCnt] = TEST + BuffCnt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register volume work area, initialize device
|
||||
*/
|
||||
Res = f_mount(&fatfs, Path, 0);
|
||||
|
||||
if (Res != FR_OK) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open file with required permissions.
|
||||
* Here - Creating new file with read/write permissions. .
|
||||
*/
|
||||
SD_File = (char *)FileName;
|
||||
|
||||
Res = f_open(&fil, SD_File, FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pointer to beginning of file .
|
||||
*/
|
||||
Res = f_lseek(&fil, 0);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write data to file.
|
||||
*/
|
||||
Res = f_write(&fil, (const void*)SourceAddress, FileSize,
|
||||
&NumBytesWritten);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pointer to beginning of file .
|
||||
*/
|
||||
Res = f_lseek(&fil, 0);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read data from file.
|
||||
*/
|
||||
Res = f_read(&fil, (void*)DestinationAddress, FileSize,
|
||||
&NumBytesRead);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Data verification
|
||||
*/
|
||||
for(BuffCnt = 0; BuffCnt < FileSize; BuffCnt++){
|
||||
if(SourceAddress[BuffCnt] != DestinationAddress[BuffCnt]){
|
||||
return XST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Close file.
|
||||
*/
|
||||
Res = f_close(&fil);
|
||||
if (Res) {
|
||||
return XST_FAILURE;
|
||||
}
|
||||
|
||||
return XST_SUCCESS;
|
||||
}
|
105
lib/sw_services/xilffs/src/Makefile
Normal file
105
lib/sw_services/xilffs/src/Makefile
Normal file
|
@ -0,0 +1,105 @@
|
|||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2013 - 2014 Xilinx, Inc. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# Use of the Software is limited solely to applications:
|
||||
# (a) running on a Xilinx device, or
|
||||
# (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
# in advertising or otherwise to promote the sale, use or other dealings in
|
||||
# this Software without prior written authorization from Xilinx.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
COMPILER=
|
||||
ARCHIVER=
|
||||
CP=cp
|
||||
COMPILER_FLAGS=
|
||||
|
||||
ifeq ($(notdir $(COMPILER)) , arm-xilinx-eabi-gcc)
|
||||
EXTRA_ARCHIVE_FLAGS=rc
|
||||
else
|
||||
ifeq ($(notdir $(COMPILER)), aarch64-none-elf-gcc)
|
||||
EXTRA_ARCHIVE_FLAGS=rc
|
||||
else
|
||||
ifeq ($(notdir $(COMPILER)), arm-none-eabi-gcc)
|
||||
EXTRA_ARCHIVE_FLAGS=rc
|
||||
else
|
||||
EXTRA_ARCHIVE_FLAGS=--create
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(COMPILER) , mb-gcc)
|
||||
EXTRA_ARCHIVE_FLAGS=rc
|
||||
endif
|
||||
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
INCLUDES=-I./include/ -I${INCLUDEDIR}
|
||||
FATFS_DIR = .
|
||||
|
||||
LIB_SRCS = $(FATFS_DIR)/ff.c \
|
||||
$(FATFS_DIR)/diskio.c
|
||||
|
||||
|
||||
# create FATFS_SRCS based on configured options
|
||||
|
||||
FATFS_SRCS = $(LIB_SRCS)
|
||||
|
||||
FATFS_OBJS = $(FATFS_SRCS:%.c=%.o)
|
||||
|
||||
|
||||
EXPORT_INCLUDE_FILES = $(FATFS_DIR)/include/ff.h \
|
||||
$(FATFS_DIR)/include/ffconf.h \
|
||||
$(FATFS_DIR)/include/diskio.h \
|
||||
$(FATFS_DIR)/include/integer.h
|
||||
|
||||
|
||||
libs: libxilffs.a
|
||||
cp libxilffs.a $(RELEASEDIR)
|
||||
make clean
|
||||
|
||||
include:
|
||||
@for i in $(EXPORT_INCLUDE_FILES); do \
|
||||
${CP} -r $$i ${INCLUDEDIR}; \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -rf obj/ff.o obj/diskio.o
|
||||
rmdir obj
|
||||
rm libxilffs.a
|
||||
|
||||
|
||||
libxilffs.a: obj_dir print_msg_fatfs_base $(FATFS_OBJS)
|
||||
@echo "Creating archive $@"
|
||||
$(ARCHIVER) $(EXTRA_ARCHIVE_FLAGS) $@ obj/ff.o obj/diskio.o
|
||||
|
||||
|
||||
obj_dir:
|
||||
mkdir obj
|
||||
|
||||
print_msg_fatfs_base:
|
||||
@echo "Compiling XilFFs Library"
|
||||
|
||||
.c.o:
|
||||
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) -c $< -o obj/$(@F)
|
550
lib/sw_services/xilffs/src/diskio.c
Normal file
550
lib/sw_services/xilffs/src/diskio.c
Normal file
|
@ -0,0 +1,550 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2013 - 2015 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
*
|
||||
******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* @file diskio.c
|
||||
* This file is the glue layer between file system and
|
||||
* driver.
|
||||
* Description related to SD driver:
|
||||
* Process to use file system with SD
|
||||
* Select xilffs in SDK when creating a BSP
|
||||
* In SDK, set "fs_interface" to 1 to select SD interface.
|
||||
* This glue layer can currently be used only with one
|
||||
* SD controller enabled.
|
||||
* In order to use eMMC, in SDK set "Enable MMC" to 1. If not,
|
||||
* SD support is enabled by default.
|
||||
*
|
||||
* Description:
|
||||
* This glue layer initializes the host controller and SD card
|
||||
* in disk_initialize. If SD card supports it, 4-bit mode and
|
||||
* high speed mode will be enabled.
|
||||
* The default block size is 512 bytes.
|
||||
* disk_read and disk_write functions are used to read and
|
||||
* write files using ADMA2 in polled mode.
|
||||
* The file system can be used to read from and write to an
|
||||
* SD card that is already formatted as FATFS.
|
||||
*
|
||||
* <pre>
|
||||
* MODIFICATION HISTORY:
|
||||
*
|
||||
* Ver Who Date Changes
|
||||
* ----- ---- -------- -------------------------------------------------------
|
||||
* 1.00a hk 10/17/13 First release
|
||||
* 2.0 hk 02/12/14 Corrected status check in disk initialize. CR# 772072.
|
||||
* 2.1 hk 04/16/14 Move check for ExtCSD high speed bit set inside if
|
||||
* condition for high speed support.
|
||||
* Include xil_types.h irrespective of xsdps.h. CR# 797086.
|
||||
* 2.2 hk 07/28/14 Make changes to enable use of data cache.
|
||||
* 3.0 sk 12/04/14 Added support for micro SD without
|
||||
* 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.
|
||||
* Updated the FatFs to R0.10b
|
||||
* Removed alignment for local buffers as CacheInvalidate
|
||||
* will take care of it.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "diskio.h"
|
||||
#include "ff.h"
|
||||
#include "xparameters.h"
|
||||
#include "xil_types.h"
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
#include "xsdps.h" /* SD device driver */
|
||||
#endif
|
||||
|
||||
#include "xil_printf.h"
|
||||
|
||||
#define SD_DEVICE_ID XPAR_XSDPS_0_DEVICE_ID
|
||||
#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
|
||||
#define EXT_CSD_DEVICE_TYPE_HIGH_SPEED 0x3
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
Public Functions
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
static DSTATUS Stat; /* Disk status */
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
static XSdPs SdInstance;
|
||||
#endif
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#pragma data_alignment = 32
|
||||
static u8 ExtCsd[512];
|
||||
#pragma data_alignment = 4
|
||||
#else
|
||||
static u8 ExtCsd[512] __attribute__ ((aligned(32)));
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Disk Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Gets the status of the disk.
|
||||
* In case of SD, it checks whether card is present or not.
|
||||
*
|
||||
* @param pdrv - Drive number
|
||||
*
|
||||
* @return
|
||||
* 0 Status ok
|
||||
* STA_NOINIT Drive not initialized
|
||||
* STA_NODISK No medium in the drive
|
||||
* STA_PROTECT Write protected
|
||||
*
|
||||
* @note In case Card detect signal is not connected,
|
||||
* this function will not be able to check if card is present.
|
||||
*
|
||||
******************************************************************************/
|
||||
DSTATUS disk_status (
|
||||
BYTE pdrv /* Drive number (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS s = Stat;
|
||||
u32 StatusReg;
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
StatusReg = XSdPs_GetPresentStatusReg((u32)XPAR_XSDPS_0_BASEADDR);
|
||||
#if XPAR_XSDPS_0_HAS_CD
|
||||
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) == 0U){
|
||||
s |= STA_PROTECT;
|
||||
goto Label;
|
||||
}
|
||||
#endif
|
||||
s &= ~STA_PROTECT;
|
||||
|
||||
Label:
|
||||
Stat = s;
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize Disk Drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initializes the drive.
|
||||
* In case of SD, it initializes the host controller and the card.
|
||||
* This function also selects additional settings such as bus width,
|
||||
* speed and block size.
|
||||
*
|
||||
* @param pdrv - Drive number
|
||||
*
|
||||
* @return s - which contains an OR of the following information
|
||||
* STA_NODISK Disk is not present
|
||||
* STA_NOINIT Drive not initialized
|
||||
* STA_PROTECT Drive is write protected
|
||||
* 0 or only STA_PROTECT both indicate successful initialization.
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive number (0) */
|
||||
)
|
||||
{
|
||||
DSTATUS s;
|
||||
s32 Status;
|
||||
u8 SCR[8] = {0U};
|
||||
u8 ReadBuff[64] = {0U};
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
|
||||
XSdPs_Config *SdConfig;
|
||||
|
||||
/*
|
||||
* Check if card is in the socket
|
||||
*/
|
||||
s = disk_status(pdrv);
|
||||
if ((s & STA_NODISK) != 0U) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the host controller
|
||||
*/
|
||||
SdConfig = XSdPs_LookupConfig((u16)SD_DEVICE_ID);
|
||||
if (NULL == SdConfig) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Stat = STA_NOINIT;
|
||||
Status = XSdPs_CfgInitialize(&SdInstance, SdConfig,
|
||||
SdConfig->BaseAddress);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifndef MMC_CARD
|
||||
Status = XSdPs_SdCardInitialize(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Change_ClkFreq(&SdInstance, SD_CLK_25_MHZ);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Select_Card(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Get_BusWidth(&SdInstance, SCR);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Get_BusSpeed(&SdInstance, ReadBuff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
if((ReadBuff[13] & HIGH_SPEED_SUPPORT) != 0U){
|
||||
Status = XSdPs_Change_BusSpeed(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_Pullup(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
if ((SCR[1] & WIDTH_4_BIT_SUPPORT) != 0U) {
|
||||
Status = XSdPs_Change_BusWidth(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_SetBlkSize(&SdInstance, (u16)XSDPS_BLK_SIZE_512_MASK);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
#else
|
||||
Status = XSdPs_MmcCardInitialize(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Change_ClkFreq(&SdInstance, SD_CLK_26_MHZ);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Select_Card(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Change_BusWidth(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Get_Mmc_ExtCsd(&SdInstance, ExtCsd);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
if(ExtCsd[EXT_CSD_4_BIT_WIDTH_BYTE] != 0x1) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
if(ExtCsd[EXT_CSD_DEVICE_TYPE_BYTE] & EXT_CSD_DEVICE_TYPE_HIGH_SPEED){
|
||||
Status = XSdPs_Change_BusSpeed(&SdInstance);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
Status = XSdPs_Get_Mmc_ExtCsd(&SdInstance, ExtCsd);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
if(ExtCsd[EXT_CSD_HIGH_SPEED_BYTE] != 0x1) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
Status = XSdPs_SetBlkSize(&SdInstance, XSDPS_BLK_SIZE_512_MASK);
|
||||
if (Status != XST_SUCCESS) {
|
||||
s |= STA_NOINIT;
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disk is initialized.
|
||||
* Store the same in Stat.
|
||||
*/
|
||||
s &= (~STA_NOINIT);
|
||||
|
||||
Stat = s;
|
||||
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Reads the drive
|
||||
* In case of SD, it reads the SD card using ADMA2 in polled mode.
|
||||
*
|
||||
* @param pdrv - Drive number
|
||||
* @param *buff - Pointer to the data buffer to store read data
|
||||
* @param sector - Start sector number
|
||||
* @param count - Sector count
|
||||
*
|
||||
* @return
|
||||
* RES_OK Read successful
|
||||
* STA_NOINIT Drive not initialized
|
||||
* RES_ERROR Read not successful
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
DRESULT disk_read (
|
||||
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) */
|
||||
)
|
||||
{
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
DSTATUS s;
|
||||
s32 Status;
|
||||
DWORD LocSector = sector;
|
||||
|
||||
s = disk_status(pdrv);
|
||||
|
||||
if ((s & STA_NOINIT) != 0U) {
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
if (count == 0U) {
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
/* Convert LBA to byte address if needed */
|
||||
if ((SdInstance.HCS) == 0U) {
|
||||
LocSector *= (DWORD)XSDPS_BLK_SIZE_512_MASK;
|
||||
}
|
||||
|
||||
Status = XSdPs_ReadPolled(&SdInstance, (u32)LocSector, count, buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
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;
|
||||
void *LocBuff = buff;
|
||||
if ((disk_status(pdrv) & STA_NOINIT) != 0U) { /* Check if card is in the socket */
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
|
||||
res = RES_ERROR;
|
||||
switch (cmd) {
|
||||
case (BYTE)CTRL_SYNC : /* Make sure that no pending write process */
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case (BYTE)GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
res = RES_ERROR;
|
||||
break;
|
||||
|
||||
case (BYTE)GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
(*((DWORD *)((void *)LocBuff))) = ((DWORD)128);
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* This function is User Provided Timer Function for FatFs module
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return DWORD
|
||||
*
|
||||
* @note None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
DWORD get_fattime (void)
|
||||
{
|
||||
return ((DWORD)(2010U - 1980U) << 25U) /* Fixed to Jan. 1, 2010 */
|
||||
| ((DWORD)1 << 21)
|
||||
| ((DWORD)1 << 16)
|
||||
| ((DWORD)0 << 11)
|
||||
| ((DWORD)0 << 5)
|
||||
| ((DWORD)0 >> 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Reads the drive
|
||||
* In case of SD, it reads the SD card using ADMA2 in polled mode.
|
||||
*
|
||||
* @param pdrv - Drive number
|
||||
* @param *buff - Pointer to the data to be written
|
||||
* @param sector - Sector address
|
||||
* @param count - Sector count
|
||||
*
|
||||
* @return
|
||||
* RES_OK Read successful
|
||||
* STA_NOINIT Drive not initialized
|
||||
* RES_ERROR Read not successful
|
||||
*
|
||||
* @note
|
||||
*
|
||||
******************************************************************************/
|
||||
DRESULT disk_write (
|
||||
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;
|
||||
s32 Status;
|
||||
DWORD LocSector = sector;
|
||||
|
||||
#ifdef FILE_SYSTEM_INTERFACE_SD
|
||||
s = disk_status(pdrv);
|
||||
|
||||
if ((s & STA_NOINIT) != 0U) {
|
||||
return RES_NOTRDY;
|
||||
}
|
||||
if (count == 0U) {
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
/* Convert LBA to byte address if needed */
|
||||
if ((SdInstance.HCS) == 0U) {
|
||||
LocSector *= (DWORD)XSDPS_BLK_SIZE_512_MASK;
|
||||
}
|
||||
|
||||
Status = XSdPs_WritePolled(&SdInstance, (u32)LocSector, count, buff);
|
||||
if (Status != XST_SUCCESS) {
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
return RES_OK;
|
||||
}
|
5226
lib/sw_services/xilffs/src/ff.c
Normal file
5226
lib/sw_services/xilffs/src/ff.c
Normal file
File diff suppressed because it is too large
Load diff
79
lib/sw_services/xilffs/src/include/diskio.h
Normal file
79
lib/sw_services/xilffs/src/include/diskio.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2014 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#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 */
|
||||
|
||||
#include "integer.h"
|
||||
#include "xil_types.h"
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
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, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#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 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 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 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 20U /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21U /* Get model name */
|
||||
#define ATA_GET_SN 22U /* Get serial number */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
385
lib/sw_services/xilffs/src/include/ff.h
Normal file
385
lib/sw_services/xilffs/src/include/ff.h
Normal file
|
@ -0,0 +1,385 @@
|
|||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.10b (C)ChaN, 2014
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||
/ This is a free software that opened for education, research and commercial
|
||||
/ developments under license policy of following terms.
|
||||
/
|
||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#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 FAT_FS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
||||
#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) 0U /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#error _LFN_UNICODE must be 0 at non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
#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)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
#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;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* Status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
|
||||
DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector number containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
#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;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File status structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
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 */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
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_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 */
|
||||
#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 */
|
||||
#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 */
|
||||
#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 */
|
||||
#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 file_size(fp) ((fp)->fsize)
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01U
|
||||
#define FA_OPEN_EXISTING 0x00U
|
||||
|
||||
#if !_FS_READONLY
|
||||
#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 1U
|
||||
#define FS_FAT16 2U
|
||||
#define FS_FAT32 3U
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#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 0xFFFFFFFFU
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#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)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#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)); (*((BYTE*)(void *)((ptr)+1U)))=((BYTE)((DWORD)(val)>>8)); (*((BYTE*)(void *)((ptr)+2U)))=((BYTE)((DWORD)(val)>>16)); (*((BYTE*)(void *)((ptr)+3U)))=((BYTE)((DWORD)(val)>>24))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FAT_FS */
|
228
lib/sw_services/xilffs/src/include/ffconf.h
Normal file
228
lib/sw_services/xilffs/src/include/ffconf.h
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.10b (C)ChaN, 2014
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 8051 /* Revision ID */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
|
||||
/* When _FS_TINY is set to 1, it reduces memory consumption _MAX_SS bytes each
|
||||
/ file object. For file data transfer, FatFs uses the common sector buffer in
|
||||
/ the file system object (FATFS) instead of private sector buffer eliminated
|
||||
/ from the file object (FIL). */
|
||||
|
||||
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(),
|
||||
/ f_rename(), f_truncate() and useless f_getfree(). */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
/* The _FS_MINIMIZE option defines minimization level to remove API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
|
||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
||||
|
||||
|
||||
#define _USE_MKFS 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_mkfs() function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
|
||||
|
||||
|
||||
#define _USE_LABEL 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable volume label functions, set _USE_LAVEL to 1 */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable f_forward() function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 932
|
||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
/ 1250 - Central Europe (Windows)
|
||||
/ 1251 - Cyrillic (Windows)
|
||||
/ 1252 - Latin 1 (Windows)
|
||||
/ 1253 - Greek (Windows)
|
||||
/ 1254 - Turkish (Windows)
|
||||
/ 1255 - Hebrew (Windows)
|
||||
/ 1256 - Arabic (Windows)
|
||||
/ 1257 - Baltic (Windows)
|
||||
/ 1258 - Vietnam (OEM, Windows)
|
||||
/ 437 - U.S. (OEM)
|
||||
/ 720 - Arabic (OEM)
|
||||
/ 737 - Greek (OEM)
|
||||
/ 775 - Baltic (OEM)
|
||||
/ 850 - Multilingual Latin 1 (OEM)
|
||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
||||
/ 852 - Latin 2 (OEM)
|
||||
/ 855 - Cyrillic (OEM)
|
||||
/ 866 - Russian (OEM)
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII (Valid for only non-LFN configuration) */
|
||||
|
||||
|
||||
#define _USE_LFN 0 /* 0 to 3 */
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 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.
|
||||
/
|
||||
/ When enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper()
|
||||
/ function must be added to the project.
|
||||
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. 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. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
|
||||
/* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN
|
||||
/ feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O
|
||||
/ functions. This option must be 0 when LFN feature is not enabled. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
|
||||
/* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character
|
||||
/ encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(),
|
||||
/ f_puts and f_printf(). This option has no effect when _LFN_UNICODE == 0. Note that
|
||||
/ FatFs supports only BMP. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0U /* 0 to 2 */
|
||||
/* The _FS_RPATH option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that output of the f_readdir() fnction is affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1U
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each logical
|
||||
/ drives. Number of items must be equal to _VOLUMES. Valid characters for the drive ID
|
||||
/ strings are: 0-9 and A-Z. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
|
||||
/* By default(0), each logical drive number is bound to the same physical drive number
|
||||
/ and only a FAT volume found on the physical drive is mounted. When it is set to 1,
|
||||
/ each logical drive number is bound to arbitrary drive/partition listed in VolToPart[].
|
||||
*/
|
||||
|
||||
|
||||
#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.
|
||||
/ When _MAX_SS is larger than _MIN_SS, FatFs is configured to variable sector size and
|
||||
/ GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_ERASE 0 /* 0:Disable or 1:Enable */
|
||||
/* To enable sector erase feature, set _USE_ERASE to 1. Also CTRL_ERASE_SECTOR command
|
||||
/ should be added to the disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0 /* 0 to 3 */
|
||||
/* 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 last allocated cluster number as bit 0.
|
||||
/
|
||||
/ 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
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
|
||||
/* To enable file lock control feature, set _FS_LOCK to non-zero value.
|
||||
/ The value defines how many files/sub-directories can be opened simultaneously
|
||||
/ with file lock control. This feature uses bss _FS_LOCK * 12 bytes. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time tick */
|
||||
#define _SYNC_t HANDLE /* O/S dependent sync object type. e.g. HANDLE, OS_EVENT*, ID, SemaphoreHandle_t and etc.. */
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function must be added to the project.
|
||||
*/
|
||||
|
||||
|
||||
#define _WORD_ACCESS 0 /* 0 or 1 */
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed for ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and
|
||||
/ reduce code size. Following table shows an example of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(BE) 0 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 x86 0/1
|
||||
*/
|
||||
|
||||
|
||||
#endif /* _FFCONF */
|
33
lib/sw_services/xilffs/src/include/integer.h
Normal file
33
lib/sw_services/xilffs/src/include/integer.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* This type MUST be 8 bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types MUST be 16 bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types MUST be 16 bit or 32 bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types MUST be 32 bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue