TianoCore EDK2 master
Loading...
Searching...
No Matches
Gpt.c File Reference
#include <IndustryStandard/Mbr.h>
#include <Uefi/UefiGpt.h>
#include <Library/BaseLib.h>
#include "FatLitePeim.h"

Go to the source code of this file.

Data Structures

struct  EFI_PARTITION_ENTRY_STATUS
 

Macros

#define EFI_SIZE_TO_BLOCKS(a, blocksize)   (((a) / (blocksize)) + (((a) % (blocksize)) ? 1 : 0))
 

Functions

BOOLEAN PartitionCheckGptHeaderCRC (IN EFI_PARTITION_TABLE_HEADER *PartHeader)
 
BOOLEAN PartitionCheckGptEntryArrayCRC (IN EFI_PARTITION_TABLE_HEADER *PartHeader, IN EFI_PARTITION_ENTRY *PartEntry)
 
BOOLEAN PartitionCheckGptHeader (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN ParentBlockDevNo, IN BOOLEAN IsPrimaryHeader, IN EFI_PARTITION_TABLE_HEADER *PartHdr)
 
BOOLEAN PartitionCheckGptEntryArray (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN ParentBlockDevNo, IN EFI_PARTITION_TABLE_HEADER *PartHdr)
 
BOOLEAN PartitionCheckGptStructure (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN ParentBlockDevNo, IN BOOLEAN IsPrimary)
 
BOOLEAN PartitionCheckProtectiveMbr (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN ParentBlockDevNo)
 
BOOLEAN FatFindGptPartitions (IN PEI_FAT_PRIVATE_DATA *PrivateData, IN UINTN ParentBlockDevNo)
 

Detailed Description

Routines supporting partition discovery and logical device reading

Copyright (c) 2019 Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Gpt.c.

Macro Definition Documentation

◆ EFI_SIZE_TO_BLOCKS

#define EFI_SIZE_TO_BLOCKS (   a,
  blocksize 
)    (((a) / (blocksize)) + (((a) % (blocksize)) ? 1 : 0))

Definition at line 20 of file Gpt.c.

Function Documentation

◆ FatFindGptPartitions()

BOOLEAN FatFindGptPartitions ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  ParentBlockDevNo 
)

This function is used for finding GPT partition on block device. As follow UEFI spec we should check protective MBR first and then try to check both primary/backup GPT structures.

Parameters
[in]PrivateDataThe global memory map
[in]ParentBlockDevNoThe parent block device
Return values
TRUENew partitions are detected and logical block devices are added to block device array
FALSENo new partitions are added

Definition at line 486 of file Gpt.c.

◆ PartitionCheckGptEntryArray()

BOOLEAN PartitionCheckGptEntryArray ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  ParentBlockDevNo,
IN EFI_PARTITION_TABLE_HEADER PartHdr 
)

This function is used to verify each partition in block device.

Parameters
[in]PrivateDataThe global memory map
[in]ParentBlockDevNoThe parent block device
[in]PartHdrStores the partition table that is read
Return values
TRUEThe partition is valid
FALSEThe partition is not valid

Definition at line 185 of file Gpt.c.

◆ PartitionCheckGptEntryArrayCRC()

BOOLEAN PartitionCheckGptEntryArrayCRC ( IN EFI_PARTITION_TABLE_HEADER PartHeader,
IN EFI_PARTITION_ENTRY PartEntry 
)

Check if the CRC field in the Partition table header is valid for Partition entry array.

Parameters
[in]PartHeaderPartition table header structure
[in]PartEntryThe partition entry array
Return values
TRUEthe CRC is valid
FALSEthe CRC is invalid

Definition at line 77 of file Gpt.c.

◆ PartitionCheckGptHeader()

BOOLEAN PartitionCheckGptHeader ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  ParentBlockDevNo,
IN BOOLEAN  IsPrimaryHeader,
IN EFI_PARTITION_TABLE_HEADER PartHdr 
)

The function is used for valid GPT table. Both for Primary and Backup GPT header.

Parameters
[in]PrivateDataThe global memory map
[in]ParentBlockDevNoThe parent block device
[in]IsPrimaryHeaderIndicate to which header will be checked.
[in]PartHdrStores the partition table that is read
Return values
TRUEThe partition table is valid
FALSEThe partition table is not valid

Definition at line 104 of file Gpt.c.

◆ PartitionCheckGptHeaderCRC()

BOOLEAN PartitionCheckGptHeaderCRC ( IN EFI_PARTITION_TABLE_HEADER PartHeader)

Check if the CRC field in the Partition table header is valid.

Parameters
[in]PartHeaderPartition table header structure
Return values
TRUEthe CRC is valid
FALSEthe CRC is invalid

Definition at line 41 of file Gpt.c.

◆ PartitionCheckGptStructure()

BOOLEAN PartitionCheckGptStructure ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  ParentBlockDevNo,
IN BOOLEAN  IsPrimary 
)

The function is used to check GPT structure, include GPT header and GPT entry array.

  1. Check GPT header.
  2. Check partition entry array.
  3. Check each partitions.
Parameters
[in]PrivateDataThe global memory map
[in]ParentBlockDevNoThe parent block device
[in]IsPrimaryIndicate primary or backup to be check
Return values
TRUEPrimary or backup GPT structure is valid.
FALSEBoth primary and backup are invalid.

Definition at line 365 of file Gpt.c.

◆ PartitionCheckProtectiveMbr()

BOOLEAN PartitionCheckProtectiveMbr ( IN PEI_FAT_PRIVATE_DATA PrivateData,
IN UINTN  ParentBlockDevNo 
)

This function is used to check protective MBR structure before checking GPT.

Parameters
[in]PrivateDataThe global memory map
[in]ParentBlockDevNoThe parent block device
Return values
TRUEValid protective MBR
FALSEInvalid MBR

Definition at line 417 of file Gpt.c.