TianoCore EDK2 master
|
#include "Fat.h"
Go to the source code of this file.
Functions | |
STATIC VOID | ClearCacheTagDirtyState (IN CACHE_TAG *CacheTag) |
STATIC VOID | SetBitInDirtyBlock (IN UINTN BitNumber, IN DIRTY_BLOCKS *DirtyBlocks) |
STATIC BOOLEAN | IsBitInBlockDirty (IN UINTN BitNumber, IN DIRTY_BLOCKS *DirtyBlocks) |
STATIC VOID | SetCacheTagDirty (IN DISK_CACHE *DiskCache, IN CACHE_TAG *CacheTag, IN UINTN Offset, IN UINTN Length) |
STATIC EFI_STATUS | CacheFatDiskIo (IN CACHE_TAG *CacheTag, IN CACHE_DATA_TYPE DataType, IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT VOID *Buffer, IN FAT_TASK *Task) |
STATIC VOID | FatFlushDataCacheRange (IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN UINTN StartPageNo, IN UINTN EndPageNo, OUT UINT8 *Buffer) |
STATIC EFI_STATUS | FatExchangeCachePage (IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE DataType, IN IO_MODE IoMode, IN CACHE_TAG *CacheTag, IN FAT_TASK *Task) |
STATIC EFI_STATUS | FatGetCachePage (IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE CacheDataType, IN UINTN PageNo, IN CACHE_TAG *CacheTag) |
STATIC EFI_STATUS | FatAccessUnalignedCachePage (IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE CacheDataType, IN IO_MODE IoMode, IN UINTN PageNo, IN UINTN Offset, IN UINTN Length, IN OUT VOID *Buffer) |
EFI_STATUS | FatAccessCache (IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE CacheDataType, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT UINT8 *Buffer, IN FAT_TASK *Task) |
EFI_STATUS | FatVolumeFlushCache (IN FAT_VOLUME *Volume, IN FAT_TASK *Task) |
EFI_STATUS | FatInitializeDiskCache (IN FAT_VOLUME *Volume) |
Cache implementation for EFI FAT File system driver.
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file DiskCache.c.
STATIC EFI_STATUS CacheFatDiskIo | ( | IN CACHE_TAG * | CacheTag, |
IN CACHE_DATA_TYPE | DataType, | ||
IN FAT_VOLUME * | Volume, | ||
IN IO_MODE | IoMode, | ||
IN UINT64 | Offset, | ||
IN UINTN | BufferSize, | ||
IN OUT VOID * | Buffer, | ||
IN FAT_TASK * | Task | ||
) |
Cache version of FatDiskIo for writing only those LBA's with dirty data.
Keep track of LBA blocks within a cache line. Allow reads from the disk to read the full cache line, and all writes to the cache line will update which Lba is dirty in DIRTY_BITS.
At flush time, when the cache line is written out, only write the blocks that are dirty, coalescing adjacent writes to a single FatDiskIo write.
[in] | CacheTag | - Cache line to check for dirty bits from |
[in] | DataType | - Type of Cache. |
[in] | Volume | - FAT file system volume. |
[in] | IoMode | - The access mode (disk read/write or cache access). |
[in] | Offset | - The starting byte offset to read from. |
[in] | BufferSize | - Size of Buffer. |
[in,out] | Buffer | - Buffer containing read data. |
[in] | Task | point to task instance. |
EFI_SUCCESS | - The operation is performed successfully. |
EFI_VOLUME_CORRUPTED | - The access is |
Definition at line 146 of file DiskCache.c.
Helper function to clear the dirty state of the cache line.
[in] | CacheTag | - CacheTag to clear |
Definition at line 19 of file DiskCache.c.
EFI_STATUS FatAccessCache | ( | IN FAT_VOLUME * | Volume, |
IN CACHE_DATA_TYPE | CacheDataType, | ||
IN IO_MODE | IoMode, | ||
IN UINT64 | Offset, | ||
IN UINTN | BufferSize, | ||
IN OUT UINT8 * | Buffer, | ||
IN FAT_TASK * | Task | ||
) |
Read BufferSize bytes from the position of Offset into Buffer, or write BufferSize bytes from Buffer into the position of Offset.
Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):
Volume | - FAT file system volume. |
CacheDataType | - The type of cache: CACHE_DATA or CACHE_FAT. |
IoMode | - Indicate the type of disk access. |
Offset | - The starting byte offset to read from. |
BufferSize | - Size of Buffer. |
Buffer | - Buffer containing cache data. |
Task | point to task instance. |
EFI_SUCCESS | - The data was accessed correctly. |
EFI_MEDIA_CHANGED | - The MediaId does not match the current device. |
Definition at line 493 of file DiskCache.c.
STATIC EFI_STATUS FatAccessUnalignedCachePage | ( | IN FAT_VOLUME * | Volume, |
IN CACHE_DATA_TYPE | CacheDataType, | ||
IN IO_MODE | IoMode, | ||
IN UINTN | PageNo, | ||
IN UINTN | Offset, | ||
IN UINTN | Length, | ||
IN OUT VOID * | Buffer | ||
) |
Read Length bytes from the position of Offset into Buffer, or write Length bytes from Buffer into the position of Offset.
Volume | - FAT file system volume. |
CacheDataType | - The type of cache: CACHE_DATA or CACHE_FAT. |
IoMode | - Indicate the type of disk access. |
PageNo | - The number of unaligned cache page. |
Offset | - The starting byte of cache page. |
Length | - The number of bytes that is read or written |
Buffer | - Buffer containing cache data. |
EFI_SUCCESS | - The data was accessed correctly. |
Definition at line 426 of file DiskCache.c.
STATIC EFI_STATUS FatExchangeCachePage | ( | IN FAT_VOLUME * | Volume, |
IN CACHE_DATA_TYPE | DataType, | ||
IN IO_MODE | IoMode, | ||
IN CACHE_TAG * | CacheTag, | ||
IN FAT_TASK * | Task | ||
) |
Exchange the cache page with the image on the disk
Volume | - FAT file system volume. |
DataType | - Indicate the cache type. |
IoMode | - Indicate whether to load this page from disk or store this page to disk. |
CacheTag | - The Cache Tag for the current cache page. |
Task | point to task instance. |
EFI_SUCCESS | - Cache page exchanged successfully. |
Definition at line 298 of file DiskCache.c.
STATIC VOID FatFlushDataCacheRange | ( | IN FAT_VOLUME * | Volume, |
IN IO_MODE | IoMode, | ||
IN UINTN | StartPageNo, | ||
IN UINTN | EndPageNo, | ||
OUT UINT8 * | Buffer | ||
) |
This function is used by the Data Cache.
When this function is called by write command, all entries in this range are older than the contents in disk, so they are invalid; just mark them invalid.
When this function is called by read command, if any entry in this range is dirty, it means that the relative info directly read from media is older than than the info in the cache; So need to update the relative info in the Buffer.
Volume | - FAT file system volume. |
IoMode | - This function is called by read command or write command |
StartPageNo | - First PageNo to be checked in the cache. |
EndPageNo | - Last PageNo to be checked in the cache. |
Buffer | - The user buffer need to update. Only when doing the read command and there is dirty cache in the cache range, this parameter will be used. |
Definition at line 232 of file DiskCache.c.
STATIC EFI_STATUS FatGetCachePage | ( | IN FAT_VOLUME * | Volume, |
IN CACHE_DATA_TYPE | CacheDataType, | ||
IN UINTN | PageNo, | ||
IN CACHE_TAG * | CacheTag | ||
) |
Get one cache page by specified PageNo.
Volume | - FAT file system volume. |
CacheDataType | - The cache type: CACHE_FAT or CACHE_DATA. |
PageNo | - PageNo to match with the cache. |
CacheTag | - The Cache Tag for the current cache page. |
EFI_SUCCESS | - Get the cache page successfully. |
Definition at line 370 of file DiskCache.c.
EFI_STATUS FatInitializeDiskCache | ( | IN FAT_VOLUME * | Volume | ) |
Initialize the disk cache according to Volume's FatType.
Volume | - FAT file system volume. |
EFI_SUCCESS | - The disk cache is successfully initialized. |
EFI_OUT_OF_RESOURCES | - Not enough memory to allocate disk cache. |
Definition at line 649 of file DiskCache.c.
EFI_STATUS FatVolumeFlushCache | ( | IN FAT_VOLUME * | Volume, |
IN FAT_TASK * | Task | ||
) |
Flush all the dirty cache back, include the FAT cache and the Data cache.
Volume | - FAT file system volume. |
Task | point to task instance. |
EFI_SUCCESS | - Flush all the dirty cache back successfully |
Definition at line 595 of file DiskCache.c.
Helper function to check if a particular bit in a dirty block is marked dirty or not, so that it can be written to the disk if it is dirty.
[in] | BitNumber | - Which bit to check in DirtyBlocks |
[in] | DirtyBlocks | - Array of bits |
Definition at line 71 of file DiskCache.c.
Helper function to set a bit in a dirty block. This is used to track which blocks to later write to disk.
[in] | BitNumber | - Which bit to set in DirtyBlocks |
[in] | DirtyBlocks | - Array of bits |
Definition at line 42 of file DiskCache.c.
STATIC VOID SetCacheTagDirty | ( | IN DISK_CACHE * | DiskCache, |
IN CACHE_TAG * | CacheTag, | ||
IN UINTN | Offset, | ||
IN UINTN | Length | ||
) |
Helper function to set a cache tag dirty for a given offset and length. Dirty blocks marked here will be flushed to disk when the file is closed.
[in] | DiskCache | - DiskCache |
[in] | CacheTag | - CacheTag to update |
[in] | Offset | - Offset in the cache line to be marked modified |
[in] | Length | - Length of the data to be marked modified |
Definition at line 98 of file DiskCache.c.