/** @file
Decode a hard disk partitioned with the GPT scheme in the UEFI 2.0
specification.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
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
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"
/**
Install child handles if the Handle supports GPT partition structure.
@param[in] BlockIo Parent BlockIo interface.
@param[in] DiskIo Disk Io protocol.
@param[in] Lba The starting Lba of the Partition Table
@param[out] PartHeader Stores the partition table that is read
@retval TRUE The partition table is valid
@retval FALSE The partition table is not valid
**/
);
/**
Check if the CRC field in the Partition table header is valid
for Partition entry array.
@param[in] BlockIo Parent BlockIo interface
@param[in] DiskIo Disk Io Protocol.
@param[in] PartHeader Partition table header structure
@retval TRUE the CRC is valid
@retval FALSE the CRC is invalid
**/
);
/**
Restore Partition Table to its alternate place
(Primary -> Backup or Backup -> Primary).
@param[in] BlockIo Parent BlockIo interface.
@param[in] DiskIo Disk Io Protocol.
@param[in] PartHeader Partition table header structure.
@retval TRUE Restoring succeeds
@retval FALSE Restoring failed
**/
);
/**
Restore Partition Table to its alternate place.
(Primary -> Backup or Backup -> Primary)
@param[in] PartHeader Partition table header structure
@param[in] PartEntry The partition entry array
@param[out] PEntryStatus the partition entry status array
recording the status of each partition
**/
);
/**
Checks the CRC32 value in the table header.
@param MaxSize Max Size limit
@param Size The size of the table
@param Hdr Table to check
@return TRUE CRC Valid
@return FALSE CRC Invalid
**/
);
/**
Checks the CRC32 value in the table header.
@param MaxSize Max Size limit
@param Hdr Table to check
@return TRUE CRC Valid
@return FALSE CRC Invalid
**/
);
/**
Updates the CRC32 value in the table header.
@param Size The size of the table
@param Hdr Table to update
**/
);
/**
Updates the CRC32 value in the table header.
@param Hdr Table to update
**/
);
/**
Install child handles if the Handle supports GPT partition structure.
@param[in] This Calling context.
@param[in] Handle Parent Handle.
@param[in] DiskIo Parent DiskIo interface.
@param[in] BlockIo Parent BlockIo interface.
@param[in] BlockIo2 Parent BlockIo2 interface.
@param[in] DevicePath Parent Device Path.
@retval EFI_SUCCESS Valid GPT disk.
@retval EFI_MEDIA_CHANGED Media changed Detected.
@retval other Not a valid GPT disk.
**/
)
{
BackupHeader = NULL;
PEntryStatus = NULL;
//
// Allocate a buffer for the Protective MBR
//
if (ProtectiveMbr == NULL) {
return EFI_NOT_FOUND;
}
//
// Read the Protective MBR from LBA #0
//
0,
);
goto Done;
}
//
// Verify that the Protective MBR is valid
//
) {
break;
}
}
if (Index == MAX_MBR_PARTITIONS) {
goto Done;
}
//
// Allocate the GPT structures
//
if (PrimaryHeader == NULL) {
goto Done;
}
if (BackupHeader == NULL) {
goto Done;
}
//
// Check primary and backup partition tables
//
goto Done;
} else {
}
}
}
}
}
}
//
// Read the EFI Partition Entries
//
PartEntry = AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry);
goto Done;
}
);
goto Done;
}
DEBUG ((EFI_D_INFO, " Number of partition entries: %d\n", PrimaryHeader->NumberOfPartitionEntries));
PEntryStatus = AllocateZeroPool (PrimaryHeader->NumberOfPartitionEntries * sizeof (EFI_PARTITION_ENTRY_STATUS));
if (PEntryStatus == NULL) {
goto Done;
}
//
// Check the integrity of partition entries
//
//
// If we got this far the GPT layout of the disk is valid and we should return true
//
//
// Create child device handles
//
Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index * PrimaryHeader->SizeOfPartitionEntry);
) {
//
// Don't use null EFI Partition Entries, Invalid Partition Entries or OS specific
// partition Entries
//
continue;
}
This,
);
}
Done:
if (ProtectiveMbr != NULL) {
}
if (PrimaryHeader != NULL) {
}
if (BackupHeader != NULL) {
}
}
if (PEntryStatus != NULL) {
}
return GptValidStatus;
}
/**
Install child handles if the Handle supports GPT partition structure.
@param[in] BlockIo Parent BlockIo interface.
@param[in] DiskIo Disk Io protocol.
@param[in] Lba The starting Lba of the Partition Table
@param[out] PartHeader Stores the partition table that is read
@retval TRUE The partition table is valid
@retval FALSE The partition table is not valid
**/
)
{
return FALSE;
}
//
// Read the EFI Partition Table Header
//
);
return FALSE;
}
) {
return FALSE;
}
return FALSE;
}
return TRUE;
}
/**
Check if the CRC field in the Partition table header is valid
for Partition entry array.
@param[in] BlockIo Parent BlockIo interface
@param[in] DiskIo Disk Io Protocol.
@param[in] PartHeader Partition table header structure
@retval TRUE the CRC is valid
@retval FALSE the CRC is invalid
**/
)
{
//
// Read the EFI Partition Entries
//
return FALSE;
}
);
return FALSE;
}
return FALSE;
}
}
/**
Restore Partition Table to its alternate place
(Primary -> Backup or Backup -> Primary).
@param[in] BlockIo Parent BlockIo interface.
@param[in] DiskIo Disk Io Protocol.
@param[in] PartHeader Partition table header structure.
@retval TRUE Restoring succeeds
@retval FALSE Restoring failed
**/
)
{
return FALSE;
}
(PRIMARY_PART_HEADER_LBA + 1);
);
goto Done;
}
goto Done;
}
);
goto Done;
}
);
Done:
}
return FALSE;
}
return TRUE;
}
/**
Restore Partition Table to its alternate place.
(Primary -> Backup or Backup -> Primary)
@param[in] PartHeader Partition table header structure
@param[in] PartEntry The partition entry array
@param[out] PEntryStatus the partition entry status array
recording the status of each partition
**/
)
{
continue;
}
if (StartingLBA > EndingLBA ||
) {
continue;
}
//
// If Bit 1 is set, this indicate that this is an OS specific GUID partition.
//
}
continue;
}
//
// This region overlaps with the Index1'th region
//
continue;
}
}
}
}
/**
Updates the CRC32 value in the table header.
@param Hdr Table to update
**/
)
{
}
/**
Updates the CRC32 value in the table header.
@param Size The size of the table
@param Hdr Table to update
**/
)
{
}
/**
Checks the CRC32 value in the table header.
@param MaxSize Max Size limit
@param Hdr Table to check
@return TRUE CRC Valid
@return FALSE CRC Invalid
**/
)
{
}
/**
Checks the CRC32 value in the table header.
@param MaxSize Max Size limit
@param Size The size of the table
@param Hdr Table to check
@return TRUE CRC Valid
@return FALSE CRC Invalid
**/
)
{
Crc = 0;
if (Size == 0) {
//
// If header size is 0 CRC will pass so return FALSE here
//
return FALSE;
}
return FALSE;
}
//
// clear old crc from header
//
return FALSE;
}
//
// set results
//
//
// return status
//
DEBUG_CODE_BEGIN ();
}
DEBUG_CODE_END ();
}