-/*++\r
-\r
-Copyright (c) 2006, 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
- Gpt.c\r
-\r
-Abstract:\r
-\r
+/** @file\r
Decode a hard disk partitioned with the GPT scheme in the EFI 1.0\r
specification.\r
\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
+**/\r
\r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
\r
#include "Partition.h"\r
\r
-STATIC\r
+\r
BOOLEAN\r
PartitionValidGptTable (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
OUT EFI_PARTITION_TABLE_HEADER *PartHeader\r
);\r
\r
-STATIC\r
+\r
BOOLEAN\r
PartitionCheckGptEntryArrayCRC (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
IN EFI_PARTITION_TABLE_HEADER *PartHeader\r
);\r
\r
-STATIC\r
+\r
BOOLEAN\r
PartitionRestoreGptTable (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
IN EFI_PARTITION_TABLE_HEADER *PartHeader\r
);\r
\r
-STATIC\r
+\r
VOID\r
PartitionCheckGptEntry (\r
IN EFI_PARTITION_TABLE_HEADER *PartHeader,\r
OUT EFI_PARTITION_ENTRY_STATUS *PEntryStatus\r
);\r
\r
-STATIC\r
+\r
BOOLEAN\r
PartitionCheckCrcAltSize (\r
IN UINTN MaxSize,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
);\r
\r
-STATIC\r
+\r
BOOLEAN\r
PartitionCheckCrc (\r
IN UINTN MaxSize,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
);\r
\r
-STATIC\r
+\r
VOID\r
PartitionSetCrcAltSize (\r
IN UINTN Size,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
);\r
\r
-STATIC\r
+\r
VOID\r
PartitionSetCrc (\r
IN OUT EFI_TABLE_HEADER *Hdr\r
);\r
\r
+/**\r
+ Install child handles if the Handle supports GPT partition structure.\r
+\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] DevicePath - Parent Device Path\r
+\r
+ @retval EFI_SUCCESS Valid GPT disk\r
+ @retval EFI_MEDIA_CHANGED Media changed Detected\r
+ @retval other Not a valid GPT disk\r
+\r
+**/\r
EFI_STATUS\r
PartitionInstallGptChildHandles (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
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 GPT partition structure.\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 - Valid GPT disk\r
- EFI_MEDIA_CHANGED - Media changed Detected\r
- !EFI_SUCCESS - Not a valid GPT disk\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
UINT32 BlockSize;\r
return GptValid;\r
}\r
\r
-STATIC\r
+\r
+/**\r
+ Install child handles if the Handle supports GPT partition structure.\r
+\r
+ @param[in] BlockIo Parent BlockIo interface\r
+ @param[in] DiskIo Disk Io protocol.\r
+ @param[in] Lba The starting Lba of the Partition Table\r
+ @param[in] PartHeader Stores the partition table that is read\r
+\r
+ @retval TRUE The partition table is valid\r
+ @retval FALSE The partition table is not valid\r
+\r
+**/\r
BOOLEAN\r
PartitionValidGptTable (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
IN EFI_LBA Lba,\r
OUT EFI_PARTITION_TABLE_HEADER *PartHeader\r
)\r
-/*++\r
-\r
-Routine Description:\r
- Check if the GPT partition table is valid\r
-\r
-Arguments:\r
- BlockIo - Parent BlockIo interface\r
- DiskIo - Disk Io protocol.\r
- Lba - The starting Lba of the Partition Table\r
- PartHeader - Stores the partition table that is read\r
-\r
-Returns:\r
- TRUE - The partition table is valid\r
- FALSE - The partition table is not valid\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
UINT32 BlockSize;\r
return TRUE;\r
}\r
\r
-STATIC\r
+\r
+/**\r
+ Check if the CRC field in the Partition table header is valid\r
+ for Partition entry array.\r
+\r
+ @param[in] BlockIo Parent BlockIo interface\r
+ @param[in] DiskIo Disk Io Protocol.\r
+ @param[in] PartHeader Partition table header structure\r
+\r
+ @retval TRUE the CRC is valid\r
+ @retval FALSE the CRC is invalid\r
+\r
+**/\r
BOOLEAN\r
PartitionCheckGptEntryArrayCRC (\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
IN EFI_PARTITION_TABLE_HEADER *PartHeader\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Check if the CRC field in the Partition table header is valid\r
- for Partition entry array\r
-\r
-Arguments:\r
-\r
- BlockIo - parent BlockIo interface\r
- DiskIo - Disk Io Protocol.\r
- PartHeader - Partition table header structure\r
-\r
-Returns:\r
-\r
- TRUE - the CRC is valid\r
- FALSE - the CRC is invalid\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
UINT8 *Ptr;\r
return (BOOLEAN) (PartHeader->PartitionEntryArrayCRC32 == Crc);\r
}\r
\r
-STATIC\r
-BOOLEAN\r
-PartitionRestoreGptTable (\r
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
- IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
- IN EFI_PARTITION_TABLE_HEADER *PartHeader\r
- )\r
-/*++\r
-\r
-Routine Description:\r
\r
+/**\r
Restore Partition Table to its alternate place\r
(Primary -> Backup or Backup -> Primary)\r
\r
-Arguments:\r
-\r
- BlockIo - parent BlockIo interface\r
- DiskIo - Disk Io Protocol.\r
- PartHeader - the source Partition table header structure\r
+ @param[in] BlockIo Parent BlockIo interface\r
+ @param[in] DiskIo Disk Io Protocol.\r
+ @param[in] PartHeader Partition table header structure\r
\r
-Returns:\r
+ @retval TRUE Restoring succeeds\r
+ @retval FALSE Restoring failed\r
\r
- TRUE - Restoring succeeds\r
- FALSE - Restoring failed\r
-\r
---*/\r
+**/\r
+BOOLEAN\r
+PartitionRestoreGptTable (\r
+ IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
+ IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
+ IN EFI_PARTITION_TABLE_HEADER *PartHeader\r
+ )\r
{\r
EFI_STATUS Status;\r
UINTN BlockSize;\r
return TRUE;\r
}\r
\r
-STATIC\r
+\r
+/**\r
+ Restore Partition Table to its alternate place\r
+ (Primary -> Backup or Backup -> Primary)\r
+\r
+ @param[in] PartHeader Partition table header structure\r
+ @param[in] PartEntry The partition entry array\r
+ @param[out] PEntryStatus the partition entry status array \r
+ recording the status of each partition\r
+**/\r
VOID\r
PartitionCheckGptEntry (\r
IN EFI_PARTITION_TABLE_HEADER *PartHeader,\r
IN EFI_PARTITION_ENTRY *PartEntry,\r
OUT EFI_PARTITION_ENTRY_STATUS *PEntryStatus\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Check each partition entry for its range\r
-\r
-Arguments:\r
-\r
- PartHeader - the partition table header\r
- PartEntry - the partition entry array\r
- PEntryStatus - the partition entry status array recording the status of\r
- each partition\r
-\r
-Returns:\r
- VOID\r
-\r
---*/\r
{\r
EFI_LBA StartingLBA;\r
EFI_LBA EndingLBA;\r
DEBUG ((EFI_D_INFO, " End check partition entries\n"));\r
}\r
\r
-STATIC\r
+\r
+/**\r
+ Updates the CRC32 value in the table header\r
+\r
+ @param[in,out] Hdr Table to update\r
+\r
+**/\r
VOID\r
PartitionSetCrc (\r
IN OUT EFI_TABLE_HEADER *Hdr\r
)\r
-/*++\r
+{\r
+ PartitionSetCrcAltSize (Hdr->HeaderSize, Hdr);\r
+}\r
\r
-Routine Description:\r
\r
+/**\r
Updates the CRC32 value in the table header\r
\r
-Arguments:\r
-\r
- Hdr - The table to update\r
+ @param[in] Size The size of the table\r
+ @param[in,out] Hdr Table to update\r
\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- PartitionSetCrcAltSize (Hdr->HeaderSize, Hdr);\r
-}\r
-\r
-STATIC\r
+**/\r
VOID\r
PartitionSetCrcAltSize (\r
IN UINTN Size,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
)\r
-/*++\r
-\r
-Routine Description:\r
\r
- Updates the CRC32 value in the table header\r
-\r
-Arguments:\r
-\r
- Size - The size of the table\r
- Hdr - The table to update\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
{\r
UINT32 Crc;\r
\r
Hdr->CRC32 = Crc;\r
}\r
\r
-STATIC\r
+\r
+/**\r
+ Checks the CRC32 value in the table header\r
+\r
+ @param[in] MaxSize Max Size limit\r
+ @param[in,out] Hdr Table to check\r
+\r
+ @return TRUE CRC Valid\r
+ @return FALSE CRC Invalid\r
+\r
+**/\r
BOOLEAN\r
PartitionCheckCrc (\r
IN UINTN MaxSize,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
)\r
-/*++\r
+{\r
+ return PartitionCheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);\r
+}\r
\r
-Routine Description:\r
\r
+/**\r
Checks the CRC32 value in the table header\r
\r
-Arguments:\r
+ @param[in] MaxSize Max Size limit\r
+ @param[in] Size The size of the table\r
+ @param[in,out] Hdr Table to check\r
\r
- MaxSize - Max Size limit\r
- Hdr - The table to check\r
+ @return TRUE CRC Valid\r
+ @return FALSE CRC Invalid\r
\r
-Returns:\r
-\r
- TRUE if the CRC is OK in the table\r
-\r
---*/\r
-{\r
- return PartitionCheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);\r
-}\r
-\r
-STATIC\r
+**/\r
BOOLEAN\r
PartitionCheckCrcAltSize (\r
IN UINTN MaxSize,\r
IN UINTN Size,\r
IN OUT EFI_TABLE_HEADER *Hdr\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Checks the CRC32 value in the table header\r
-\r
-Arguments:\r
-\r
- MaxSize - Max Size Limit\r
- Size - The size of the table\r
- Hdr - The table to check\r
-\r
-Returns:\r
-\r
- TRUE if the CRC is OK in the table\r
-\r
---*/\r
{\r
UINT32 Crc;\r
UINT32 OrgCrc;\r