summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2017-08-02 09:54:47 +0800
committerGuo Mang <mang.guo@intel.com>2017-09-05 19:45:08 +0800
commit6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8 (patch)
tree444372d92a0ae8991fe4d15eb3937df43690dfda /MdeModulePkg/Universal/Disk
parentb207c6434d7a5a4502975d322312e07017e8a8cb (diff)
downloadedk2-platforms-6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8.tar.xz
Remove core packages since we can get them from edk2 repository
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/Disk')
-rw-r--r--MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.inf75
-rw-r--r--MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.unibin2296 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPeiExtra.unibin1368 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c717
-rw-r--r--MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h303
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c189
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c1276
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h473
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf71
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.unibin3152 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxeExtra.unibin1340 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c188
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c274
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c871
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c331
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c1265
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h443
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf89
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.unibin3206 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxeExtra.unibin1348 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf60
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.unibin2874 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxeExtra.unibin1352 -> 0 bytes
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c473
-rw-r--r--MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h187
25 files changed, 0 insertions, 7285 deletions
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.inf b/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.inf
deleted file mode 100644
index e9d45e5b86..0000000000
--- a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.inf
+++ /dev/null
@@ -1,75 +0,0 @@
-## @file
-# PeiCdExpress recovery module.
-#
-# This module reads data from CDROM device by all installed block IO ppi and
-# finds whether there is Recovery data in the device. If it finds recovery
-# data, it will install Device Recovery Module PPI.
-#
-# Copyright (c) 2006 - 2015, 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
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = CdExpressPei
- MODULE_UNI_FILE = CdExpressPei.uni
- FILE_GUID = 31e147a6-d39a-4147-9da3-befd4d523243
- MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
-
- ENTRY_POINT = CdExpressPeimEntry
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources]
- PeiCdExpress.c
- PeiCdExpress.h
-
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- BaseMemoryLib
- PeimEntryPoint
- DebugLib
- PeiServicesTablePointerLib
- PeiServicesLib
- MemoryAllocationLib
- PcdLib
-
-[Guids]
- gRecoveryOnDataCdGuid ## CONSUMES ## UNDEFINED # Indicate the recovery device type
-
-
-[Ppis]
- ## NOTIFY
- ## CONSUMES
- gEfiPeiVirtualBlockIoPpiGuid
- ## NOTIFY
- ## CONSUMES
- gEfiPeiVirtualBlockIo2PpiGuid
- gEfiPeiDeviceRecoveryModulePpiGuid ## PRODUCES
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES
-
-[Depex]
- gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid
-
-[UserExtensions.TianoCore."ExtraFiles"]
- CdExpressPeiExtra.uni
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.uni b/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.uni
deleted file mode 100644
index 9ef1b035d7..0000000000
--- a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPei.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPeiExtra.uni b/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPeiExtra.uni
deleted file mode 100644
index b76d2a6e79..0000000000
--- a/MdeModulePkg/Universal/Disk/CdExpressPei/CdExpressPeiExtra.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c
deleted file mode 100644
index f78118a6a8..0000000000
--- a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c
+++ /dev/null
@@ -1,717 +0,0 @@
-/** @file
- Source file for CD recovery PEIM
-
-Copyright (c) 2006 - 2015, 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
-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 "PeiCdExpress.h"
-
-PEI_CD_EXPRESS_PRIVATE_DATA *mPrivateData = NULL;
-
-/**
- Installs the Device Recovery Module PPI, Initialize BlockIo Ppi
- installation notification
-
- @param FileHandle The file handle of the image.
- @param PeiServices General purpose services available to every PEIM.
-
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_OUT_OF_RESOURCES There is not enough system memory.
-
-**/
-EFI_STATUS
-EFIAPI
-CdExpressPeimEntry (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
- )
-{
- EFI_STATUS Status;
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
-
- if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle))) {
- return EFI_SUCCESS;
- }
-
- PrivateData = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (*PrivateData)));
- if (PrivateData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Initialize Private Data (to zero, as is required by subsequent operations)
- //
- ZeroMem (PrivateData, sizeof (*PrivateData));
- PrivateData->Signature = PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE;
-
- PrivateData->BlockBuffer = AllocatePages (EFI_SIZE_TO_PAGES (PEI_CD_BLOCK_SIZE));
- if (PrivateData->BlockBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- PrivateData->CapsuleCount = 0;
- Status = UpdateBlocksAndVolumes (PrivateData, TRUE);
- Status = UpdateBlocksAndVolumes (PrivateData, FALSE);
-
- //
- // Installs Ppi
- //
- PrivateData->DeviceRecoveryPpi.GetNumberRecoveryCapsules = GetNumberRecoveryCapsules;
- PrivateData->DeviceRecoveryPpi.GetRecoveryCapsuleInfo = GetRecoveryCapsuleInfo;
- PrivateData->DeviceRecoveryPpi.LoadRecoveryCapsule = LoadRecoveryCapsule;
-
- PrivateData->PpiDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
- PrivateData->PpiDescriptor.Guid = &gEfiPeiDeviceRecoveryModulePpiGuid;
- PrivateData->PpiDescriptor.Ppi = &PrivateData->DeviceRecoveryPpi;
-
- Status = PeiServicesInstallPpi (&PrivateData->PpiDescriptor);
- if (EFI_ERROR (Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // PrivateData is allocated now, set it to the module variable
- //
- mPrivateData = PrivateData;
-
- //
- // Installs Block Io Ppi notification function
- //
- PrivateData->NotifyDescriptor.Flags =
- (
- EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
- );
- PrivateData->NotifyDescriptor.Guid = &gEfiPeiVirtualBlockIoPpiGuid;
- PrivateData->NotifyDescriptor.Notify = BlockIoNotifyEntry;
-
- PrivateData->NotifyDescriptor2.Flags =
- (
- EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
- EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
- );
- PrivateData->NotifyDescriptor2.Guid = &gEfiPeiVirtualBlockIo2PpiGuid;
- PrivateData->NotifyDescriptor2.Notify = BlockIoNotifyEntry;
-
- return PeiServicesNotifyPpi (&PrivateData->NotifyDescriptor);
-
-}
-
-/**
- BlockIo installation notification function.
-
- This function finds out all the current Block IO PPIs in the system and add them
- into private data.
-
- @param PeiServices Indirect reference to the PEI Services Table.
- @param NotifyDescriptor Address of the notification descriptor data structure.
- @param Ppi Address of the PPI that was installed.
-
- @retval EFI_SUCCESS The function completes successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-BlockIoNotifyEntry (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
- IN VOID *Ppi
- )
-{
- if (CompareGuid (NotifyDescriptor->Guid, &gEfiPeiVirtualBlockIo2PpiGuid)) {
- UpdateBlocksAndVolumes (mPrivateData, TRUE);
- } else {
- UpdateBlocksAndVolumes (mPrivateData, FALSE);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Finds out all the current Block IO PPIs in the system and add them into private data.
-
- @param PrivateData The private data structure that contains recovery module information.
- @param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo.
-
- @retval EFI_SUCCESS The blocks and volumes are updated successfully.
-
-**/
-EFI_STATUS
-UpdateBlocksAndVolumes (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN BOOLEAN BlockIo2
- )
-{
- EFI_STATUS Status;
- EFI_PEI_PPI_DESCRIPTOR *TempPpiDescriptor;
- UINTN BlockIoPpiInstance;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi;
- UINTN NumberBlockDevices;
- UINTN IndexBlockDevice;
- EFI_PEI_BLOCK_IO_MEDIA Media;
- EFI_PEI_BLOCK_IO2_MEDIA Media2;
- EFI_PEI_SERVICES **PeiServices;
-
- IndexBlockDevice = 0;
- BlockIo2Ppi = NULL;
- BlockIoPpi = NULL;
- //
- // Find out all Block Io Ppi instances within the system
- // Assuming all device Block Io Peims are dispatched already
- //
- for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) {
- if (BlockIo2) {
- Status = PeiServicesLocatePpi (
- &gEfiPeiVirtualBlockIo2PpiGuid,
- BlockIoPpiInstance,
- &TempPpiDescriptor,
- (VOID **) &BlockIo2Ppi
- );
- } else {
- Status = PeiServicesLocatePpi (
- &gEfiPeiVirtualBlockIoPpiGuid,
- BlockIoPpiInstance,
- &TempPpiDescriptor,
- (VOID **) &BlockIoPpi
- );
- }
- if (EFI_ERROR (Status)) {
- //
- // Done with all Block Io Ppis
- //
- break;
- }
-
- PeiServices = (EFI_PEI_SERVICES **) GetPeiServicesTablePointer ();
- if (BlockIo2) {
- Status = BlockIo2Ppi->GetNumberOfBlockDevices (
- PeiServices,
- BlockIo2Ppi,
- &NumberBlockDevices
- );
- } else {
- Status = BlockIoPpi->GetNumberOfBlockDevices (
- PeiServices,
- BlockIoPpi,
- &NumberBlockDevices
- );
- }
- if (EFI_ERROR (Status) || (NumberBlockDevices == 0)) {
- continue;
- }
- //
- // Just retrieve the first block, should emulate all blocks.
- //
- for (IndexBlockDevice = 1; IndexBlockDevice <= NumberBlockDevices && PrivateData->CapsuleCount < PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER; IndexBlockDevice ++) {
- if (BlockIo2) {
- Status = BlockIo2Ppi->GetBlockDeviceMediaInfo (
- PeiServices,
- BlockIo2Ppi,
- IndexBlockDevice,
- &Media2
- );
- if (EFI_ERROR (Status) ||
- !Media2.MediaPresent ||
- ((Media2.InterfaceType != MSG_ATAPI_DP) && (Media2.InterfaceType != MSG_USB_DP)) ||
- (Media2.BlockSize != PEI_CD_BLOCK_SIZE)
- ) {
- continue;
- }
- DEBUG ((EFI_D_INFO, "PeiCdExpress InterfaceType is %d\n", Media2.InterfaceType));
- DEBUG ((EFI_D_INFO, "PeiCdExpress MediaPresent is %d\n", Media2.MediaPresent));
- DEBUG ((EFI_D_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media2.BlockSize));
- } else {
- Status = BlockIoPpi->GetBlockDeviceMediaInfo (
- PeiServices,
- BlockIoPpi,
- IndexBlockDevice,
- &Media
- );
- if (EFI_ERROR (Status) ||
- !Media.MediaPresent ||
- ((Media.DeviceType != IdeCDROM) && (Media.DeviceType != UsbMassStorage)) ||
- (Media.BlockSize != PEI_CD_BLOCK_SIZE)
- ) {
- continue;
- }
- DEBUG ((EFI_D_INFO, "PeiCdExpress DeviceType is %d\n", Media.DeviceType));
- DEBUG ((EFI_D_INFO, "PeiCdExpress MediaPresent is %d\n", Media.MediaPresent));
- DEBUG ((EFI_D_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media.BlockSize));
- }
-
- DEBUG ((EFI_D_INFO, "PeiCdExpress Status is %d\n", Status));
-
- DEBUG ((EFI_D_INFO, "IndexBlockDevice is %d\n", IndexBlockDevice));
- PrivateData->CapsuleData[PrivateData->CapsuleCount].IndexBlock = IndexBlockDevice;
- if (BlockIo2) {
- PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo2 = BlockIo2Ppi;
- } else {
- PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo = BlockIoPpi;
- }
- Status = FindRecoveryCapsules (PrivateData);
- DEBUG ((EFI_D_INFO, "Status is %d\n", Status));
-
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- PrivateData->CapsuleCount++;
- }
-
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Finds out the recovery capsule in the current volume.
-
- @param PrivateData The private data structure that contains recovery module information.
-
- @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
- @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
-
-**/
-EFI_STATUS
-EFIAPI
-FindRecoveryCapsules (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
- )
-{
- EFI_STATUS Status;
- UINTN Lba;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi;
- UINTN BufferSize;
- UINT8 *Buffer;
- UINT8 Type;
- UINT8 *StandardID;
- UINT32 RootDirLBA;
- PEI_CD_EXPRESS_DIR_FILE_RECORD *RoorDirRecord;
- UINTN VolumeSpaceSize;
- BOOLEAN StartOfVolume;
- UINTN OriginalLBA;
- UINTN IndexBlockDevice;
-
- Buffer = PrivateData->BlockBuffer;
- BufferSize = PEI_CD_BLOCK_SIZE;
-
- Lba = 16;
- //
- // The volume descriptor starts on Lba 16
- //
- IndexBlockDevice = PrivateData->CapsuleData[PrivateData->CapsuleCount].IndexBlock;
- BlockIoPpi = PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo;
- BlockIo2Ppi = PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo2;
-
- VolumeSpaceSize = 0;
- StartOfVolume = TRUE;
- OriginalLBA = 16;
-
- while (TRUE) {
- SetMem (Buffer, BufferSize, 0);
- if (BlockIo2Ppi != NULL) {
- Status = BlockIo2Ppi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIo2Ppi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
- } else {
- Status = BlockIoPpi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIoPpi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- StandardID = (UINT8 *) (Buffer + PEI_CD_EXPRESS_STANDARD_ID_OFFSET);
- if (!StringCmp (StandardID, (UINT8 *) PEI_CD_STANDARD_ID, PEI_CD_EXPRESS_STANDARD_ID_SIZE, TRUE)) {
- break;
- }
-
- if (StartOfVolume) {
- OriginalLBA = Lba;
- StartOfVolume = FALSE;
- }
-
- Type = *(UINT8 *) (Buffer + PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET);
- if (Type == PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR) {
- if (VolumeSpaceSize == 0) {
- break;
- } else {
- Lba = (OriginalLBA + VolumeSpaceSize);
- VolumeSpaceSize = 0;
- StartOfVolume = TRUE;
- continue;
- }
- }
-
- if (Type != PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY) {
- Lba++;
- continue;
- }
-
- VolumeSpaceSize = *(UINT32 *) (Buffer + PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET);
-
- RoorDirRecord = (PEI_CD_EXPRESS_DIR_FILE_RECORD *) (Buffer + PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET);
- RootDirLBA = RoorDirRecord->LocationOfExtent[0];
-
- Status = RetrieveCapsuleFileFromRoot (PrivateData, BlockIoPpi, BlockIo2Ppi, IndexBlockDevice, RootDirLBA);
- if (!EFI_ERROR (Status)) {
- //
- // Just look for the first primary descriptor
- //
- return EFI_SUCCESS;
- }
-
- Lba++;
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- Retrieves the recovery capsule in root directory of the current volume.
-
- @param PrivateData The private data structure that contains recovery module information.
- @param BlockIoPpi The Block IO PPI used to access the volume.
- @param BlockIo2Ppi The Block IO 2 PPI used to access the volume.
- @param IndexBlockDevice The index of current block device.
- @param Lba The starting logic block address to retrieve capsule.
-
- @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
- @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
- @retval Others
-
-**/
-EFI_STATUS
-EFIAPI
-RetrieveCapsuleFileFromRoot (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi,
- IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi,
- IN UINTN IndexBlockDevice,
- IN UINT32 Lba
- )
-{
- EFI_STATUS Status;
- UINTN BufferSize;
- UINT8 *Buffer;
- PEI_CD_EXPRESS_DIR_FILE_RECORD *FileRecord;
- UINTN Index;
-
- Buffer = PrivateData->BlockBuffer;
- BufferSize = PEI_CD_BLOCK_SIZE;
-
- SetMem (Buffer, BufferSize, 0);
-
- if (BlockIo2Ppi != NULL) {
- Status = BlockIo2Ppi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIo2Ppi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
- } else {
- Status = BlockIoPpi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIoPpi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- while (1) {
- FileRecord = (PEI_CD_EXPRESS_DIR_FILE_RECORD *) Buffer;
-
- if (FileRecord->Length == 0) {
- break;
- }
- //
- // Not intend to check other flag now
- //
- if ((FileRecord->Flag & PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR) != 0) {
- Buffer += FileRecord->Length;
- continue;
- }
-
- for (Index = 0; Index < FileRecord->FileIDLength; Index++) {
- if (FileRecord->FileID[Index] == ';') {
- break;
- }
- }
-
- if (Index != (sizeof (PEI_RECOVERY_FILE_NAME) - 1)) {
- Buffer += FileRecord->Length;
- continue;
- }
-
- if (!StringCmp (FileRecord->FileID, (UINT8 *) PEI_RECOVERY_FILE_NAME, sizeof (PEI_RECOVERY_FILE_NAME) - 1, FALSE)) {
- Buffer += FileRecord->Length;
- continue;
- }
-
- PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleStartLBA = FileRecord->LocationOfExtent[0];
- PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleSize =
- (
- FileRecord->DataLength[0] /
- PEI_CD_BLOCK_SIZE +
- 1
- ) *
- PEI_CD_BLOCK_SIZE;
-
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- Returns the number of DXE capsules residing on the device.
-
- This function searches for DXE capsules from the associated device and returns
- the number and maximum size in bytes of the capsules discovered. Entry 1 is
- assumed to be the highest load priority and entry N is assumed to be the lowest
- priority.
-
- @param[in] PeiServices General-purpose services that are available
- to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On
- output, *NumberRecoveryCapsules contains
- the number of recovery capsule images
- available for retrieval from this PEIM
- instance.
-
- @retval EFI_SUCCESS One or more capsules were discovered.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-GetNumberRecoveryCapsules (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- OUT UINTN *NumberRecoveryCapsules
- )
-{
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
-
- PrivateData = PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS (This);
- UpdateBlocksAndVolumes (PrivateData, TRUE);
- UpdateBlocksAndVolumes (PrivateData, FALSE);
- *NumberRecoveryCapsules = PrivateData->CapsuleCount;
-
- if (*NumberRecoveryCapsules == 0) {
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Returns the size and type of the requested recovery capsule.
-
- This function gets the size and type of the capsule specified by CapsuleInstance.
-
- @param[in] PeiServices General-purpose services that are available to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[in] CapsuleInstance Specifies for which capsule instance to retrieve
- the information. This parameter must be between
- one and the value returned by GetNumberRecoveryCapsules()
- in NumberRecoveryCapsules.
- @param[out] Size A pointer to a caller-allocated UINTN in which
- the size of the requested recovery module is
- returned.
- @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which
- the type of the requested recovery capsule is
- returned. The semantic meaning of the value
- returned is defined by the implementation.
-
- @retval EFI_SUCCESS One or more capsules were discovered.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-GetRecoveryCapsuleInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT UINTN *Size,
- OUT EFI_GUID *CapsuleType
- )
-{
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
- UINTN NumberRecoveryCapsules;
- EFI_STATUS Status;
-
- Status = GetNumberRecoveryCapsules (PeiServices, This, &NumberRecoveryCapsules);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {
- CapsuleInstance = CapsuleInstance + 1;
- }
-
- if ((CapsuleInstance == 0) || (CapsuleInstance > NumberRecoveryCapsules)) {
- return EFI_NOT_FOUND;
- }
-
- PrivateData = PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS (This);
-
- *Size = PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleSize;
- CopyMem (
- CapsuleType,
- &gRecoveryOnDataCdGuid,
- sizeof (EFI_GUID)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Loads a DXE capsule from some media into memory.
-
- This function, by whatever mechanism, retrieves a DXE capsule from some device
- and loads it into memory. Note that the published interface is device neutral.
-
- @param[in] PeiServices General-purpose services that are available
- to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[in] CapsuleInstance Specifies which capsule instance to retrieve.
- @param[out] Buffer Specifies a caller-allocated buffer in which
- the requested recovery capsule will be returned.
-
- @retval EFI_SUCCESS The capsule was loaded correctly.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi;
- UINTN NumberRecoveryCapsules;
-
- Status = GetNumberRecoveryCapsules (PeiServices, This, &NumberRecoveryCapsules);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {
- CapsuleInstance = CapsuleInstance + 1;
- }
-
- if ((CapsuleInstance == 0) || (CapsuleInstance > NumberRecoveryCapsules)) {
- return EFI_NOT_FOUND;
- }
-
- PrivateData = PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS (This);
- BlockIoPpi = PrivateData->CapsuleData[CapsuleInstance - 1].BlockIo;
- BlockIo2Ppi = PrivateData->CapsuleData[CapsuleInstance - 1].BlockIo2;
-
- if (BlockIo2Ppi != NULL) {
- Status = BlockIo2Ppi->ReadBlocks (
- PeiServices,
- BlockIo2Ppi,
- PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleSize,
- Buffer
- );
- } else {
- Status = BlockIoPpi->ReadBlocks (
- PeiServices,
- BlockIoPpi,
- PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleSize,
- Buffer
- );
- }
- return Status;
-}
-
-/**
- This function compares two ASCII strings in case sensitive/insensitive way.
-
- @param Source1 The first string.
- @param Source2 The second string.
- @param Size The maximum comparison length.
- @param CaseSensitive Flag to indicate whether the comparison is case sensitive.
-
- @retval TRUE The two strings are the same.
- @retval FALSE The two string are not the same.
-
-**/
-BOOLEAN
-StringCmp (
- IN UINT8 *Source1,
- IN UINT8 *Source2,
- IN UINTN Size,
- IN BOOLEAN CaseSensitive
- )
-{
- UINTN Index;
- UINT8 Dif;
-
- for (Index = 0; Index < Size; Index++) {
- if (Source1[Index] == Source2[Index]) {
- continue;
- }
-
- if (!CaseSensitive) {
- Dif = (UINT8) ((Source1[Index] > Source2[Index]) ? (Source1[Index] - Source2[Index]) : (Source2[Index] - Source1[Index]));
- if (Dif == ('a' - 'A')) {
- continue;
- }
- }
-
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h
deleted file mode 100644
index 5ca26722a7..0000000000
--- a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/** @file
- Header file for CD recovery PEIM
-
-Copyright (c) 2006 - 2015, 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
-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.
-
-**/
-
-#ifndef _PEI_CD_EXPRESS_H_
-#define _PEI_CD_EXPRESS_H_
-
-
-#include <PiPei.h>
-
-#include <Ppi/BlockIo.h>
-#include <Ppi/BlockIo2.h>
-#include <Guid/RecoveryDevice.h>
-#include <Ppi/DeviceRecoveryModule.h>
-
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PeimEntryPoint.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PeiServicesTablePointerLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-
-#pragma pack(1)
-
-#define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8
-#define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16
-
-#define PEI_CD_BLOCK_SIZE 0x800
-#define PEI_MEMMORY_PAGE_SIZE 0x1000
-
-//
-// Recovery file name (in root directory)
-//
-#define PEI_RECOVERY_FILE_NAME "FVMAIN.FV"
-
-//
-// Following are defined according to ISO-9660 specification
-//
-#define PEI_CD_STANDARD_ID "CD001"
-#define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5
-
-#define PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET 0
-#define PEI_CD_EXPRESS_STANDARD_ID_OFFSET 1
-#define PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET 80
-#define PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET 156
-
-#define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1
-#define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255
-
-#define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02
-
-typedef struct {
- UINTN CapsuleStartLBA;
- UINTN CapsuleSize;
- UINTN IndexBlock;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2;
-} PEI_CD_EXPRESS_CAPSULE_DATA;
-
-#define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')
-
-typedef struct {
-
- UINTN Signature;
- EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi;
- EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
- EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;
- EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor2;
-
- UINT8 *BlockBuffer;
- UINTN CapsuleCount;
- PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER];
-
-} PEI_CD_EXPRESS_PRIVATE_DATA;
-
-#define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \
- CR (a, \
- PEI_CD_EXPRESS_PRIVATE_DATA, \
- DeviceRecoveryPpi, \
- PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \
- )
-
-typedef struct {
- UINT8 Length;
- UINT8 ExtendedAttributeRecordLength;
- UINT32 LocationOfExtent[2];
- UINT32 DataLength[2];
- UINT8 DateTime[7];
- UINT8 Flag;
- UINT8 FileUnitSize;
- UINT8 InterleaveGapSize;
- UINT32 VolumeSequenceNumber;
- UINT8 FileIDLength;
- UINT8 FileID[1];
-} PEI_CD_EXPRESS_DIR_FILE_RECORD;
-
-/**
- BlockIo installation notification function.
-
- This function finds out all the current Block IO PPIs in the system and add them
- into private data.
-
- @param PeiServices Indirect reference to the PEI Services Table.
- @param NotifyDescriptor Address of the notification descriptor data structure.
- @param Ppi Address of the PPI that was installed.
-
- @retval EFI_SUCCESS The function completes successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-BlockIoNotifyEntry (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
- IN VOID *Ppi
- );
-
-/**
- Finds out all the current Block IO PPIs in the system and add them into private data.
-
- @param PrivateData The private data structure that contains recovery module information.
- @param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo.
-
- @retval EFI_SUCCESS The blocks and volumes are updated successfully.
-
-**/
-EFI_STATUS
-UpdateBlocksAndVolumes (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN BOOLEAN BlockIo2
- );
-
-/**
- Returns the number of DXE capsules residing on the device.
-
- This function searches for DXE capsules from the associated device and returns
- the number and maximum size in bytes of the capsules discovered. Entry 1 is
- assumed to be the highest load priority and entry N is assumed to be the lowest
- priority.
-
- @param[in] PeiServices General-purpose services that are available
- to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On
- output, *NumberRecoveryCapsules contains
- the number of recovery capsule images
- available for retrieval from this PEIM
- instance.
-
- @retval EFI_SUCCESS One or more capsules were discovered.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-GetNumberRecoveryCapsules (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- OUT UINTN *NumberRecoveryCapsules
- );
-
-/**
- Returns the size and type of the requested recovery capsule.
-
- This function gets the size and type of the capsule specified by CapsuleInstance.
-
- @param[in] PeiServices General-purpose services that are available to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[in] CapsuleInstance Specifies for which capsule instance to retrieve
- the information. This parameter must be between
- one and the value returned by GetNumberRecoveryCapsules()
- in NumberRecoveryCapsules.
- @param[out] Size A pointer to a caller-allocated UINTN in which
- the size of the requested recovery module is
- returned.
- @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which
- the type of the requested recovery capsule is
- returned. The semantic meaning of the value
- returned is defined by the implementation.
-
- @retval EFI_SUCCESS One or more capsules were discovered.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-GetRecoveryCapsuleInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT UINTN *Size,
- OUT EFI_GUID *CapsuleType
- );
-
-/**
- Loads a DXE capsule from some media into memory.
-
- This function, by whatever mechanism, retrieves a DXE capsule from some device
- and loads it into memory. Note that the published interface is device neutral.
-
- @param[in] PeiServices General-purpose services that are available
- to every PEIM
- @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
- instance.
- @param[in] CapsuleInstance Specifies which capsule instance to retrieve.
- @param[out] Buffer Specifies a caller-allocated buffer in which
- the requested recovery capsule will be returned.
-
- @retval EFI_SUCCESS The capsule was loaded correctly.
- @retval EFI_DEVICE_ERROR A device error occurred.
- @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.
-
-**/
-EFI_STATUS
-EFIAPI
-LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT VOID *Buffer
- );
-
-/**
- Finds out the recovery capsule in the current volume.
-
- @param PrivateData The private data structure that contains recovery module information.
-
- @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
- @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
-
-**/
-EFI_STATUS
-EFIAPI
-FindRecoveryCapsules (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
- );
-
-/**
- Retrieves the recovery capsule in root directory of the current volume.
-
- @param PrivateData The private data structure that contains recovery module information.
- @param BlockIoPpi The Block IO PPI used to access the volume.
- @param BlockIo2Ppi The Block IO 2 PPI used to access the volume.
- @param IndexBlockDevice The index of current block device.
- @param Lba The starting logic block address to retrieve capsule.
-
- @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
- @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
- @retval Others
-
-**/
-EFI_STATUS
-EFIAPI
-RetrieveCapsuleFileFromRoot (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi,
- IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2Ppi,
- IN UINTN IndexBlockDevice,
- IN UINT32 Lba
- );
-
-
-/**
- This function compares two ASCII strings in case sensitive/insensitive way.
-
- @param Source1 The first string.
- @param Source2 The second string.
- @param Size The maximum comparison length.
- @param CaseSensitive Flag to indicate whether the comparison is case sensitive.
-
- @retval TRUE The two strings are the same.
- @retval FALSE The two string are not the same.
-
-**/
-BOOLEAN
-StringCmp (
- IN UINT8 *Source1,
- IN UINT8 *Source2,
- IN UINTN Size,
- IN BOOLEAN CaseSensitive
- );
-
-#pragma pack()
-
-#endif
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c
deleted file mode 100644
index 8c3db5e725..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/** @file
- UEFI Component Name(2) protocol implementation for DiskIo driver.
-
-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
-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 "DiskIo.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName = {
- DiskIoComponentNameGetDriverName,
- DiskIoComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DiskIoComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DiskIoComponentNameGetControllerName,
- "en"
-};
-
-//
-// Driver name table for DiskIo module.
-// It is shared by the implementation of ComponentName & ComponentName2 Protocol.
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDiskIoDriverNameTable[] = {
- {
- "eng;en",
- (CHAR16 *)L"Generic Disk I/O Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDiskIoDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gDiskIoComponentName)
- );
-}
-
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
deleted file mode 100644
index 0f0dbfee82..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
+++ /dev/null
@@ -1,1276 +0,0 @@
-/** @file
- DiskIo driver that lays on every BlockIo protocol in the system.
- DiskIo converts a block oriented device to a byte oriented device.
-
- Disk access may have to handle unaligned request about sector boundaries.
- There are three cases:
- UnderRun - The first byte is not on a sector boundary or the read request is
- less than a sector in length.
- Aligned - A read of N contiguous sectors.
- OverRun - The last byte is not on a sector boundary.
-
-Copyright (c) 2006 - 2014, 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
-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 "DiskIo.h"
-
-//
-// Driver binding protocol implementation for DiskIo driver.
-//
-EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
- DiskIoDriverBindingSupported,
- DiskIoDriverBindingStart,
- DiskIoDriverBindingStop,
- 0xa,
- NULL,
- NULL
-};
-
-//
-// Template for DiskIo private data structure.
-// The pointer to BlockIo protocol interface is assigned dynamically.
-//
-DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
- DISK_IO_PRIVATE_DATA_SIGNATURE,
- {
- EFI_DISK_IO_PROTOCOL_REVISION,
- DiskIoReadDisk,
- DiskIoWriteDisk
- },
- {
- EFI_DISK_IO2_PROTOCOL_REVISION,
- DiskIo2Cancel,
- DiskIo2ReadDiskEx,
- DiskIo2WriteDiskEx,
- DiskIo2FlushDiskEx
- }
-};
-
-/**
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to test
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the I/O Abstraction(s) used to perform the supported test.
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- return EFI_SUCCESS;
-}
-
-
-/**
- Start this driver on ControllerHandle by opening a Block IO protocol and
- installing a Disk IO protocol on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to bind driver to
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to ControllerHandle
- @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- DISK_IO_PRIVATE_DATA *Instance;
- EFI_TPL OldTpl;
-
- Instance = NULL;
-
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
-
- //
- // Connect to the Block IO and Block IO2 interface on ControllerHandle.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &gDiskIoPrivateDataTemplate.BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- goto ErrorExit1;
- }
-
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIo2ProtocolGuid,
- (VOID **) &gDiskIoPrivateDataTemplate.BlockIo2,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- gDiskIoPrivateDataTemplate.BlockIo2 = NULL;
- }
-
- //
- // Initialize the Disk IO device instance.
- //
- Instance = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate);
- if (Instance == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
-
- //
- // The BlockSize and IoAlign of BlockIo and BlockIo2 should equal.
- //
- ASSERT ((Instance->BlockIo2 == NULL) ||
- ((Instance->BlockIo->Media->IoAlign == Instance->BlockIo2->Media->IoAlign) &&
- (Instance->BlockIo->Media->BlockSize == Instance->BlockIo2->Media->BlockSize)
- ));
-
- InitializeListHead (&Instance->TaskQueue);
- EfiInitializeLock (&Instance->TaskQueueLock, TPL_NOTIFY);
- Instance->SharedWorkingBuffer = AllocateAlignedPages (
- EFI_SIZE_TO_PAGES (PcdGet32 (PcdDiskIoDataBufferBlockNum) * Instance->BlockIo->Media->BlockSize),
- Instance->BlockIo->Media->IoAlign
- );
- if (Instance->SharedWorkingBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
-
- //
- // Install protocol interfaces for the Disk IO device.
- //
- if (Instance->BlockIo2 != NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2,
- NULL
- );
- } else {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- NULL
- );
- }
-
-ErrorExit:
- if (EFI_ERROR (Status)) {
- if (Instance != NULL && Instance->SharedWorkingBuffer != NULL) {
- FreeAlignedPages (
- Instance->SharedWorkingBuffer,
- EFI_SIZE_TO_PAGES (PcdGet32 (PcdDiskIoDataBufferBlockNum) * Instance->BlockIo->Media->BlockSize)
- );
- }
-
- if (Instance != NULL) {
- FreePool (Instance);
- }
-
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- }
-
-ErrorExit1:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle by removing Disk IO protocol and closing
- the Block IO protocol on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed ControllerHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_DISK_IO2_PROTOCOL *DiskIo2;
- DISK_IO_PRIVATE_DATA *Instance;
- BOOLEAN AllTaskDone;
-
- //
- // Get our context back.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIo2ProtocolGuid,
- (VOID **) &DiskIo2,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- DiskIo2 = NULL;
- }
-
- Instance = DISK_IO_PRIVATE_DATA_FROM_DISK_IO (DiskIo);
-
- if (DiskIo2 != NULL) {
- //
- // Call BlockIo2::Reset() to terminate any in-flight non-blocking I/O requests
- //
- ASSERT (Instance->BlockIo2 != NULL);
- Status = Instance->BlockIo2->Reset (Instance->BlockIo2, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2,
- NULL
- );
- } else {
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- NULL
- );
- }
- if (!EFI_ERROR (Status)) {
-
- do {
- EfiAcquireLock (&Instance->TaskQueueLock);
- AllTaskDone = IsListEmpty (&Instance->TaskQueue);
- EfiReleaseLock (&Instance->TaskQueueLock);
- } while (!AllTaskDone);
-
- FreeAlignedPages (
- Instance->SharedWorkingBuffer,
- EFI_SIZE_TO_PAGES (PcdGet32 (PcdDiskIoDataBufferBlockNum) * Instance->BlockIo->Media->BlockSize)
- );
-
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- ASSERT_EFI_ERROR (Status);
- if (DiskIo2 != NULL) {
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIo2ProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- ASSERT_EFI_ERROR (Status);
- }
-
- FreePool (Instance);
- }
-
- return Status;
-}
-
-
-/**
- Destroy the sub task.
-
- @param Instance Pointer to the DISK_IO_PRIVATE_DATA.
- @param Subtask Subtask.
-
- @return LIST_ENTRY * Pointer to the next link of subtask.
-**/
-LIST_ENTRY *
-DiskIoDestroySubtask (
- IN DISK_IO_PRIVATE_DATA *Instance,
- IN DISK_IO_SUBTASK *Subtask
- )
-{
- LIST_ENTRY *Link;
-
- if (Subtask->Task != NULL) {
- EfiAcquireLock (&Subtask->Task->SubtasksLock);
- }
- Link = RemoveEntryList (&Subtask->Link);
- if (Subtask->Task != NULL) {
- EfiReleaseLock (&Subtask->Task->SubtasksLock);
- }
-
- if (!Subtask->Blocking) {
- if (Subtask->WorkingBuffer != NULL) {
- FreeAlignedPages (
- Subtask->WorkingBuffer,
- Subtask->Length < Instance->BlockIo->Media->BlockSize
- ? EFI_SIZE_TO_PAGES (Instance->BlockIo->Media->BlockSize)
- : EFI_SIZE_TO_PAGES (Subtask->Length)
- );
- }
- if (Subtask->BlockIo2Token.Event != NULL) {
- gBS->CloseEvent (Subtask->BlockIo2Token.Event);
- }
- }
- FreePool (Subtask);
-
- return Link;
-}
-
-/**
- The callback for the BlockIo2 ReadBlocksEx/WriteBlocksEx.
- @param Event Event whose notification function is being invoked.
- @param Context The pointer to the notification function's context,
- which points to the DISK_IO_SUBTASK instance.
-**/
-VOID
-EFIAPI
-DiskIo2OnReadWriteComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- DISK_IO_SUBTASK *Subtask;
- DISK_IO2_TASK *Task;
- EFI_STATUS TransactionStatus;
- DISK_IO_PRIVATE_DATA *Instance;
-
- Subtask = (DISK_IO_SUBTASK *) Context;
- TransactionStatus = Subtask->BlockIo2Token.TransactionStatus;
- Task = Subtask->Task;
- Instance = Task->Instance;
-
- ASSERT (Subtask->Signature == DISK_IO_SUBTASK_SIGNATURE);
- ASSERT (Instance->Signature == DISK_IO_PRIVATE_DATA_SIGNATURE);
- ASSERT (Task->Signature == DISK_IO2_TASK_SIGNATURE);
-
- if ((Subtask->WorkingBuffer != NULL) && !EFI_ERROR (TransactionStatus) &&
- (Task->Token != NULL) && !Subtask->Write
- ) {
- CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);
- }
-
- DiskIoDestroySubtask (Instance, Subtask);
-
- if (EFI_ERROR (TransactionStatus) || IsListEmpty (&Task->Subtasks)) {
- if (Task->Token != NULL) {
- //
- // Signal error status once the subtask is failed.
- // Or signal the last status once the last subtask is finished.
- //
- Task->Token->TransactionStatus = TransactionStatus;
- gBS->SignalEvent (Task->Token->Event);
-
- //
- // Mark token to NULL indicating the Task is a dead task.
- //
- Task->Token = NULL;
- }
- }
-}
-
-/**
- Create the subtask.
-
- @param Write TRUE: Write request; FALSE: Read request.
- @param Lba The starting logical block address to read from on the device.
- @param Offset The starting byte offset to read from the LBA.
- @param Length The number of bytes to read from the device.
- @param WorkingBuffer The aligned buffer to hold the data for reading or writing.
- @param Buffer The buffer to hold the data for reading or writing.
- @param Blocking TRUE: Blocking request; FALSE: Non-blocking request.
-
- @return A pointer to the created subtask.
-**/
-DISK_IO_SUBTASK *
-DiskIoCreateSubtask (
- IN BOOLEAN Write,
- IN UINT64 Lba,
- IN UINT32 Offset,
- IN UINTN Length,
- IN VOID *WorkingBuffer, OPTIONAL
- IN VOID *Buffer,
- IN BOOLEAN Blocking
- )
-{
- DISK_IO_SUBTASK *Subtask;
- EFI_STATUS Status;
-
- Subtask = AllocateZeroPool (sizeof (DISK_IO_SUBTASK));
- if (Subtask == NULL) {
- return NULL;
- }
- Subtask->Signature = DISK_IO_SUBTASK_SIGNATURE;
- Subtask->Write = Write;
- Subtask->Lba = Lba;
- Subtask->Offset = Offset;
- Subtask->Length = Length;
- Subtask->WorkingBuffer = WorkingBuffer;
- Subtask->Buffer = Buffer;
- Subtask->Blocking = Blocking;
- if (!Blocking) {
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- DiskIo2OnReadWriteComplete,
- Subtask,
- &Subtask->BlockIo2Token.Event
- );
- if (EFI_ERROR (Status)) {
- FreePool (Subtask);
- return NULL;
- }
- }
- DEBUG ((
- EFI_D_BLKIO,
- " %c:Lba/Offset/Length/WorkingBuffer/Buffer = %016lx/%08x/%08x/%08x/%08x\n",
- Write ? 'W': 'R', Lba, Offset, Length, WorkingBuffer, Buffer
- ));
-
- return Subtask;
-}
-
-/**
- Create the subtask list.
-
- @param Instance Pointer to the DISK_IO_PRIVATE_DATA.
- @param Write TRUE: Write request; FALSE: Read request.
- @param Offset The starting byte offset to read from the device.
- @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
- @param Buffer A pointer to the buffer for the data.
- @param Blocking TRUE: Blocking request; FALSE: Non-blocking request.
- @param SharedWorkingBuffer The aligned buffer to hold the data for reading or writing.
- @param Subtasks The subtask list header.
-
- @retval TRUE The subtask list is created successfully.
- @retval FALSE The subtask list is not created.
-**/
-BOOLEAN
-DiskIoCreateSubtaskList (
- IN DISK_IO_PRIVATE_DATA *Instance,
- IN BOOLEAN Write,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- IN VOID *Buffer,
- IN BOOLEAN Blocking,
- IN VOID *SharedWorkingBuffer,
- IN OUT LIST_ENTRY *Subtasks
- )
-{
- UINT32 BlockSize;
- UINT32 IoAlign;
- UINT64 Lba;
- UINT64 OverRunLba;
- UINT32 UnderRun;
- UINT32 OverRun;
- UINT8 *BufferPtr;
- UINTN Length;
- UINTN DataBufferSize;
- DISK_IO_SUBTASK *Subtask;
- VOID *WorkingBuffer;
- LIST_ENTRY *Link;
-
- DEBUG ((EFI_D_BLKIO, "DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = %016lx/%08x/%08x\n", Offset, BufferSize, Buffer));
-
- BlockSize = Instance->BlockIo->Media->BlockSize;
- IoAlign = Instance->BlockIo->Media->IoAlign;
- if (IoAlign == 0) {
- IoAlign = 1;
- }
-
- Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
- BufferPtr = (UINT8 *) Buffer;
-
- //
- // Special handling for zero BufferSize
- //
- if (BufferSize == 0) {
- Subtask = DiskIoCreateSubtask (Write, Lba, UnderRun, 0, NULL, BufferPtr, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
- return TRUE;
- }
-
- if (UnderRun != 0) {
- Length = MIN (BlockSize - UnderRun, BufferSize);
- if (Blocking) {
- WorkingBuffer = SharedWorkingBuffer;
- } else {
- WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BlockSize), IoAlign);
- if (WorkingBuffer == NULL) {
- goto Done;
- }
- }
- if (Write) {
- //
- // A half write operation can be splitted to a blocking block-read and half write operation
- // This can simplify the sub task processing logic
- //
- Subtask = DiskIoCreateSubtask (FALSE, Lba, 0, BlockSize, NULL, WorkingBuffer, TRUE);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
- }
-
- Subtask = DiskIoCreateSubtask (Write, Lba, UnderRun, Length, WorkingBuffer, BufferPtr, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
-
- BufferPtr += Length;
- Offset += Length;
- BufferSize -= Length;
- Lba ++;
- }
-
- OverRunLba = Lba + DivU64x32Remainder (BufferSize, BlockSize, &OverRun);
- BufferSize -= OverRun;
-
- if (OverRun != 0) {
- if (Blocking) {
- WorkingBuffer = SharedWorkingBuffer;
- } else {
- WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BlockSize), IoAlign);
- if (WorkingBuffer == NULL) {
- goto Done;
- }
- }
- if (Write) {
- //
- // A half write operation can be splitted to a blocking block-read and half write operation
- // This can simplify the sub task processing logic
- //
- Subtask = DiskIoCreateSubtask (FALSE, OverRunLba, 0, BlockSize, NULL, WorkingBuffer, TRUE);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
- }
-
- Subtask = DiskIoCreateSubtask (Write, OverRunLba, 0, OverRun, WorkingBuffer, BufferPtr + BufferSize, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
- }
-
- if (OverRunLba > Lba) {
- //
- // If the DiskIo maps directly to a BlockIo device do the read.
- //
- if (ALIGN_POINTER (BufferPtr, IoAlign) == BufferPtr) {
- Subtask = DiskIoCreateSubtask (Write, Lba, 0, BufferSize, NULL, BufferPtr, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
-
- BufferPtr += BufferSize;
- Offset += BufferSize;
- BufferSize -= BufferSize;
-
- } else {
- if (Blocking) {
- //
- // Use the allocated buffer instead of the original buffer
- // to avoid alignment issue.
- //
- for (; Lba < OverRunLba; Lba += PcdGet32 (PcdDiskIoDataBufferBlockNum)) {
- DataBufferSize = MIN (BufferSize, PcdGet32 (PcdDiskIoDataBufferBlockNum) * BlockSize);
-
- Subtask = DiskIoCreateSubtask (Write, Lba, 0, DataBufferSize, SharedWorkingBuffer, BufferPtr, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
-
- BufferPtr += DataBufferSize;
- Offset += DataBufferSize;
- BufferSize -= DataBufferSize;
- }
- } else {
- WorkingBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), IoAlign);
- if (WorkingBuffer == NULL) {
- //
- // If there is not enough memory, downgrade to blocking access
- //
- DEBUG ((EFI_D_VERBOSE, "DiskIo: No enough memory so downgrade to blocking access\n"));
- if (!DiskIoCreateSubtaskList (Instance, Write, Offset, BufferSize, BufferPtr, TRUE, SharedWorkingBuffer, Subtasks)) {
- goto Done;
- }
- } else {
- Subtask = DiskIoCreateSubtask (Write, Lba, 0, BufferSize, WorkingBuffer, BufferPtr, Blocking);
- if (Subtask == NULL) {
- goto Done;
- }
- InsertTailList (Subtasks, &Subtask->Link);
- }
-
- BufferPtr += BufferSize;
- Offset += BufferSize;
- BufferSize -= BufferSize;
- }
- }
- }
-
- ASSERT (BufferSize == 0);
-
- return TRUE;
-
-Done:
- //
- // Remove all the subtasks.
- //
- for (Link = GetFirstNode (Subtasks); !IsNull (Subtasks, Link); ) {
- Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
- Link = DiskIoDestroySubtask (Instance, Subtask);
- }
- return FALSE;
-}
-
-/**
- Terminate outstanding asynchronous requests to a device.
-
- @param This Indicates a pointer to the calling context.
-
- @retval EFI_SUCCESS All outstanding requests were successfully terminated.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel
- operation.
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2Cancel (
- IN EFI_DISK_IO2_PROTOCOL *This
- )
-{
- DISK_IO_PRIVATE_DATA *Instance;
- DISK_IO2_TASK *Task;
- LIST_ENTRY *Link;
-
- Instance = DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This);
-
- EfiAcquireLock (&Instance->TaskQueueLock);
-
- for (Link = GetFirstNode (&Instance->TaskQueue)
- ; !IsNull (&Instance->TaskQueue, Link)
- ; Link = GetNextNode (&Instance->TaskQueue, Link)
- ) {
- Task = CR (Link, DISK_IO2_TASK, Link, DISK_IO2_TASK_SIGNATURE);
-
- if (Task->Token != NULL) {
- Task->Token->TransactionStatus = EFI_ABORTED;
- gBS->SignalEvent (Task->Token->Event);
- //
- // Set Token to NULL so that the further BlockIo2 responses will be ignored
- //
- Task->Token = NULL;
- }
- }
-
- EfiReleaseLock (&Instance->TaskQueueLock);
-
- return EFI_SUCCESS;
-}
-
-/**
- Remove the completed tasks from Instance->TaskQueue. Completed tasks are those who don't have any subtasks.
-
- @param Instance Pointer to the DISK_IO_PRIVATE_DATA.
-
- @retval TRUE The Instance->TaskQueue is empty after the completed tasks are removed.
- @retval FALSE The Instance->TaskQueue is not empty after the completed tasks are removed.
-**/
-BOOLEAN
-DiskIo2RemoveCompletedTask (
- IN DISK_IO_PRIVATE_DATA *Instance
- )
-{
- BOOLEAN QueueEmpty;
- LIST_ENTRY *Link;
- DISK_IO2_TASK *Task;
-
- QueueEmpty = TRUE;
-
- EfiAcquireLock (&Instance->TaskQueueLock);
- for (Link = GetFirstNode (&Instance->TaskQueue); !IsNull (&Instance->TaskQueue, Link); ) {
- Task = CR (Link, DISK_IO2_TASK, Link, DISK_IO2_TASK_SIGNATURE);
- if (IsListEmpty (&Task->Subtasks)) {
- Link = RemoveEntryList (&Task->Link);
- ASSERT (Task->Token == NULL);
- FreePool (Task);
- } else {
- Link = GetNextNode (&Instance->TaskQueue, Link);
- QueueEmpty = FALSE;
- }
- }
- EfiReleaseLock (&Instance->TaskQueueLock);
-
- return QueueEmpty;
-}
-
-/**
- Common routine to access the disk.
-
- @param Instance Pointer to the DISK_IO_PRIVATE_DATA.
- @param Write TRUE: Write operation; FALSE: Read operation.
- @param MediaId ID of the medium to access.
- @param Offset The starting byte offset on the logical block I/O device to access.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
- @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
- @param Buffer A pointer to the destination buffer for the data.
- The caller is responsible either having implicit or explicit ownership of the buffer.
-**/
-EFI_STATUS
-DiskIo2ReadWriteDisk (
- IN DISK_IO_PRIVATE_DATA *Instance,
- IN BOOLEAN Write,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN EFI_DISK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- IN UINT8 *Buffer
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- EFI_BLOCK_IO_MEDIA *Media;
- LIST_ENTRY *Link;
- LIST_ENTRY *NextLink;
- LIST_ENTRY Subtasks;
- DISK_IO_SUBTASK *Subtask;
- DISK_IO2_TASK *Task;
- EFI_TPL OldTpl;
- BOOLEAN Blocking;
- BOOLEAN SubtaskBlocking;
- LIST_ENTRY *SubtasksPtr;
-
- Task = NULL;
- BlockIo = Instance->BlockIo;
- BlockIo2 = Instance->BlockIo2;
- Media = BlockIo->Media;
- Status = EFI_SUCCESS;
- Blocking = (BOOLEAN) ((Token == NULL) || (Token->Event == NULL));
-
- if (Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- if (Write && Media->ReadOnly) {
- return EFI_WRITE_PROTECTED;
- }
-
- if (Blocking) {
- //
- // Wait till pending async task is completed.
- //
- while (!DiskIo2RemoveCompletedTask (Instance));
-
- SubtasksPtr = &Subtasks;
- } else {
- DiskIo2RemoveCompletedTask (Instance);
- Task = AllocatePool (sizeof (DISK_IO2_TASK));
- if (Task == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- EfiAcquireLock (&Instance->TaskQueueLock);
- InsertTailList (&Instance->TaskQueue, &Task->Link);
- EfiReleaseLock (&Instance->TaskQueueLock);
-
- Task->Signature = DISK_IO2_TASK_SIGNATURE;
- Task->Instance = Instance;
- Task->Token = Token;
- EfiInitializeLock (&Task->SubtasksLock, TPL_NOTIFY);
-
- SubtasksPtr = &Task->Subtasks;
- }
-
- InitializeListHead (SubtasksPtr);
- if (!DiskIoCreateSubtaskList (Instance, Write, Offset, BufferSize, Buffer, Blocking, Instance->SharedWorkingBuffer, SubtasksPtr)) {
- if (Task != NULL) {
- FreePool (Task);
- }
- return EFI_OUT_OF_RESOURCES;
- }
- ASSERT (!IsListEmpty (SubtasksPtr));
-
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- for ( Link = GetFirstNode (SubtasksPtr), NextLink = GetNextNode (SubtasksPtr, Link)
- ; !IsNull (SubtasksPtr, Link)
- ; Link = NextLink, NextLink = GetNextNode (SubtasksPtr, NextLink)
- ) {
- Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
- Subtask->Task = Task;
- SubtaskBlocking = Subtask->Blocking;
-
- ASSERT ((Subtask->Length % Media->BlockSize == 0) || (Subtask->Length < Media->BlockSize));
-
- if (Subtask->Write) {
- //
- // Write
- //
- if (Subtask->WorkingBuffer != NULL) {
- //
- // A sub task before this one should be a block read operation, causing the WorkingBuffer filled with the entire one block data.
- //
- CopyMem (Subtask->WorkingBuffer + Subtask->Offset, Subtask->Buffer, Subtask->Length);
- }
-
- if (SubtaskBlocking) {
- Status = BlockIo->WriteBlocks (
- BlockIo,
- MediaId,
- Subtask->Lba,
- (Subtask->Length % Media->BlockSize == 0) ? Subtask->Length : Media->BlockSize,
- (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer
- );
- } else {
- Status = BlockIo2->WriteBlocksEx (
- BlockIo2,
- MediaId,
- Subtask->Lba,
- &Subtask->BlockIo2Token,
- (Subtask->Length % Media->BlockSize == 0) ? Subtask->Length : Media->BlockSize,
- (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer
- );
- }
-
- } else {
- //
- // Read
- //
- if (SubtaskBlocking) {
- Status = BlockIo->ReadBlocks (
- BlockIo,
- MediaId,
- Subtask->Lba,
- (Subtask->Length % Media->BlockSize == 0) ? Subtask->Length : Media->BlockSize,
- (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer
- );
- if (!EFI_ERROR (Status) && (Subtask->WorkingBuffer != NULL)) {
- CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);
- }
- } else {
- Status = BlockIo2->ReadBlocksEx (
- BlockIo2,
- MediaId,
- Subtask->Lba,
- &Subtask->BlockIo2Token,
- (Subtask->Length % Media->BlockSize == 0) ? Subtask->Length : Media->BlockSize,
- (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer
- );
- }
- }
-
- if (SubtaskBlocking || EFI_ERROR (Status)) {
- //
- // Make sure the subtask list only contains non-blocking subtasks.
- // Remove failed non-blocking subtasks as well because the callback won't be called.
- //
- DiskIoDestroySubtask (Instance, Subtask);
- }
-
- if (EFI_ERROR (Status)) {
- break;
- }
- }
-
- gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Remove all the remaining subtasks when failure.
- // We shouldn't remove all the tasks because the non-blocking requests have been submitted and cannot be canceled.
- //
- if (EFI_ERROR (Status)) {
- while (!IsNull (SubtasksPtr, NextLink)) {
- Subtask = CR (NextLink, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
- NextLink = DiskIoDestroySubtask (Instance, Subtask);
- }
- }
-
- //
- // It's possible that the non-blocking subtasks finish before raising TPL to NOTIFY,
- // so the subtasks list might be empty at this point.
- //
- if (!Blocking && IsListEmpty (SubtasksPtr)) {
- EfiAcquireLock (&Instance->TaskQueueLock);
- RemoveEntryList (&Task->Link);
- EfiReleaseLock (&Instance->TaskQueueLock);
-
- if (!EFI_ERROR (Status) && (Task->Token != NULL)) {
- //
- // Task->Token should be set to NULL by the DiskIo2OnReadWriteComplete
- // It it's not, that means the non-blocking request was downgraded to blocking request.
- //
- DEBUG ((EFI_D_VERBOSE, "DiskIo: Non-blocking request was downgraded to blocking request, signal event directly.\n"));
- Task->Token->TransactionStatus = Status;
- gBS->SignalEvent (Task->Token->Event);
- }
-
- FreePool (Task);
- }
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-/**
- Reads a specified number of bytes from a device.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to be read.
- @param Offset The starting byte offset on the logical block I/O device to read from.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
- @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
- @param Buffer A pointer to the destination buffer for the data.
- The caller is responsible either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2ReadDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN OUT EFI_DISK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- return DiskIo2ReadWriteDisk (
- DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This),
- FALSE, MediaId, Offset, Token, BufferSize, (UINT8 *) Buffer
- );
-}
-
-/**
- Writes a specified number of bytes to a device.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to be written.
- @param Offset The starting byte offset on the logical block I/O device to write to.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
- @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
- @param Buffer A pointer to the buffer containing the data to be written.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
- @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2WriteDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN OUT EFI_DISK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- return DiskIo2ReadWriteDisk (
- DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This),
- TRUE, MediaId, Offset, Token, BufferSize, (UINT8 *) Buffer
- );
-}
-
-/**
- The callback for the BlockIo2 FlushBlocksEx.
- @param Event Event whose notification function is being invoked.
- @param Context The pointer to the notification function's context,
- which points to the DISK_IO2_FLUSH_TASK instance.
-**/
-VOID
-EFIAPI
-DiskIo2OnFlushComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- DISK_IO2_FLUSH_TASK *Task;
-
- gBS->CloseEvent (Event);
-
- Task = (DISK_IO2_FLUSH_TASK *) Context;
- ASSERT (Task->Signature == DISK_IO2_FLUSH_TASK_SIGNATURE);
- Task->Token->TransactionStatus = Task->BlockIo2Token.TransactionStatus;
- gBS->SignalEvent (Task->Token->Event);
-
- FreePool (Task);
-}
-
-/**
- Flushes all modified data to the physical device.
-
- @param This Indicates a pointer to the calling context.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2FlushDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN OUT EFI_DISK_IO2_TOKEN *Token
- )
-{
- EFI_STATUS Status;
- DISK_IO2_FLUSH_TASK *Task;
- DISK_IO_PRIVATE_DATA *Private;
-
- Private = DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This);
-
- if ((Token != NULL) && (Token->Event != NULL)) {
- Task = AllocatePool (sizeof (DISK_IO2_FLUSH_TASK));
- if (Task == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DiskIo2OnFlushComplete,
- Task,
- &Task->BlockIo2Token.Event
- );
- if (EFI_ERROR (Status)) {
- FreePool (Task);
- return Status;
- }
- Task->Signature = DISK_IO2_FLUSH_TASK_SIGNATURE;
- Task->Token = Token;
- Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, &Task->BlockIo2Token);
- if (EFI_ERROR (Status)) {
- gBS->CloseEvent (Task->BlockIo2Token.Event);
- FreePool (Task);
- }
- } else {
- Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, NULL);
- }
-
- return Status;
-}
-
-/**
- Read BufferSize bytes from Offset into Buffer.
- Reads may support reads that are not aligned on
- sector boundaries. There are three cases:
- UnderRun - The first byte is not on a sector boundary or the read request is
- less than a sector in length.
- Aligned - A read of N contiguous sectors.
- OverRun - The last byte is not on a sector boundary.
-
- @param This Protocol instance pointer.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Offset The starting byte offset to read from
- @param BufferSize Size of Buffer
- @param Buffer Buffer containing read data
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoReadDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- return DiskIo2ReadWriteDisk (
- DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This),
- FALSE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer
- );
-}
-
-
-/**
- Writes BufferSize bytes from Buffer into Offset.
- Writes may require a read modify write to support writes that are not
- aligned on sector boundaries. There are three cases:
- UnderRun - The first byte is not on a sector boundary or the write request
- is less than a sector in length. Read modify write is required.
- Aligned - A write of N contiguous sectors.
- OverRun - The last byte is not on a sector boundary. Read modified write
- required.
-
- @param This Protocol instance pointer.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Offset The starting byte offset to read from
- @param BufferSize Size of Buffer
- @param Buffer Buffer containing read data
-
- @retval EFI_SUCCESS The data was written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoWriteDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- return DiskIo2ReadWriteDisk (
- DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This),
- TRUE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer
- );
-}
-
-/**
- The user Entry Point for module DiskIo. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeDiskIo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gDiskIoDriverBinding,
- ImageHandle,
- &gDiskIoComponentName,
- &gDiskIoComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
deleted file mode 100644
index 7591e469a1..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/** @file
- Master header file for DiskIo driver. It includes the module private defininitions.
-
-Copyright (c) 2006 - 2013, 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
-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.
-
-**/
-
-#ifndef _DISK_IO_H_
-#define _DISK_IO_H_
-
-#include <Uefi.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/BlockIo2.h>
-#include <Protocol/DiskIo2.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/DiskIo.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')
-typedef struct {
- UINT32 Signature;
-
- EFI_DISK_IO_PROTOCOL DiskIo;
- EFI_DISK_IO2_PROTOCOL DiskIo2;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
-
- UINT8 *SharedWorkingBuffer;
-
- EFI_LOCK TaskQueueLock;
- LIST_ENTRY TaskQueue;
-} DISK_IO_PRIVATE_DATA;
-#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)
-#define DISK_IO_PRIVATE_DATA_FROM_DISK_IO2(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo2, DISK_IO_PRIVATE_DATA_SIGNATURE)
-
-#define DISK_IO2_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'a', 't')
-typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link; /// < link to other task
- EFI_LOCK SubtasksLock;
- LIST_ENTRY Subtasks; /// < header of subtasks
- EFI_DISK_IO2_TOKEN *Token;
- DISK_IO_PRIVATE_DATA *Instance;
-} DISK_IO2_TASK;
-
-#define DISK_IO2_FLUSH_TASK_SIGNATURE SIGNATURE_32 ('d', 'i', 'f', 't')
-typedef struct {
- UINT32 Signature;
- EFI_BLOCK_IO2_TOKEN BlockIo2Token;
- EFI_DISK_IO2_TOKEN *Token;
-} DISK_IO2_FLUSH_TASK;
-
-#define DISK_IO_SUBTASK_SIGNATURE SIGNATURE_32 ('d', 'i', 's', 't')
-typedef struct {
- //
- // UnderRun: Offset != 0, Length < BlockSize
- // OverRun: Offset == 0, Length < BlockSize
- // Middle: Offset is block aligned, Length is multiple of block size
- //
- UINT32 Signature;
- LIST_ENTRY Link;
- BOOLEAN Write;
- UINT64 Lba;
- UINT32 Offset;
- UINTN Length;
- UINT8 *WorkingBuffer; /// < NULL indicates using "Buffer" directly
- UINT8 *Buffer;
- BOOLEAN Blocking;
-
- //
- // Following fields are for DiskIo2
- //
- DISK_IO2_TASK *Task;
- EFI_BLOCK_IO2_TOKEN BlockIo2Token;
-} DISK_IO_SUBTASK;
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2;
-
-//
-// Prototypes
-// Driver model protocol interface
-//
-/**
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to test
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Start this driver on ControllerHandle by opening a Block IO protocol and
- installing a Disk IO protocol on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to bind driver to
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to ControllerHandle
- @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Stop this driver on ControllerHandle by removing Disk IO protocol and closing
- the Block IO protocol on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed ControllerHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// Disk I/O Protocol Interface
-//
-/**
- Read BufferSize bytes from Offset into Buffer.
- Reads may support reads that are not aligned on
- sector boundaries. There are three cases:
- UnderRun - The first byte is not on a sector boundary or the read request is
- less than a sector in length.
- Aligned - A read of N contiguous sectors.
- OverRun - The last byte is not on a sector boundary.
-
- @param This Protocol instance pointer.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Offset The starting byte offset to read from
- @param BufferSize Size of Buffer
- @param Buffer Buffer containing read data
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoReadDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Writes BufferSize bytes from Buffer into Offset.
- Writes may require a read modify write to support writes that are not
- aligned on sector boundaries. There are three cases:
- UnderRun - The first byte is not on a sector boundary or the write request
- is less than a sector in length. Read modify write is required.
- Aligned - A write of N contiguous sectors.
- OverRun - The last byte is not on a sector boundary. Read modified write
- required.
-
- @param This Protocol instance pointer.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Offset The starting byte offset to read from
- @param BufferSize Size of Buffer
- @param Buffer Buffer containing read data
-
- @retval EFI_SUCCESS The data was written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoWriteDisk (
- IN EFI_DISK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-
-/**
- Terminate outstanding asynchronous requests to a device.
-
- @param This Indicates a pointer to the calling context.
-
- @retval EFI_SUCCESS All outstanding requests were successfully terminated.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel
- operation.
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2Cancel (
- IN EFI_DISK_IO2_PROTOCOL *This
- );
-
-/**
- Reads a specified number of bytes from a device.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to be read.
- @param Offset The starting byte offset on the logical block I/O device to read from.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
- @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
- @param Buffer A pointer to the destination buffer for the data.
- The caller is responsible either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2ReadDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN OUT EFI_DISK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Writes a specified number of bytes to a device.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to be written.
- @param Offset The starting byte offset on the logical block I/O device to write to.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
- @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
- @param Buffer A pointer to the buffer containing the data to be written.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
- @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2WriteDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Offset,
- IN EFI_DISK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Flushes all modified data to the physical device.
-
- @param This Indicates a pointer to the calling context.
- @param Token A pointer to the token associated with the transaction.
- If this field is NULL, synchronous/blocking IO is performed.
-
- @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.
- If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
- Event will be signaled upon completion.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
- @retval EFI_NO_MEDIA There is no medium in the device.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-DiskIo2FlushDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN OUT EFI_DISK_IO2_TOKEN *Token
- );
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-DiskIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-#endif
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
deleted file mode 100644
index cee27d5b11..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+++ /dev/null
@@ -1,71 +0,0 @@
-## @file
-# Module that lays Disk I/O protocol on every Block I/O protocol.
-#
-# This module produces Disk I/O protocol to abstract the block accesses
-# of the Block I/O protocol to a more general offset-length protocol
-# to provide byte-oriented access to block media. It adds this protocol
-# to any Block I/O interface that appears in the system that does not
-# already have a Disk I/O protocol. File systems and other disk access
-# code utilize the Disk I/O protocol.
-#
-# Copyright (c) 2006 - 2014, 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
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DiskIoDxe
- MODULE_UNI_FILE = DiskIoDxe.uni
- FILE_GUID = 6B38F7B4-AD98-40e9-9093-ACA2B5A253C4
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeDiskIo
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-# DRIVER_BINDING = gDiskIoDriverBinding
-# COMPONENT_NAME = gDiskIoComponentName
-# COMPONENT_NAME2 = gDiskIoComponentName2
-#
-
-[Sources]
- ComponentName.c
- DiskIo.h
- DiskIo.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- BaseLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
- PcdLib
-
-[Protocols]
- gEfiDiskIoProtocolGuid ## BY_START
- gEfiDiskIo2ProtocolGuid ## BY_START
- gEfiBlockIoProtocolGuid ## TO_START
- gEfiBlockIo2ProtocolGuid ## TO_START
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdDiskIoDataBufferBlockNum ## SOMETIMES_CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- DiskIoDxeExtra.uni
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.uni b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.uni
deleted file mode 100644
index 9fd078ac70..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxeExtra.uni b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxeExtra.uni
deleted file mode 100644
index 7a2a1b84e3..0000000000
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxeExtra.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c
deleted file mode 100644
index c917cd79e6..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/** @file
- UEFI Component Name protocol for Partition driver.
-
-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
-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"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName = {
- PartitionComponentNameGetDriverName,
- PartitionComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PartitionComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PartitionComponentNameGetControllerName,
- "en"
-};
-
-//
-// Driver name table for Partition module.
-// It is shared by the implementation of ComponentName & ComponentName2 Protocol.
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPartitionDriverNameTable[] = {
- {
- "eng;en",
- L"Partition Driver(MBR/GPT/El Torito)"
- },
- {
- NULL,
- NULL
- }
-};
-
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mPartitionDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gPartitionComponentName)
- );
-}
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
deleted file mode 100644
index 22384499c5..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/** @file
- Decode an El Torito formatted CD-ROM
-
-Copyright (c) 2006 - 2015, 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
-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"
-
-
-/**
- Install child handles if the Handle supports El Torito format.
-
- @param[in] This Calling context.
- @param[in] Handle Parent Handle.
- @param[in] DiskIo Parent DiskIo interface.
- @param[in] DiskIo2 Parent DiskIo2 interface.
- @param[in] BlockIo Parent BlockIo interface.
- @param[in] BlockIo2 Parent BlockIo2 interface.
- @param[in] DevicePath Parent Device Path
-
-
- @retval EFI_SUCCESS Child handle(s) was added.
- @retval EFI_MEDIA_CHANGED Media changed Detected.
- @retval other no child handle was added.
-
-**/
-EFI_STATUS
-PartitionInstallElToritoChildHandles (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- EFI_STATUS Status;
- UINT64 VolDescriptorOffset;
- UINT32 Lba2KB;
- EFI_BLOCK_IO_MEDIA *Media;
- CDROM_VOLUME_DESCRIPTOR *VolDescriptor;
- ELTORITO_CATALOG *Catalog;
- UINTN Check;
- UINTN Index;
- UINTN BootEntry;
- UINTN MaxIndex;
- UINT16 *CheckBuffer;
- CDROM_DEVICE_PATH CdDev;
- UINT32 SubBlockSize;
- UINT32 SectorCount;
- EFI_STATUS Found;
- UINT32 VolSpaceSize;
-
- Found = EFI_NOT_FOUND;
- Media = BlockIo->Media;
-
- VolSpaceSize = 0;
-
- //
- // CD_ROM has the fixed block size as 2048 bytes (SIZE_2KB)
- //
-
- // If the ISO image has been copied onto a different storage media
- // then the block size might be different (eg: USB).
- // Ensure 2048 (SIZE_2KB) is a multiple of block size
- if (((SIZE_2KB % Media->BlockSize) != 0) || (Media->BlockSize > SIZE_2KB)) {
- return EFI_NOT_FOUND;
- }
-
- VolDescriptor = AllocatePool ((UINTN)SIZE_2KB);
-
- if (VolDescriptor == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Catalog = (ELTORITO_CATALOG *) VolDescriptor;
-
- //
- // Loop: handle one volume descriptor per time
- // The ISO-9660 volume descriptor starts at 32k on the media
- //
- for (VolDescriptorOffset = SIZE_32KB;
- VolDescriptorOffset <= MultU64x32 (Media->LastBlock, Media->BlockSize);
- VolDescriptorOffset += SIZE_2KB) {
- Status = DiskIo->ReadDisk (
- DiskIo,
- Media->MediaId,
- VolDescriptorOffset,
- SIZE_2KB,
- VolDescriptor
- );
- if (EFI_ERROR (Status)) {
- Found = Status;
- break;
- }
- //
- // Check for valid volume descriptor signature
- //
- if (VolDescriptor->Unknown.Type == CDVOL_TYPE_END ||
- CompareMem (VolDescriptor->Unknown.Id, CDVOL_ID, sizeof (VolDescriptor->Unknown.Id)) != 0
- ) {
- //
- // end of Volume descriptor list
- //
- break;
- }
- //
- // Read the Volume Space Size from Primary Volume Descriptor 81-88 byte,
- // the 32-bit numerical values is stored in Both-byte orders
- //
- if (VolDescriptor->PrimaryVolume.Type == CDVOL_TYPE_CODED) {
- VolSpaceSize = VolDescriptor->PrimaryVolume.VolSpaceSize[0];
- }
- //
- // Is it an El Torito volume descriptor?
- //
- if (CompareMem (VolDescriptor->BootRecordVolume.SystemId, CDVOL_ELTORITO_ID, sizeof (CDVOL_ELTORITO_ID) - 1) != 0) {
- continue;
- }
- //
- // Read in the boot El Torito boot catalog
- // The LBA unit used by El Torito boot catalog is 2KB unit
- //
- Lba2KB = UNPACK_INT32 (VolDescriptor->BootRecordVolume.EltCatalog);
- // Ensure the LBA (in 2KB unit) fits into our media
- if (Lba2KB * (SIZE_2KB / Media->BlockSize) > Media->LastBlock) {
- continue;
- }
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- Media->MediaId,
- MultU64x32 (Lba2KB, SIZE_2KB),
- SIZE_2KB,
- Catalog
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "EltCheckDevice: error reading catalog %r\n", Status));
- continue;
- }
- //
- // We don't care too much about the Catalog header's contents, but we do want
- // to make sure it looks like a Catalog header
- //
- if (Catalog->Catalog.Indicator != ELTORITO_ID_CATALOG || Catalog->Catalog.Id55AA != 0xAA55) {
- DEBUG ((EFI_D_ERROR, "EltCheckBootCatalog: El Torito boot catalog header IDs not correct\n"));
- continue;
- }
-
- Check = 0;
- CheckBuffer = (UINT16 *) Catalog;
- for (Index = 0; Index < sizeof (ELTORITO_CATALOG) / sizeof (UINT16); Index += 1) {
- Check += CheckBuffer[Index];
- }
-
- if ((Check & 0xFFFF) != 0) {
- DEBUG ((EFI_D_ERROR, "EltCheckBootCatalog: El Torito boot catalog header checksum failed\n"));
- continue;
- }
-
- MaxIndex = Media->BlockSize / sizeof (ELTORITO_CATALOG);
- for (Index = 1, BootEntry = 1; Index < MaxIndex; Index += 1) {
- //
- // Next entry
- //
- Catalog += 1;
-
- //
- // Check this entry
- //
- if (Catalog->Boot.Indicator != ELTORITO_ID_SECTION_BOOTABLE || Catalog->Boot.Lba == 0) {
- continue;
- }
-
- SubBlockSize = 512;
- SectorCount = Catalog->Boot.SectorCount * (SIZE_2KB / Media->BlockSize);
-
- switch (Catalog->Boot.MediaType) {
-
- case ELTORITO_NO_EMULATION:
- SubBlockSize = Media->BlockSize;
- break;
-
- case ELTORITO_HARD_DISK:
- break;
-
- case ELTORITO_12_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x0F;
- break;
-
- case ELTORITO_14_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x12;
- break;
-
- case ELTORITO_28_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x24;
- break;
-
- default:
- DEBUG ((EFI_D_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType));
- SectorCount = 0;
- SubBlockSize = Media->BlockSize;
- break;
- }
- //
- // Create child device handle
- //
- CdDev.Header.Type = MEDIA_DEVICE_PATH;
- CdDev.Header.SubType = MEDIA_CDROM_DP;
- SetDevicePathNodeLength (&CdDev.Header, sizeof (CdDev));
-
- if (Index == 1) {
- //
- // This is the initial/default entry
- //
- BootEntry = 0;
- }
-
- CdDev.BootEntry = (UINT32) BootEntry;
- BootEntry++;
- CdDev.PartitionStart = Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize);
- if (SectorCount < 2) {
- //
- // When the SectorCount < 2, set the Partition as the whole CD.
- //
- if (VolSpaceSize > (Media->LastBlock + 1)) {
- CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba + 1);
- } else {
- CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba);
- }
- } else {
- CdDev.PartitionSize = DivU64x32 (
- MultU64x32 (
- SectorCount,
- SubBlockSize
- ) + Media->BlockSize - 1,
- Media->BlockSize
- );
- }
-
- Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &CdDev,
- Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
- MultU64x32 (Catalog->Boot.Lba + CdDev.PartitionSize - 1, SIZE_2KB / Media->BlockSize),
- SubBlockSize,
- FALSE
- );
- if (!EFI_ERROR (Status)) {
- Found = EFI_SUCCESS;
- }
- }
- }
-
- FreePool (VolDescriptor);
-
- return Found;
-}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
deleted file mode 100644
index 35860515c1..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
+++ /dev/null
@@ -1,871 +0,0 @@
-/** @file
- Decode a hard disk partitioned with the GPT scheme in the UEFI 2.0
- specification.
-
- Caution: This file requires additional review when modified.
- This driver will have external input - disk partition.
- This external input must be validated carefully to avoid security issue like
- buffer overflow, integer overflow.
-
- PartitionInstallGptChildHandles() routine will read disk partition content and
- do basic validation before PartitionInstallChildHandle().
-
- PartitionValidGptTable(), PartitionCheckGptEntry() routine will accept disk
- partition content and validate the GPT table and GPT entry.
-
-Copyright (c) 2006 - 2013, 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
-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"
-
-/**
- Install child handles if the Handle supports GPT partition structure.
-
- Caution: This function may receive untrusted input.
- The GPT partition table header is external input, so this routine
- will do basic validation for GPT partition table header before return.
-
- @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
-
-**/
-BOOLEAN
-PartitionValidGptTable (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_LBA Lba,
- OUT EFI_PARTITION_TABLE_HEADER *PartHeader
- );
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionCheckGptEntryArrayCRC (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_PARTITION_TABLE_HEADER *PartHeader
- );
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionRestoreGptTable (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_PARTITION_TABLE_HEADER *PartHeader
- );
-
-
-/**
- This routine will check GPT partition entry and return entry status.
-
- Caution: This function may receive untrusted input.
- The GPT partition entry is external input, so this routine
- will do basic validation for GPT partition entry and report status.
-
- @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
-
-**/
-VOID
-PartitionCheckGptEntry (
- IN EFI_PARTITION_TABLE_HEADER *PartHeader,
- IN EFI_PARTITION_ENTRY *PartEntry,
- OUT EFI_PARTITION_ENTRY_STATUS *PEntryStatus
- );
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionCheckCrcAltSize (
- IN UINTN MaxSize,
- IN UINTN Size,
- IN OUT EFI_TABLE_HEADER *Hdr
- );
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionCheckCrc (
- IN UINTN MaxSize,
- IN OUT EFI_TABLE_HEADER *Hdr
- );
-
-
-/**
- Updates the CRC32 value in the table header.
-
- @param Size The size of the table
- @param Hdr Table to update
-
-**/
-VOID
-PartitionSetCrcAltSize (
- IN UINTN Size,
- IN OUT EFI_TABLE_HEADER *Hdr
- );
-
-
-/**
- Updates the CRC32 value in the table header.
-
- @param Hdr Table to update
-
-**/
-VOID
-PartitionSetCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
- );
-
-/**
- Install child handles if the Handle supports GPT partition structure.
-
- Caution: This function may receive untrusted input.
- The GPT partition table is external input, so this routine
- will do basic validation for GPT partition table before install
- child handle for each GPT partition.
-
- @param[in] This Calling context.
- @param[in] Handle Parent Handle.
- @param[in] DiskIo Parent DiskIo interface.
- @param[in] DiskIo2 Parent DiskIo2 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.
-
-**/
-EFI_STATUS
-PartitionInstallGptChildHandles (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- EFI_STATUS Status;
- UINT32 BlockSize;
- EFI_LBA LastBlock;
- MASTER_BOOT_RECORD *ProtectiveMbr;
- EFI_PARTITION_TABLE_HEADER *PrimaryHeader;
- EFI_PARTITION_TABLE_HEADER *BackupHeader;
- EFI_PARTITION_ENTRY *PartEntry;
- EFI_PARTITION_ENTRY *Entry;
- EFI_PARTITION_ENTRY_STATUS *PEntryStatus;
- UINTN Index;
- EFI_STATUS GptValidStatus;
- HARDDRIVE_DEVICE_PATH HdDev;
- UINT32 MediaId;
-
- ProtectiveMbr = NULL;
- PrimaryHeader = NULL;
- BackupHeader = NULL;
- PartEntry = NULL;
- PEntryStatus = NULL;
-
- BlockSize = BlockIo->Media->BlockSize;
- LastBlock = BlockIo->Media->LastBlock;
- MediaId = BlockIo->Media->MediaId;
-
- DEBUG ((EFI_D_INFO, " BlockSize : %d \n", BlockSize));
- DEBUG ((EFI_D_INFO, " LastBlock : %lx \n", LastBlock));
-
- GptValidStatus = EFI_NOT_FOUND;
-
- //
- // Allocate a buffer for the Protective MBR
- //
- ProtectiveMbr = AllocatePool (BlockSize);
- if (ProtectiveMbr == NULL) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Read the Protective MBR from LBA #0
- //
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- 0,
- BlockSize,
- ProtectiveMbr
- );
- if (EFI_ERROR (Status)) {
- GptValidStatus = Status;
- goto Done;
- }
-
- //
- // Verify that the Protective MBR is valid
- //
- for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {
- if (ProtectiveMbr->Partition[Index].BootIndicator == 0x00 &&
- ProtectiveMbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION &&
- UNPACK_UINT32 (ProtectiveMbr->Partition[Index].StartingLBA) == 1
- ) {
- break;
- }
- }
- if (Index == MAX_MBR_PARTITIONS) {
- goto Done;
- }
-
- //
- // Allocate the GPT structures
- //
- PrimaryHeader = AllocateZeroPool (sizeof (EFI_PARTITION_TABLE_HEADER));
- if (PrimaryHeader == NULL) {
- goto Done;
- }
-
- BackupHeader = AllocateZeroPool (sizeof (EFI_PARTITION_TABLE_HEADER));
- if (BackupHeader == NULL) {
- goto Done;
- }
-
- //
- // Check primary and backup partition tables
- //
- if (!PartitionValidGptTable (BlockIo, DiskIo, PRIMARY_PART_HEADER_LBA, PrimaryHeader)) {
- DEBUG ((EFI_D_INFO, " Not Valid primary partition table\n"));
-
- if (!PartitionValidGptTable (BlockIo, DiskIo, LastBlock, BackupHeader)) {
- DEBUG ((EFI_D_INFO, " Not Valid backup partition table\n"));
- goto Done;
- } else {
- DEBUG ((EFI_D_INFO, " Valid backup partition table\n"));
- DEBUG ((EFI_D_INFO, " Restore primary partition table by the backup\n"));
- if (!PartitionRestoreGptTable (BlockIo, DiskIo, BackupHeader)) {
- DEBUG ((EFI_D_INFO, " Restore primary partition table error\n"));
- }
-
- if (PartitionValidGptTable (BlockIo, DiskIo, BackupHeader->AlternateLBA, PrimaryHeader)) {
- DEBUG ((EFI_D_INFO, " Restore backup partition table success\n"));
- }
- }
- } else if (!PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) {
- DEBUG ((EFI_D_INFO, " Valid primary and !Valid backup partition table\n"));
- DEBUG ((EFI_D_INFO, " Restore backup partition table by the primary\n"));
- if (!PartitionRestoreGptTable (BlockIo, DiskIo, PrimaryHeader)) {
- DEBUG ((EFI_D_INFO, " Restore backup partition table error\n"));
- }
-
- if (PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) {
- DEBUG ((EFI_D_INFO, " Restore backup partition table success\n"));
- }
-
- }
-
- DEBUG ((EFI_D_INFO, " Valid primary and Valid backup partition table\n"));
-
- //
- // Read the EFI Partition Entries
- //
- PartEntry = AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry);
- if (PartEntry == NULL) {
- DEBUG ((EFI_D_ERROR, "Allocate pool error\n"));
- goto Done;
- }
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockSize),
- PrimaryHeader->NumberOfPartitionEntries * (PrimaryHeader->SizeOfPartitionEntry),
- PartEntry
- );
- if (EFI_ERROR (Status)) {
- GptValidStatus = Status;
- DEBUG ((EFI_D_ERROR, " Partition Entry ReadDisk error\n"));
- goto Done;
- }
-
- DEBUG ((EFI_D_INFO, " Partition entries read block success\n"));
-
- DEBUG ((EFI_D_INFO, " Number of partition entries: %d\n", PrimaryHeader->NumberOfPartitionEntries));
-
- PEntryStatus = AllocateZeroPool (PrimaryHeader->NumberOfPartitionEntries * sizeof (EFI_PARTITION_ENTRY_STATUS));
- if (PEntryStatus == NULL) {
- DEBUG ((EFI_D_ERROR, "Allocate pool error\n"));
- goto Done;
- }
-
- //
- // Check the integrity of partition entries
- //
- PartitionCheckGptEntry (PrimaryHeader, PartEntry, PEntryStatus);
-
- //
- // If we got this far the GPT layout of the disk is valid and we should return true
- //
- GptValidStatus = EFI_SUCCESS;
-
- //
- // Create child device handles
- //
- for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index * PrimaryHeader->SizeOfPartitionEntry);
- if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid) ||
- PEntryStatus[Index].OutOfRange ||
- PEntryStatus[Index].Overlap ||
- PEntryStatus[Index].OsSpecific
- ) {
- //
- // Don't use null EFI Partition Entries, Invalid Partition Entries or OS specific
- // partition Entries
- //
- continue;
- }
-
- ZeroMem (&HdDev, sizeof (HdDev));
- HdDev.Header.Type = MEDIA_DEVICE_PATH;
- HdDev.Header.SubType = MEDIA_HARDDRIVE_DP;
- SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));
-
- HdDev.PartitionNumber = (UINT32) Index + 1;
- HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;
- HdDev.SignatureType = SIGNATURE_TYPE_GUID;
- HdDev.PartitionStart = Entry->StartingLBA;
- HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1;
- CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof (EFI_GUID));
-
- DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index));
- DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart));
- DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA));
- DEBUG ((EFI_D_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize));
- DEBUG ((EFI_D_INFO, " Start : %lx", MultU64x32 (Entry->StartingLBA, BlockSize)));
- DEBUG ((EFI_D_INFO, " End : %lx\n", MultU64x32 (Entry->EndingLBA, BlockSize)));
-
- Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
- Entry->StartingLBA,
- Entry->EndingLBA,
- BlockSize,
- CompareGuid(&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)
- );
- }
-
- DEBUG ((EFI_D_INFO, "Prepare to Free Pool\n"));
-
-Done:
- if (ProtectiveMbr != NULL) {
- FreePool (ProtectiveMbr);
- }
- if (PrimaryHeader != NULL) {
- FreePool (PrimaryHeader);
- }
- if (BackupHeader != NULL) {
- FreePool (BackupHeader);
- }
- if (PartEntry != NULL) {
- FreePool (PartEntry);
- }
- if (PEntryStatus != NULL) {
- FreePool (PEntryStatus);
- }
-
- return GptValidStatus;
-}
-
-/**
- This routine will read GPT partition table header and return it.
-
- Caution: This function may receive untrusted input.
- The GPT partition table header is external input, so this routine
- will do basic validation for GPT partition table header before return.
-
- @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
-
-**/
-BOOLEAN
-PartitionValidGptTable (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_LBA Lba,
- OUT EFI_PARTITION_TABLE_HEADER *PartHeader
- )
-{
- EFI_STATUS Status;
- UINT32 BlockSize;
- EFI_PARTITION_TABLE_HEADER *PartHdr;
- UINT32 MediaId;
-
- BlockSize = BlockIo->Media->BlockSize;
- MediaId = BlockIo->Media->MediaId;
- PartHdr = AllocateZeroPool (BlockSize);
-
- if (PartHdr == NULL) {
- DEBUG ((EFI_D_ERROR, "Allocate pool error\n"));
- return FALSE;
- }
- //
- // Read the EFI Partition Table Header
- //
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- MultU64x32 (Lba, BlockSize),
- BlockSize,
- PartHdr
- );
- if (EFI_ERROR (Status)) {
- FreePool (PartHdr);
- return FALSE;
- }
-
- if ((PartHdr->Header.Signature != EFI_PTAB_HEADER_ID) ||
- !PartitionCheckCrc (BlockSize, &PartHdr->Header) ||
- PartHdr->MyLBA != Lba ||
- (PartHdr->SizeOfPartitionEntry < sizeof (EFI_PARTITION_ENTRY))
- ) {
- DEBUG ((EFI_D_INFO, "Invalid efi partition table header\n"));
- FreePool (PartHdr);
- return FALSE;
- }
-
- //
- // Ensure the NumberOfPartitionEntries * SizeOfPartitionEntry doesn't overflow.
- //
- if (PartHdr->NumberOfPartitionEntries > DivU64x32 (MAX_UINTN, PartHdr->SizeOfPartitionEntry)) {
- FreePool (PartHdr);
- return FALSE;
- }
-
- CopyMem (PartHeader, PartHdr, sizeof (EFI_PARTITION_TABLE_HEADER));
- if (!PartitionCheckGptEntryArrayCRC (BlockIo, DiskIo, PartHeader)) {
- FreePool (PartHdr);
- return FALSE;
- }
-
- DEBUG ((EFI_D_INFO, " Valid efi partition table header\n"));
- FreePool (PartHdr);
- 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
-
-**/
-BOOLEAN
-PartitionCheckGptEntryArrayCRC (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_PARTITION_TABLE_HEADER *PartHeader
- )
-{
- EFI_STATUS Status;
- UINT8 *Ptr;
- UINT32 Crc;
- UINTN Size;
-
- //
- // Read the EFI Partition Entries
- //
- Ptr = AllocatePool (PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry);
- if (Ptr == NULL) {
- DEBUG ((EFI_D_ERROR, " Allocate pool error\n"));
- return FALSE;
- }
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32(PartHeader->PartitionEntryLBA, BlockIo->Media->BlockSize),
- PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
- Ptr
- );
- if (EFI_ERROR (Status)) {
- FreePool (Ptr);
- return FALSE;
- }
-
- Size = PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry;
-
- Status = gBS->CalculateCrc32 (Ptr, Size, &Crc);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CheckPEntryArrayCRC: Crc calculation failed\n"));
- FreePool (Ptr);
- return FALSE;
- }
-
- FreePool (Ptr);
-
- return (BOOLEAN) (PartHeader->PartitionEntryArrayCRC32 == Crc);
-}
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionRestoreGptTable (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_PARTITION_TABLE_HEADER *PartHeader
- )
-{
- EFI_STATUS Status;
- UINTN BlockSize;
- EFI_PARTITION_TABLE_HEADER *PartHdr;
- EFI_LBA PEntryLBA;
- UINT8 *Ptr;
- UINT32 MediaId;
-
- PartHdr = NULL;
- Ptr = NULL;
-
- BlockSize = BlockIo->Media->BlockSize;
- MediaId = BlockIo->Media->MediaId;
-
- PartHdr = AllocateZeroPool (BlockSize);
-
- if (PartHdr == NULL) {
- DEBUG ((EFI_D_ERROR, "Allocate pool error\n"));
- return FALSE;
- }
-
- PEntryLBA = (PartHeader->MyLBA == PRIMARY_PART_HEADER_LBA) ? \
- (PartHeader->LastUsableLBA + 1) : \
- (PRIMARY_PART_HEADER_LBA + 1);
-
- CopyMem (PartHdr, PartHeader, sizeof (EFI_PARTITION_TABLE_HEADER));
-
- PartHdr->MyLBA = PartHeader->AlternateLBA;
- PartHdr->AlternateLBA = PartHeader->MyLBA;
- PartHdr->PartitionEntryLBA = PEntryLBA;
- PartitionSetCrc ((EFI_TABLE_HEADER *) PartHdr);
-
- Status = DiskIo->WriteDisk (
- DiskIo,
- MediaId,
- MultU64x32 (PartHdr->MyLBA, (UINT32) BlockSize),
- BlockSize,
- PartHdr
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- Ptr = AllocatePool (PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry);
- if (Ptr == NULL) {
- DEBUG ((EFI_D_ERROR, " Allocate pool error\n"));
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- MultU64x32(PartHeader->PartitionEntryLBA, (UINT32) BlockSize),
- PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
- Ptr
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- Status = DiskIo->WriteDisk (
- DiskIo,
- MediaId,
- MultU64x32(PEntryLBA, (UINT32) BlockSize),
- PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
- Ptr
- );
-
-Done:
- FreePool (PartHdr);
-
- if (Ptr != NULL) {
- FreePool (Ptr);
- }
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- This routine will check GPT partition entry and return entry status.
-
- Caution: This function may receive untrusted input.
- The GPT partition entry is external input, so this routine
- will do basic validation for GPT partition entry and report status.
-
- @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
-
-**/
-VOID
-PartitionCheckGptEntry (
- IN EFI_PARTITION_TABLE_HEADER *PartHeader,
- IN EFI_PARTITION_ENTRY *PartEntry,
- OUT EFI_PARTITION_ENTRY_STATUS *PEntryStatus
- )
-{
- EFI_LBA StartingLBA;
- EFI_LBA EndingLBA;
- EFI_PARTITION_ENTRY *Entry;
- UINTN Index1;
- UINTN Index2;
-
- DEBUG ((EFI_D_INFO, " start check partition entries\n"));
- for (Index1 = 0; Index1 < PartHeader->NumberOfPartitionEntries; Index1++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index1 * PartHeader->SizeOfPartitionEntry);
- if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid)) {
- continue;
- }
-
- StartingLBA = Entry->StartingLBA;
- EndingLBA = Entry->EndingLBA;
- if (StartingLBA > EndingLBA ||
- StartingLBA < PartHeader->FirstUsableLBA ||
- StartingLBA > PartHeader->LastUsableLBA ||
- EndingLBA < PartHeader->FirstUsableLBA ||
- EndingLBA > PartHeader->LastUsableLBA
- ) {
- PEntryStatus[Index1].OutOfRange = TRUE;
- continue;
- }
-
- if ((Entry->Attributes & BIT1) != 0) {
- //
- // If Bit 1 is set, this indicate that this is an OS specific GUID partition.
- //
- PEntryStatus[Index1].OsSpecific = TRUE;
- }
-
- for (Index2 = Index1 + 1; Index2 < PartHeader->NumberOfPartitionEntries; Index2++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index2 * PartHeader->SizeOfPartitionEntry);
- if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid)) {
- continue;
- }
-
- if (Entry->EndingLBA >= StartingLBA && Entry->StartingLBA <= EndingLBA) {
- //
- // This region overlaps with the Index1'th region
- //
- PEntryStatus[Index1].Overlap = TRUE;
- PEntryStatus[Index2].Overlap = TRUE;
- continue;
- }
- }
- }
-
- DEBUG ((EFI_D_INFO, " End check partition entries\n"));
-}
-
-
-/**
- Updates the CRC32 value in the table header.
-
- @param Hdr Table to update
-
-**/
-VOID
-PartitionSetCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
- )
-{
- PartitionSetCrcAltSize (Hdr->HeaderSize, Hdr);
-}
-
-
-/**
- Updates the CRC32 value in the table header.
-
- @param Size The size of the table
- @param Hdr Table to update
-
-**/
-VOID
-PartitionSetCrcAltSize (
- IN UINTN Size,
- IN OUT EFI_TABLE_HEADER *Hdr
- )
-{
- UINT32 Crc;
-
- Hdr->CRC32 = 0;
- gBS->CalculateCrc32 ((UINT8 *) Hdr, Size, &Crc);
- Hdr->CRC32 = Crc;
-}
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionCheckCrc (
- IN UINTN MaxSize,
- IN OUT EFI_TABLE_HEADER *Hdr
- )
-{
- return PartitionCheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);
-}
-
-
-/**
- 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
-
-**/
-BOOLEAN
-PartitionCheckCrcAltSize (
- IN UINTN MaxSize,
- IN UINTN Size,
- IN OUT EFI_TABLE_HEADER *Hdr
- )
-{
- UINT32 Crc;
- UINT32 OrgCrc;
- EFI_STATUS Status;
-
- Crc = 0;
-
- if (Size == 0) {
- //
- // If header size is 0 CRC will pass so return FALSE here
- //
- return FALSE;
- }
-
- if ((MaxSize != 0) && (Size > MaxSize)) {
- DEBUG ((EFI_D_ERROR, "CheckCrc32: Size > MaxSize\n"));
- return FALSE;
- }
- //
- // clear old crc from header
- //
- OrgCrc = Hdr->CRC32;
- Hdr->CRC32 = 0;
-
- Status = gBS->CalculateCrc32 ((UINT8 *) Hdr, Size, &Crc);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc calculation failed\n"));
- return FALSE;
- }
- //
- // set results
- //
- Hdr->CRC32 = Crc;
-
- //
- // return status
- //
- DEBUG_CODE_BEGIN ();
- if (OrgCrc != Crc) {
- DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc check failed\n"));
- }
- DEBUG_CODE_END ();
-
- return (BOOLEAN) (OrgCrc == Crc);
-}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
deleted file mode 100644
index 4b0159c4fa..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/** @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.
- The MBR supports four partitions per disk. The MBR also contains legacy
- code that is not run on an EFI system. The legacy code reads the
- first sector of the active partition into memory and
-
- 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) 2014, Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2013, 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
-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"
-
-/**
- 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
- )
-{
- UINT32 StartingLBA;
- UINT32 EndingLBA;
- UINT32 NewEndingLBA;
- INTN Index1;
- INTN Index2;
- BOOLEAN MbrValid;
-
- if (Mbr->Signature != MBR_SIGNATURE) {
- return FALSE;
- }
- //
- // The BPB also has this signature, so it can not be used alone.
- //
- MbrValid = FALSE;
- for (Index1 = 0; Index1 < MAX_MBR_PARTITIONS; Index1++) {
- if (Mbr->Partition[Index1].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) == 0) {
- continue;
- }
-
- MbrValid = TRUE;
- StartingLBA = UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA);
- EndingLBA = StartingLBA + UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) - 1;
- if (EndingLBA > LastLba) {
- //
- // Compatibility Errata:
- // Some systems try to hide drive space with their INT 13h driver
- // This does not hide space from the OS driver. This means the MBR
- // that gets created from DOS is smaller than the MBR created from
- // a real OS (NT & Win98). This leads to BlockIo->LastBlock being
- // wrong on some systems FDISKed by the OS.
- //
- // return FALSE since no block devices on a system are implemented
- // with INT 13h
- //
-
- DEBUG((EFI_D_INFO, "PartitionValidMbr: Bad MBR partition size EndingLBA(%1x) > LastLBA(%1x)\n", EndingLBA, LastLba));
-
- return FALSE;
- }
-
- for (Index2 = Index1 + 1; Index2 < MAX_MBR_PARTITIONS; Index2++) {
- if (Mbr->Partition[Index2].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) == 0) {
- continue;
- }
-
- NewEndingLBA = UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) + UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) - 1;
- if (NewEndingLBA >= StartingLBA && UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) <= EndingLBA) {
- //
- // This region overlaps with the Index1'th region
- //
- return FALSE;
- }
- }
- }
- //
- // None of the regions overlapped so MBR is O.K.
- //
- return MbrValid;
-}
-
-
-/**
- Install child handles if the Handle supports MBR format.
-
- @param[in] This Calling context.
- @param[in] Handle Parent Handle.
- @param[in] DiskIo Parent DiskIo interface.
- @param[in] DiskIo2 Parent DiskIo2 interface.
- @param[in] BlockIo Parent BlockIo interface.
- @param[in] BlockIo2 Parent BlockIo2 interface.
- @param[in] 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,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- EFI_STATUS Status;
- MASTER_BOOT_RECORD *Mbr;
- UINT32 ExtMbrStartingLba;
- UINTN Index;
- HARDDRIVE_DEVICE_PATH HdDev;
- HARDDRIVE_DEVICE_PATH ParentHdDev;
- EFI_STATUS Found;
- UINT32 PartitionNumber;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode;
- UINT32 BlockSize;
- UINT32 MediaId;
- EFI_LBA LastBlock;
-
- Found = EFI_NOT_FOUND;
-
- BlockSize = BlockIo->Media->BlockSize;
- MediaId = BlockIo->Media->MediaId;
- LastBlock = BlockIo->Media->LastBlock;
-
- Mbr = AllocatePool (BlockSize);
- if (Mbr == NULL) {
- return Found;
- }
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- 0,
- BlockSize,
- Mbr
- );
- if (EFI_ERROR (Status)) {
- Found = Status;
- goto Done;
- }
- if (!PartitionValidMbr (Mbr, LastBlock)) {
- goto Done;
- }
- //
- // We have a valid mbr - add each partition
- //
- //
- // Get starting and ending LBA of the parent block device.
- //
- LastDevicePathNode = NULL;
- ZeroMem (&ParentHdDev, sizeof (ParentHdDev));
- DevicePathNode = DevicePath;
- while (!IsDevicePathEnd (DevicePathNode)) {
- LastDevicePathNode = DevicePathNode;
- DevicePathNode = NextDevicePathNode (DevicePathNode);
- }
-
- if (LastDevicePathNode != NULL) {
- if (DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (LastDevicePathNode) == MEDIA_HARDDRIVE_DP
- ) {
- CopyMem (&ParentHdDev, LastDevicePathNode, sizeof (ParentHdDev));
- } else {
- LastDevicePathNode = NULL;
- }
- }
-
- PartitionNumber = 1;
-
- ZeroMem (&HdDev, sizeof (HdDev));
- HdDev.Header.Type = MEDIA_DEVICE_PATH;
- HdDev.Header.SubType = MEDIA_HARDDRIVE_DP;
- SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));
- HdDev.MBRType = MBR_TYPE_PCAT;
- HdDev.SignatureType = SIGNATURE_TYPE_MBR;
-
- if (LastDevicePathNode == NULL) {
- //
- // This is a MBR, add each partition
- //
- for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {
- if (Mbr->Partition[Index].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index].SizeInLBA) == 0) {
- //
- // Don't use null MBR entries
- //
- continue;
- }
-
- if (Mbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION) {
- //
- // This is the guard MBR for the GPT. If you ever see a GPT disk with zero partitions you can get here.
- // We can not produce an MBR BlockIo for this device as the MBR spans the GPT headers. So formating
- // this BlockIo would corrupt the GPT structures and require a recovery that would corrupt the format
- // that corrupted the GPT partition.
- //
- continue;
- }
-
- 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 (Mbr->UniqueMbrSignature));
-
- Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
- HdDev.PartitionStart,
- HdDev.PartitionStart + HdDev.PartitionSize - 1,
- MBR_SIZE,
- (BOOLEAN) (Mbr->Partition[Index].OSIndicator == EFI_PARTITION)
- );
-
- if (!EFI_ERROR (Status)) {
- Found = EFI_SUCCESS;
- }
- }
- } else {
- //
- // It's an extended partition. Follow the extended partition
- // chain to get all the logical drives
- //
- ExtMbrStartingLba = 0;
-
- do {
-
- Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- MultU64x32 (ExtMbrStartingLba, BlockSize),
- BlockSize,
- Mbr
- );
- if (EFI_ERROR (Status)) {
- Found = Status;
- goto Done;
- }
-
- if (UNPACK_UINT32 (Mbr->Partition[0].SizeInLBA) == 0) {
- break;
- }
-
- if ((Mbr->Partition[0].OSIndicator == EXTENDED_DOS_PARTITION) ||
- (Mbr->Partition[0].OSIndicator == EXTENDED_WINDOWS_PARTITION)) {
- ExtMbrStartingLba = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA);
- continue;
- }
- HdDev.PartitionNumber = PartitionNumber ++;
- HdDev.PartitionStart = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA) + ExtMbrStartingLba + ParentHdDev.PartitionStart;
- HdDev.PartitionSize = UNPACK_UINT32 (Mbr->Partition[0].SizeInLBA);
- if ((HdDev.PartitionStart + HdDev.PartitionSize - 1 >= ParentHdDev.PartitionStart + ParentHdDev.PartitionSize) ||
- (HdDev.PartitionStart <= ParentHdDev.PartitionStart)) {
- break;
- }
-
- //
- // The signature in EBR(Extended Boot Record) should always be 0.
- //
- *((UINT32 *) &HdDev.Signature[0]) = 0;
-
- Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
- HdDev.PartitionStart - ParentHdDev.PartitionStart,
- HdDev.PartitionStart - ParentHdDev.PartitionStart + HdDev.PartitionSize - 1,
- MBR_SIZE,
- (BOOLEAN) (Mbr->Partition[0].OSIndicator == EFI_PARTITION)
- );
- if (!EFI_ERROR (Status)) {
- Found = EFI_SUCCESS;
- }
-
- if ((Mbr->Partition[1].OSIndicator != EXTENDED_DOS_PARTITION) &&
- (Mbr->Partition[1].OSIndicator != EXTENDED_WINDOWS_PARTITION)
- ) {
- break;
- }
-
- ExtMbrStartingLba = UNPACK_UINT32 (Mbr->Partition[1].StartingLBA);
- //
- // Don't allow partition to be self referencing
- //
- if (ExtMbrStartingLba == 0) {
- break;
- }
- } while (ExtMbrStartingLba < ParentHdDev.PartitionSize);
- }
-
-Done:
- FreePool (Mbr);
-
- return Found;
-}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
deleted file mode 100644
index 89cc540210..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ /dev/null
@@ -1,1265 +0,0 @@
-/** @file
- Partition driver that produces logical BlockIo devices from a physical
- BlockIo device. The logical BlockIo devices are based on the format
- of the raw block devices media. Currently "El Torito CD-ROM", Legacy
- MBR, and GPT partition schemes are supported.
-
-Copyright (c) 2006 - 2014, 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
-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"
-
-//
-// Partition Driver Global Variables.
-//
-EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
- PartitionDriverBindingSupported,
- PartitionDriverBindingStart,
- PartitionDriverBindingStop,
- //
- // Grub4Dos copies the BPB of the first partition to the MBR. If the
- // DriverBindingStart() of the Fat driver gets run before that of Partition
- // driver only the first partition can be recognized.
- // Let the driver binding version of Partition driver be higher than that of
- // Fat driver to make sure the DriverBindingStart() of the Partition driver
- // gets run before that of Fat driver so that all the partitions can be recognized.
- //
- 0xb,
- NULL,
- NULL
-};
-
-//
-// Prioritized function list to detect partition table.
-//
-PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
- PartitionInstallGptChildHandles,
- PartitionInstallElToritoChildHandles,
- PartitionInstallMbrChildHandles,
- NULL
-};
-
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a BlockIo and DiskIo protocol or a BlockIo2 protocol can be
- supported.
-
- @param[in] This Protocol instance pointer.
- @param[in] ControllerHandle Handle of device to test.
- @param[in] RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_DEV_PATH *Node;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, go on checking other conditions
- //
- if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- Node = (EFI_DEV_PATH *) RemainingDevicePath;
- if (Node->DevPath.Type != MEDIA_DEVICE_PATH ||
- Node->DevPath.SubType != MEDIA_HARDDRIVE_DP ||
- DevicePathNodeLength (&Node->DevPath) != sizeof (HARDDRIVE_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
-
- //
- // Open the EFI Device Path protocol needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close protocol, don't use device path protocol in the Support() function
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
-
- return Status;
-}
-
-/**
- Start this driver on ControllerHandle by opening a Block IO or a Block IO2
- or both, and Disk IO protocol, reading Device Path, and creating a child
- handle with a Disk IO and device path protocol.
-
- @param[in] This Protocol instance pointer.
- @param[in] ControllerHandle Handle of device to bind driver to
- @param[in] RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to ControllerHandle
- @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_STATUS OpenStatus;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_DISK_IO2_PROTOCOL *DiskIo2;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- PARTITION_DETECT_ROUTINE *Routine;
- BOOLEAN MediaPresent;
- EFI_TPL OldTpl;
-
- BlockIo2 = NULL;
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, return EFI_SUCCESS
- //
- if (IsDevicePathEnd (RemainingDevicePath)) {
- Status = EFI_SUCCESS;
- goto Exit;
- }
- }
-
- //
- // Try to open BlockIO and BlockIO2. If BlockIO would be opened, continue,
- // otherwise, return error.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIo2ProtocolGuid,
- (VOID **) &BlockIo2,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- BlockIo2 = NULL;
- }
-
- //
- // Get the Device Path Protocol on ControllerHandle's handle.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- goto Exit;
- }
-
- //
- // Get the DiskIo and DiskIo2.
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- goto Exit;
- }
-
- OpenStatus = Status;
-
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIo2ProtocolGuid,
- (VOID **) &DiskIo2,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- DiskIo2 = NULL;
- }
-
- //
- // Try to read blocks when there's media or it is removable physical partition.
- //
- Status = EFI_UNSUPPORTED;
- MediaPresent = BlockIo->Media->MediaPresent;
- if (BlockIo->Media->MediaPresent ||
- (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {
- //
- // Try for GPT, then El Torito, and then legacy MBR partition types. If the
- // media supports a given partition type install child handles to represent
- // the partitions described by the media.
- //
- Routine = &mPartitionDetectRoutineTable[0];
- while (*Routine != NULL) {
- Status = (*Routine) (
- This,
- ControllerHandle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- ParentDevicePath
- );
- if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {
- break;
- }
- Routine++;
- }
- }
- //
- // In the case that the driver is already started (OpenStatus == EFI_ALREADY_STARTED),
- // the DevicePathProtocol and the DiskIoProtocol are not actually opened by the
- // driver. So don't try to close them. Otherwise, we will break the dependency
- // between the controller and the driver set up before.
- //
- // In the case that when the media changes on a device it will Reinstall the
- // BlockIo interaface. This will cause a call to our Stop(), and a subsequent
- // reentrant call to our Start() successfully. We should leave the device open
- // when this happen. The "media change" case includes either the status is
- // EFI_MEDIA_CHANGED or it is a "media" to "no media" change.
- //
- if (EFI_ERROR (Status) &&
- !EFI_ERROR (OpenStatus) &&
- Status != EFI_MEDIA_CHANGED &&
- !(MediaPresent && Status == EFI_NO_MEDIA)) {
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- //
- // Close Parent DiskIo2 if has.
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIo2ProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
-
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- }
-
-Exit:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed ControllerHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- BOOLEAN AllChildrenStopped;
- PARTITION_PRIVATE_DATA *Private;
- EFI_DISK_IO_PROTOCOL *DiskIo;
-
- BlockIo = NULL;
- BlockIo2 = NULL;
- Private = NULL;
-
- if (NumberOfChildren == 0) {
- //
- // Close the bus driver
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- //
- // Close Parent BlockIO2 if has.
- //
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIo2ProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
-
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- return EFI_SUCCESS;
- }
-
- AllChildrenStopped = TRUE;
- for (Index = 0; Index < NumberOfChildren; Index++) {
- gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- //
- // Try to locate BlockIo2.
- //
- gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gEfiBlockIo2ProtocolGuid,
- (VOID **) &BlockIo2,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
-
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
- );
- //
- // All Software protocols have be freed from the handle so remove it.
- // Remove the BlockIo Protocol if has.
- // Remove the BlockIo2 Protocol if has.
- //
- if (BlockIo2 != NULL) {
- BlockIo->FlushBlocks (BlockIo);
- BlockIo2->FlushBlocksEx (BlockIo2, NULL);
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- &gEfiBlockIo2ProtocolGuid,
- &Private->BlockIo2,
- Private->EspGuid,
- NULL,
- NULL
- );
- } else {
- BlockIo->FlushBlocks (BlockIo);
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- Private->EspGuid,
- NULL,
- NULL
- );
- }
-
- if (EFI_ERROR (Status)) {
- gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index],
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- } else {
- FreePool (Private->DevicePath);
- FreePool (Private);
- }
-
- if (EFI_ERROR (Status)) {
- AllChildrenStopped = FALSE;
- }
- }
-
- if (!AllChildrenStopped) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Reset the Block Device.
-
- @param This Protocol instance pointer.
- @param ExtendedVerification Driver may perform diagnostics on reset.
-
- @retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
- not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- PARTITION_PRIVATE_DATA *Private;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
-
- return Private->ParentBlockIo->Reset (
- Private->ParentBlockIo,
- ExtendedVerification
- );
-}
-
-/**
- Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED
- for no media or media change case. Otherwise DefaultStatus is returned.
-
- @param DiskIo Pointer to the DiskIo instance.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param DefaultStatus The default status to return when it's not the no media
- or media change case.
-
- @retval EFI_NO_MEDIA There is no media.
- @retval EFI_MEDIA_CHANGED The media was changed.
- @retval others The default status to return.
-**/
-EFI_STATUS
-ProbeMediaStatus (
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN UINT32 MediaId,
- IN EFI_STATUS DefaultStatus
- )
-{
- EFI_STATUS Status;
- UINT8 Buffer[1];
-
- //
- // Read 1 byte from offset 0 to check if the MediaId is still valid.
- // The reading operation is synchronious thus it is not worth it to
- // allocate a buffer from the pool. The destination buffer for the
- // data is in the stack.
- //
- Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, (VOID*)Buffer);
- if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
- return Status;
- }
- return DefaultStatus;
-}
-
-/**
- Read by using the Disk IO protocol on the parent device. Lba addresses
- must be converted to byte offsets.
-
- @param This Protocol instance pointer.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Lba The starting Logical Block Address to read from
- @param BufferSize Size of Buffer, must be a multiple of device block size.
- @param Buffer Buffer containing read data
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- PARTITION_PRIVATE_DATA *Private;
- UINT64 Offset;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
-
- if (BufferSize % Private->BlockSize != 0) {
- return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_BAD_BUFFER_SIZE);
- }
-
- Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
- if (Offset + BufferSize > Private->End) {
- return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_INVALID_PARAMETER);
- }
- //
- // Because some kinds of partition have different block size from their parent
- // device, we call the Disk IO protocol on the parent device, not the Block IO
- // protocol
- //
- return Private->DiskIo->ReadDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
-}
-
-/**
- Write by using the Disk IO protocol on the parent device. Lba addresses
- must be converted to byte offsets.
-
- @param[in] This Protocol instance pointer.
- @param[in] MediaId Id of the media, changes every time the media is replaced.
- @param[in] Lba The starting Logical Block Address to read from
- @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
- @param[in] Buffer Buffer containing data to be written to device.
-
- @retval EFI_SUCCESS The data was written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not
- valid for the device.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- PARTITION_PRIVATE_DATA *Private;
- UINT64 Offset;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
-
- if (BufferSize % Private->BlockSize != 0) {
- return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_BAD_BUFFER_SIZE);
- }
-
- Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
- if (Offset + BufferSize > Private->End) {
- return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_INVALID_PARAMETER);
- }
- //
- // Because some kinds of partition have different block size from their parent
- // device, we call the Disk IO protocol on the parent device, not the Block IO
- // protocol
- //
- return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
-}
-
-
-/**
- Flush the parent Block Device.
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS All outstanding data was written to the device
- @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
- @retval EFI_NO_MEDIA There is no media in the device.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- PARTITION_PRIVATE_DATA *Private;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
-
- return Private->ParentBlockIo->FlushBlocks (Private->ParentBlockIo);
-}
-
-/**
- Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED
- for no media or media change case. Otherwise DefaultStatus is returned.
-
- @param DiskIo2 Pointer to the DiskIo2 instance.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param DefaultStatus The default status to return when it's not the no media
- or media change case.
-
- @retval EFI_NO_MEDIA There is no media.
- @retval EFI_MEDIA_CHANGED The media was changed.
- @retval others The default status to return.
-**/
-EFI_STATUS
-ProbeMediaStatusEx (
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN UINT32 MediaId,
- IN EFI_STATUS DefaultStatus
- )
-{
- EFI_STATUS Status;
-
- //
- // Read 1 byte from offset 0 but passing NULL as buffer pointer
- //
- Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, NULL);
- if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
- return Status;
- }
- return DefaultStatus;
-}
-
-/**
- Reset the Block Device throught Block I/O2 protocol.
-
- @param This Protocol instance pointer.
- @param ExtendedVerification Driver may perform diagnostics on reset.
-
- @retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
- not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionResetEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- PARTITION_PRIVATE_DATA *Private;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
-
- return Private->ParentBlockIo2->Reset (
- Private->ParentBlockIo2,
- ExtendedVerification
- );
-}
-
-/**
- The general callback for the DiskIo2 interfaces.
- @param Event Event whose notification function is being invoked.
- @param Context The pointer to the notification function's context,
- which points to the PARTITION_ACCESS_TASK instance.
-**/
-VOID
-EFIAPI
-PartitionOnAccessComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- PARTITION_ACCESS_TASK *Task;
-
- Task = (PARTITION_ACCESS_TASK *) Context;
-
- gBS->CloseEvent (Event);
-
- Task->BlockIo2Token->TransactionStatus = Task->DiskIo2Token.TransactionStatus;
- gBS->SignalEvent (Task->BlockIo2Token->Event);
-
- FreePool (Task);
-}
-
-/**
- Create a new PARTITION_ACCESS_TASK instance.
-
- @param Token Pointer to the EFI_BLOCK_IO2_TOKEN.
-
- @return Pointer to the created PARTITION_ACCESS_TASK instance or NULL upon failure.
-**/
-PARTITION_ACCESS_TASK *
-PartitionCreateAccessTask (
- IN EFI_BLOCK_IO2_TOKEN *Token
- )
-{
- EFI_STATUS Status;
- PARTITION_ACCESS_TASK *Task;
-
- Task = AllocatePool (sizeof (*Task));
- if (Task == NULL) {
- return NULL;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- PartitionOnAccessComplete,
- Task,
- &Task->DiskIo2Token.Event
- );
- if (EFI_ERROR (Status)) {
- FreePool (Task);
- return NULL;
- }
-
- Task->BlockIo2Token = Token;
-
- return Task;
-}
-
-/**
- Read BufferSize bytes from Lba into Buffer.
-
- This function reads the requested number of blocks from the device. All the
- blocks are read, or an error is returned.
- If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
- non-blocking I/O is being used, the Event associated with this request will
- not be signaled.
-
- @param[in] This Indicates a pointer to the calling context.
- @param[in] MediaId Id of the media, changes every time the media is
- replaced.
- @param[in] Lba The starting Logical Block Address to read from.
- @param[in, out] Token A pointer to the token associated with the transaction.
- @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
- @param[out] Buffer A pointer to the destination buffer for the data. The
- caller is responsible for either having implicit or
- explicit ownership of the buffer.
-
- @retval EFI_SUCCESS The read request was queued if Token->Event is
- not NULL.The data was read correctly from the
- device if the Token->Event is NULL.
- @retval EFI_DEVICE_ERROR The device reported an error while performing
- the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
- of resources.
-**/
-EFI_STATUS
-EFIAPI
-PartitionReadBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- PARTITION_PRIVATE_DATA *Private;
- UINT64 Offset;
- PARTITION_ACCESS_TASK *Task;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
-
- if (BufferSize % Private->BlockSize != 0) {
- return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_BAD_BUFFER_SIZE);
- }
-
- Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
- if (Offset + BufferSize > Private->End) {
- return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_INVALID_PARAMETER);
- }
-
- if ((Token != NULL) && (Token->Event != NULL)) {
- Task = PartitionCreateAccessTask (Token);
- if (Task == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer);
- if (EFI_ERROR (Status)) {
- gBS->CloseEvent (Task->DiskIo2Token.Event);
- FreePool (Task);
- }
- } else {
- Status = Private->DiskIo2->ReadDiskEx (Private->DiskIo2, MediaId, Offset, NULL, BufferSize, Buffer);
- }
-
- return Status;
-}
-
-/**
- Write BufferSize bytes from Lba into Buffer.
-
- This function writes the requested number of blocks to the device. All blocks
- are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
- EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
- being used, the Event associated with this request will not be signaled.
-
- @param[in] This Indicates a pointer to the calling context.
- @param[in] MediaId The media ID that the write request is for.
- @param[in] Lba The starting logical block address to be written. The
- caller is responsible for writing to only legitimate
- locations.
- @param[in, out] Token A pointer to the token associated with the transaction.
- @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
- @param[in] Buffer A pointer to the source buffer for the data.
-
- @retval EFI_SUCCESS The write request was queued if Event is not NULL.
- The data was written correctly to the device if
- the Event is NULL.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
- of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionWriteBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- PARTITION_PRIVATE_DATA *Private;
- UINT64 Offset;
- PARTITION_ACCESS_TASK *Task;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
-
- if (BufferSize % Private->BlockSize != 0) {
- return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_BAD_BUFFER_SIZE);
- }
-
- Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
- if (Offset + BufferSize > Private->End) {
- return ProbeMediaStatusEx (Private->DiskIo2, MediaId, EFI_INVALID_PARAMETER);
- }
-
- if ((Token != NULL) && (Token->Event != NULL)) {
- Task = PartitionCreateAccessTask (Token);
- if (Task == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, &Task->DiskIo2Token, BufferSize, Buffer);
- if (EFI_ERROR (Status)) {
- gBS->CloseEvent (Task->DiskIo2Token.Event);
- FreePool (Task);
- }
- } else {
- Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, NULL, BufferSize, Buffer);
- }
- return Status;
-}
-
-/**
- Flush the Block Device.
-
- If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
- is returned and non-blocking I/O is being used, the Event associated with
- this request will not be signaled.
-
- @param[in] This Indicates a pointer to the calling context.
- @param[in, out] Token A pointer to the token associated with the transaction
-
- @retval EFI_SUCCESS The flush request was queued if Event is not NULL.
- All outstanding data was written correctly to the
- device if the Event is NULL.
- @retval EFI_DEVICE_ERROR The device reported an error while writting back
- the data.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
- of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionFlushBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
- )
-{
- EFI_STATUS Status;
- PARTITION_PRIVATE_DATA *Private;
- PARTITION_ACCESS_TASK *Task;
-
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);
-
- if ((Token != NULL) && (Token->Event != NULL)) {
- Task = PartitionCreateAccessTask (Token);
- if (Task == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2, &Task->DiskIo2Token);
- if (EFI_ERROR (Status)) {
- gBS->CloseEvent (Task->DiskIo2Token.Event);
- FreePool (Task);
- }
- } else {
- Status = Private->DiskIo2->FlushDiskEx (Private->DiskIo2, NULL);
- }
- return Status;
-}
-
-
-/**
- Create a child handle for a logical block device that represents the
- bytes Start to End of the Parent Block IO device.
-
- @param[in] This Protocol instance pointer.
- @param[in] ParentHandle Parent Handle for new child.
- @param[in] ParentDiskIo Parent DiskIo interface.
- @param[in] ParentDiskIo2 Parent DiskIo2 interface.
- @param[in] ParentBlockIo Parent BlockIo interface.
- @param[in] ParentBlockIo2 Parent BlockIo2 interface.
- @param[in] ParentDevicePath Parent Device Path.
- @param[in] DevicePathNode Child Device Path node.
- @param[in] Start Start Block.
- @param[in] End End Block.
- @param[in] BlockSize Child block size.
- @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle.
-
- @retval EFI_SUCCESS A child handle was added.
- @retval other A child handle was not added.
-
-**/
-EFI_STATUS
-PartitionInstallChildHandle (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ParentHandle,
- IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
- IN EFI_DISK_IO2_PROTOCOL *ParentDiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN EFI_LBA Start,
- IN EFI_LBA End,
- IN UINT32 BlockSize,
- IN BOOLEAN InstallEspGuid
- )
-{
- EFI_STATUS Status;
- PARTITION_PRIVATE_DATA *Private;
-
- Status = EFI_SUCCESS;
- Private = AllocateZeroPool (sizeof (PARTITION_PRIVATE_DATA));
- if (Private == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;
-
- Private->Start = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
- Private->End = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
-
- Private->BlockSize = BlockSize;
- Private->ParentBlockIo = ParentBlockIo;
- Private->ParentBlockIo2 = ParentBlockIo2;
- Private->DiskIo = ParentDiskIo;
- Private->DiskIo2 = ParentDiskIo2;
-
- //
- // Set the BlockIO into Private Data.
- //
- Private->BlockIo.Revision = ParentBlockIo->Revision;
-
- Private->BlockIo.Media = &Private->Media;
- CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
-
- Private->BlockIo.Reset = PartitionReset;
- Private->BlockIo.ReadBlocks = PartitionReadBlocks;
- Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
- Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
-
- //
- // Set the BlockIO2 into Private Data.
- //
- if (Private->DiskIo2 != NULL) {
- ASSERT (Private->ParentBlockIo2 != NULL);
- Private->BlockIo2.Media = &Private->Media2;
- CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));
-
- Private->BlockIo2.Reset = PartitionResetEx;
- Private->BlockIo2.ReadBlocksEx = PartitionReadBlocksEx;
- Private->BlockIo2.WriteBlocksEx = PartitionWriteBlocksEx;
- Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx;
- }
-
- Private->Media.IoAlign = 0;
- Private->Media.LogicalPartition = TRUE;
- Private->Media.LastBlock = DivU64x32 (
- MultU64x32 (
- End - Start + 1,
- ParentBlockIo->Media->BlockSize
- ),
- BlockSize
- ) - 1;
-
- Private->Media.BlockSize = (UINT32) BlockSize;
-
- Private->Media2.IoAlign = 0;
- Private->Media2.LogicalPartition = TRUE;
- Private->Media2.LastBlock = Private->Media.LastBlock;
- Private->Media2.BlockSize = (UINT32) BlockSize;
-
- //
- // Per UEFI Spec, LowestAlignedLba, LogicalBlocksPerPhysicalBlock and OptimalTransferLengthGranularity must be 0
- // for logical partitions.
- //
- if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION2) {
- Private->Media.LowestAlignedLba = 0;
- Private->Media.LogicalBlocksPerPhysicalBlock = 0;
- Private->Media2.LowestAlignedLba = 0;
- Private->Media2.LogicalBlocksPerPhysicalBlock = 0;
- if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION3) {
- Private->Media.OptimalTransferLengthGranularity = 0;
- Private->Media2.OptimalTransferLengthGranularity = 0;
- }
- }
-
- Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);
-
- if (Private->DevicePath == NULL) {
- FreePool (Private);
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (InstallEspGuid) {
- Private->EspGuid = &gEfiPartTypeSystemPartGuid;
- } else {
- //
- // If NULL InstallMultipleProtocolInterfaces will ignore it.
- //
- Private->EspGuid = NULL;
- }
-
- //
- // Create the new handle.
- //
- Private->Handle = NULL;
- if (Private->DiskIo2 != NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- &gEfiBlockIo2ProtocolGuid,
- &Private->BlockIo2,
- Private->EspGuid,
- NULL,
- NULL
- );
- } else {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- Private->EspGuid,
- NULL,
- NULL
- );
- }
-
- if (!EFI_ERROR (Status)) {
- //
- // Open the Parent Handle for the child
- //
- Status = gBS->OpenProtocol (
- ParentHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &ParentDiskIo,
- This->DriverBindingHandle,
- Private->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- } else {
- FreePool (Private->DevicePath);
- FreePool (Private);
- }
-
- return Status;
-}
-
-
-/**
- The user Entry Point for module Partition. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializePartition (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gPartitionDriverBinding,
- ImageHandle,
- &gPartitionComponentName,
- &gPartitionComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
-
- return Status;
-}
-
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
deleted file mode 100644
index 06470f689f..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
+++ /dev/null
@@ -1,443 +0,0 @@
-/** @file
- Partition driver that produces logical BlockIo devices from a physical
- BlockIo device. The logical BlockIo devices are based on the format
- of the raw block devices media. Currently "El Torito CD-ROM", Legacy
- MBR, and GPT partition schemes are supported.
-
-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
-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.
-
-**/
-
-#ifndef _PARTITION_H_
-#define _PARTITION_H_
-
-#include <Uefi.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/BlockIo2.h>
-#include <Guid/Gpt.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/DiskIo.h>
-#include <Protocol/DiskIo2.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#include <IndustryStandard/Mbr.h>
-#include <IndustryStandard/ElTorito.h>
-
-
-//
-// Partition private data
-//
-#define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', 't')
-typedef struct {
- UINT64 Signature;
-
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- EFI_BLOCK_IO2_PROTOCOL BlockIo2;
- EFI_BLOCK_IO_MEDIA Media;
- EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2
-
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_DISK_IO2_PROTOCOL *DiskIo2;
- EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;
- EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2;
- UINT64 Start;
- UINT64 End;
- UINT32 BlockSize;
-
- EFI_GUID *EspGuid;
-
-} PARTITION_PRIVATE_DATA;
-
-typedef struct {
- EFI_DISK_IO2_TOKEN DiskIo2Token;
- EFI_BLOCK_IO2_TOKEN *BlockIo2Token;
-} PARTITION_ACCESS_TASK;
-
-#define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
-#define PARTITION_DEVICE_FROM_BLOCK_IO2_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo2, PARTITION_PRIVATE_DATA_SIGNATURE)
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2;
-
-//
-// Extract INT32 from char array
-//
-#define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
- (((UINT8 *) a)[1] << 8) | \
- (((UINT8 *) a)[2] << 16) | \
- (((UINT8 *) a)[3] << 24) )
-
-//
-// Extract UINT32 from char array
-//
-#define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
- (((UINT8 *) a)[1] << 8) | \
- (((UINT8 *) a)[2] << 16) | \
- (((UINT8 *) a)[3] << 24) )
-
-
-//
-// GPT Partition Entry Status
-//
-typedef struct {
- BOOLEAN OutOfRange;
- BOOLEAN Overlap;
- BOOLEAN OsSpecific;
-} EFI_PARTITION_ENTRY_STATUS;
-
-//
-// Function Prototypes
-//
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a BlockIo and DiskIo protocol can be supported.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to test
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start this driver on ControllerHandle by opening a Block IO and Disk IO
- protocol, reading Device Path, and creating a child handle with a
- Disk IO and device path protocol.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to bind driver to
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to ControllerHandle
- @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed ControllerHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PartitionComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-/**
- Create a child handle for a logical block device that represents the
- bytes Start to End of the Parent Block IO device.
-
- @param[in] This Protocol instance pointer.
- @param[in] ParentHandle Parent Handle for new child.
- @param[in] ParentDiskIo Parent DiskIo interface.
- @param[in] ParentDiskIo2 Parent DiskIo2 interface.
- @param[in] ParentBlockIo Parent BlockIo interface.
- @param[in] ParentBlockIo2 Parent BlockIo2 interface.
- @param[in] ParentDevicePath Parent Device Path.
- @param[in] DevicePathNode Child Device Path node.
- @param[in] Start Start Block.
- @param[in] End End Block.
- @param[in] BlockSize Child block size.
- @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle.
-
- @retval EFI_SUCCESS A child handle was added.
- @retval other A child handle was not added.
-
-**/
-EFI_STATUS
-PartitionInstallChildHandle (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ParentHandle,
- IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
- IN EFI_DISK_IO2_PROTOCOL *ParentDiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
- IN EFI_LBA Start,
- IN EFI_LBA End,
- IN UINT32 BlockSize,
- IN BOOLEAN InstallEspGuid
- );
-
-/**
- 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] DiskIo2 Parent DiskIo2 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 EFI_INVALID_PARAMETER If both BlockIo and BlockIo2 are NULL;
- @retval other Not a valid GPT disk.
-
-**/
-EFI_STATUS
-PartitionInstallGptChildHandles (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
-
-/**
- Install child handles if the Handle supports El Torito format.
-
- @param[in] This Calling context.
- @param[in] Handle Parent Handle.
- @param[in] DiskIo Parent DiskIo interface.
- @param[in] DiskIo2 Parent DiskIo2 interface.
- @param[in] BlockIo Parent BlockIo interface.
- @param[in] BlockIo2 Parent BlockIo2 interface.
- @param[in] DevicePath Parent Device Path
-
-
- @retval EFI_SUCCESS Child handle(s) was added.
- @retval EFI_MEDIA_CHANGED Media changed Detected.
- @retval other no child handle was added.
-
-**/
-EFI_STATUS
-PartitionInstallElToritoChildHandles (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
-
-/**
- Install child handles if the Handle supports MBR format.
-
- @param[in] This Calling context.
- @param[in] Handle Parent Handle.
- @param[in] DiskIo Parent DiskIo interface.
- @param[in] DiskIo2 Parent DiskIo2 interface.
- @param[in] BlockIo Parent BlockIo interface.
- @param[in] BlockIo2 Parent BlockIo2 interface.
- @param[in] 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,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
-
-typedef
-EFI_STATUS
-(*PARTITION_DETECT_ROUTINE) (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Handle,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
-
-#endif
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
deleted file mode 100644
index 680626378f..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+++ /dev/null
@@ -1,89 +0,0 @@
-## @file
-# Modules that produces the logic Block I/O protocol for every partition via the physical Block I/O.
-#
-# This module produces the logical Block I/O device that represents
-# the bytes from Start to End of the Parent Block I/O device.
-# The partition of physical BlockIo device supported is one of legacy MBR, GPT,
-# and "El Torito" partitions.
-#
-# Caution: This module requires additional review when modified.
-# This driver will have external input - disk partition.
-# This external input must be validated carefully to avoid security issue like
-# buffer overflow, integer overflow.
-#
-# Copyright (c) 2006 - 2014, 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
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PartitionDxe
- MODULE_UNI_FILE = PartitionDxe.uni
- FILE_GUID = 1FA1F39E-FEFF-4aae-BD7B-38A070A3B609
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializePartition
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-# DRIVER_BINDING = gPartitionDriverBinding
-# COMPONENT_NAME = gPartitionComponentName
-# COMPONENT_NAME2 = gPartitionComponentName2
-#
-
-[Sources]
- ComponentName.c
- Mbr.c
- Gpt.c
- ElTorito.c
- Partition.c
- Partition.h
-
-
-[Packages]
- MdePkg/MdePkg.dec
-
-
-[LibraryClasses]
- DevicePathLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- UefiLib
- BaseLib
- UefiDriverEntryPoint
- DebugLib
-
-
-[Guids]
- gEfiPartTypeUnusedGuid ## SOMETIMES_CONSUMES ## GUID
- ## SOMETIMES_CONSUMES ## GUID
- ## SOMETIMES_CONSUMES ## GUID # Install protocol
- gEfiPartTypeSystemPartGuid
-
-
-[Protocols]
- ## BY_START
- ## TO_START
- gEfiBlockIoProtocolGuid
- ## BY_START
- ## TO_START
- gEfiBlockIo2ProtocolGuid
- ## BY_START
- ## TO_START
- gEfiDevicePathProtocolGuid
- gEfiDiskIoProtocolGuid ## TO_START
- gEfiDiskIo2ProtocolGuid ## TO_START
-
-[UserExtensions.TianoCore."ExtraFiles"]
- PartitionDxeExtra.uni
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.uni b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.uni
deleted file mode 100644
index 53e439843d..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxeExtra.uni b/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxeExtra.uni
deleted file mode 100644
index a9b13695a9..0000000000
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxeExtra.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
deleted file mode 100644
index 46c834c648..0000000000
--- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+++ /dev/null
@@ -1,60 +0,0 @@
-## @file
-# English module that provides Unicode Collation supports.
-#
-# This driver installs Unicode ISO 639-2 Collation and
-# RFC 4646 Unicode Collation 2 protocols based on feature flags
-# PcdUnicodeCollationSupport & PcdUnicodeCollation2Support respectively.
-# It allows code running in the boot services environment to perform lexical
-# comparison functions on Unicode strings for English languages.
-#
-# Copyright (c) 2006 - 2014, 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
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = EnglishDxe
- MODULE_UNI_FILE = EnglishDxe.uni
- FILE_GUID = CD3BAFB6-50FB-4fe8-8E4E-AB74D2C1A600
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeUnicodeCollationEng
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources]
- UnicodeCollationEng.c
- UnicodeCollationEng.h
-
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- DebugLib
- PcdLib
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdUnicodeCollationSupport ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdUnicodeCollation2Support ## CONSUMES
-
-[Protocols]
- gEfiUnicodeCollationProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdUnicodeCollationSupport ## SOMETIMES_PRODUCES
- gEfiUnicodeCollation2ProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdUnicodeCollation2Support ## PRODUCES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- EnglishDxeExtra.uni
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.uni b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.uni
deleted file mode 100644
index 4ca63be4d1..0000000000
--- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxeExtra.uni b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxeExtra.uni
deleted file mode 100644
index 1ec5c4c3f9..0000000000
--- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxeExtra.uni
+++ /dev/null
Binary files differ
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c
deleted file mode 100644
index a37f5c923c..0000000000
--- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/** @file
- Driver to implement English version of Unicode Collation Protocol.
-
-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
-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 "UnicodeCollationEng.h"
-
-CHAR8 mEngUpperMap[MAP_TABLE_SIZE];
-CHAR8 mEngLowerMap[MAP_TABLE_SIZE];
-CHAR8 mEngInfoMap[MAP_TABLE_SIZE];
-
-CHAR8 mOtherChars[] = {
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '\\',
- '.',
- '_',
- '^',
- '$',
- '~',
- '!',
- '#',
- '%',
- '&',
- '-',
- '{',
- '}',
- '(',
- ')',
- '@',
- '`',
- '\'',
- '\0'
-};
-
-EFI_HANDLE mHandle = NULL;
-
-//
-// EFI Unicode Collation Protocol supporting ISO 639-2 language code
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL UnicodeEng = {
- EngStriColl,
- EngMetaiMatch,
- EngStrLwr,
- EngStrUpr,
- EngFatToStr,
- EngStrToFat,
- "eng"
-};
-
-//
-// EFI Unicode Collation2 Protocol supporting RFC 4646 language code
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL Unicode2Eng = {
- EngStriColl,
- EngMetaiMatch,
- EngStrLwr,
- EngStrUpr,
- EngFatToStr,
- EngStrToFat,
- "en"
-};
-
-/**
- The user Entry Point for English module.
-
- This function initializes unicode character mapping and then installs Unicode
- Collation & Unicode Collation 2 Protocols based on the feature flags.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeUnicodeCollationEng (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- UINTN Index2;
-
- //
- // Initialize mapping tables for the supported languages
- //
- for (Index = 0; Index < MAP_TABLE_SIZE; Index++) {
- mEngUpperMap[Index] = (CHAR8) Index;
- mEngLowerMap[Index] = (CHAR8) Index;
- mEngInfoMap[Index] = 0;
-
- if ((Index >= 'a' && Index <= 'z') || (Index >= 0xe0 && Index <= 0xf6) || (Index >= 0xf8 && Index <= 0xfe)) {
-
- Index2 = Index - 0x20;
- mEngUpperMap[Index] = (CHAR8) Index2;
- mEngLowerMap[Index2] = (CHAR8) Index;
-
- mEngInfoMap[Index] |= CHAR_FAT_VALID;
- mEngInfoMap[Index2] |= CHAR_FAT_VALID;
- }
- }
-
- for (Index = 0; mOtherChars[Index] != 0; Index++) {
- Index2 = mOtherChars[Index];
- mEngInfoMap[Index2] |= CHAR_FAT_VALID;
- }
-
- if (FeaturePcdGet (PcdUnicodeCollation2Support)) {
- if (FeaturePcdGet (PcdUnicodeCollationSupport)) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mHandle,
- &gEfiUnicodeCollationProtocolGuid,
- &UnicodeEng,
- &gEfiUnicodeCollation2ProtocolGuid,
- &Unicode2Eng,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
- } else {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mHandle,
- &gEfiUnicodeCollation2ProtocolGuid,
- &Unicode2Eng,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
- }
- } else {
- if (FeaturePcdGet (PcdUnicodeCollationSupport)) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mHandle,
- &gEfiUnicodeCollationProtocolGuid,
- &UnicodeEng,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
- } else {
- //
- // This module must support to produce at least one of Unicode Collation Protocol
- // and Unicode Collation 2 Protocol.
- //
- ASSERT (FALSE);
- Status = EFI_UNSUPPORTED;
- }
- }
-
- return Status;
-}
-
-
-/**
- Performs a case-insensitive comparison of two Null-terminated strings.
-
- @param This Protocol instance pointer.
- @param Str1 A pointer to a Null-terminated string.
- @param Str2 A pointer to a Null-terminated string.
-
- @retval 0 Str1 is equivalent to Str2
- @retval > 0 Str1 is lexically greater than Str2
- @retval < 0 Str1 is lexically less than Str2
-
-**/
-INTN
-EFIAPI
-EngStriColl (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *Str1,
- IN CHAR16 *Str2
- )
-{
- while (*Str1 != 0) {
- if (TO_UPPER (*Str1) != TO_UPPER (*Str2)) {
- break;
- }
-
- Str1 += 1;
- Str2 += 1;
- }
-
- return TO_UPPER (*Str1) - TO_UPPER (*Str2);
-}
-
-
-/**
- Converts all the characters in a Null-terminated string to
- lower case characters.
-
- @param This Protocol instance pointer.
- @param Str A pointer to a Null-terminated string.
-
-**/
-VOID
-EFIAPI
-EngStrLwr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
- )
-{
- while (*Str != 0) {
- *Str = TO_LOWER (*Str);
- Str += 1;
- }
-}
-
-
-/**
- Converts all the characters in a Null-terminated string to upper
- case characters.
-
- @param This Protocol instance pointer.
- @param Str A pointer to a Null-terminated string.
-
-**/
-VOID
-EFIAPI
-EngStrUpr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
- )
-{
- while (*Str != 0) {
- *Str = TO_UPPER (*Str);
- Str += 1;
- }
-}
-
-/**
- Performs a case-insensitive comparison of a Null-terminated
- pattern string and a Null-terminated string.
-
- @param This Protocol instance pointer.
- @param String A pointer to a Null-terminated string.
- @param Pattern A pointer to a Null-terminated pattern string.
-
- @retval TRUE Pattern was found in String.
- @retval FALSE Pattern was not found in String.
-
-**/
-BOOLEAN
-EFIAPI
-EngMetaiMatch (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN CHAR16 *Pattern
- )
-{
- CHAR16 CharC;
- CHAR16 CharP;
- CHAR16 Index3;
-
- for (;;) {
- CharP = *Pattern;
- Pattern += 1;
-
- switch (CharP) {
- case 0:
- //
- // End of pattern. If end of string, TRUE match
- //
- if (*String != 0) {
- return FALSE;
- } else {
- return TRUE;
- }
-
- case '*':
- //
- // Match zero or more chars
- //
- while (*String != 0) {
- if (EngMetaiMatch (This, String, Pattern)) {
- return TRUE;
- }
-
- String += 1;
- }
-
- return EngMetaiMatch (This, String, Pattern);
-
- case '?':
- //
- // Match any one char
- //
- if (*String == 0) {
- return FALSE;
- }
-
- String += 1;
- break;
-
- case '[':
- //
- // Match char set
- //
- CharC = *String;
- if (CharC == 0) {
- //
- // syntax problem
- //
- return FALSE;
- }
-
- Index3 = 0;
- CharP = *Pattern++;
- while (CharP != 0) {
- if (CharP == ']') {
- return FALSE;
- }
-
- if (CharP == '-') {
- //
- // if range of chars, get high range
- //
- CharP = *Pattern;
- if (CharP == 0 || CharP == ']') {
- //
- // syntax problem
- //
- return FALSE;
- }
-
- if (TO_UPPER (CharC) >= TO_UPPER (Index3) && TO_UPPER (CharC) <= TO_UPPER (CharP)) {
- //
- // if in range, it's a match
- //
- break;
- }
- }
-
- Index3 = CharP;
- if (TO_UPPER (CharC) == TO_UPPER (CharP)) {
- //
- // if char matches
- //
- break;
- }
-
- CharP = *Pattern++;
- }
- //
- // skip to end of match char set
- //
- while ((CharP != 0) && (CharP != ']')) {
- CharP = *Pattern;
- Pattern += 1;
- }
-
- String += 1;
- break;
-
- default:
- CharC = *String;
- if (TO_UPPER (CharC) != TO_UPPER (CharP)) {
- return FALSE;
- }
-
- String += 1;
- break;
- }
- }
-}
-
-
-/**
- Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
-
- @param This Protocol instance pointer.
- @param FatSize The size of the string Fat in bytes.
- @param Fat A pointer to a Null-terminated string that contains an 8.3 file
- name using an 8-bit OEM character set.
- @param String A pointer to a Null-terminated string. The string must
- be preallocated to hold FatSize characters.
-
-**/
-VOID
-EFIAPI
-EngFatToStr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN UINTN FatSize,
- IN CHAR8 *Fat,
- OUT CHAR16 *String
- )
-{
- //
- // No DBCS issues, just expand and add null terminate to end of string
- //
- while ((*Fat != 0) && (FatSize != 0)) {
- *String = *Fat;
- String += 1;
- Fat += 1;
- FatSize -= 1;
- }
-
- *String = 0;
-}
-
-
-/**
- Converts a Null-terminated string to legal characters in a FAT
- filename using an OEM character set.
-
- @param This Protocol instance pointer.
- @param String A pointer to a Null-terminated string. The string must
- be preallocated to hold FatSize characters.
- @param FatSize The size of the string Fat in bytes.
- @param Fat A pointer to a Null-terminated string that contains an 8.3 file
- name using an OEM character set.
-
- @retval TRUE Fat is a Long File Name
- @retval FALSE Fat is an 8.3 file name
-
-**/
-BOOLEAN
-EFIAPI
-EngStrToFat (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN UINTN FatSize,
- OUT CHAR8 *Fat
- )
-{
- BOOLEAN SpecialCharExist;
-
- SpecialCharExist = FALSE;
- while ((*String != 0) && (FatSize != 0)) {
- //
- // Skip '.' or ' ' when making a fat name
- //
- if (*String != '.' && *String != ' ') {
- //
- // If this is a valid fat char, move it.
- // Otherwise, move a '_' and flag the fact that the name needs a long file name.
- //
- if (*String < MAP_TABLE_SIZE && ((mEngInfoMap[*String] & CHAR_FAT_VALID) != 0)) {
- *Fat = mEngUpperMap[*String];
- } else {
- *Fat = '_';
- SpecialCharExist = TRUE;
- }
-
- Fat += 1;
- FatSize -= 1;
- }
-
- String += 1;
- }
- //
- // Do not terminate that fat string
- //
- return SpecialCharExist;
-}
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h
deleted file mode 100644
index ac6dfc4033..0000000000
--- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/** @file
- Head file for Unicode Collation Protocol (English)
-
-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
-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.
-
-**/
-
-#ifndef _UNICODE_COLLATION_ENG_H_
-#define _UNICODE_COLLATION_ENG_H_
-
-
-
-#include <Uefi.h>
-
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PcdLib.h>
-
-//
-// Bit mask to indicate the validity of character in FAT file name.
-//
-#define CHAR_FAT_VALID 0x01
-
-//
-// Maximum FAT table size.
-//
-#define MAP_TABLE_SIZE 0x100
-
-//
-// Macro to map character a to upper case.
-//
-#define TO_UPPER(a) (CHAR16) ((a) <= 0xFF ? mEngUpperMap[a] : (a))
-
-//
-// Macro to map character a to lower case.
-//
-#define TO_LOWER(a) (CHAR16) ((a) <= 0xFF ? mEngLowerMap[a] : (a))
-
-//
-// Prototypes
-//
-/**
- Performs a case-insensitive comparison of two Null-terminated strings.
-
- @param This Protocol instance pointer.
- @param Str1 A pointer to a Null-terminated string.
- @param Str2 A pointer to a Null-terminated string.
-
- @retval 0 Str1 is equivalent to Str2
- @retval > 0 Str1 is lexically greater than Str2
- @retval < 0 Str1 is lexically less than Str2
-
-**/
-INTN
-EFIAPI
-EngStriColl (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *Str1,
- IN CHAR16 *Str2
- );
-
-/**
- Performs a case-insensitive comparison of a Null-terminated
- pattern string and a Null-terminated string.
-
- @param This Protocol instance pointer.
- @param String A pointer to a Null-terminated string.
- @param Pattern A pointer to a Null-terminated pattern string.
-
- @retval TRUE Pattern was found in String.
- @retval FALSE Pattern was not found in String.
-
-**/
-BOOLEAN
-EFIAPI
-EngMetaiMatch (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN CHAR16 *Pattern
- );
-
-/**
- Converts all the characters in a Null-terminated string to
- lower case characters.
-
- @param This Protocol instance pointer.
- @param Str A pointer to a Null-terminated string.
-
-**/
-VOID
-EFIAPI
-EngStrLwr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
- );
-
-/**
- Converts all the characters in a Null-terminated string to upper
- case characters.
-
- @param This Protocol instance pointer.
- @param Str A pointer to a Null-terminated string.
-
-**/
-VOID
-EFIAPI
-EngStrUpr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
- );
-
-/**
- Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
-
- @param This Protocol instance pointer.
- @param FatSize The size of the string Fat in bytes.
- @param Fat A pointer to a Null-terminated string that contains an 8.3 file
- name using an 8-bit OEM character set.
- @param String A pointer to a Null-terminated string. The string must
- be preallocated to hold FatSize characters.
-
-**/
-VOID
-EFIAPI
-EngFatToStr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN UINTN FatSize,
- IN CHAR8 *Fat,
- OUT CHAR16 *String
- );
-
-/**
- Converts a Null-terminated string to legal characters in a FAT
- filename using an OEM character set.
-
- @param This Protocol instance pointer.
- @param String A pointer to a Null-terminated string. The string must
- be preallocated to hold FatSize characters.
- @param FatSize The size of the string Fat in bytes.
- @param Fat A pointer to a Null-terminated string that contains an 8.3 file
- name using an OEM character set.
-
- @retval TRUE Fat is a Long File Name
- @retval FALSE Fat is an 8.3 file name
-
-**/
-BOOLEAN
-EFIAPI
-EngStrToFat (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN UINTN FatSize,
- OUT CHAR8 *Fat
- );
-
-/**
- The user Entry Point for English module.
-
- This function initializes unicode character mapping and then installs Unicode
- Collation & Unicode Collation 2 Protocols based on the feature flags.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeUnicodeCollationEng (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#endif
-