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