mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
FAT: Add an option to force all transfers to be performed indirectly through the FAT file system's internal sector buffers
This commit is contained in:
@@ -11515,4 +11515,12 @@
|
|||||||
* sched/pthread: Add pthread_setaffinity() and pthread_getaffinity()
|
* sched/pthread: Add pthread_setaffinity() and pthread_getaffinity()
|
||||||
(2016-02-19).
|
(2016-02-19).
|
||||||
* sched/sched: Add sched_setaffinity() and sched_getaffinity() (2016-02-19).
|
* sched/sched: Add sched_setaffinity() and sched_getaffinity() (2016-02-19).
|
||||||
|
* drivers/leds/rgbled.c: Add a driver to manage a RGB LED via PWM. From
|
||||||
|
Alan Carvalho de Assis (2016-02-22).
|
||||||
|
* arch/arm/src/stm32fcdiscovery: Add PWM support for the onboard RGB LED
|
||||||
|
From Alan Carvalho de Assis (2016-02-22).
|
||||||
|
* arch/arm/src/samv7: HSMCI driver can now be configured to handle unaligned
|
||||||
|
data buffers (2016-02-22).
|
||||||
|
* fs/fat: Add an option to force all transfers to be performed indirectly
|
||||||
|
using the FAT file system's internal sector buffers (2016-02-22).
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule arch updated: 1182e9ab34...7ed1d2eb50
+25
-1
@@ -13,6 +13,7 @@ config FS_FAT
|
|||||||
Enable FAT filesystem support
|
Enable FAT filesystem support
|
||||||
|
|
||||||
if FS_FAT
|
if FS_FAT
|
||||||
|
|
||||||
config FAT_LCNAMES
|
config FAT_LCNAMES
|
||||||
bool "FAT upper/lower names"
|
bool "FAT upper/lower names"
|
||||||
default n
|
default n
|
||||||
@@ -49,6 +50,29 @@ config FS_FATTIME
|
|||||||
much sense in supporting FAT date and time unless you have a
|
much sense in supporting FAT date and time unless you have a
|
||||||
hardware RTC or other way to get the time and date.
|
hardware RTC or other way to get the time and date.
|
||||||
|
|
||||||
|
config FAT_FORCE_INDIRECT
|
||||||
|
bool "Force all in-direct transfers"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Normally, the default behavior for the FAT file system is to perform
|
||||||
|
data transfers indirectly though specially allocated sector buffers
|
||||||
|
or, under certain circumstances, directly through user provided
|
||||||
|
buffers . These circumstances are: (1) The transfer is being
|
||||||
|
performed from the beginning of a sector (2) the user-provided
|
||||||
|
buffer will hold the full sector of data.
|
||||||
|
|
||||||
|
Some hardware, however, may require special DMA-capable memory or
|
||||||
|
specially aligned memory in order to perform the transfers. In this
|
||||||
|
case, there may be no circumstance where the user buffer can be used.
|
||||||
|
Selecting this option will disable all attempts to use the user-
|
||||||
|
provided buffer: All transfers will be force to be performed
|
||||||
|
indirectly through the FAT file systems sector buffers.
|
||||||
|
|
||||||
|
Note: This will have the negative impact of: (1) An extra data
|
||||||
|
copy to transfer the data between the user buffer and the FAT file
|
||||||
|
systems internal sector buffers, and (2) A loss of performance
|
||||||
|
because I/O will be limited to one sector at a time.
|
||||||
|
|
||||||
config FAT_DMAMEMORY
|
config FAT_DMAMEMORY
|
||||||
bool "DMA memory allocator"
|
bool "DMA memory allocator"
|
||||||
default n
|
default n
|
||||||
@@ -66,4 +90,4 @@ config FAT_DMAMEMORY
|
|||||||
corresponding function that will be called to free the DMA-capable
|
corresponding function that will be called to free the DMA-capable
|
||||||
memory.
|
memory.
|
||||||
|
|
||||||
endif
|
endif # FAT
|
||||||
|
|||||||
+14
-4
@@ -479,13 +479,16 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
FAR struct fat_file_s *ff;
|
FAR struct fat_file_s *ff;
|
||||||
unsigned int bytesread;
|
unsigned int bytesread;
|
||||||
unsigned int readsize;
|
unsigned int readsize;
|
||||||
unsigned int nsectors;
|
|
||||||
size_t bytesleft;
|
size_t bytesleft;
|
||||||
int32_t cluster;
|
int32_t cluster;
|
||||||
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
|
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
|
||||||
int sectorindex;
|
int sectorindex;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifndef CONFIG_FAT_FORCE_INDIRECT
|
||||||
|
unsigned int nsectors;
|
||||||
bool force_indirect = false;
|
bool force_indirect = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
@@ -590,6 +593,7 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
fat_read_restart:
|
fat_read_restart:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_FAT_FORCE_INDIRECT
|
||||||
/* Check if the user has provided a buffer large enough to hold one
|
/* Check if the user has provided a buffer large enough to hold one
|
||||||
* or more complete sectors -AND- the read is aligned to a sector
|
* or more complete sectors -AND- the read is aligned to a sector
|
||||||
* boundary.
|
* boundary.
|
||||||
@@ -636,7 +640,7 @@ fat_read_restart:
|
|||||||
force_indirect = true;
|
force_indirect = true;
|
||||||
goto fat_read_restart;
|
goto fat_read_restart;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_FAT_DMAMEMORY */
|
||||||
|
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -646,6 +650,7 @@ fat_read_restart:
|
|||||||
bytesread = nsectors * fs->fs_hwsectorsize;
|
bytesread = nsectors * fs->fs_hwsectorsize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif /* CONFIG_FAT_FORCE_INDIRECT */
|
||||||
{
|
{
|
||||||
/* We are reading a partial sector, or handling a non-DMA-able
|
/* We are reading a partial sector, or handling a non-DMA-able
|
||||||
* whole-sector transfer. First, read the whole sector
|
* whole-sector transfer. First, read the whole sector
|
||||||
@@ -709,11 +714,14 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
int32_t cluster;
|
int32_t cluster;
|
||||||
unsigned int byteswritten;
|
unsigned int byteswritten;
|
||||||
unsigned int writesize;
|
unsigned int writesize;
|
||||||
unsigned int nsectors;
|
|
||||||
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
|
FAR uint8_t *userbuffer = (FAR uint8_t *)buffer;
|
||||||
int sectorindex;
|
int sectorindex;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifndef CONFIG_FAT_FORCE_INDIRECT
|
||||||
|
unsigned int nsectors;
|
||||||
bool force_indirect = false;
|
bool force_indirect = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Sanity checks. I have seen the following assertion misfire if
|
/* Sanity checks. I have seen the following assertion misfire if
|
||||||
* CONFIG_DEBUG_MM is enabled while re-directing output to a
|
* CONFIG_DEBUG_MM is enabled while re-directing output to a
|
||||||
@@ -844,6 +852,7 @@ static ssize_t fat_write(FAR struct file *filep, FAR const char *buffer,
|
|||||||
fat_write_restart:
|
fat_write_restart:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_FAT_FORCE_INDIRECT
|
||||||
/* Check if the user has provided a buffer large enough to
|
/* Check if the user has provided a buffer large enough to
|
||||||
* hold one or more complete sectors.
|
* hold one or more complete sectors.
|
||||||
*/
|
*/
|
||||||
@@ -890,7 +899,7 @@ fat_write_restart:
|
|||||||
force_indirect = true;
|
force_indirect = true;
|
||||||
goto fat_write_restart;
|
goto fat_write_restart;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_FAT_DMAMEMORY */
|
||||||
|
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
@@ -901,6 +910,7 @@ fat_write_restart:
|
|||||||
ff->ff_bflags |= FFBUFF_MODIFIED;
|
ff->ff_bflags |= FFBUFF_MODIFIED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif /* CONFIG_FAT_FORCE_INDIRECT */
|
||||||
{
|
{
|
||||||
/* Decide whether we are performing a read-modify-write
|
/* Decide whether we are performing a read-modify-write
|
||||||
* operation, in which case we have to read the existing sector
|
* operation, in which case we have to read the existing sector
|
||||||
|
|||||||
Reference in New Issue
Block a user