]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code scrub for DiskIo, Partition & Unicode Collation
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Jul 2008 09:49:25 +0000 (09:49 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 18 Jul 2008 09:49:25 +0000 (09:49 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5519 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c
MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c

index a3402745c95266450c5fd2e511aaf69a76c6182b..b136430c201d8c6e0b5af94b68d75f839032c586 100644 (file)
@@ -32,7 +32,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2
   "en"\r
 };\r
 \r
-\r
+//\r
+// Driver name table for DiskIo module.\r
+// It is shared by the implementation of ComponentName & ComponentName2 Protocol.\r
+//\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDiskIoDriverNameTable[] = {\r
   {\r
     "eng;en",\r
index 710d042de9d471b38cf60f3178d8bd6064f9f9d6..ec1d68f6312a62a4e7fea5918e3d5ba6506b276b 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
-  DiskIo driver that layers it's self on every Block IO protocol in the system.\r
+  DiskIo driver that lays on every BlockIo protocol in the system.\r
   DiskIo converts a block oriented device to a byte oriented device.\r
 \r
-  ReadDisk may have to do reads that are not aligned on sector boundaries.\r
+  Disk access may have to handle unaligned request about sector boundaries.\r
   There are three cases:\r
     UnderRun - The first byte is not on a sector boundary or the read request is\r
                less than a sector in length.\r
@@ -22,6 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DiskIo.h"\r
 \r
+//\r
+// Driver binding protocol implementation for DiskIo driver.\r
+//\r
 EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {\r
   DiskIoDriverBindingSupported,\r
   DiskIoDriverBindingStart,\r
@@ -31,6 +34,10 @@ EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
   NULL\r
 };\r
 \r
+//\r
+// Template for DiskIo private data structure.\r
+// The pointer to BlockIo protocol interface is assigned dynamically.\r
+//\r
 DISK_IO_PRIVATE_DATA        gDiskIoPrivateDataTemplate = {\r
   DISK_IO_PRIVATE_DATA_SIGNATURE,\r
   {\r
@@ -459,7 +466,7 @@ Done:
 \r
 \r
 /**\r
-  Read BufferSize bytes from Offset into Buffer.\r
+  Writes BufferSize bytes from Buffer into Offset.\r
   Writes may require a read modify write to support writes that are not\r
   aligned on sector boundaries. There are three cases:\r
     UnderRun - The first byte is not on a sector boundary or the write request\r
index f4a378133b13d9d8562115e46c8826cb49007ef2..cedda09ac00e5595998d226b861b690e4373938b 100644 (file)
@@ -1,6 +1,5 @@
 /** @file\r
-  DiskIo driver that layers it's self on every Block IO protocol in the system.\r
-  DiskIo converts a block oriented device to a byte oriented device.\r
+  Master header file for DiskIo driver. It includes the module private defininitions.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -156,7 +155,7 @@ DiskIoReadDisk (
   );\r
 \r
 /**\r
-  Read BufferSize bytes from Offset into Buffer.\r
+  Writes BufferSize bytes from Buffer into Offset.\r
   Writes may require a read modify write to support writes that are not\r
   aligned on sector boundaries. There are three cases:\r
     UnderRun - The first byte is not on a sector boundary or the write request\r
index 5cef9b4955541a0814babe3686406e411977e737..61a2c4f5c34c01272ee140f96e79d400adb5648d 100644 (file)
@@ -1,6 +1,7 @@
 #/** @file\r
 #  \r
-#    Component description file for DiskIo module.\r
+#  This module lays DiskIo protocol on every blockIo protocol\r
+#  to provide byte-oriented access to block media. \r
 #  \r
 #  Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 #  All rights reserved. This program and the accompanying materials\r
index 8065f6b764a3a3ea7881c3942ce8172f58bc836f..4d1a6fe8887720503729ceb3edf916e30698ca66 100644 (file)
@@ -32,11 +32,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentNa
   "en"\r
 };\r
 \r
-\r
+//\r
+// Driver name table for Partition module.\r
+// It is shared by the implementation of ComponentName & ComponentName2 Protocol.\r
+//\r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPartitionDriverNameTable[] = {\r
   {\r
     "eng;en",\r
-    (CHAR16 *)L"Partition Driver(MBR/GPT/El Torito)"\r
+    L"Partition Driver(MBR/GPT/El Torito)"\r
   },\r
   {\r
     NULL,\r
index 6d3abae843c2a530198350fdab097156f6e7bffc..cdace18f481a1aad3b960266b397cd27cc65765a 100644 (file)
@@ -189,7 +189,7 @@ PartitionInstallGptChildHandles (
   EFI_PARTITION_ENTRY         *PartEntry;\r
   EFI_PARTITION_ENTRY_STATUS  *PEntryStatus;\r
   UINTN                       Index;\r
-  EFI_STATUS                  GptValid;\r
+  EFI_STATUS                  GptValidStatus;\r
   HARDDRIVE_DEVICE_PATH       HdDev;\r
 \r
   ProtectiveMbr = NULL;\r
@@ -204,7 +204,7 @@ PartitionInstallGptChildHandles (
   DEBUG ((EFI_D_INFO, " BlockSize : %d \n", BlockSize));\r
   DEBUG ((EFI_D_INFO, " LastBlock : %x \n", LastBlock));\r
 \r
-  GptValid = EFI_NOT_FOUND;\r
+  GptValidStatus = EFI_NOT_FOUND;\r
 \r
   //\r
   // Allocate a buffer for the Protective MBR\r
@@ -225,7 +225,7 @@ PartitionInstallGptChildHandles (
                       ProtectiveMbr\r
                       );\r
   if (EFI_ERROR (Status)) {\r
-    GptValid = Status;\r
+    GptValidStatus = Status;\r
     goto Done;\r
   }\r
   //\r
@@ -247,7 +247,6 @@ PartitionInstallGptChildHandles (
   }\r
 \r
   BackupHeader = AllocateZeroPool (sizeof (EFI_PARTITION_TABLE_HEADER));\r
-\r
   if (BackupHeader == NULL) {\r
     goto Done;\r
   }\r
@@ -304,8 +303,8 @@ PartitionInstallGptChildHandles (
                     PartEntry\r
                     );\r
   if (EFI_ERROR (Status)) {\r
-    GptValid = Status;\r
-    DEBUG ((EFI_D_INFO, " Partition Entry ReadBlocks error\n"));\r
+    GptValidStatus = Status;\r
+    DEBUG ((EFI_D_ERROR, " Partition Entry ReadBlocks error\n"));\r
     goto Done;\r
   }\r
 \r
@@ -327,7 +326,7 @@ PartitionInstallGptChildHandles (
   //\r
   // If we got this far the GPT layout of the disk is valid and we should return true\r
   //\r
-  GptValid = EFI_SUCCESS;\r
+  GptValidStatus = EFI_SUCCESS;\r
 \r
   //\r
   // Create child device handles\r
@@ -355,12 +354,12 @@ PartitionInstallGptChildHandles (
     HdDev.PartitionSize   = PartEntry[Index].EndingLBA - PartEntry[Index].StartingLBA + 1;\r
     CopyMem (HdDev.Signature, &PartEntry[Index].UniquePartitionGUID, sizeof (EFI_GUID));\r
 \r
-    DEBUG ((EFI_D_INFO, " Index : %d\n", Index));\r
-    DEBUG ((EFI_D_INFO, " Start LBA : %x\n", HdDev.PartitionStart));\r
-    DEBUG ((EFI_D_INFO, " End LBA : %x\n", PartEntry[Index].EndingLBA));\r
-    DEBUG ((EFI_D_INFO, " Partition size: %x\n", HdDev.PartitionSize));\r
-    DEBUG ((EFI_D_INFO, " Start : %x", MultU64x32 (PartEntry[Index].StartingLBA, BlockSize)));\r
-    DEBUG ((EFI_D_INFO, " End : %x\n", MultU64x32 (PartEntry[Index].EndingLBA, BlockSize)));\r
+    DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index));\r
+    DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart));\r
+    DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) PartEntry[Index].EndingLBA));\r
+    DEBUG ((EFI_D_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize));\r
+    DEBUG ((EFI_D_INFO, " Start : %lx", MultU64x32 (PartEntry[Index].StartingLBA, BlockSize)));\r
+    DEBUG ((EFI_D_INFO, " End : %lx\n", MultU64x32 (PartEntry[Index].EndingLBA, BlockSize)));\r
 \r
     Status = PartitionInstallChildHandle (\r
               This,\r
@@ -395,7 +394,7 @@ Done:
     FreePool (PEntryStatus);\r
   }\r
 \r
-  return GptValid;\r
+  return GptValidStatus;\r
 }\r
 \r
 \r
@@ -450,7 +449,7 @@ PartitionValidGptTable (
       !PartitionCheckCrc (BlockSize, &PartHdr->Header) ||\r
       PartHdr->MyLBA != Lba\r
       ) {\r
-    DEBUG ((EFI_D_INFO, " !Valid efi partition table header\n"));\r
+    DEBUG ((EFI_D_INFO, "Invalid efi partition table header\n"));\r
     FreePool (PartHdr);\r
     return FALSE;\r
   }\r
@@ -608,7 +607,10 @@ PartitionRestoreGptTable (
 \r
 Done:\r
   FreePool (PartHdr);\r
-  FreePool (Ptr);\r
+\r
+  if (Ptr != NULL) {\r
+    FreePool (Ptr);\r
+  }\r
 \r
   if (EFI_ERROR (Status)) {\r
     return FALSE;\r
index 68b389ae91cb2d1c8e63bafd9141ea944c5cbfd9..51fdca4254a4f78e6cb418400c4ec4a1cdf0a946 100644 (file)
@@ -34,7 +34,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @retval FALSE       Mbr is not a Valid MBR.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 PartitionValidMbr (\r
   IN  MASTER_BOOT_RECORD      *Mbr,\r
index 66fa9507f3202d8730c7fd61a2f22a952763a083..15061bec30368ac916d4720ac4adbb8816777de9 100644 (file)
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Partition.h"\r
 \r
 //\r
-// Partition Driver Global Variables\r
+// Partition Driver Global Variables.\r
 //\r
 EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {\r
   PartitionDriverBindingSupported,\r
@@ -30,7 +30,9 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
   NULL\r
 };\r
 \r
-STATIC \r
+//\r
+// Priortized function list to detect partition table. \r
+//\r
 PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {\r
   PartitionInstallGptChildHandles,\r
   PartitionInstallElToritoChildHandles,\r
@@ -98,11 +100,11 @@ PartitionDriverBindingSupported (
   // Close the I/O Abstraction(s) used to perform the supported test\r
   //\r
   gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
+         ControllerHandle,\r
+         &gEfiDevicePathProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         ControllerHandle\r
+         );\r
 \r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
@@ -402,7 +404,6 @@ PartitionDriverBindingStop (
                                not be reset.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 PartitionReset (\r
@@ -440,7 +441,6 @@ PartitionReset (
                                 valid for the device.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 PartitionReadBlocks (\r
@@ -492,7 +492,6 @@ PartitionReadBlocks (
                                 valid for the device.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 PartitionWriteBlocks (\r
@@ -535,7 +534,6 @@ PartitionWriteBlocks (
   @retval EFI_NO_MEDIA      There is no media in the device.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 PartitionFlushBlocks (\r
index 67f1db1c6cfcd02048af7a887c1552d04db56a47..e8c5bd953c9c3d1e9d4d22bea612322132d5415f 100644 (file)
@@ -51,7 +51,7 @@ CHAR8 mOtherChars[] = {
   '\0'\r
 };\r
 \r
-STATIC EFI_HANDLE  mHandle = NULL;\r
+EFI_HANDLE  mHandle = NULL;\r
 \r
 //\r
 // EFI Unicode Collation Protocol supporting ISO 639-2 language code\r