summaryrefslogtreecommitdiffstats
path: root/FatPkg/EnhancedFatDxe
diff options
context:
space:
mode:
Diffstat (limited to 'FatPkg/EnhancedFatDxe')
-rw-r--r--FatPkg/EnhancedFatDxe/Fat.h16
-rw-r--r--FatPkg/EnhancedFatDxe/FatFileSystem.h2
-rw-r--r--FatPkg/EnhancedFatDxe/FileSpace.c1
-rw-r--r--FatPkg/EnhancedFatDxe/Init.c62
4 files changed, 10 insertions, 71 deletions
diff --git a/FatPkg/EnhancedFatDxe/Fat.h b/FatPkg/EnhancedFatDxe/Fat.h
index 525393dbd4..fb6699061e 100644
--- a/FatPkg/EnhancedFatDxe/Fat.h
+++ b/FatPkg/EnhancedFatDxe/Fat.h
@@ -975,22 +975,6 @@ FatComputeFreeInfo (
IN FAT_VOLUME *Volume
);
-/**
-
- Get the FAT entry value of the volume, which is identified with the Index.
-
- @param Volume - FAT file system volume.
- @param Index - The index of the FAT entry of the volume.
-
- @return The value of the FAT entry.
-
-**/
-UINTN
-FatGetFatEntry (
- IN FAT_VOLUME *Volume,
- IN UINTN Index
- );
-
//
// Init.c
//
diff --git a/FatPkg/EnhancedFatDxe/FatFileSystem.h b/FatPkg/EnhancedFatDxe/FatFileSystem.h
index 3bad7fceea..60b9c56b71 100644
--- a/FatPkg/EnhancedFatDxe/FatFileSystem.h
+++ b/FatPkg/EnhancedFatDxe/FatFileSystem.h
@@ -35,8 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FAT_CLUSTER_SPECIAL_FAT32 0x0FFFFFF7
#define FAT_CLUSTER_MASK_FAT12 0xFFF
#define FAT_CLUSTER_UNMASK_FAT12 0xF000
-#define FAT_CLUSTER_MASK_FAT16 0xFFFF
-#define FAT_CLUSTER_UNMASK_FAT16 0xF0000
#define FAT_CLUSTER_MASK_FAT32 0x0FFFFFFF
#define FAT_CLUSTER_UNMASK_FAT32 0xF0000000
#define FAT_POS_FAT12(a) ((a) * 3 / 2)
diff --git a/FatPkg/EnhancedFatDxe/FileSpace.c b/FatPkg/EnhancedFatDxe/FileSpace.c
index 6852c3ea00..909d4980d2 100644
--- a/FatPkg/EnhancedFatDxe/FileSpace.c
+++ b/FatPkg/EnhancedFatDxe/FileSpace.c
@@ -80,6 +80,7 @@ FatLoadFatEntry (
@return The value of the FAT entry.
**/
+STATIC
UINTN
FatGetFatEntry (
IN FAT_VOLUME *Volume,
diff --git a/FatPkg/EnhancedFatDxe/Init.c b/FatPkg/EnhancedFatDxe/Init.c
index f020cf703d..9c51ed5b7b 100644
--- a/FatPkg/EnhancedFatDxe/Init.c
+++ b/FatPkg/EnhancedFatDxe/Init.c
@@ -96,6 +96,14 @@ FatAllocateVolume (
}
//
+ // Initialize cache
+ //
+ Status = FatInitializeDiskCache (Volume);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
// Install our protocol interfaces on the device's handle
//
Status = gBS->InstallMultipleProtocolInterfaces (
@@ -229,7 +237,6 @@ FatOpenDevice (
UINTN SectorsPerFat;
UINT8 SectorsPerClusterAlignment;
UINT8 BlockAlignment;
- UINTN ReservedFatEntry;
//
// Read the FAT_BOOT_SECTOR BPB info
@@ -416,58 +423,7 @@ FatOpenDevice (
// We are now defining FAT Type
//
Volume->FatType = FatType;
-
- //
- // Initialize cache before we use the helper functions that hit the cache
- //
- Status = FatInitializeDiskCache (Volume);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check the reserved FAT entries to ensure they contain valid values
- //
- ReservedFatEntry = FatGetFatEntry (Volume, 0);
- if (Volume->FatEntryBuffer == MAX_UINT32) {
- return EFI_VOLUME_CORRUPTED;
- }
-
- // Reserved FAT entry 0 should contain the BPB_MEDIA byte value in the low 8 bits with all other bits set to 1
- switch (FatType) {
- case Fat12:
- if ((ReservedFatEntry & FAT_CLUSTER_MASK_FAT12) != ((UINTN)FatBs.FatBsb.Media | 0xF00)) {
- return EFI_VOLUME_CORRUPTED;
- }
-
- break;
-
- case Fat16:
- if ((ReservedFatEntry & FAT_CLUSTER_MASK_FAT16) != ((UINTN)FatBs.FatBsb.Media | 0xFF00)) {
- return EFI_VOLUME_CORRUPTED;
- }
-
- break;
-
- case Fat32:
- // the upper 4 bits of a FAT32 entry are reserved, so are unchecked here
- if ((ReservedFatEntry & FAT_CLUSTER_MASK_FAT32) != ((UINTN)FatBs.FatBsb.Media | 0x0FFFFF00)) {
- return EFI_VOLUME_CORRUPTED;
- }
-
- break;
-
- default:
- return EFI_VOLUME_CORRUPTED;
- }
-
- // Reserved FAT entry 1 should contain the end of chain mark. On FAT16 and FAT32, the high 2 bits may be used as
- // dirty and hardware error bits, so are ignored in this check, but FatGetFatEntry already ignores them to unify the
- // logic across FAT types
- ReservedFatEntry = FatGetFatEntry (Volume, 1);
- if ((Volume->FatEntryBuffer == MAX_UINT32) || !FAT_END_OF_FAT_CHAIN (ReservedFatEntry)) {
- return EFI_VOLUME_CORRUPTED;
- }
+ ASSERT (FatType != FatUndefined);
return EFI_SUCCESS;
}