/** @file
Source file for CD recovery PEIM
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The
full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "PeiCdExpress.h"
/**
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.
**/
)
{
return EFI_SUCCESS;
}
if (PrivateData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Initialize Private Data (to zero, as is required by subsequent operations)
//
return EFI_OUT_OF_RESOURCES;
}
PrivateData->CapsuleCount = 0;
//
// Installs Ppi
//
PrivateData->PpiDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
return EFI_OUT_OF_RESOURCES;
}
//
// PrivateData is allocated now, set it to the module variable
//
//
// Installs Block Io Ppi notification function
//
(
);
}
/**
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.
**/
)
{
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.
@retval EFI_SUCCESS The blocks and volumes are updated successfully.
**/
)
{
IndexBlockDevice = 0;
//
// 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++) {
(VOID **) &BlockIoPpi
);
//
// Done with all Block Io Ppis
//
break;
}
);
continue;
}
//
// Just retrieve the first block, should emulate all blocks.
//
for (IndexBlockDevice = 1; IndexBlockDevice <= NumberBlockDevices && PrivateData->CapsuleCount < PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER; IndexBlockDevice ++) {
);
!Media.MediaPresent ||
) {
continue;
}
continue;
}
}
}
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.
**/
)
{
Lba = 16;
//
// The volume descriptor starts on Lba 16
//
VolumeSpaceSize = 0;
OriginalLBA = 16;
while (TRUE) {
Lba,
);
return Status;
}
break;
}
if (StartOfVolume) {
OriginalLBA = Lba;
}
if (Type == PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR) {
if (VolumeSpaceSize == 0) {
break;
} else {
VolumeSpaceSize = 0;
continue;
}
}
if (Type != PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY) {
Lba++;
continue;
}
RoorDirRecord = (PEI_CD_EXPRESS_DIR_FILE_RECORD *) (Buffer + PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET);
//
// 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 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
**/
)
{
Lba,
);
return Status;
}
while (1) {
if (FileRecord->Length == 0) {
break;
}
//
// Not intend to check other flag now
//
continue;
}
break;
}
}
continue;
}
if (!StringCmp (FileRecord->FileID, (UINT8 *) PEI_RECOVERY_FILE_NAME, sizeof (PEI_RECOVERY_FILE_NAME) - 1, FALSE)) {
continue;
}
PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleStartLBA = FileRecord->LocationOfExtent[0];
(
FileRecord->DataLength[0] /
1
) *
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.
**/
)
{
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.
**/
)
{
return Status;
}
}
return EFI_NOT_FOUND;
}
CopyMem (
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.
**/
)
{
return Status;
}
}
return EFI_NOT_FOUND;
}
);
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.
**/
)
{
continue;
}
if (!CaseSensitive) {
Dif = (UINT8) ((Source1[Index] > Source2[Index]) ? (Source1[Index] - Source2[Index]) : (Source2[Index] - Source1[Index]));
continue;
}
}
return FALSE;
}
return TRUE;
}