]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
Add BlockIO2 Protocol.
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Mbr.c
index 8aef497ad38049579b5404b29567bbd563c83839..4c64663746cc07adc66840c1ab09a4dd779d7d15 100644 (file)
@@ -11,7 +11,7 @@
         always on the first sector of a media. The first sector also contains\r
         the legacy boot strap code.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -101,11 +101,12 @@ PartitionValidMbr (
 /**\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
+  @param[in]  This              Calling context.\r
+  @param[in]  Handle            Parent Handle.\r
+  @param[in]  DiskIo            Parent DiskIo interface.\r
+  @param[in]  BlockIo           Parent BlockIo interface.\r
+  @param[in]  BlockIo2          Parent BlockIo2 interface.\r
+  @param[in]  DevicePath        Parent Device Path.\r
    \r
   @retval EFI_SUCCESS       A child handle was added.\r
   @retval EFI_MEDIA_CHANGED Media change was detected.\r
@@ -118,6 +119,7 @@ PartitionInstallMbrChildHandles (
   IN  EFI_HANDLE                   Handle,\r
   IN  EFI_DISK_IO_PROTOCOL         *DiskIo,\r
   IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,\r
+  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,\r
   IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath\r
   )\r
 {\r
@@ -131,26 +133,33 @@ PartitionInstallMbrChildHandles (
   UINT32                    PartitionNumber;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;\r
   EFI_DEVICE_PATH_PROTOCOL  *LastDevicePathNode;\r
+  UINT32                    BlockSize;\r
+  UINT32                    MediaId;\r
+  EFI_LBA                   LastBlock;\r
 \r
   Found           = EFI_NOT_FOUND;\r
 \r
-  Mbr             = AllocatePool (BlockIo->Media->BlockSize);\r
+  BlockSize = BlockIo->Media->BlockSize;\r
+  MediaId   = BlockIo->Media->MediaId;\r
+  LastBlock = BlockIo->Media->LastBlock;\r
+\r
+  Mbr = AllocatePool (BlockSize);\r
   if (Mbr == NULL) {\r
     return Found;\r
   }\r
 \r
   Status = DiskIo->ReadDisk (\r
                      DiskIo,\r
-                     BlockIo->Media->MediaId,\r
+                     MediaId,\r
                      0,\r
-                     BlockIo->Media->BlockSize,\r
+                     BlockSize,\r
                      Mbr\r
                      );\r
   if (EFI_ERROR (Status)) {\r
     Found = Status;\r
     goto Done;\r
   }\r
-  if (!PartitionValidMbr (Mbr, BlockIo->Media->LastBlock)) {\r
+  if (!PartitionValidMbr (Mbr, LastBlock)) {\r
     goto Done;\r
   }\r
   //\r
@@ -218,6 +227,7 @@ PartitionInstallMbrChildHandles (
                 Handle,\r
                 DiskIo,\r
                 BlockIo,\r
+                BlockIo2,\r
                 DevicePath,\r
                 (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,\r
                 HdDev.PartitionStart,\r
@@ -241,9 +251,9 @@ PartitionInstallMbrChildHandles (
 \r
       Status = DiskIo->ReadDisk (\r
                          DiskIo,\r
-                         BlockIo->Media->MediaId,\r
-                         MultU64x32 (ExtMbrStartingLba, BlockIo->Media->BlockSize),\r
-                         BlockIo->Media->BlockSize,\r
+                         MediaId,\r
+                         MultU64x32 (ExtMbrStartingLba, BlockSize),\r
+                         BlockSize,\r
                          Mbr\r
                          );\r
       if (EFI_ERROR (Status)) {\r
@@ -274,17 +284,18 @@ PartitionInstallMbrChildHandles (
       *((UINT32 *) &HdDev.Signature[0]) = 0;\r
 \r
       Status = PartitionInstallChildHandle (\r
-                This,\r
-                Handle,\r
-                DiskIo,\r
-                BlockIo,\r
-                DevicePath,\r
-                (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,\r
-                HdDev.PartitionStart - ParentHdDev.PartitionStart,\r
-                HdDev.PartitionStart - ParentHdDev.PartitionStart + HdDev.PartitionSize - 1,\r
-                MBR_SIZE,\r
-                (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION)\r
-                );\r
+                 This,\r
+                 Handle,\r
+                 DiskIo,\r
+                 BlockIo,\r
+                 BlockIo2,\r
+                 DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,\r
+                 HdDev.PartitionStart - ParentHdDev.PartitionStart,\r
+                 HdDev.PartitionStart - ParentHdDev.PartitionStart + HdDev.PartitionSize - 1,\r
+                 MBR_SIZE,\r
+                 (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION)\r
+                 );\r
       if (!EFI_ERROR (Status)) {\r
         Found = EFI_SUCCESS;\r
       }\r