]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
Code scrub DxeIpl, Runtime, DevicePath, FvbServicesLib, DiskIo, Partition, English...
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Mbr.c
index d71698c82673dcb08641b05b5482c4c4eca4f755..5d544e8b775d5cae7c4053b3577eba5094ce9bfd 100644 (file)
@@ -1,20 +1,4 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-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
-Module Name:\r
-\r
-  Mbr.c\r
-  \r
-Abstract:\r
-\r
+/** @file\r
   Decode a hard disk partitioned with the legacy MBR found on most PC's\r
 \r
   MBR - Master Boot Record is in the first sector of a partitioned hard disk.\r
@@ -22,35 +6,39 @@ Abstract:
         code that is not run on an EFI system. The legacy code reads the \r
         first sector of the active partition into memory and \r
 \r
-  BPB - Boot(?) Parameter Block is in the first sector of a FAT file system. \r
+  BPB - BIOS Parameter Block is in the first sector of a FAT file system. \r
         The BPB contains information about the FAT file system. The BPB is \r
         always on the first sector of a media. The first sector also contains\r
         the legacy boot strap code.\r
 \r
---*/\r
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
 #include "Partition.h"\r
 \r
-STATIC\r
+/**\r
+  Test to see if the Mbr buffer is a valid MBR.\r
+\r
+  @param  Mbr         Parent Handle.\r
+  @param  LastLba     Last Lba address on the device.\r
+   \r
+  @retval TRUE        Mbr is a Valid MBR.\r
+  @retval FALSE       Mbr is not a Valid MBR.\r
+\r
+**/\r
 BOOLEAN\r
 PartitionValidMbr (\r
   IN  MASTER_BOOT_RECORD      *Mbr,\r
   IN  EFI_LBA                 LastLba\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Test to see if the Mbr buffer is a valid MBR\r
-\r
-Arguments:       \r
-  Mbr     - Parent Handle \r
-  LastLba - Last Lba address on the device.\r
-\r
-Returns:\r
-  TRUE  - Mbr is a Valid MBR\r
-  FALSE - Mbr is not a Valid MBR\r
-\r
---*/\r
 {\r
   UINT32  StartingLBA;\r
   UINT32  EndingLBA;\r
@@ -104,11 +92,26 @@ Returns:
     }\r
   }\r
   //\r
-  // Non of the regions overlapped so MBR is O.K.\r
+  // None of the regions overlapped so MBR is O.K.\r
   //\r
   return MbrValid;\r
 }\r
 \r
+\r
+/**\r
+  Install child handles if the Handle supports MBR format.\r
+\r
+  @param  This              Calling context.\r
+  @param  Handle            Parent Handle.\r
+  @param  DiskIo            Parent DiskIo interface.\r
+  @param  BlockIo           Parent BlockIo interface.\r
+  @param  DevicePath        Parent Device Path.\r
+   \r
+  @retval EFI_SUCCESS       A child handle was added.\r
+  @retval EFI_MEDIA_CHANGED Media change was detected.\r
+  @retval Others            MBR partition was not found.\r
+\r
+**/\r
 EFI_STATUS\r
 PartitionInstallMbrChildHandles (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
@@ -117,24 +120,6 @@ PartitionInstallMbrChildHandles (
   IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,\r
   IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Install child handles if the Handle supports MBR format.\r
-\r
-Arguments:       \r
-  This       - Calling context.\r
-  Handle     - Parent Handle \r
-  DiskIo     - Parent DiskIo interface\r
-  BlockIo    - Parent BlockIo interface\r
-  DevicePath - Parent Device Path\r
-\r
-Returns:\r
-  EFI_SUCCESS       - If a child handle was added\r
-  EFI_MEDIA_CHANGED - Media changed Detected\r
-       !EFI_SUCCESS      - Not found MBR partition.\r
-\r
---*/\r
 {\r
   EFI_STATUS                Status;\r
   MASTER_BOOT_RECORD        *Mbr;\r
@@ -178,9 +163,9 @@ Returns:
   LastDevicePathNode = NULL;\r
   ZeroMem (&ParentHdDev, sizeof (ParentHdDev));\r
   DevicePathNode = DevicePath;\r
-  while (!EfiIsDevicePathEnd (DevicePathNode)) {\r
+  while (!IsDevicePathEnd (DevicePathNode)) {\r
     LastDevicePathNode  = DevicePathNode;\r
-    DevicePathNode      = EfiNextDevicePathNode (DevicePathNode);\r
+    DevicePathNode      = NextDevicePathNode (DevicePathNode);\r
   }\r
 \r
   if (LastDevicePathNode != NULL) {\r
@@ -227,7 +212,7 @@ Returns:
       HdDev.PartitionNumber = PartitionNumber ++;\r
       HdDev.PartitionStart  = UNPACK_UINT32 (Mbr->Partition[Index].StartingLBA);\r
       HdDev.PartitionSize   = UNPACK_UINT32 (Mbr->Partition[Index].SizeInLBA);\r
-      CopyMem (HdDev.Signature, &(Mbr->UniqueMbrSignature[0]), sizeof (UINT32));\r
+      CopyMem (HdDev.Signature, &(Mbr->UniqueMbrSignature[0]), sizeof (Mbr->UniqueMbrSignature));\r
 \r
       Status = PartitionInstallChildHandle (\r
                 This,\r
@@ -267,7 +252,7 @@ Returns:
         goto Done;\r
       }\r
 \r
-      if (Mbr->Partition[0].OSIndicator == 0) {\r
+      if (UNPACK_UINT32 (Mbr->Partition[0].SizeInLBA) == 0) {\r
         break;\r
       }\r
 \r