Storage layer
The storage layer of emFile provides direct access to the physical media and can also be used outside of emFile.
Overview
With the emFile storage layer applications can use physical media directly without a file system.All emFile drivers can be used for the application. This includes the NAND and NOR drivers with their high performance and effective wear leveling, as well as RAID support (RAID1/RAID5) or encryption.
Main application areas
- Storage layer for use with the USB Mass Storage Device class
- Raw storage interface for direct access by the application
- Storage layer for third-party file systems
How the storage layer works
The block operations from the file system are handed over to the Storage Layer. SEGGER's Storage Layer is completely agnostic of the file system used to address it. It accepts any page or sector size. This way it can directly be used by emFile, by the application, by a third party file system or by applications passing through operations from a host, as is the case for USB mass storage class devices.
The main purpose of the Storage Layer is to provide access to the device drivers provided by SEGGER. This includes SEGGER's great NAND and NOR flash drivers with their effective wear leveling algorithms. The Storage Layer also handles storage arrays according to RAID1 or RAID5, if desired. Encryption of the storage volume is handled by the Storage Layer as well. The Storage Layer synchronizes accesses to the device driver level. For this purpose it calls a device driver to perform a block operation.
Another task performed by the storage layer is the handling of caches. This also includes mechanisms to control the garbage collection.
Storage layer API
The functions described in this section can be used to access and to manage the data at the logical sector level effectively bypassing the file system. These functions are typically used when the application comes with its own file system or when the storage device has to be mounted as a mass storage device via USB.
Function | Description |
---|---|
FS_STORAGE_Clean() | Performs garbage collection on the storage device. |
FS_STORAGE_CleanOne() | Performs a single garbage collection step on the storage device. |
FS_STORAGE_FreeSectors() | Informs the driver about unused sectors. |
FS_STORAGE_GetCleanCnt() | Returns the number of clean operations required. |
FS_STORAGE_GetCounters() | Returns the statistic counters. |
FS_STORAGE_GetSectorUsage() | Returns the device info. |
FS_STORAGE_Init() | Initializes the driver and OS if necessary. |
FS_STORAGE_ReadSector() | Reads a sector from a device. |
FS_STORAGE_ReadSectors() | Reads multiple sectors from a device. |
FS_STORAGE_RefreshSectors() | Rewrites a sector with the original data. |
FS_STORAGE_ResetCounters() | Sets the statistical counters to 0. |
FS_STORAGE_Sync() | Writes cached data to the storage device. |
FS_STORAGE_SyncSectors() | Writes cached sector data to storage device. |
FS_STORAGE_Unmount() | Low-level unmount. Unmounts a volume on driver layer. |
FS_STORAGE_WriteSector() | Writes a sector to storage device. |
FS_STORAGE_WriteSectors() | Writes multiple sectors to storage device. |