]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Init.c
FatPkg: Refine casting expression result to bigger size
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Init.c
index 34a7250453caf0e0cda18cf83d4b8b876b4ae3cd..6febffcddd62f1a5186988d9497b83819ba2df3b 100644 (file)
@@ -1,4 +1,5 @@
-/*++\r
+/** @file\r
+  Initialization routines.\r
 \r
 Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available\r
@@ -9,19 +10,25 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
+**/\r
 \r
-Module Name:\r
-\r
-  Init.c\r
+#include "Fat.h"\r
 \r
-Abstract:\r
+/**\r
 \r
-  Initialization routines\r
+  Allocates volume structure, detects FAT file system, installs protocol,\r
+  and initialize cache.\r
 \r
---*/\r
+  @param  Handle                - The handle of parent device.\r
+  @param  DiskIo                - The DiskIo of parent device.\r
+  @param  DiskIo2               - The DiskIo2 of parent device.\r
+  @param  BlockIo               - The BlockIo of parent devicel\r
 \r
-#include "Fat.h"\r
+  @retval EFI_SUCCESS           - Allocate a new volume successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  - Can not allocate the memory.\r
+  @return Others                - Allocating a new volume failed.\r
 \r
+**/\r
 EFI_STATUS\r
 FatAllocateVolume (\r
   IN  EFI_HANDLE                Handle,\r
@@ -29,26 +36,6 @@ FatAllocateVolume (
   IN  EFI_DISK_IO2_PROTOCOL     *DiskIo2,\r
   IN  EFI_BLOCK_IO_PROTOCOL     *BlockIo\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Allocates volume structure, detects FAT file system, installs protocol,\r
-  and initialize cache.\r
-\r
-Arguments:\r
-\r
-  Handle                - The handle of parent device.\r
-  DiskIo                - The DiskIo of parent device.\r
-  BlockIo               - The BlockIo of parent devicel\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Allocate a new volume successfully.\r
-  EFI_OUT_OF_RESOURCES  - Can not allocate the memory.\r
-  Others                - Allocating a new volume failed.\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
   FAT_VOLUME  *Volume;\r
@@ -120,26 +107,20 @@ Done:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatAbandonVolume (\r
-  IN FAT_VOLUME *Volume\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Called by FatDriverBindingStop(), Abandon the volume.\r
 \r
-Arguments:\r
-\r
-  Volume                - The volume to be abandoned.\r
-\r
-Returns:\r
+  @param  Volume                - The volume to be abandoned.\r
 \r
-  EFI_SUCCESS           - Abandoned the volume successfully.\r
-  Others                - Can not uninstall the protocol interfaces.\r
+  @retval EFI_SUCCESS           - Abandoned the volume successfully.\r
+  @return Others                - Can not uninstall the protocol interfaces.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatAbandonVolume (\r
+  IN FAT_VOLUME *Volume\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   BOOLEAN     LockedByMe;\r
@@ -202,27 +183,21 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-FatOpenDevice (\r
-  IN OUT FAT_VOLUME           *Volume\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Detects FAT file system on Disk and set relevant fields of Volume\r
-\r
-Arguments:\r
+/**\r
 \r
-  Volume                - The volume structure.\r
+  Detects FAT file system on Disk and set relevant fields of Volume.\r
 \r
-Returns:\r
+  @param Volume                - The volume structure.\r
 \r
-  EFI_SUCCESS           - The Fat File System is detected successfully\r
-  EFI_UNSUPPORTED       - The volume is not FAT file system.\r
-  EFI_VOLUME_CORRUPTED  - The volume is corrupted.\r
+  @retval EFI_SUCCESS           - The Fat File System is detected successfully\r
+  @retval EFI_UNSUPPORTED       - The volume is not FAT file system.\r
+  @retval EFI_VOLUME_CORRUPTED  - The volume is corrupted.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatOpenDevice (\r
+  IN OUT FAT_VOLUME           *Volume\r
+  )\r
 {\r
   EFI_STATUS            Status;\r
   UINT32                BlockSize;\r
@@ -265,7 +240,7 @@ Returns:
   SectorsPerFat = FatBs.FatBsb.SectorsPerFat;\r
   if (SectorsPerFat == 0) {\r
     SectorsPerFat = FatBs.FatBse.Fat32Bse.LargeSectorsPerFat;\r
-    FatType       = FAT32;\r
+    FatType       = Fat32;\r
   }\r
   //\r
   // Is boot sector a fat sector?\r
@@ -305,7 +280,7 @@ Returns:
   //\r
   // Initialize fields the volume information for this FatType\r
   //\r
-  if (FatType != FAT32) {\r
+  if (FatType != Fat32) {\r
     if (FatBs.FatBsb.RootEntries == 0) {\r
       return EFI_UNSUPPORTED;\r
     }\r
@@ -350,12 +325,12 @@ Returns:
   //\r
   // If this is not a fat32, determine if it's a fat16 or fat12\r
   //\r
-  if (FatType != FAT32) {\r
+  if (FatType != Fat32) {\r
     if (Volume->MaxCluster >= FAT_MAX_FAT16_CLUSTER) {\r
       return EFI_VOLUME_CORRUPTED;\r
     }\r
 \r
-    FatType = Volume->MaxCluster < FAT_MAX_FAT12_CLUSTER ? FAT12 : FAT16;\r
+    FatType = Volume->MaxCluster < FAT_MAX_FAT12_CLUSTER ? Fat12 : Fat16;\r
     //\r
     // fat12 & fat16 fat-entries are 2 bytes\r
     //\r
@@ -376,8 +351,8 @@ Returns:
   // We should keep the initial value as the NotDirtyValue\r
   // in case the volume is dirty already\r
   //\r
-  if (FatType != FAT12) {\r
-    Status = FatAccessVolumeDirty (Volume, READ_DISK, &Volume->NotDirtyValue);\r
+  if (FatType != Fat12) {\r
+    Status = FatAccessVolumeDirty (Volume, ReadDisk, &Volume->NotDirtyValue);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -387,10 +362,10 @@ Returns:
   //\r
   // If present, read the fat hint info\r
   //\r
-  if (FatType == FAT32) {\r
+  if (FatType == Fat32) {\r
     Volume->FreeInfoPos = FatBs.FatBse.Fat32Bse.FsInfoSector * BlockSize;\r
     if (FatBs.FatBse.Fat32Bse.FsInfoSector != 0) {\r
-      FatDiskIo (Volume, READ_DISK, Volume->FreeInfoPos, sizeof (FAT_INFO_SECTOR), &Volume->FatInfoSector, NULL);\r
+      FatDiskIo (Volume, ReadDisk, Volume->FreeInfoPos, sizeof (FAT_INFO_SECTOR), &Volume->FatInfoSector, NULL);\r
       if (Volume->FatInfoSector.Signature == FAT_INFO_SIGNATURE &&\r
           Volume->FatInfoSector.InfoBeginSignature == FAT_INFO_BEGIN_SIGNATURE &&\r
           Volume->FatInfoSector.InfoEndSignature == FAT_INFO_END_SIGNATURE &&\r