diff options
Diffstat (limited to 'MdeModulePkg/Universal/Disk')
27 files changed, 3021 insertions, 2842 deletions
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c index 242dbf8eb1..6a84f9efd1 100644 --- a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c +++ b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c @@ -9,9 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PeiCdExpress.h"
-PEI_CD_EXPRESS_PRIVATE_DATA *mPrivateData = NULL;
-CHAR8 *mRecoveryFileName;
-UINTN mRecoveryFileNameSize;
+PEI_CD_EXPRESS_PRIVATE_DATA *mPrivateData = NULL;
+CHAR8 *mRecoveryFileName;
+UINTN mRecoveryFileNameSize;
/**
Installs the Device Recovery Module PPI, Initialize BlockIo Ppi
@@ -27,12 +27,12 @@ UINTN mRecoveryFileNameSize; EFI_STATUS
EFIAPI
CdExpressPeimEntry (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
+ EFI_STATUS Status;
+ PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle))) {
return EFI_SUCCESS;
@@ -43,13 +43,14 @@ CdExpressPeimEntry ( return EFI_OUT_OF_RESOURCES;
}
- mRecoveryFileNameSize = PcdGetSize(PcdRecoveryFileName) / sizeof(CHAR16);
- mRecoveryFileName = AllocatePool(mRecoveryFileNameSize);
+ mRecoveryFileNameSize = PcdGetSize (PcdRecoveryFileName) / sizeof (CHAR16);
+ mRecoveryFileName = AllocatePool (mRecoveryFileNameSize);
if (mRecoveryFileName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = UnicodeStrToAsciiStrS(PcdGetPtr(PcdRecoveryFileName), mRecoveryFileName, mRecoveryFileNameSize);
- if (EFI_ERROR(Status)) {
+
+ Status = UnicodeStrToAsciiStrS (PcdGetPtr (PcdRecoveryFileName), mRecoveryFileName, mRecoveryFileNameSize);
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -57,23 +58,23 @@ CdExpressPeimEntry ( // Initialize Private Data (to zero, as is required by subsequent operations)
//
ZeroMem (PrivateData, sizeof (*PrivateData));
- PrivateData->Signature = PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE;
+ PrivateData->Signature = PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE;
- PrivateData->BlockBuffer = AllocatePages (EFI_SIZE_TO_PAGES (PEI_CD_BLOCK_SIZE));
+ 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);
+ Status = UpdateBlocksAndVolumes (PrivateData, TRUE);
+ Status = UpdateBlocksAndVolumes (PrivateData, FALSE);
//
// Installs Ppi
//
- PrivateData->DeviceRecoveryPpi.GetNumberRecoveryCapsules = GetNumberRecoveryCapsules;
- PrivateData->DeviceRecoveryPpi.GetRecoveryCapsuleInfo = GetRecoveryCapsuleInfo;
- PrivateData->DeviceRecoveryPpi.LoadRecoveryCapsule = LoadRecoveryCapsule;
+ 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;
@@ -83,6 +84,7 @@ CdExpressPeimEntry ( if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// PrivateData is allocated now, set it to the module variable
//
@@ -93,21 +95,20 @@ CdExpressPeimEntry ( //
PrivateData->NotifyDescriptor.Flags =
(
- EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
);
- PrivateData->NotifyDescriptor.Guid = &gEfiPeiVirtualBlockIoPpiGuid;
- PrivateData->NotifyDescriptor.Notify = BlockIoNotifyEntry;
+ PrivateData->NotifyDescriptor.Guid = &gEfiPeiVirtualBlockIoPpiGuid;
+ PrivateData->NotifyDescriptor.Notify = BlockIoNotifyEntry;
PrivateData->NotifyDescriptor2.Flags =
(
- EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
- EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
);
- PrivateData->NotifyDescriptor2.Guid = &gEfiPeiVirtualBlockIo2PpiGuid;
- PrivateData->NotifyDescriptor2.Notify = BlockIoNotifyEntry;
+ PrivateData->NotifyDescriptor2.Guid = &gEfiPeiVirtualBlockIo2PpiGuid;
+ PrivateData->NotifyDescriptor2.Notify = BlockIoNotifyEntry;
return PeiServicesNotifyPpi (&PrivateData->NotifyDescriptor);
-
}
/**
@@ -151,8 +152,8 @@ BlockIoNotifyEntry ( **/
EFI_STATUS
UpdateBlocksAndVolumes (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN BOOLEAN BlockIo2
+ IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
+ IN BOOLEAN BlockIo2
)
{
EFI_STATUS Status;
@@ -176,19 +177,20 @@ UpdateBlocksAndVolumes ( for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) {
if (BlockIo2) {
Status = PeiServicesLocatePpi (
- &gEfiPeiVirtualBlockIo2PpiGuid,
- BlockIoPpiInstance,
- &TempPpiDescriptor,
- (VOID **) &BlockIo2Ppi
- );
+ &gEfiPeiVirtualBlockIo2PpiGuid,
+ BlockIoPpiInstance,
+ &TempPpiDescriptor,
+ (VOID **)&BlockIo2Ppi
+ );
} else {
Status = PeiServicesLocatePpi (
- &gEfiPeiVirtualBlockIoPpiGuid,
- BlockIoPpiInstance,
- &TempPpiDescriptor,
- (VOID **) &BlockIoPpi
- );
+ &gEfiPeiVirtualBlockIoPpiGuid,
+ BlockIoPpiInstance,
+ &TempPpiDescriptor,
+ (VOID **)&BlockIoPpi
+ );
}
+
if (EFI_ERROR (Status)) {
//
// Done with all Block Io Ppis
@@ -196,7 +198,7 @@ UpdateBlocksAndVolumes ( break;
}
- PeiServices = (EFI_PEI_SERVICES **) GetPeiServicesTablePointer ();
+ PeiServices = (EFI_PEI_SERVICES **)GetPeiServicesTablePointer ();
if (BlockIo2) {
Status = BlockIo2Ppi->GetNumberOfBlockDevices (
PeiServices,
@@ -205,18 +207,20 @@ UpdateBlocksAndVolumes ( );
} else {
Status = BlockIoPpi->GetNumberOfBlockDevices (
- PeiServices,
- BlockIoPpi,
- &NumberBlockDevices
- );
+ 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 ++) {
+ for (IndexBlockDevice = 1; IndexBlockDevice <= NumberBlockDevices && PrivateData->CapsuleCount < PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER; IndexBlockDevice++) {
if (BlockIo2) {
Status = BlockIo2Ppi->GetBlockDeviceMediaInfo (
PeiServices,
@@ -226,28 +230,32 @@ UpdateBlocksAndVolumes ( );
if (EFI_ERROR (Status) ||
!Media2.MediaPresent ||
- ((Media2.InterfaceType != MSG_ATAPI_DP) && (Media2.InterfaceType != MSG_USB_DP)) ||
+ ((Media2.InterfaceType != MSG_ATAPI_DP) && (Media2.InterfaceType != MSG_USB_DP)) ||
(Media2.BlockSize != PEI_CD_BLOCK_SIZE)
- ) {
+ )
+ {
continue;
}
+
DEBUG ((DEBUG_INFO, "PeiCdExpress InterfaceType is %d\n", Media2.InterfaceType));
DEBUG ((DEBUG_INFO, "PeiCdExpress MediaPresent is %d\n", Media2.MediaPresent));
DEBUG ((DEBUG_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media2.BlockSize));
} else {
Status = BlockIoPpi->GetBlockDeviceMediaInfo (
- PeiServices,
- BlockIoPpi,
- IndexBlockDevice,
- &Media
- );
+ PeiServices,
+ BlockIoPpi,
+ IndexBlockDevice,
+ &Media
+ );
if (EFI_ERROR (Status) ||
!Media.MediaPresent ||
- ((Media.DeviceType != IdeCDROM) && (Media.DeviceType != UsbMassStorage)) ||
+ ((Media.DeviceType != IdeCDROM) && (Media.DeviceType != UsbMassStorage)) ||
(Media.BlockSize != PEI_CD_BLOCK_SIZE)
- ) {
+ )
+ {
continue;
}
+
DEBUG ((DEBUG_INFO, "PeiCdExpress DeviceType is %d\n", Media.DeviceType));
DEBUG ((DEBUG_INFO, "PeiCdExpress MediaPresent is %d\n", Media.MediaPresent));
DEBUG ((DEBUG_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media.BlockSize));
@@ -260,8 +268,9 @@ UpdateBlocksAndVolumes ( if (BlockIo2) {
PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo2 = BlockIo2Ppi;
} else {
- PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo = BlockIoPpi;
+ PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo = BlockIoPpi;
}
+
Status = FindRecoveryCapsules (PrivateData);
DEBUG ((DEBUG_INFO, "Status is %d\n", Status));
@@ -271,7 +280,6 @@ UpdateBlocksAndVolumes ( PrivateData->CapsuleCount++;
}
-
}
return EFI_SUCCESS;
@@ -289,7 +297,7 @@ UpdateBlocksAndVolumes ( EFI_STATUS
EFIAPI
FindRecoveryCapsules (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
+ IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
)
{
EFI_STATUS Status;
@@ -307,10 +315,10 @@ FindRecoveryCapsules ( UINTN OriginalLBA;
UINTN IndexBlockDevice;
- Buffer = PrivateData->BlockBuffer;
- BufferSize = PEI_CD_BLOCK_SIZE;
+ Buffer = PrivateData->BlockBuffer;
+ BufferSize = PEI_CD_BLOCK_SIZE;
- Lba = 16;
+ Lba = 16;
//
// The volume descriptor starts on Lba 16
//
@@ -326,29 +334,30 @@ FindRecoveryCapsules ( SetMem (Buffer, BufferSize, 0);
if (BlockIo2Ppi != NULL) {
Status = BlockIo2Ppi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIo2Ppi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
+ (EFI_PEI_SERVICES **)GetPeiServicesTablePointer (),
+ BlockIo2Ppi,
+ IndexBlockDevice,
+ Lba,
+ BufferSize,
+ Buffer
+ );
} else {
Status = BlockIoPpi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIoPpi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
+ (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)) {
+ 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;
}
@@ -357,7 +366,7 @@ FindRecoveryCapsules ( StartOfVolume = FALSE;
}
- Type = *(UINT8 *) (Buffer + PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET);
+ Type = *(UINT8 *)(Buffer + PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET);
if (Type == PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR) {
if (VolumeSpaceSize == 0) {
break;
@@ -374,12 +383,12 @@ FindRecoveryCapsules ( continue;
}
- VolumeSpaceSize = *(UINT32 *) (Buffer + PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET);
+ 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];
+ 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);
+ Status = RetrieveCapsuleFileFromRoot (PrivateData, BlockIoPpi, BlockIo2Ppi, IndexBlockDevice, RootDirLBA);
if (!EFI_ERROR (Status)) {
//
// Just look for the first primary descriptor
@@ -410,11 +419,11 @@ FindRecoveryCapsules ( 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
+ 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;
@@ -423,40 +432,42 @@ RetrieveCapsuleFileFromRoot ( PEI_CD_EXPRESS_DIR_FILE_RECORD *FileRecord;
UINTN Index;
- Buffer = PrivateData->BlockBuffer;
- BufferSize = PEI_CD_BLOCK_SIZE;
+ 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
- );
+ (EFI_PEI_SERVICES **)GetPeiServicesTablePointer (),
+ BlockIo2Ppi,
+ IndexBlockDevice,
+ Lba,
+ BufferSize,
+ Buffer
+ );
} else {
Status = BlockIoPpi->ReadBlocks (
- (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
- BlockIoPpi,
- IndexBlockDevice,
- Lba,
- BufferSize,
- Buffer
- );
+ (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;
+ FileRecord = (PEI_CD_EXPRESS_DIR_FILE_RECORD *)Buffer;
if (FileRecord->Length == 0) {
break;
}
+
//
// Not intend to check other flag now
//
@@ -481,12 +492,12 @@ RetrieveCapsuleFileFromRoot ( continue;
}
- PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleStartLBA = FileRecord->LocationOfExtent[0];
+ PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleStartLBA = FileRecord->LocationOfExtent[0];
PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleBlockAlignedSize =
(
- FileRecord->DataLength[0] /
- PEI_CD_BLOCK_SIZE +
- 1
+ FileRecord->DataLength[0] /
+ PEI_CD_BLOCK_SIZE +
+ 1
) *
PEI_CD_BLOCK_SIZE;
PrivateData->CapsuleData[PrivateData->CapsuleCount].CapsuleSize = FileRecord->DataLength[0];
@@ -523,12 +534,12 @@ RetrieveCapsuleFileFromRoot ( EFI_STATUS
EFIAPI
GetNumberRecoveryCapsules (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- OUT UINTN *NumberRecoveryCapsules
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
+ OUT UINTN *NumberRecoveryCapsules
)
{
- PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
+ PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
PrivateData = PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS (This);
UpdateBlocksAndVolumes (PrivateData, TRUE);
@@ -570,16 +581,16 @@ GetNumberRecoveryCapsules ( 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
+ 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;
+ PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData;
+ UINTN NumberRecoveryCapsules;
+ EFI_STATUS Status;
Status = GetNumberRecoveryCapsules (PeiServices, This, &NumberRecoveryCapsules);
@@ -625,10 +636,10 @@ GetRecoveryCapsuleInfo ( EFI_STATUS
EFIAPI
LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT VOID *Buffer
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
+ IN UINTN CapsuleInstance,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -653,23 +664,24 @@ LoadRecoveryCapsule ( if (BlockIo2Ppi != NULL) {
Status = BlockIo2Ppi->ReadBlocks (
- PeiServices,
- BlockIo2Ppi,
- PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,
- Buffer
- );
+ PeiServices,
+ BlockIo2Ppi,
+ PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
+ PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
+ PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,
+ Buffer
+ );
} else {
Status = BlockIoPpi->ReadBlocks (
- PeiServices,
- BlockIoPpi,
- PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
- PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,
- Buffer
- );
+ PeiServices,
+ BlockIoPpi,
+ PrivateData->CapsuleData[CapsuleInstance - 1].IndexBlock,
+ PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleStartLBA,
+ PrivateData->CapsuleData[CapsuleInstance - 1].CapsuleBlockAlignedSize,
+ Buffer
+ );
}
+
return Status;
}
@@ -687,14 +699,14 @@ LoadRecoveryCapsule ( **/
BOOLEAN
StringCmp (
- IN UINT8 *Source1,
- IN UINT8 *Source2,
- IN UINTN Size,
- IN BOOLEAN CaseSensitive
+ IN UINT8 *Source1,
+ IN UINT8 *Source2,
+ IN UINTN Size,
+ IN BOOLEAN CaseSensitive
)
{
- UINTN Index;
- UINT8 Dif;
+ UINTN Index;
+ UINT8 Dif;
for (Index = 0; Index < Size; Index++) {
if (Source1[Index] == Source2[Index]) {
@@ -702,7 +714,7 @@ StringCmp ( }
if (!CaseSensitive) {
- Dif = (UINT8) ((Source1[Index] > Source2[Index]) ? (Source1[Index] - Source2[Index]) : (Source2[Index] - Source1[Index]));
+ Dif = (UINT8)((Source1[Index] > Source2[Index]) ? (Source1[Index] - Source2[Index]) : (Source2[Index] - Source1[Index]));
if (Dif == ('a' - 'A')) {
continue;
}
diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h index 513f0709b7..e5b9c1eaa2 100644 --- a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h +++ b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h @@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _PEI_CD_EXPRESS_H_
#define _PEI_CD_EXPRESS_H_
-
#include <PiPei.h>
#include <Ppi/BlockIo.h>
@@ -26,44 +25,42 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #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_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
+#define PEI_CD_BLOCK_SIZE 0x800
+#define PEI_MEMMORY_PAGE_SIZE 0x1000
//
// 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_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_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_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 CapsuleBlockAlignedSize;
- UINTN IndexBlock;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2;
+ UINTN CapsuleStartLBA;
+ UINTN CapsuleSize;
+ UINTN CapsuleBlockAlignedSize;
+ 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')
+#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;
@@ -73,7 +70,6 @@ typedef struct { 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) \
@@ -84,17 +80,17 @@ typedef struct { )
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];
+ 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;
/**
@@ -129,8 +125,8 @@ BlockIoNotifyEntry ( **/
EFI_STATUS
UpdateBlocksAndVolumes (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
- IN BOOLEAN BlockIo2
+ IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
+ IN BOOLEAN BlockIo2
);
/**
@@ -159,9 +155,9 @@ UpdateBlocksAndVolumes ( EFI_STATUS
EFIAPI
GetNumberRecoveryCapsules (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- OUT UINTN *NumberRecoveryCapsules
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
+ OUT UINTN *NumberRecoveryCapsules
);
/**
@@ -192,11 +188,11 @@ GetNumberRecoveryCapsules ( 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
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
+ IN UINTN CapsuleInstance,
+ OUT UINTN *Size,
+ OUT EFI_GUID *CapsuleType
);
/**
@@ -221,10 +217,10 @@ GetRecoveryCapsuleInfo ( EFI_STATUS
EFIAPI
LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
- IN UINTN CapsuleInstance,
- OUT VOID *Buffer
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
+ IN UINTN CapsuleInstance,
+ OUT VOID *Buffer
);
/**
@@ -239,7 +235,7 @@ LoadRecoveryCapsule ( EFI_STATUS
EFIAPI
FindRecoveryCapsules (
- IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
+ IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
);
/**
@@ -259,14 +255,13 @@ FindRecoveryCapsules ( 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
+ 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.
@@ -281,10 +276,10 @@ RetrieveCapsuleFileFromRoot ( **/
BOOLEAN
StringCmp (
- IN UINT8 *Source1,
- IN UINT8 *Source2,
- IN UINTN Size,
- IN BOOLEAN CaseSensitive
+ IN UINT8 *Source1,
+ IN UINT8 *Source2,
+ IN UINTN Size,
+ IN BOOLEAN CaseSensitive
);
#pragma pack()
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c index ba6e427cd4..a6f31ed245 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/ComponentName.c @@ -20,9 +20,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName //
// 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,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)DiskIoComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)DiskIoComponentNameGetControllerName,
"en"
};
@@ -30,7 +30,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2 // 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[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDiskIoDriverNameTable[] = {
{
"eng;en",
(CHAR16 *)L"Generic Disk I/O Driver"
@@ -41,8 +41,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDiskIoDriverNameTable[] }
};
-
-
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -99,8 +97,6 @@ DiskIoComponentNameGetDriverName ( );
}
-
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -172,11 +168,11 @@ DiskIoComponentNameGetDriverName ( 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
+ 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 index bc43d92e4e..38af39f41e 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c @@ -19,7 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Driver binding protocol implementation for DiskIo driver.
//
-EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {
DiskIoDriverBindingSupported,
DiskIoDriverBindingStart,
DiskIoDriverBindingStop,
@@ -32,7 +32,7 @@ EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = { // Template for DiskIo private data structure.
// The pointer to BlockIo protocol interface is assigned dynamically.
//
-DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
+DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
DISK_IO_PRIVATE_DATA_SIGNATURE,
{
EFI_DISK_IO_PROTOCOL_REVISION,
@@ -69,8 +69,8 @@ DiskIoDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
//
// Open the IO Abstraction(s) needed to perform the supported test.
@@ -78,7 +78,7 @@ DiskIoDriverBindingSupported ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -99,7 +99,6 @@ DiskIoDriverBindingSupported ( return EFI_SUCCESS;
}
-
/**
Start this driver on ControllerHandle by opening a Block IO protocol and
installing a Disk IO protocol on ControllerHandle.
@@ -136,7 +135,7 @@ DiskIoDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &gDiskIoPrivateDataTemplate.BlockIo,
+ (VOID **)&gDiskIoPrivateDataTemplate.BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -148,7 +147,7 @@ DiskIoDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIo2ProtocolGuid,
- (VOID **) &gDiskIoPrivateDataTemplate.BlockIo2,
+ (VOID **)&gDiskIoPrivateDataTemplate.BlockIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -169,10 +168,12 @@ DiskIoDriverBindingStart ( //
// 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)
- ));
+ 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);
@@ -191,21 +192,24 @@ DiskIoDriverBindingStart ( if (Instance->BlockIo2 != NULL) {
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2,
+ &gEfiDiskIoProtocolGuid,
+ &Instance->DiskIo,
+ &gEfiDiskIo2ProtocolGuid,
+ &Instance->DiskIo2,
NULL
);
} else {
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
+ &gEfiDiskIoProtocolGuid,
+ &Instance->DiskIo,
NULL
);
}
ErrorExit:
if (EFI_ERROR (Status)) {
- if (Instance != NULL && Instance->SharedWorkingBuffer != NULL) {
+ if ((Instance != NULL) && (Instance->SharedWorkingBuffer != NULL)) {
FreeAlignedPages (
Instance->SharedWorkingBuffer,
EFI_SIZE_TO_PAGES (PcdGet32 (PcdDiskIoDataBufferBlockNum) * Instance->BlockIo->Media->BlockSize)
@@ -246,17 +250,17 @@ ErrorExit1: EFI_STATUS
EFIAPI
DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ 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;
+ EFI_STATUS Status;
+ EFI_DISK_IO_PROTOCOL *DiskIo;
+ EFI_DISK_IO2_PROTOCOL *DiskIo2;
+ DISK_IO_PRIVATE_DATA *Instance;
+ BOOLEAN AllTaskDone;
//
// Get our context back.
@@ -264,7 +268,7 @@ DiskIoDriverBindingStop ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ (VOID **)&DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -272,10 +276,11 @@ DiskIoDriverBindingStop ( if (EFI_ERROR (Status)) {
return Status;
}
+
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIo2ProtocolGuid,
- (VOID **) &DiskIo2,
+ (VOID **)&DiskIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -295,21 +300,25 @@ DiskIoDriverBindingStop ( if (EFI_ERROR (Status)) {
return Status;
}
+
Status = gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
- &gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2,
+ &gEfiDiskIoProtocolGuid,
+ &Instance->DiskIo,
+ &gEfiDiskIo2ProtocolGuid,
+ &Instance->DiskIo2,
NULL
);
} else {
Status = gBS->UninstallMultipleProtocolInterfaces (
ControllerHandle,
- &gEfiDiskIoProtocolGuid, &Instance->DiskIo,
+ &gEfiDiskIoProtocolGuid,
+ &Instance->DiskIo,
NULL
);
}
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
do {
EfiAcquireLock (&Instance->TaskQueueLock);
AllTaskDone = IsListEmpty (&Instance->TaskQueue);
@@ -344,7 +353,6 @@ DiskIoDriverBindingStop ( return Status;
}
-
/**
Destroy the sub task.
@@ -355,15 +363,16 @@ DiskIoDriverBindingStop ( **/
LIST_ENTRY *
DiskIoDestroySubtask (
- IN DISK_IO_PRIVATE_DATA *Instance,
- IN DISK_IO_SUBTASK *Subtask
+ IN DISK_IO_PRIVATE_DATA *Instance,
+ IN DISK_IO_SUBTASK *Subtask
)
{
- LIST_ENTRY *Link;
+ LIST_ENTRY *Link;
if (Subtask->Task != NULL) {
EfiAcquireLock (&Subtask->Task->SubtasksLock);
}
+
Link = RemoveEntryList (&Subtask->Link);
if (Subtask->Task != NULL) {
EfiReleaseLock (&Subtask->Task->SubtasksLock);
@@ -378,10 +387,12 @@ DiskIoDestroySubtask ( : EFI_SIZE_TO_PAGES (Subtask->Length)
);
}
+
if (Subtask->BlockIo2Token.Event != NULL) {
gBS->CloseEvent (Subtask->BlockIo2Token.Event);
}
}
+
FreePool (Subtask);
return Link;
@@ -396,8 +407,8 @@ DiskIoDestroySubtask ( VOID
EFIAPI
DiskIo2OnReadWriteComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
DISK_IO_SUBTASK *Subtask;
@@ -405,7 +416,7 @@ DiskIo2OnReadWriteComplete ( EFI_STATUS TransactionStatus;
DISK_IO_PRIVATE_DATA *Instance;
- Subtask = (DISK_IO_SUBTASK *) Context;
+ Subtask = (DISK_IO_SUBTASK *)Context;
TransactionStatus = Subtask->BlockIo2Token.TransactionStatus;
Task = Subtask->Task;
Instance = Task->Instance;
@@ -416,7 +427,8 @@ DiskIo2OnReadWriteComplete ( if ((Subtask->WorkingBuffer != NULL) && !EFI_ERROR (TransactionStatus) &&
(Task->Token != NULL) && !Subtask->Write
- ) {
+ )
+ {
CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);
}
@@ -454,22 +466,23 @@ DiskIo2OnReadWriteComplete ( **/
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
+ 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;
+ 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;
@@ -491,10 +504,16 @@ DiskIoCreateSubtask ( return NULL;
}
}
+
DEBUG ((
DEBUG_BLKIO,
" %c:Lba/Offset/Length/WorkingBuffer/Buffer = %016lx/%08x/%08x/%08x/%08x\n",
- Write ? 'W': 'R', Lba, Offset, Length, WorkingBuffer, Buffer
+ Write ? 'W' : 'R',
+ Lba,
+ Offset,
+ Length,
+ WorkingBuffer,
+ Buffer
));
return Subtask;
@@ -527,18 +546,18 @@ DiskIoCreateSubtaskList ( 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;
+ 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 ((DEBUG_BLKIO, "DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = %016lx/%08x/%08x\n", Offset, BufferSize, Buffer));
@@ -549,7 +568,7 @@ DiskIoCreateSubtaskList ( }
Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);
- BufferPtr = (UINT8 *) Buffer;
+ BufferPtr = (UINT8 *)Buffer;
//
// Special handling for zero BufferSize
@@ -559,6 +578,7 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
return TRUE;
}
@@ -573,6 +593,7 @@ DiskIoCreateSubtaskList ( goto Done;
}
}
+
if (Write) {
//
// A half write operation can be splitted to a blocking block-read and half write operation
@@ -582,6 +603,7 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
}
@@ -589,12 +611,13 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
BufferPtr += Length;
Offset += Length;
BufferSize -= Length;
- Lba ++;
+ Lba++;
}
OverRunLba = Lba + DivU64x32Remainder (BufferSize, BlockSize, &OverRun);
@@ -609,6 +632,7 @@ DiskIoCreateSubtaskList ( goto Done;
}
}
+
if (Write) {
//
// A half write operation can be splitted to a blocking block-read and half write operation
@@ -618,6 +642,7 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
}
@@ -625,6 +650,7 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
}
@@ -637,25 +663,26 @@ DiskIoCreateSubtaskList ( 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)) {
+ 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;
@@ -677,6 +704,7 @@ DiskIoCreateSubtaskList ( if (Subtask == NULL) {
goto Done;
}
+
InsertTailList (Subtasks, &Subtask->Link);
}
@@ -697,8 +725,9 @@ Done: //
for (Link = GetFirstNode (Subtasks); !IsNull (Subtasks, Link); ) {
Subtask = CR (Link, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
- Link = DiskIoDestroySubtask (Instance, Subtask);
+ Link = DiskIoDestroySubtask (Instance, Subtask);
}
+
return FALSE;
}
@@ -714,7 +743,7 @@ Done: EFI_STATUS
EFIAPI
DiskIo2Cancel (
- IN EFI_DISK_IO2_PROTOCOL *This
+ IN EFI_DISK_IO2_PROTOCOL *This
)
{
DISK_IO_PRIVATE_DATA *Instance;
@@ -726,9 +755,10 @@ DiskIo2Cancel ( EfiAcquireLock (&Instance->TaskQueueLock);
for (Link = GetFirstNode (&Instance->TaskQueue)
- ; !IsNull (&Instance->TaskQueue, Link)
- ; Link = GetNextNode (&Instance->TaskQueue, Link)
- ) {
+ ; !IsNull (&Instance->TaskQueue, Link)
+ ; Link = GetNextNode (&Instance->TaskQueue, Link)
+ )
+ {
Task = CR (Link, DISK_IO2_TASK, Link, DISK_IO2_TASK_SIGNATURE);
if (Task->Token != NULL) {
@@ -756,12 +786,12 @@ DiskIo2Cancel ( **/
BOOLEAN
DiskIo2RemoveCompletedTask (
- IN DISK_IO_PRIVATE_DATA *Instance
+ IN DISK_IO_PRIVATE_DATA *Instance
)
{
- BOOLEAN QueueEmpty;
- LIST_ENTRY *Link;
- DISK_IO2_TASK *Task;
+ BOOLEAN QueueEmpty;
+ LIST_ENTRY *Link;
+ DISK_IO2_TASK *Task;
QueueEmpty = TRUE;
@@ -773,10 +803,11 @@ DiskIo2RemoveCompletedTask ( ASSERT (Task->Token == NULL);
FreePool (Task);
} else {
- Link = GetNextNode (&Instance->TaskQueue, Link);
+ Link = GetNextNode (&Instance->TaskQueue, Link);
QueueEmpty = FALSE;
}
}
+
EfiReleaseLock (&Instance->TaskQueueLock);
return QueueEmpty;
@@ -797,41 +828,42 @@ DiskIo2RemoveCompletedTask ( **/
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
+ 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));
+ 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 (Blocking) {
//
// Wait till pending async task is completed.
//
- while (!DiskIo2RemoveCompletedTask (Instance));
+ while (!DiskIo2RemoveCompletedTask (Instance)) {
+ }
SubtasksPtr = &Subtasks;
} else {
@@ -858,15 +890,18 @@ DiskIo2ReadWriteDisk ( 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)
- ) {
+ ; !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;
@@ -902,7 +937,6 @@ DiskIo2ReadWriteDisk ( (Subtask->WorkingBuffer != NULL) ? Subtask->WorkingBuffer : Subtask->Buffer
);
}
-
} else {
//
// Read
@@ -951,7 +985,7 @@ DiskIo2ReadWriteDisk ( //
if (EFI_ERROR (Status)) {
while (!IsNull (SubtasksPtr, NextLink)) {
- Subtask = CR (NextLink, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
+ Subtask = CR (NextLink, DISK_IO_SUBTASK, Link, DISK_IO_SUBTASK_SIGNATURE);
NextLink = DiskIoDestroySubtask (Instance, Subtask);
}
}
@@ -1008,17 +1042,22 @@ DiskIo2ReadWriteDisk ( 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
+ 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
+ FALSE,
+ MediaId,
+ Offset,
+ Token,
+ BufferSize,
+ (UINT8 *)Buffer
);
}
@@ -1047,17 +1086,22 @@ DiskIo2ReadDiskEx ( 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
+ 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
+ TRUE,
+ MediaId,
+ Offset,
+ Token,
+ BufferSize,
+ (UINT8 *)Buffer
);
}
@@ -1070,15 +1114,15 @@ DiskIo2WriteDiskEx ( VOID
EFIAPI
DiskIo2OnFlushComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- DISK_IO2_FLUSH_TASK *Task;
+ DISK_IO2_FLUSH_TASK *Task;
gBS->CloseEvent (Event);
- Task = (DISK_IO2_FLUSH_TASK *) Context;
+ 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);
@@ -1104,13 +1148,13 @@ DiskIo2OnFlushComplete ( EFI_STATUS
EFIAPI
DiskIo2FlushDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN OUT EFI_DISK_IO2_TOKEN *Token
+ 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;
+ EFI_STATUS Status;
+ DISK_IO2_FLUSH_TASK *Task;
+ DISK_IO_PRIVATE_DATA *Private;
Private = DISK_IO_PRIVATE_DATA_FROM_DISK_IO2 (This);
@@ -1131,9 +1175,10 @@ DiskIo2FlushDiskEx ( FreePool (Task);
return Status;
}
+
Task->Signature = DISK_IO2_FLUSH_TASK_SIGNATURE;
Task->Token = Token;
- Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, &Task->BlockIo2Token);
+ Status = Private->BlockIo2->FlushBlocksEx (Private->BlockIo2, &Task->BlockIo2Token);
if (EFI_ERROR (Status)) {
gBS->CloseEvent (Task->BlockIo2Token.Event);
FreePool (Task);
@@ -1180,11 +1225,15 @@ DiskIoReadDisk ( {
return DiskIo2ReadWriteDisk (
DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This),
- FALSE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer
+ 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
@@ -1222,7 +1271,12 @@ DiskIoWriteDisk ( {
return DiskIo2ReadWriteDisk (
DISK_IO_PRIVATE_DATA_FROM_DISK_IO (This),
- TRUE, MediaId, Offset, NULL, BufferSize, (UINT8 *) Buffer
+ TRUE,
+ MediaId,
+ Offset,
+ NULL,
+ BufferSize,
+ (UINT8 *)Buffer
);
}
@@ -1239,11 +1293,11 @@ DiskIoWriteDisk ( EFI_STATUS
EFIAPI
InitializeDiskIo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h index 3207b9fa23..13edb5ff7b 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h @@ -26,60 +26,60 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')
typedef struct {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_DISK_IO_PROTOCOL DiskIo;
- EFI_DISK_IO2_PROTOCOL DiskIo2;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
+ EFI_DISK_IO_PROTOCOL DiskIo;
+ EFI_DISK_IO2_PROTOCOL DiskIo2;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- UINT8 *SharedWorkingBuffer;
+ UINT8 *SharedWorkingBuffer;
- EFI_LOCK TaskQueueLock;
- LIST_ENTRY TaskQueue;
+ 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_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')
+#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;
+ 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')
+#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;
+ 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')
+#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;
+ 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_IO2_TASK *Task;
+ EFI_BLOCK_IO2_TOKEN BlockIo2Token;
} DISK_IO_SUBTASK;
//
@@ -93,6 +93,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2; // Prototypes
// Driver model protocol interface
//
+
/**
Test to see if this driver supports ControllerHandle.
@@ -153,15 +154,16 @@ DiskIoDriverBindingStart ( EFI_STATUS
EFIAPI
DiskIoDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ 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
@@ -230,7 +232,6 @@ DiskIoWriteDisk ( IN VOID *Buffer
);
-
/**
Terminate outstanding asynchronous requests to a device.
@@ -243,7 +244,7 @@ DiskIoWriteDisk ( EFI_STATUS
EFIAPI
DiskIo2Cancel (
- IN EFI_DISK_IO2_PROTOCOL *This
+ IN EFI_DISK_IO2_PROTOCOL *This
);
/**
@@ -271,12 +272,12 @@ DiskIo2Cancel ( 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
+ 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
);
/**
@@ -304,12 +305,12 @@ DiskIo2ReadDiskEx ( 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
+ IN EFI_DISK_IO2_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN EFI_DISK_IO2_TOKEN *Token,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
/**
@@ -330,13 +331,14 @@ DiskIo2WriteDiskEx ( EFI_STATUS
EFIAPI
DiskIo2FlushDiskEx (
- IN EFI_DISK_IO2_PROTOCOL *This,
- IN OUT EFI_DISK_IO2_TOKEN *Token
+ 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.
@@ -384,7 +386,6 @@ DiskIoComponentNameGetDriverName ( OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -456,12 +457,11 @@ DiskIoComponentNameGetDriverName ( 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
+ 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/PartitionDxe/ComponentName.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c index 7d1031f35c..fd27a84b81 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ComponentName.c @@ -20,9 +20,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentNa //
// 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,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)PartitionComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)PartitionComponentNameGetControllerName,
"en"
};
@@ -30,7 +30,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentNa // 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[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPartitionDriverNameTable[] = {
{
"eng;en",
L"Partition Driver(MBR/GPT/El Torito)"
@@ -41,8 +41,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPartitionDriverNameTable }
};
-
-
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -99,7 +97,6 @@ PartitionComponentNameGetDriverName ( );
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -171,11 +168,11 @@ PartitionComponentNameGetDriverName ( 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
+ 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 index e2b028f733..977ded851e 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c @@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "Partition.h"
-
/**
Install child handles if the Handle supports El Torito format.
@@ -57,10 +55,10 @@ PartitionInstallElToritoChildHandles ( UINT32 VolSpaceSize;
EFI_PARTITION_INFO_PROTOCOL PartitionInfo;
- Found = EFI_NOT_FOUND;
- Media = BlockIo->Media;
+ Found = EFI_NOT_FOUND;
+ Media = BlockIo->Media;
- VolSpaceSize = 0;
+ VolSpaceSize = 0;
//
// CD_ROM has the fixed block size as 2048 bytes (SIZE_2KB)
@@ -79,7 +77,7 @@ PartitionInstallElToritoChildHandles ( return EFI_NOT_FOUND;
}
- Catalog = (ELTORITO_CATALOG *) VolDescriptor;
+ Catalog = (ELTORITO_CATALOG *)VolDescriptor;
//
// Loop: handle one volume descriptor per time
@@ -87,7 +85,8 @@ PartitionInstallElToritoChildHandles ( //
for (VolDescriptorOffset = SIZE_32KB;
VolDescriptorOffset <= MultU64x32 (Media->LastBlock, Media->BlockSize);
- VolDescriptorOffset += SIZE_2KB) {
+ VolDescriptorOffset += SIZE_2KB)
+ {
Status = DiskIo->ReadDisk (
DiskIo,
Media->MediaId,
@@ -99,17 +98,20 @@ PartitionInstallElToritoChildHandles ( 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
- ) {
+ 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
@@ -117,12 +119,14 @@ PartitionInstallElToritoChildHandles ( 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
@@ -144,17 +148,18 @@ PartitionInstallElToritoChildHandles ( DEBUG ((DEBUG_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) {
+ if ((Catalog->Catalog.Indicator != ELTORITO_ID_CATALOG) || (Catalog->Catalog.Id55AA != 0xAA55)) {
DEBUG ((DEBUG_ERROR, "EltCheckBootCatalog: El Torito boot catalog header IDs not correct\n"));
continue;
}
Check = 0;
- CheckBuffer = (UINT16 *) Catalog;
+ CheckBuffer = (UINT16 *)Catalog;
for (Index = 0; Index < sizeof (ELTORITO_CATALOG) / sizeof (UINT16); Index += 1) {
Check += CheckBuffer[Index];
}
@@ -174,45 +179,45 @@ PartitionInstallElToritoChildHandles ( //
// Check this entry
//
- if (Catalog->Boot.Indicator != ELTORITO_ID_SECTION_BOOTABLE || Catalog->Boot.Lba == 0) {
+ if ((Catalog->Boot.Indicator != ELTORITO_ID_SECTION_BOOTABLE) || (Catalog->Boot.Lba == 0)) {
continue;
}
- SubBlockSize = 512;
- SectorCount = Catalog->Boot.SectorCount;
+ SubBlockSize = 512;
+ SectorCount = Catalog->Boot.SectorCount;
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 ((DEBUG_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType));
- SectorCount = 0;
- SubBlockSize = Media->BlockSize;
- break;
+ 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 ((DEBUG_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;
+ CdDev.Header.Type = MEDIA_DEVICE_PATH;
+ CdDev.Header.SubType = MEDIA_CDROM_DP;
SetDevicePathNodeLength (&CdDev.Header, sizeof (CdDev));
if (Index == 1) {
@@ -222,7 +227,7 @@ PartitionInstallElToritoChildHandles ( BootEntry = 0;
}
- CdDev.BootEntry = (UINT32) BootEntry;
+ CdDev.BootEntry = (UINT32)BootEntry;
BootEntry++;
CdDev.PartitionStart = Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize);
if (SectorCount < 2) {
@@ -249,20 +254,20 @@ PartitionInstallElToritoChildHandles ( PartitionInfo.Type = PARTITION_TYPE_OTHER;
Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &CdDev,
- &PartitionInfo,
- Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
- Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,
- SubBlockSize,
- NULL
- );
+ This,
+ Handle,
+ DiskIo,
+ DiskIo2,
+ BlockIo,
+ BlockIo2,
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&CdDev,
+ &PartitionInfo,
+ Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
+ Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,
+ SubBlockSize,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
Found = EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c index e985bd2c44..5bcf94d587 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c @@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "Partition.h"
/**
@@ -65,7 +64,6 @@ PartitionCheckGptEntryArrayCRC ( IN EFI_PARTITION_TABLE_HEADER *PartHeader
);
-
/**
Restore Partition Table to its alternate place
(Primary -> Backup or Backup -> Primary).
@@ -85,7 +83,6 @@ PartitionRestoreGptTable ( IN EFI_PARTITION_TABLE_HEADER *PartHeader
);
-
/**
This routine will check GPT partition entry and return entry status.
@@ -106,7 +103,6 @@ PartitionCheckGptEntry ( OUT EFI_PARTITION_ENTRY_STATUS *PEntryStatus
);
-
/**
Checks the CRC32 value in the table header.
@@ -125,7 +121,6 @@ PartitionCheckCrcAltSize ( IN OUT EFI_TABLE_HEADER *Hdr
);
-
/**
Checks the CRC32 value in the table header.
@@ -142,7 +137,6 @@ PartitionCheckCrc ( IN OUT EFI_TABLE_HEADER *Hdr
);
-
/**
Updates the CRC32 value in the table header.
@@ -156,7 +150,6 @@ PartitionSetCrcAltSize ( IN OUT EFI_TABLE_HEADER *Hdr
);
-
/**
Updates the CRC32 value in the table header.
@@ -165,7 +158,7 @@ PartitionSetCrcAltSize ( **/
VOID
PartitionSetCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
+ IN OUT EFI_TABLE_HEADER *Hdr
);
/**
@@ -221,9 +214,9 @@ PartitionInstallGptChildHandles ( PartEntry = NULL;
PEntryStatus = NULL;
- BlockSize = BlockIo->Media->BlockSize;
- LastBlock = BlockIo->Media->LastBlock;
- MediaId = BlockIo->Media->MediaId;
+ BlockSize = BlockIo->Media->BlockSize;
+ LastBlock = BlockIo->Media->LastBlock;
+ MediaId = BlockIo->Media->MediaId;
DEBUG ((DEBUG_INFO, " BlockSize : %d \n", BlockSize));
DEBUG ((DEBUG_INFO, " LastBlock : %lx \n", LastBlock));
@@ -264,12 +257,14 @@ PartitionInstallGptChildHandles ( // Verify that the Protective MBR is valid
//
for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {
- if (ProtectiveMbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION &&
- UNPACK_UINT32 (ProtectiveMbr->Partition[Index].StartingLBA) == 1
- ) {
+ if ((ProtectiveMbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION) &&
+ (UNPACK_UINT32 (ProtectiveMbr->Partition[Index].StartingLBA) == 1)
+ )
+ {
break;
}
}
+
if (Index == MAX_MBR_PARTITIONS) {
goto Done;
}
@@ -317,7 +312,6 @@ PartitionInstallGptChildHandles ( if (PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) {
DEBUG ((DEBUG_INFO, " Restore backup partition table success\n"));
}
-
}
DEBUG ((DEBUG_INFO, " Valid primary and Valid backup partition table\n"));
@@ -334,7 +328,7 @@ PartitionInstallGptChildHandles ( Status = DiskIo->ReadDisk (
DiskIo,
MediaId,
- MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockSize),
+ MultU64x32 (PrimaryHeader->PartitionEntryLBA, BlockSize),
PrimaryHeader->NumberOfPartitionEntries * (PrimaryHeader->SizeOfPartitionEntry),
PartEntry
);
@@ -368,12 +362,13 @@ PartitionInstallGptChildHandles ( // Create child device handles
//
for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index * PrimaryHeader->SizeOfPartitionEntry);
+ 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
@@ -382,15 +377,15 @@ PartitionInstallGptChildHandles ( }
ZeroMem (&HdDev, sizeof (HdDev));
- HdDev.Header.Type = MEDIA_DEVICE_PATH;
- HdDev.Header.SubType = MEDIA_HARDDRIVE_DP;
+ 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;
+ 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));
ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));
@@ -399,12 +394,13 @@ PartitionInstallGptChildHandles ( if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)) {
PartitionInfo.System = 1;
}
+
CopyMem (&PartitionInfo.Info.Gpt, Entry, sizeof (EFI_PARTITION_ENTRY));
- DEBUG ((DEBUG_INFO, " Index : %d\n", (UINT32) Index));
- DEBUG ((DEBUG_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart));
- DEBUG ((DEBUG_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA));
- DEBUG ((DEBUG_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize));
+ DEBUG ((DEBUG_INFO, " Index : %d\n", (UINT32)Index));
+ DEBUG ((DEBUG_INFO, " Start LBA : %lx\n", (UINT64)HdDev.PartitionStart));
+ DEBUG ((DEBUG_INFO, " End LBA : %lx\n", (UINT64)Entry->EndingLBA));
+ DEBUG ((DEBUG_INFO, " Partition size: %lx\n", (UINT64)HdDev.PartitionSize));
DEBUG ((DEBUG_INFO, " Start : %lx", MultU64x32 (Entry->StartingLBA, BlockSize)));
DEBUG ((DEBUG_INFO, " End : %lx\n", MultU64x32 (Entry->EndingLBA, BlockSize)));
@@ -416,7 +412,7 @@ PartitionInstallGptChildHandles ( BlockIo,
BlockIo2,
DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
+ (EFI_DEVICE_PATH_PROTOCOL *)&HdDev,
&PartitionInfo,
Entry->StartingLBA,
Entry->EndingLBA,
@@ -431,15 +427,19 @@ 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);
}
@@ -484,6 +484,7 @@ PartitionValidGptTable ( DEBUG ((DEBUG_ERROR, "Allocate pool error\n"));
return FALSE;
}
+
//
// Read the EFI Partition Table Header
//
@@ -501,9 +502,10 @@ PartitionValidGptTable ( if ((PartHdr->Header.Signature != EFI_PTAB_HEADER_ID) ||
!PartitionCheckCrc (BlockSize, &PartHdr->Header) ||
- PartHdr->MyLBA != Lba ||
+ (PartHdr->MyLBA != Lba) ||
(PartHdr->SizeOfPartitionEntry < sizeof (EFI_PARTITION_ENTRY))
- ) {
+ )
+ {
DEBUG ((DEBUG_INFO, "Invalid efi partition table header\n"));
FreePool (PartHdr);
return FALSE;
@@ -562,20 +564,20 @@ PartitionCheckGptEntryArrayCRC ( }
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32(PartHeader->PartitionEntryLBA, BlockIo->Media->BlockSize),
- PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
- Ptr
- );
+ 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;
+ Size = PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry;
- Status = gBS->CalculateCrc32 (Ptr, Size, &Crc);
+ Status = gBS->CalculateCrc32 (Ptr, Size, &Crc);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "CheckPEntryArrayCRC: Crc calculation failed\n"));
FreePool (Ptr);
@@ -584,10 +586,9 @@ PartitionCheckGptEntryArrayCRC ( FreePool (Ptr);
- return (BOOLEAN) (PartHeader->PartitionEntryArrayCRC32 == Crc);
+ return (BOOLEAN)(PartHeader->PartitionEntryArrayCRC32 == Crc);
}
-
/**
Restore Partition Table to its alternate place
(Primary -> Backup or Backup -> Primary).
@@ -614,13 +615,13 @@ PartitionRestoreGptTable ( UINT8 *Ptr;
UINT32 MediaId;
- PartHdr = NULL;
- Ptr = NULL;
+ PartHdr = NULL;
+ Ptr = NULL;
BlockSize = BlockIo->Media->BlockSize;
MediaId = BlockIo->Media->MediaId;
- PartHdr = AllocateZeroPool (BlockSize);
+ PartHdr = AllocateZeroPool (BlockSize);
if (PartHdr == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate pool error\n"));
@@ -628,20 +629,20 @@ PartitionRestoreGptTable ( }
PEntryLBA = (PartHeader->MyLBA == PRIMARY_PART_HEADER_LBA) ? \
- (PartHeader->LastUsableLBA + 1) : \
- (PRIMARY_PART_HEADER_LBA + 1);
+ (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);
+ 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),
+ MultU64x32 (PartHdr->MyLBA, (UINT32)BlockSize),
BlockSize,
PartHdr
);
@@ -657,23 +658,23 @@ PartitionRestoreGptTable ( }
Status = DiskIo->ReadDisk (
- DiskIo,
- MediaId,
- MultU64x32(PartHeader->PartitionEntryLBA, (UINT32) BlockSize),
- PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
- Ptr
- );
+ 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
- );
+ DiskIo,
+ MediaId,
+ MultU64x32 (PEntryLBA, (UINT32)BlockSize),
+ PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,
+ Ptr
+ );
Done:
FreePool (PartHdr);
@@ -717,19 +718,20 @@ PartitionCheckGptEntry ( DEBUG ((DEBUG_INFO, " start check partition entries\n"));
for (Index1 = 0; Index1 < PartHeader->NumberOfPartitionEntries; Index1++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index1 * PartHeader->SizeOfPartitionEntry);
+ 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
- ) {
+ if ((StartingLBA > EndingLBA) ||
+ (StartingLBA < PartHeader->FirstUsableLBA) ||
+ (StartingLBA > PartHeader->LastUsableLBA) ||
+ (EndingLBA < PartHeader->FirstUsableLBA) ||
+ (EndingLBA > PartHeader->LastUsableLBA)
+ )
+ {
PEntryStatus[Index1].OutOfRange = TRUE;
continue;
}
@@ -742,17 +744,17 @@ PartitionCheckGptEntry ( }
for (Index2 = Index1 + 1; Index2 < PartHeader->NumberOfPartitionEntries; Index2++) {
- Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index2 * PartHeader->SizeOfPartitionEntry);
+ Entry = (EFI_PARTITION_ENTRY *)((UINT8 *)PartEntry + Index2 * PartHeader->SizeOfPartitionEntry);
if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid)) {
continue;
}
- if (Entry->EndingLBA >= StartingLBA && Entry->StartingLBA <= EndingLBA) {
+ if ((Entry->EndingLBA >= StartingLBA) && (Entry->StartingLBA <= EndingLBA)) {
//
// This region overlaps with the Index1'th region
//
- PEntryStatus[Index1].Overlap = TRUE;
- PEntryStatus[Index2].Overlap = TRUE;
+ PEntryStatus[Index1].Overlap = TRUE;
+ PEntryStatus[Index2].Overlap = TRUE;
continue;
}
}
@@ -761,7 +763,6 @@ PartitionCheckGptEntry ( DEBUG ((DEBUG_INFO, " End check partition entries\n"));
}
-
/**
Updates the CRC32 value in the table header.
@@ -770,13 +771,12 @@ PartitionCheckGptEntry ( **/
VOID
PartitionSetCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
+ IN OUT EFI_TABLE_HEADER *Hdr
)
{
PartitionSetCrcAltSize (Hdr->HeaderSize, Hdr);
}
-
/**
Updates the CRC32 value in the table header.
@@ -793,11 +793,10 @@ PartitionSetCrcAltSize ( UINT32 Crc;
Hdr->CRC32 = 0;
- gBS->CalculateCrc32 ((UINT8 *) Hdr, Size, &Crc);
+ gBS->CalculateCrc32 ((UINT8 *)Hdr, Size, &Crc);
Hdr->CRC32 = Crc;
}
-
/**
Checks the CRC32 value in the table header.
@@ -817,7 +816,6 @@ PartitionCheckCrc ( return PartitionCheckCrcAltSize (MaxSize, Hdr->HeaderSize, Hdr);
}
-
/**
Checks the CRC32 value in the table header.
@@ -853,17 +851,19 @@ PartitionCheckCrcAltSize ( DEBUG ((DEBUG_ERROR, "CheckCrc32: Size > MaxSize\n"));
return FALSE;
}
+
//
// clear old crc from header
//
- OrgCrc = Hdr->CRC32;
- Hdr->CRC32 = 0;
+ OrgCrc = Hdr->CRC32;
+ Hdr->CRC32 = 0;
- Status = gBS->CalculateCrc32 ((UINT8 *) Hdr, Size, &Crc);
+ Status = gBS->CalculateCrc32 ((UINT8 *)Hdr, Size, &Crc);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "CheckCrc32: Crc calculation failed\n"));
return FALSE;
}
+
//
// set results
//
@@ -873,10 +873,11 @@ PartitionCheckCrcAltSize ( // return status
//
DEBUG_CODE_BEGIN ();
- if (OrgCrc != Crc) {
- DEBUG ((DEBUG_ERROR, "CheckCrc32: Crc check failed\n"));
- }
+ if (OrgCrc != Crc) {
+ DEBUG ((DEBUG_ERROR, "CheckCrc32: Crc check failed\n"));
+ }
+
DEBUG_CODE_END ();
- return (BOOLEAN) (OrgCrc == Crc);
+ return (BOOLEAN)(OrgCrc == Crc);
}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c index df25a93f85..0f8dc54865 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c @@ -32,26 +32,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
BOOLEAN
PartitionValidMbr (
- IN MASTER_BOOT_RECORD *Mbr,
- IN EFI_LBA LastLba
+ IN MASTER_BOOT_RECORD *Mbr,
+ IN EFI_LBA LastLba
)
{
- UINT32 StartingLBA;
- UINT32 EndingLBA;
- UINT32 NewEndingLBA;
- INTN Index1;
- INTN Index2;
- BOOLEAN MbrValid;
+ 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) {
+ if ((Mbr->Partition[Index1].OSIndicator == 0x00) || (UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) == 0)) {
continue;
}
@@ -71,18 +72,18 @@ PartitionValidMbr ( // with INT 13h
//
- DEBUG((DEBUG_INFO, "PartitionValidMbr: Bad MBR partition size EndingLBA(%1x) > LastLBA(%1x)\n", EndingLBA, LastLba));
+ DEBUG ((DEBUG_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) {
+ 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) {
+ if ((NewEndingLBA >= StartingLBA) && (UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) <= EndingLBA)) {
//
// This region overlaps with the Index1'th region
//
@@ -90,13 +91,13 @@ PartitionValidMbr ( }
}
}
+
//
// None of the regions overlapped so MBR is O.K.
//
return MbrValid;
}
-
/**
Install child handles if the Handle supports MBR format.
@@ -138,14 +139,14 @@ PartitionInstallMbrChildHandles ( EFI_LBA LastSector;
EFI_PARTITION_INFO_PROTOCOL PartitionInfo;
- Found = EFI_NOT_FOUND;
+ Found = EFI_NOT_FOUND;
- BlockSize = BlockIo->Media->BlockSize;
- MediaId = BlockIo->Media->MediaId;
- LastSector = DivU64x32 (
- MultU64x32 (BlockIo->Media->LastBlock + 1, BlockSize),
- MBR_SIZE
- ) - 1;
+ BlockSize = BlockIo->Media->BlockSize;
+ MediaId = BlockIo->Media->MediaId;
+ LastSector = DivU64x32 (
+ MultU64x32 (BlockIo->Media->LastBlock + 1, BlockSize),
+ MBR_SIZE
+ ) - 1;
//
// Ensure the block size can hold the MBR
@@ -170,9 +171,11 @@ PartitionInstallMbrChildHandles ( Found = Status;
goto Done;
}
+
if (!PartitionValidMbr (Mbr, LastSector)) {
goto Done;
}
+
//
// We have a valid mbr - add each partition
//
@@ -183,14 +186,15 @@ PartitionInstallMbrChildHandles ( ZeroMem (&ParentHdDev, sizeof (ParentHdDev));
DevicePathNode = DevicePath;
while (!IsDevicePathEnd (DevicePathNode)) {
- LastDevicePathNode = DevicePathNode;
- DevicePathNode = NextDevicePathNode (DevicePathNode);
+ LastDevicePathNode = DevicePathNode;
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
}
if (LastDevicePathNode != NULL) {
- if (DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (LastDevicePathNode) == MEDIA_HARDDRIVE_DP
- ) {
+ if ((DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (LastDevicePathNode) == MEDIA_HARDDRIVE_DP)
+ )
+ {
CopyMem (&ParentHdDev, LastDevicePathNode, sizeof (ParentHdDev));
} else {
LastDevicePathNode = NULL;
@@ -198,18 +202,18 @@ PartitionInstallMbrChildHandles ( }
ZeroMem (&HdDev, sizeof (HdDev));
- HdDev.Header.Type = MEDIA_DEVICE_PATH;
- HdDev.Header.SubType = MEDIA_HARDDRIVE_DP;
+ 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;
+ 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) {
+ if ((Mbr->Partition[Index].OSIndicator == 0x00) || (UNPACK_UINT32 (Mbr->Partition[Index].SizeInLBA) == 0)) {
//
// Don't use null MBR entries
//
@@ -237,23 +241,24 @@ PartitionInstallMbrChildHandles ( if (Mbr->Partition[Index].OSIndicator == EFI_PARTITION) {
PartitionInfo.System = 1;
}
+
CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[Index], sizeof (MBR_PARTITION_RECORD));
Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
- &PartitionInfo,
- HdDev.PartitionStart,
- HdDev.PartitionStart + HdDev.PartitionSize - 1,
- MBR_SIZE,
- ((Mbr->Partition[Index].OSIndicator == EFI_PARTITION) ? &gEfiPartTypeSystemPartGuid: NULL)
- );
+ This,
+ Handle,
+ DiskIo,
+ DiskIo2,
+ BlockIo,
+ BlockIo2,
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&HdDev,
+ &PartitionInfo,
+ HdDev.PartitionStart,
+ HdDev.PartitionStart + HdDev.PartitionSize - 1,
+ MBR_SIZE,
+ ((Mbr->Partition[Index].OSIndicator == EFI_PARTITION) ? &gEfiPartTypeSystemPartGuid : NULL)
+ );
if (!EFI_ERROR (Status)) {
Found = EFI_SUCCESS;
@@ -268,7 +273,6 @@ PartitionInstallMbrChildHandles ( ExtMbrStartingLba = 0;
do {
-
Status = DiskIo->ReadDisk (
DiskIo,
MediaId,
@@ -286,22 +290,25 @@ PartitionInstallMbrChildHandles ( }
if ((Mbr->Partition[0].OSIndicator == EXTENDED_DOS_PARTITION) ||
- (Mbr->Partition[0].OSIndicator == EXTENDED_WINDOWS_PARTITION)) {
+ (Mbr->Partition[0].OSIndicator == EXTENDED_WINDOWS_PARTITION))
+ {
ExtMbrStartingLba = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA);
continue;
}
+
HdDev.PartitionNumber = ++Index;
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)) {
+ (HdDev.PartitionStart <= ParentHdDev.PartitionStart))
+ {
break;
}
//
// The signature in EBR(Extended Boot Record) should always be 0.
//
- *((UINT32 *) &HdDev.Signature[0]) = 0;
+ *((UINT32 *)&HdDev.Signature[0]) = 0;
ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));
PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION;
@@ -309,6 +316,7 @@ PartitionInstallMbrChildHandles ( if (Mbr->Partition[0].OSIndicator == EFI_PARTITION) {
PartitionInfo.System = 1;
}
+
CopyMem (&PartitionInfo.Info.Mbr, &Mbr->Partition[0], sizeof (MBR_PARTITION_RECORD));
Status = PartitionInstallChildHandle (
@@ -319,12 +327,12 @@ PartitionInstallMbrChildHandles ( BlockIo,
BlockIo2,
DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,
+ (EFI_DEVICE_PATH_PROTOCOL *)&HdDev,
&PartitionInfo,
HdDev.PartitionStart - ParentHdDev.PartitionStart,
HdDev.PartitionStart - ParentHdDev.PartitionStart + HdDev.PartitionSize - 1,
MBR_SIZE,
- ((Mbr->Partition[0].OSIndicator == EFI_PARTITION) ? &gEfiPartTypeSystemPartGuid: NULL)
+ ((Mbr->Partition[0].OSIndicator == EFI_PARTITION) ? &gEfiPartTypeSystemPartGuid : NULL)
);
if (!EFI_ERROR (Status)) {
Found = EFI_SUCCESS;
@@ -332,7 +340,8 @@ PartitionInstallMbrChildHandles ( if ((Mbr->Partition[1].OSIndicator != EXTENDED_DOS_PARTITION) &&
(Mbr->Partition[1].OSIndicator != EXTENDED_WINDOWS_PARTITION)
- ) {
+ )
+ {
break;
}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c index aebc8a1dac..bc89559727 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -10,13 +10,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "Partition.h"
//
// Partition Driver Global Variables.
//
-EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
PartitionDriverBindingSupported,
PartitionDriverBindingStart,
PartitionDriverBindingStop,
@@ -44,7 +43,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = { // Note: UDF is using a same method as booting from CD-ROM, so put it along
// with CD-ROM check.
//
-PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
+PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
PartitionInstallGptChildHandles,
PartitionInstallUdfChildHandles,
PartitionInstallMbrChildHandles,
@@ -92,10 +91,11 @@ PartitionDriverBindingSupported ( // 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)) {
+ 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;
}
}
@@ -107,7 +107,7 @@ PartitionDriverBindingSupported ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ (VOID **)&DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -115,9 +115,11 @@ PartitionDriverBindingSupported ( 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
//
@@ -134,7 +136,7 @@ PartitionDriverBindingSupported ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -151,11 +153,11 @@ PartitionDriverBindingSupported ( // Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Open the IO Abstraction(s) needed to perform the supported test
@@ -207,7 +209,7 @@ PartitionDriverBindingStart ( EFI_TPL OldTpl;
BlockIo2 = NULL;
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
// Check RemainingDevicePath validation
//
@@ -229,7 +231,7 @@ PartitionDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -241,7 +243,7 @@ PartitionDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIo2ProtocolGuid,
- (VOID **) &BlockIo2,
+ (VOID **)&BlockIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -256,12 +258,12 @@ PartitionDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
goto Exit;
}
@@ -271,18 +273,18 @@ PartitionDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ (VOID **)&DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
goto Exit;
}
@@ -291,12 +293,12 @@ PartitionDriverBindingStart ( Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIo2ProtocolGuid,
- (VOID **) &DiskIo2,
+ (VOID **)&DiskIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
DiskIo2 = NULL;
}
@@ -306,7 +308,8 @@ PartitionDriverBindingStart ( Status = EFI_UNSUPPORTED;
MediaPresent = BlockIo->Media->MediaPresent;
if (BlockIo->Media->MediaPresent ||
- (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {
+ (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition))
+ {
//
// Try for GPT, then legacy MBR partition types, and then UDF and El Torito.
// If the media supports a given partition type install child handles to
@@ -314,21 +317,23 @@ PartitionDriverBindingStart ( //
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) {
+ 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
@@ -343,14 +348,15 @@ PartitionDriverBindingStart ( //
if (EFI_ERROR (Status) &&
!EFI_ERROR (OpenStatus) &&
- Status != EFI_MEDIA_CHANGED &&
- !(MediaPresent && Status == EFI_NO_MEDIA)) {
+ (Status != EFI_MEDIA_CHANGED) &&
+ !(MediaPresent && (Status == EFI_NO_MEDIA)))
+ {
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Close Parent DiskIo2 if has.
//
@@ -362,11 +368,11 @@ PartitionDriverBindingStart ( );
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
Exit:
@@ -391,10 +397,10 @@ Exit: EFI_STATUS
EFIAPI
PartitionDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
EFI_STATUS Status;
@@ -408,7 +414,7 @@ PartitionDriverBindingStop ( BlockIo = NULL;
BlockIo2 = NULL;
- Private = NULL;
+ Private = NULL;
if (NumberOfChildren == 0) {
//
@@ -417,7 +423,7 @@ PartitionDriverBindingStop ( // bus driver. Hence, additional check is needed here.
//
if (HasChildren (ControllerHandle)) {
- DEBUG((DEBUG_ERROR, "PartitionDriverBindingStop: Still has child.\n"));
+ DEBUG ((DEBUG_ERROR, "PartitionDriverBindingStop: Still has child.\n"));
return EFI_DEVICE_ERROR;
}
@@ -425,11 +431,11 @@ PartitionDriverBindingStop ( // Close the bus driver
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Close Parent BlockIO2 if has.
//
@@ -441,11 +447,11 @@ PartitionDriverBindingStop ( );
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return EFI_SUCCESS;
}
@@ -454,7 +460,7 @@ PartitionDriverBindingStop ( gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -465,13 +471,12 @@ PartitionDriverBindingStop ( gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIo2ProtocolGuid,
- (VOID **) &BlockIo2,
+ (VOID **)&BlockIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
-
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
if (Private->InStop) {
//
@@ -480,13 +485,14 @@ PartitionDriverBindingStop ( //
break;
}
+
Private->InStop = TRUE;
BlockIo->FlushBlocks (BlockIo);
if (BlockIo2 != NULL) {
Status = BlockIo2->FlushBlocksEx (BlockIo2, NULL);
- DEBUG((DEBUG_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status));
} else {
Status = EFI_SUCCESS;
}
@@ -518,33 +524,33 @@ PartitionDriverBindingStop ( //
if (Status != EFI_MEDIA_CHANGED) {
Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- &gEfiBlockIo2ProtocolGuid,
- &Private->BlockIo2,
- &gEfiPartitionInfoProtocolGuid,
- &Private->PartitionInfo,
- TypeGuid,
- NULL,
- NULL
- );
+ ChildHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ &gEfiBlockIo2ProtocolGuid,
+ &Private->BlockIo2,
+ &gEfiPartitionInfoProtocolGuid,
+ &Private->PartitionInfo,
+ TypeGuid,
+ NULL,
+ NULL
+ );
}
} else {
Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- &gEfiPartitionInfoProtocolGuid,
- &Private->PartitionInfo,
- TypeGuid,
- NULL,
- NULL
- );
+ ChildHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ &gEfiPartitionInfoProtocolGuid,
+ &Private->PartitionInfo,
+ TypeGuid,
+ NULL,
+ NULL
+ );
}
if (EFI_ERROR (Status)) {
@@ -552,7 +558,7 @@ PartitionDriverBindingStop ( gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ (VOID **)&DiskIo,
This->DriverBindingHandle,
ChildHandleBuffer[Index],
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -577,7 +583,6 @@ PartitionDriverBindingStop ( return EFI_SUCCESS;
}
-
/**
Reset the Block Device.
@@ -601,9 +606,9 @@ PartitionReset ( Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
return Private->ParentBlockIo->Reset (
- Private->ParentBlockIo,
- ExtendedVerification
- );
+ Private->ParentBlockIo,
+ ExtendedVerification
+ );
}
/**
@@ -621,13 +626,13 @@ PartitionReset ( **/
EFI_STATUS
ProbeMediaStatus (
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN UINT32 MediaId,
- IN EFI_STATUS DefaultStatus
+ IN EFI_DISK_IO_PROTOCOL *DiskIo,
+ IN UINT32 MediaId,
+ IN EFI_STATUS DefaultStatus
)
{
- EFI_STATUS Status;
- UINT8 Buffer[1];
+ EFI_STATUS Status;
+ UINT8 Buffer[1];
//
// Read 1 byte from offset 0 to check if the MediaId is still valid.
@@ -635,10 +640,11 @@ ProbeMediaStatus ( // 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);
+ Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, (VOID *)Buffer);
if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
return Status;
}
+
return DefaultStatus;
}
@@ -684,6 +690,7 @@ PartitionReadBlocks ( 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
@@ -719,7 +726,7 @@ PartitionWriteBlocks ( IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
PARTITION_PRIVATE_DATA *Private;
@@ -735,6 +742,7 @@ PartitionWriteBlocks ( 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
@@ -743,7 +751,6 @@ PartitionWriteBlocks ( return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
}
-
/**
Flush the parent Block Device.
@@ -782,13 +789,13 @@ PartitionFlushBlocks ( **/
EFI_STATUS
ProbeMediaStatusEx (
- IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
- IN UINT32 MediaId,
- IN EFI_STATUS DefaultStatus
+ IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
+ IN UINT32 MediaId,
+ IN EFI_STATUS DefaultStatus
)
{
- EFI_STATUS Status;
- UINT8 Buffer[1];
+ EFI_STATUS Status;
+ UINT8 Buffer[1];
//
// Read 1 byte from offset 0 to check if the MediaId is still valid.
@@ -796,10 +803,11 @@ ProbeMediaStatusEx ( // allocate a buffer from the pool. The destination buffer for the
// data is in the stack.
//
- Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, (VOID*)Buffer);
+ Status = DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, (VOID *)Buffer);
if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {
return Status;
}
+
return DefaultStatus;
}
@@ -817,8 +825,8 @@ ProbeMediaStatusEx ( EFI_STATUS
EFIAPI
PartitionResetEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
PARTITION_PRIVATE_DATA *Private;
@@ -840,13 +848,13 @@ PartitionResetEx ( VOID
EFIAPI
PartitionOnAccessComplete (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- PARTITION_ACCESS_TASK *Task;
+ PARTITION_ACCESS_TASK *Task;
- Task = (PARTITION_ACCESS_TASK *) Context;
+ Task = (PARTITION_ACCESS_TASK *)Context;
gBS->CloseEvent (Event);
@@ -865,11 +873,11 @@ PartitionOnAccessComplete ( **/
PARTITION_ACCESS_TASK *
PartitionCreateAccessTask (
- IN EFI_BLOCK_IO2_TOKEN *Token
+ IN EFI_BLOCK_IO2_TOKEN *Token
)
{
- EFI_STATUS Status;
- PARTITION_ACCESS_TASK *Task;
+ EFI_STATUS Status;
+ PARTITION_ACCESS_TASK *Task;
Task = AllocatePool (sizeof (*Task));
if (Task == NULL) {
@@ -929,12 +937,12 @@ PartitionCreateAccessTask ( 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
+ 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;
@@ -1005,12 +1013,12 @@ PartitionReadBlocksEx ( 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
+ 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;
@@ -1043,6 +1051,7 @@ PartitionWriteBlocksEx ( } else {
Status = Private->DiskIo2->WriteDiskEx (Private->DiskIo2, MediaId, Offset, NULL, BufferSize, Buffer);
}
+
return Status;
}
@@ -1071,8 +1080,8 @@ PartitionWriteBlocksEx ( EFI_STATUS
EFIAPI
PartitionFlushBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
EFI_STATUS Status;
@@ -1095,10 +1104,10 @@ PartitionFlushBlocksEx ( } 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.
@@ -1147,60 +1156,60 @@ PartitionInstallChildHandle ( return EFI_OUT_OF_RESOURCES;
}
- Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;
+ Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;
- Private->Start = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
- Private->End = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
+ 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;
+ 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;
+ 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;
+ 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;
+ 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->BlockIo2.Reset = PartitionResetEx;
+ Private->BlockIo2.ReadBlocksEx = PartitionReadBlocksEx;
+ Private->BlockIo2.WriteBlocksEx = PartitionWriteBlocksEx;
+ Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx;
}
- Private->Media.IoAlign = 0;
+ Private->Media.IoAlign = 0;
Private->Media.LogicalPartition = TRUE;
- Private->Media.LastBlock = DivU64x32 (
- MultU64x32 (
- End - Start + 1,
- ParentBlockIo->Media->BlockSize
- ),
- BlockSize
- ) - 1;
+ Private->Media.LastBlock = DivU64x32 (
+ MultU64x32 (
+ End - Start + 1,
+ ParentBlockIo->Media->BlockSize
+ ),
+ BlockSize
+ ) - 1;
- Private->Media.BlockSize = (UINT32) BlockSize;
+ Private->Media.BlockSize = (UINT32)BlockSize;
- Private->Media2.IoAlign = 0;
+ Private->Media2.IoAlign = 0;
Private->Media2.LogicalPartition = TRUE;
- Private->Media2.LastBlock = Private->Media.LastBlock;
- Private->Media2.BlockSize = (UINT32) BlockSize;
+ Private->Media2.LastBlock = Private->Media.LastBlock;
+ Private->Media2.BlockSize = (UINT32)BlockSize;
//
// Per UEFI Spec, LowestAlignedLba, LogicalBlocksPerPhysicalBlock and OptimalTransferLengthGranularity must be 0
@@ -1217,7 +1226,7 @@ PartitionInstallChildHandle ( }
}
- Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);
+ Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);
if (Private->DevicePath == NULL) {
FreePool (Private);
@@ -1230,7 +1239,7 @@ PartitionInstallChildHandle ( CopyMem (&Private->PartitionInfo, PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));
if (TypeGuid != NULL) {
- CopyGuid(&(Private->TypeGuid), TypeGuid);
+ CopyGuid (&(Private->TypeGuid), TypeGuid);
} else {
ZeroMem ((VOID *)&(Private->TypeGuid), sizeof (EFI_GUID));
}
@@ -1276,7 +1285,7 @@ PartitionInstallChildHandle ( Status = gBS->OpenProtocol (
ParentHandle,
&gEfiDiskIoProtocolGuid,
- (VOID **) &ParentDiskIo,
+ (VOID **)&ParentDiskIo,
This->DriverBindingHandle,
Private->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1298,7 +1307,6 @@ PartitionInstallChildHandle ( return Status;
}
-
/**
The user Entry Point for module Partition. The user code starts with this function.
@@ -1312,11 +1320,11 @@ PartitionInstallChildHandle ( EFI_STATUS
EFIAPI
InitializePartition (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -1331,11 +1339,9 @@ InitializePartition ( );
ASSERT_EFI_ERROR (Status);
-
return Status;
}
-
/**
Test to see if there is any child on ControllerHandle.
@@ -1347,7 +1353,7 @@ InitializePartition ( **/
BOOLEAN
HasChildren (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
)
{
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
@@ -1368,7 +1374,8 @@ HasChildren ( break;
}
}
+
FreePool (OpenInfoBuffer);
- return (BOOLEAN) (Index < EntryCount);
+ return (BOOLEAN)(Index < EntryCount);
}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h index a633950bec..100aa4c310 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h @@ -41,36 +41,35 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
#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_PARTITION_INFO_PROTOCOL PartitionInfo;
-
- 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;
- BOOLEAN InStop;
-
- EFI_GUID TypeGuid;
-
+ 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_PARTITION_INFO_PROTOCOL PartitionInfo;
+
+ 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;
+ BOOLEAN InStop;
+
+ EFI_GUID TypeGuid;
} PARTITION_PRIVATE_DATA;
typedef struct {
- EFI_DISK_IO2_TOKEN DiskIo2Token;
- EFI_BLOCK_IO2_TOKEN *BlockIo2Token;
+ 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)
+#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
@@ -82,7 +81,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2; //
// Extract INT32 from char array
//
-#define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
+#define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
(((UINT8 *) a)[1] << 8) | \
(((UINT8 *) a)[2] << 16) | \
(((UINT8 *) a)[3] << 24) )
@@ -90,24 +89,24 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2; //
// Extract UINT32 from char array
//
-#define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
+#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;
+ 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.
@@ -170,15 +169,16 @@ PartitionDriverBindingStart ( EFI_STATUS
EFIAPI
PartitionDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ 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.
@@ -226,7 +226,6 @@ PartitionComponentNameGetDriverName ( OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -298,14 +297,13 @@ PartitionComponentNameGetDriverName ( 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
+ 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.
@@ -356,7 +354,7 @@ PartitionInstallChildHandle ( **/
BOOLEAN
HasChildren (
- IN EFI_HANDLE ControllerHandle
+ IN EFI_HANDLE ControllerHandle
);
/**
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c index 3bf89a1873..098e4fec66 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c @@ -18,7 +18,7 @@ #include "Partition.h"
-#define MAX_CORRECTION_BLOCKS_NUM 512u
+#define MAX_CORRECTION_BLOCKS_NUM 512u
//
// C5BD4D42-1A76-4996-8956-73CDA326CD0A
@@ -29,25 +29,27 @@ }
typedef struct {
- VENDOR_DEVICE_PATH DevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} UDF_DEVICE_PATH;
//
// Vendor-Defined Device Path GUID for UDF file system
//
-EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
+EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
//
// Vendor-Defined Media Device Path for UDF file system
//
-UDF_DEVICE_PATH gUdfDevicePath = {
- { { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
- { sizeof (VENDOR_DEVICE_PATH), 0 } },
+UDF_DEVICE_PATH gUdfDevicePath = {
+ {
+ { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
+ { sizeof (VENDOR_DEVICE_PATH), 0 }
+ },
EFI_UDF_DEVICE_PATH_GUID
},
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
}
};
@@ -99,10 +101,10 @@ FindAnchorVolumeDescriptorPointer ( // That said, we define a magic number of 512 blocks to be used as correction
// when attempting to find AVDP and define last block number.
//
- BlockSize = BlockIo->Media->BlockSize;
- EndLBA = BlockIo->Media->LastBlock;
+ BlockSize = BlockIo->Media->BlockSize;
+ EndLBA = BlockIo->Media->LastBlock;
*LastRecordedBlock = EndLBA;
- AvdpsCount = 0;
+ AvdpsCount = 0;
//
// Check if the block size of the underlying media can hold the data of an
@@ -122,12 +124,12 @@ FindAnchorVolumeDescriptorPointer ( // Find AVDP at block 256
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (256, BlockSize),
- sizeof (*AnchorPoint),
- AnchorPoint
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (256, BlockSize),
+ sizeof (*AnchorPoint),
+ AnchorPoint
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -146,12 +148,12 @@ FindAnchorVolumeDescriptorPointer ( // Find AVDP at block N - 256
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 ((UINT64)EndLBA - 256, BlockSize),
- sizeof (*AnchorPoint),
- AnchorPoint
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 ((UINT64)EndLBA - 256, BlockSize),
+ sizeof (*AnchorPoint),
+ AnchorPoint
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -159,10 +161,15 @@ FindAnchorVolumeDescriptorPointer ( //
// Check if read block is a valid AVDP descriptor
//
- if (DescriptorTag->TagIdentifier == UdfAnchorVolumeDescriptorPointer &&
- ++AvdpsCount == 2) {
- DEBUG ((DEBUG_INFO, "%a: found AVDP at block %Ld\n", __FUNCTION__,
- EndLBA - 256));
+ if ((DescriptorTag->TagIdentifier == UdfAnchorVolumeDescriptorPointer) &&
+ (++AvdpsCount == 2))
+ {
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: found AVDP at block %Ld\n",
+ __FUNCTION__,
+ EndLBA - 256
+ ));
return EFI_SUCCESS;
}
@@ -177,12 +184,12 @@ FindAnchorVolumeDescriptorPointer ( // Find AVDP at block N
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 ((UINT64)EndLBA, BlockSize),
- sizeof (*AnchorPoint),
- AnchorPoint
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 ((UINT64)EndLBA, BlockSize),
+ sizeof (*AnchorPoint),
+ AnchorPoint
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -213,12 +220,12 @@ FindAnchorVolumeDescriptorPointer ( // Read consecutive MAX_CORRECTION_BLOCKS_NUM disk blocks
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 ((UINT64)EndLBA - MAX_CORRECTION_BLOCKS_NUM, BlockSize),
- Size,
- AnchorPoints
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 ((UINT64)EndLBA - MAX_CORRECTION_BLOCKS_NUM, BlockSize),
+ Size,
+ AnchorPoints
+ );
if (EFI_ERROR (Status)) {
goto Out_Free;
}
@@ -241,10 +248,19 @@ FindAnchorVolumeDescriptorPointer ( // Calculate last recorded block number
//
LastAvdpBlockNum = EndLBA - (MAX_CORRECTION_BLOCKS_NUM - Index);
- DEBUG ((DEBUG_WARN, "%a: found AVDP at block %Ld\n", __FUNCTION__,
- LastAvdpBlockNum));
- DEBUG ((DEBUG_WARN, "%a: correcting last block from %Ld to %Ld\n",
- __FUNCTION__, EndLBA, LastAvdpBlockNum));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: found AVDP at block %Ld\n",
+ __FUNCTION__,
+ LastAvdpBlockNum
+ ));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: correcting last block from %Ld to %Ld\n",
+ __FUNCTION__,
+ EndLBA,
+ LastAvdpBlockNum
+ ));
//
// Save read AVDP from last block
//
@@ -253,7 +269,7 @@ FindAnchorVolumeDescriptorPointer ( // Set last recorded block number
//
*LastRecordedBlock = LastAvdpBlockNum;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
break;
}
}
@@ -280,49 +296,60 @@ FindUdfVolumeIdentifiers ( IN EFI_DISK_IO_PROTOCOL *DiskIo
)
{
- EFI_STATUS Status;
- UINT64 Offset;
- UINT64 EndDiskOffset;
- CDROM_VOLUME_DESCRIPTOR VolDescriptor;
- CDROM_VOLUME_DESCRIPTOR TerminatingVolDescriptor;
+ EFI_STATUS Status;
+ UINT64 Offset;
+ UINT64 EndDiskOffset;
+ CDROM_VOLUME_DESCRIPTOR VolDescriptor;
+ CDROM_VOLUME_DESCRIPTOR TerminatingVolDescriptor;
ZeroMem ((VOID *)&TerminatingVolDescriptor, sizeof (CDROM_VOLUME_DESCRIPTOR));
//
// Start Volume Recognition Sequence
//
- EndDiskOffset = MultU64x32 (BlockIo->Media->LastBlock,
- BlockIo->Media->BlockSize);
+ EndDiskOffset = MultU64x32 (
+ BlockIo->Media->LastBlock,
+ BlockIo->Media->BlockSize
+ );
for (Offset = UDF_VRS_START_OFFSET; Offset < EndDiskOffset;
- Offset += UDF_LOGICAL_SECTOR_SIZE) {
+ Offset += UDF_LOGICAL_SECTOR_SIZE)
+ {
//
// Check if block device has a Volume Structure Descriptor and an Extended
// Area.
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- Offset,
- sizeof (CDROM_VOLUME_DESCRIPTOR),
- (VOID *)&VolDescriptor
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ Offset,
+ sizeof (CDROM_VOLUME_DESCRIPTOR),
+ (VOID *)&VolDescriptor
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- if (CompareMem ((VOID *)VolDescriptor.Unknown.Id,
- (VOID *)UDF_BEA_IDENTIFIER,
- sizeof (VolDescriptor.Unknown.Id)) == 0) {
+ if (CompareMem (
+ (VOID *)VolDescriptor.Unknown.Id,
+ (VOID *)UDF_BEA_IDENTIFIER,
+ sizeof (VolDescriptor.Unknown.Id)
+ ) == 0)
+ {
break;
}
- if ((CompareMem ((VOID *)VolDescriptor.Unknown.Id,
- (VOID *)CDVOL_ID,
- sizeof (VolDescriptor.Unknown.Id)) != 0) ||
- (CompareMem ((VOID *)&VolDescriptor,
- (VOID *)&TerminatingVolDescriptor,
- sizeof (CDROM_VOLUME_DESCRIPTOR)) == 0)) {
+ if ((CompareMem (
+ (VOID *)VolDescriptor.Unknown.Id,
+ (VOID *)CDVOL_ID,
+ sizeof (VolDescriptor.Unknown.Id)
+ ) != 0) ||
+ (CompareMem (
+ (VOID *)&VolDescriptor,
+ (VOID *)&TerminatingVolDescriptor,
+ sizeof (CDROM_VOLUME_DESCRIPTOR)
+ ) == 0))
+ {
return EFI_NOT_FOUND;
}
}
@@ -336,22 +363,27 @@ FindUdfVolumeIdentifiers ( }
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- Offset,
- sizeof (CDROM_VOLUME_DESCRIPTOR),
- (VOID *)&VolDescriptor
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ Offset,
+ sizeof (CDROM_VOLUME_DESCRIPTOR),
+ (VOID *)&VolDescriptor
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- if ((CompareMem ((VOID *)VolDescriptor.Unknown.Id,
- (VOID *)UDF_NSR2_IDENTIFIER,
- sizeof (VolDescriptor.Unknown.Id)) != 0) &&
- (CompareMem ((VOID *)VolDescriptor.Unknown.Id,
- (VOID *)UDF_NSR3_IDENTIFIER,
- sizeof (VolDescriptor.Unknown.Id)) != 0)) {
+ if ((CompareMem (
+ (VOID *)VolDescriptor.Unknown.Id,
+ (VOID *)UDF_NSR2_IDENTIFIER,
+ sizeof (VolDescriptor.Unknown.Id)
+ ) != 0) &&
+ (CompareMem (
+ (VOID *)VolDescriptor.Unknown.Id,
+ (VOID *)UDF_NSR3_IDENTIFIER,
+ sizeof (VolDescriptor.Unknown.Id)
+ ) != 0))
+ {
return EFI_NOT_FOUND;
}
@@ -364,19 +396,22 @@ FindUdfVolumeIdentifiers ( }
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- Offset,
- sizeof (CDROM_VOLUME_DESCRIPTOR),
- (VOID *)&VolDescriptor
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ Offset,
+ sizeof (CDROM_VOLUME_DESCRIPTOR),
+ (VOID *)&VolDescriptor
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- if (CompareMem ((VOID *)VolDescriptor.Unknown.Id,
- (VOID *)UDF_TEA_IDENTIFIER,
- sizeof (VolDescriptor.Unknown.Id)) != 0) {
+ if (CompareMem (
+ (VOID *)VolDescriptor.Unknown.Id,
+ (VOID *)UDF_TEA_IDENTIFIER,
+ sizeof (VolDescriptor.Unknown.Id)
+ ) != 0)
+ {
return EFI_NOT_FOUND;
}
@@ -395,22 +430,22 @@ FindUdfVolumeIdentifiers ( **/
BOOLEAN
IsLogicalVolumeDescriptorSupported (
- UDF_LOGICAL_VOLUME_DESCRIPTOR *LogicalVolDesc
+ UDF_LOGICAL_VOLUME_DESCRIPTOR *LogicalVolDesc
)
{
//
// Check for a valid UDF revision range
//
switch (LogicalVolDesc->DomainIdentifier.Suffix.Domain.UdfRevision) {
- case 0x0102:
- case 0x0150:
- case 0x0200:
- case 0x0201:
- case 0x0250:
- case 0x0260:
- break;
- default:
- return FALSE;
+ case 0x0102:
+ case 0x0150:
+ case 0x0200:
+ case 0x0201:
+ case 0x0250:
+ case 0x0260:
+ break;
+ default:
+ return FALSE;
}
//
@@ -419,6 +454,7 @@ IsLogicalVolumeDescriptorSupported ( if (LogicalVolDesc->NumberOfPartitionMaps > 1) {
return FALSE;
}
+
//
// UDF 1.02 revision supports only Type 1 (Physical) partitions, but
// let's check it any way.
@@ -426,8 +462,9 @@ IsLogicalVolumeDescriptorSupported ( // PartitionMap[0] -> type
// PartitionMap[1] -> length (in bytes)
//
- if (LogicalVolDesc->PartitionMaps[0] != 1 ||
- LogicalVolDesc->PartitionMaps[1] != 6) {
+ if ((LogicalVolDesc->PartitionMaps[0] != 1) ||
+ (LogicalVolDesc->PartitionMaps[1] != 6))
+ {
return FALSE;
}
@@ -475,7 +512,7 @@ FindLogicalVolumeLocation ( UDF_DESCRIPTOR_TAG *DescriptorTag;
BlockSize = BlockIo->Media->BlockSize;
- ExtentAd = &AnchorPoint->MainVolumeDescriptorSequenceExtent;
+ ExtentAd = &AnchorPoint->MainVolumeDescriptorSequenceExtent;
//
// UDF 2.60, 2.2.3.1 struct MainVolumeDescriptorSequenceExtent
@@ -486,7 +523,7 @@ FindLogicalVolumeLocation ( // Also make sure it does not exceed maximum number of blocks in the disk.
//
SeqBlocksNum = DivU64x32 ((UINT64)ExtentAd->ExtentLength, BlockSize);
- if (SeqBlocksNum < 16 || (EFI_LBA)SeqBlocksNum > LastRecordedBlock + 1) {
+ if ((SeqBlocksNum < 16) || ((EFI_LBA)SeqBlocksNum > LastRecordedBlock + 1)) {
return EFI_VOLUME_CORRUPTED;
}
@@ -494,8 +531,9 @@ FindLogicalVolumeLocation ( // Check for valid Volume Descriptor Sequence starting block number
//
SeqStartBlock = (UINT64)ExtentAd->ExtentLocation;
- if (SeqStartBlock > LastRecordedBlock ||
- SeqStartBlock + SeqBlocksNum - 1 > LastRecordedBlock) {
+ if ((SeqStartBlock > LastRecordedBlock) ||
+ (SeqStartBlock + SeqBlocksNum - 1 > LastRecordedBlock))
+ {
return EFI_VOLUME_CORRUPTED;
}
@@ -509,24 +547,24 @@ FindLogicalVolumeLocation ( return EFI_OUT_OF_RESOURCES;
}
- SeqEndBlock = SeqStartBlock + SeqBlocksNum;
+ SeqEndBlock = SeqStartBlock + SeqBlocksNum;
StopSequence = FALSE;
- LvdsCount = 0;
- Status = EFI_VOLUME_CORRUPTED;
+ LvdsCount = 0;
+ Status = EFI_VOLUME_CORRUPTED;
//
// Start Main Volume Descriptor Sequence
//
- for (; SeqStartBlock < SeqEndBlock && !StopSequence; SeqStartBlock++) {
+ for ( ; SeqStartBlock < SeqEndBlock && !StopSequence; SeqStartBlock++) {
//
// Read disk block
//
Status = BlockIo->ReadBlocks (
- BlockIo,
- BlockIo->Media->MediaId,
- SeqStartBlock,
- BlockSize,
- Buffer
- );
+ BlockIo,
+ BlockIo->Media->MediaId,
+ SeqStartBlock,
+ BlockSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
goto Out_Free;
}
@@ -548,50 +586,51 @@ FindLogicalVolumeLocation ( // Space Descriptors.
//
switch (DescriptorTag->TagIdentifier) {
- case UdfPrimaryVolumeDescriptor:
- case UdfImplemenationUseVolumeDescriptor:
- case UdfPartitionDescriptor:
- case UdfUnallocatedSpaceDescriptor:
- break;
-
- case UdfLogicalVolumeDescriptor:
- LogicalVolDesc = Buffer;
-
- //
- // Check for existence of a single LVD and whether it is supported by
- // current EDK2 UDF file system implementation.
- //
- if (++LvdsCount > 1 ||
- !IsLogicalVolumeDescriptorSupported (LogicalVolDesc)) {
- Status = EFI_UNSUPPORTED;
+ case UdfPrimaryVolumeDescriptor:
+ case UdfImplemenationUseVolumeDescriptor:
+ case UdfPartitionDescriptor:
+ case UdfUnallocatedSpaceDescriptor:
+ break;
+
+ case UdfLogicalVolumeDescriptor:
+ LogicalVolDesc = Buffer;
+
+ //
+ // Check for existence of a single LVD and whether it is supported by
+ // current EDK2 UDF file system implementation.
+ //
+ if ((++LvdsCount > 1) ||
+ !IsLogicalVolumeDescriptorSupported (LogicalVolDesc))
+ {
+ Status = EFI_UNSUPPORTED;
+ StopSequence = TRUE;
+ }
+
+ break;
+
+ case UdfTerminatingDescriptor:
+ //
+ // Stop the sequence when we find a Terminating Descriptor
+ // (aka Unallocated Sector), se we don't have to walk all the unallocated
+ // area unnecessarily.
+ //
StopSequence = TRUE;
- }
-
- break;
-
- case UdfTerminatingDescriptor:
- //
- // Stop the sequence when we find a Terminating Descriptor
- // (aka Unallocated Sector), se we don't have to walk all the unallocated
- // area unnecessarily.
- //
- StopSequence = TRUE;
- break;
-
- default:
- //
- // An invalid Volume Descriptor has been found in the sequece. Volume is
- // corrupted.
- //
- Status = EFI_VOLUME_CORRUPTED;
- goto Out_Free;
+ break;
+
+ default:
+ //
+ // An invalid Volume Descriptor has been found in the sequece. Volume is
+ // corrupted.
+ //
+ Status = EFI_VOLUME_CORRUPTED;
+ goto Out_Free;
}
}
//
// Check if LVD was found
//
- if (!EFI_ERROR (Status) && LvdsCount == 1) {
+ if (!EFI_ERROR (Status) && (LvdsCount == 1)) {
*MainVdsStartBlock = GuardMainVdsStartBlock;
//
// We do not need to read either LVD or PD descriptors to know the last
@@ -654,11 +693,11 @@ FindUdfFileSystem ( // Find Anchor Volume Descriptor Pointer
//
Status = FindAnchorVolumeDescriptorPointer (
- BlockIo,
- DiskIo,
- &AnchorPoint,
- &LastRecordedBlock
- );
+ BlockIo,
+ DiskIo,
+ &AnchorPoint,
+ &LastRecordedBlock
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -667,13 +706,13 @@ FindUdfFileSystem ( // Find Logical Volume location
//
Status = FindLogicalVolumeLocation (
- BlockIo,
- DiskIo,
- &AnchorPoint,
- LastRecordedBlock,
- (UINT64 *)StartingLBA,
- (UINT64 *)EndingLBA
- );
+ BlockIo,
+ DiskIo,
+ &AnchorPoint,
+ LastRecordedBlock,
+ (UINT64 *)StartingLBA,
+ (UINT64 *)EndingLBA
+ );
return Status;
}
@@ -714,7 +753,7 @@ PartitionInstallUdfChildHandles ( EFI_LBA EndingLBA;
BOOLEAN ChildCreated;
- Media = BlockIo->Media;
+ Media = BlockIo->Media;
ChildCreated = FALSE;
//
@@ -760,26 +799,26 @@ PartitionInstallUdfChildHandles ( //
ZeroMem (&PartitionInfo, sizeof (EFI_PARTITION_INFO_PROTOCOL));
PartitionInfo.Revision = EFI_PARTITION_INFO_PROTOCOL_REVISION;
- PartitionInfo.Type = PARTITION_TYPE_OTHER;
+ PartitionInfo.Type = PARTITION_TYPE_OTHER;
//
// Install partition child handle for UDF file system
//
Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *)&gUdfDevicePath,
- &PartitionInfo,
- StartingLBA,
- EndingLBA,
- Media->BlockSize,
- NULL
- );
+ This,
+ Handle,
+ DiskIo,
+ DiskIo2,
+ BlockIo,
+ BlockIo2,
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUdfDevicePath,
+ &PartitionInfo,
+ StartingLBA,
+ EndingLBA,
+ Media->BlockSize,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return (ChildCreated ? EFI_SUCCESS : Status);
}
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c index 13f81bae1e..4fbbb1f3b4 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c @@ -14,7 +14,7 @@ //
EFI_BLOCK_IO_PROTOCOL mRamDiskBlockIoTemplate = {
EFI_BLOCK_IO_PROTOCOL_REVISION,
- (EFI_BLOCK_IO_MEDIA *) 0,
+ (EFI_BLOCK_IO_MEDIA *)0,
RamDiskBlkIoReset,
RamDiskBlkIoReadBlocks,
RamDiskBlkIoWriteBlocks,
@@ -26,14 +26,13 @@ EFI_BLOCK_IO_PROTOCOL mRamDiskBlockIoTemplate = { // for newly registered RAM disks
//
EFI_BLOCK_IO2_PROTOCOL mRamDiskBlockIo2Template = {
- (EFI_BLOCK_IO_MEDIA *) 0,
+ (EFI_BLOCK_IO_MEDIA *)0,
RamDiskBlkIo2Reset,
RamDiskBlkIo2ReadBlocksEx,
RamDiskBlkIo2WriteBlocksEx,
RamDiskBlkIo2FlushBlocksEx
};
-
/**
Initialize the BlockIO & BlockIO2 protocol of a RAM disk device.
@@ -42,13 +41,13 @@ EFI_BLOCK_IO2_PROTOCOL mRamDiskBlockIo2Template = { **/
VOID
RamDiskInitBlockIo (
- IN RAM_DISK_PRIVATE_DATA *PrivateData
+ IN RAM_DISK_PRIVATE_DATA *PrivateData
)
{
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- EFI_BLOCK_IO_MEDIA *Media;
- UINT32 Remainder;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
+ EFI_BLOCK_IO_MEDIA *Media;
+ UINT32 Remainder;
BlockIo = &PrivateData->BlockIo;
BlockIo2 = &PrivateData->BlockIo2;
@@ -67,18 +66,19 @@ RamDiskInitBlockIo ( for (Media->BlockSize = RAM_DISK_DEFAULT_BLOCK_SIZE;
Media->BlockSize >= 1;
- Media->BlockSize = Media->BlockSize >> 1) {
+ Media->BlockSize = Media->BlockSize >> 1)
+ {
Media->LastBlock = DivU64x32Remainder (PrivateData->Size, Media->BlockSize, &Remainder) - 1;
if (Remainder == 0) {
break;
}
}
+
ASSERT (Media->BlockSize != 0);
return;
}
-
/**
Reset the Block Device.
@@ -93,14 +93,13 @@ RamDiskInitBlockIo ( EFI_STATUS
EFIAPI
RamDiskBlkIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return EFI_SUCCESS;
}
-
/**
Read BufferSize bytes from Lba into Buffer.
@@ -129,15 +128,15 @@ RamDiskBlkIoReset ( EFI_STATUS
EFIAPI
RamDiskBlkIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- RAM_DISK_PRIVATE_DATA *PrivateData;
- UINTN NumberOfBlocks;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ UINTN NumberOfBlocks;
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
@@ -175,7 +174,6 @@ RamDiskBlkIoReadBlocks ( return EFI_SUCCESS;
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -204,15 +202,15 @@ RamDiskBlkIoReadBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- RAM_DISK_PRIVATE_DATA *PrivateData;
- UINTN NumberOfBlocks;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ UINTN NumberOfBlocks;
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
@@ -254,7 +252,6 @@ RamDiskBlkIoWriteBlocks ( return EFI_SUCCESS;
}
-
/**
Flush the Block Device.
@@ -269,13 +266,12 @@ RamDiskBlkIoWriteBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
)
{
return EFI_SUCCESS;
}
-
/**
Resets the block device hardware.
@@ -290,14 +286,13 @@ RamDiskBlkIoFlushBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIo2Reset (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return EFI_SUCCESS;
}
-
/**
Reads the requested number of blocks from the device.
@@ -334,26 +329,26 @@ RamDiskBlkIo2Reset ( EFI_STATUS
EFIAPI
RamDiskBlkIo2ReadBlocksEx (
- 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
+ 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
)
{
- RAM_DISK_PRIVATE_DATA *PrivateData;
- EFI_STATUS Status;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ EFI_STATUS Status;
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO2 (This);
Status = RamDiskBlkIoReadBlocks (
- &PrivateData->BlockIo,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
+ &PrivateData->BlockIo,
+ MediaId,
+ Lba,
+ BufferSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -369,7 +364,6 @@ RamDiskBlkIo2ReadBlocksEx ( return EFI_SUCCESS;
}
-
/**
Writes a specified number of blocks to the device.
@@ -405,26 +399,26 @@ RamDiskBlkIo2ReadBlocksEx ( EFI_STATUS
EFIAPI
RamDiskBlkIo2WriteBlocksEx (
- 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
+ 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
)
{
- RAM_DISK_PRIVATE_DATA *PrivateData;
- EFI_STATUS Status;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ EFI_STATUS Status;
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO2 (This);
Status = RamDiskBlkIoWriteBlocks (
- &PrivateData->BlockIo,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
+ &PrivateData->BlockIo,
+ MediaId,
+ Lba,
+ BufferSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -440,7 +434,6 @@ RamDiskBlkIo2WriteBlocksEx ( return EFI_SUCCESS;
}
-
/**
Flushes all modified data to a physical block device.
@@ -463,11 +456,11 @@ RamDiskBlkIo2WriteBlocksEx ( EFI_STATUS
EFIAPI
RamDiskBlkIo2FlushBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
- RAM_DISK_PRIVATE_DATA *PrivateData;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO2 (This);
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c index 1ecf8da1d3..82184c1c69 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c @@ -34,7 +34,6 @@ LIST_ENTRY RegisteredRamDisks; EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol = NULL;
EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol = NULL;
-
/**
Check whether EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL are produced.
If both protocols are produced, publish all the reserved memory type RAM
@@ -48,13 +47,13 @@ EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol = NULL; VOID
EFIAPI
RamDiskAcpiCheck (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Entry;
- RAM_DISK_PRIVATE_DATA *PrivateData;
+ EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
gBS->CloseEvent (Event);
@@ -99,7 +98,6 @@ RamDiskAcpiCheck ( }
}
-
/**
The entry point for RamDiskDxe driver.
@@ -116,14 +114,14 @@ RamDiskAcpiCheck ( EFI_STATUS
EFIAPI
RamDiskDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
- VOID *DummyInterface;
- EFI_EVENT Event;
+ EFI_STATUS Status;
+ RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
+ VOID *DummyInterface;
+ EFI_EVENT Event;
//
// If already started, return.
@@ -194,7 +192,6 @@ ErrorExit: return Status;
}
-
/**
Unload the RamDiskDxe driver and its configuration form.
@@ -208,16 +205,16 @@ ErrorExit: EFI_STATUS
EFIAPI
RamDiskDxeUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
+ EFI_STATUS Status;
+ RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
Status = gBS->HandleProtocol (
mRamDiskHandle,
&gEfiCallerIdGuid,
- (VOID **) &ConfigPrivate
+ (VOID **)&ConfigPrivate
);
if (EFI_ERROR (Status)) {
return Status;
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c index 3a000389f0..0285ff5d0e 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c @@ -8,7 +8,6 @@ #include "RamDiskImpl.h"
-
/**
Helper function called as part of the code needed to allocate the proper
sized buffer for various EFI interfaces.
@@ -24,12 +23,12 @@ **/
BOOLEAN
GrowBuffer (
- IN OUT EFI_STATUS *Status,
- IN OUT VOID **Buffer,
- IN UINTN BufferSize
+ IN OUT EFI_STATUS *Status,
+ IN OUT VOID **Buffer,
+ IN UINTN BufferSize
)
{
- BOOLEAN TryAgain;
+ BOOLEAN TryAgain;
//
// If this is an initial request, buffer will be null with a new buffer size
@@ -37,12 +36,12 @@ GrowBuffer ( if ((*Buffer == NULL) && (BufferSize != 0)) {
*Status = EFI_BUFFER_TOO_SMALL;
}
+
//
// If the status code is "buffer too small", resize the buffer
//
TryAgain = FALSE;
if (*Status == EFI_BUFFER_TOO_SMALL) {
-
if (*Buffer != NULL) {
FreePool (*Buffer);
}
@@ -55,6 +54,7 @@ GrowBuffer ( *Status = EFI_OUT_OF_RESOURCES;
}
}
+
//
// If there's an error, free the buffer
//
@@ -66,7 +66,6 @@ GrowBuffer ( return TryAgain;
}
-
/**
This function gets the file information from an open file descriptor,
and stores it in a buffer allocated from pool.
@@ -78,23 +77,23 @@ GrowBuffer ( **/
EFI_FILE_INFO *
FileInfo (
- IN EFI_FILE_HANDLE FHand
+ IN EFI_FILE_HANDLE FHand
)
{
- EFI_STATUS Status;
- EFI_FILE_INFO *Buffer;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *Buffer;
+ UINTN BufferSize;
//
// Initialize for GrowBuffer loop
//
- Buffer = NULL;
- BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
+ Buffer = NULL;
+ BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
//
// Call the real function
//
- while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {
+ while (GrowBuffer (&Status, (VOID **)&Buffer, BufferSize)) {
Status = FHand->GetInfo (
FHand,
&gEfiFileInfoGuid,
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c index e35b8fa229..60cf3c8c4a 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c @@ -12,7 +12,7 @@ CHAR16 mRamDiskStorageName[] = L"RAM_DISK_CONFIGURATION";
-RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = {
+RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = {
RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE,
{
EFI_PAGE_SIZE,
@@ -25,14 +25,14 @@ RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = { }
};
-HII_VENDOR_DEVICE_PATH mRamDiskHiiVendorDevicePath = {
+HII_VENDOR_DEVICE_PATH mRamDiskHiiVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
RAM_DISK_FORM_SET_GUID
@@ -41,13 +41,12 @@ HII_VENDOR_DEVICE_PATH mRamDiskHiiVendorDevicePath = { END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
-
/**
This function publish the RAM disk configuration Form.
@@ -61,7 +60,7 @@ HII_VENDOR_DEVICE_PATH mRamDiskHiiVendorDevicePath = { **/
EFI_STATUS
InstallRamDiskConfigForm (
- IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
+ IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
)
{
EFI_STATUS Status;
@@ -71,14 +70,14 @@ InstallRamDiskConfigForm ( DriverHandle = NULL;
ConfigAccess = &ConfigPrivateData->ConfigAccess;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mRamDiskHiiVendorDevicePath,
- &gEfiHiiConfigAccessProtocolGuid,
- ConfigAccess,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mRamDiskHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ ConfigAccess,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -112,7 +111,6 @@ InstallRamDiskConfigForm ( return EFI_SUCCESS;
}
-
/**
This function removes RAM disk configuration Form.
@@ -122,7 +120,7 @@ InstallRamDiskConfigForm ( **/
VOID
UninstallRamDiskConfigForm (
- IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
+ IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
)
{
//
@@ -151,7 +149,6 @@ UninstallRamDiskConfigForm ( FreePool (ConfigPrivateData);
}
-
/**
Unregister all registered RAM disks.
@@ -161,11 +158,11 @@ UnregisterAllRamDisks ( VOID
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- RAM_DISK_PRIVATE_DATA *PrivateData;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
- if (!IsListEmpty(&RegisteredRamDisks)) {
+ if (!IsListEmpty (&RegisteredRamDisks)) {
BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
@@ -176,7 +173,7 @@ UnregisterAllRamDisks ( &gEfiBlockIo2ProtocolGuid,
&PrivateData->BlockIo2,
&gEfiDevicePathProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL *) PrivateData->DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)PrivateData->DevicePath,
NULL
);
@@ -188,7 +185,7 @@ UnregisterAllRamDisks ( // driver is responsible for freeing the allocated memory for the
// RAM disk.
//
- FreePool ((VOID *)(UINTN) PrivateData->StartingAddr);
+ FreePool ((VOID *)(UINTN)PrivateData->StartingAddr);
}
FreePool (PrivateData->DevicePath);
@@ -197,7 +194,6 @@ UnregisterAllRamDisks ( }
}
-
/**
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
@@ -228,20 +224,20 @@ UnregisterAllRamDisks ( EFI_STATUS
EFIAPI
RamDiskExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Request;
return EFI_NOT_FOUND;
}
-
/**
This function processes the results of changes in configuration.
@@ -263,12 +259,12 @@ RamDiskExtractConfig ( EFI_STATUS
EFIAPI
RamDiskRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- if (Configuration == NULL || Progress == NULL) {
+ if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -277,7 +273,6 @@ RamDiskRouteConfig ( return EFI_NOT_FOUND;
}
-
/**
Allocate memory and register the RAM disk created within RamDiskDxe
driver HII.
@@ -295,18 +290,18 @@ RamDiskRouteConfig ( **/
EFI_STATUS
HiiCreateRamDisk (
- IN UINT64 Size,
- IN EFI_FILE_HANDLE FileHandle,
- IN UINT8 MemoryType
+ IN UINT64 Size,
+ IN EFI_FILE_HANDLE FileHandle,
+ IN UINT8 MemoryType
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- UINT64 *StartingAddr;
- EFI_INPUT_KEY Key;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- RAM_DISK_PRIVATE_DATA *PrivateData;
- EFI_FILE_INFO *FileInformation;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ UINT64 *StartingAddr;
+ EFI_INPUT_KEY Key;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ EFI_FILE_INFO *FileInformation;
FileInformation = NULL;
StartingAddr = NULL;
@@ -338,7 +333,7 @@ HiiCreateRamDisk ( Size = FileInformation->FileSize;
}
- if (Size > (UINTN) -1) {
+ if (Size > (UINTN)-1) {
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -358,19 +353,19 @@ HiiCreateRamDisk ( Status = gBS->AllocatePool (
EfiBootServicesData,
(UINTN)Size,
- (VOID**)&StartingAddr
+ (VOID **)&StartingAddr
);
} else if (MemoryType == RAM_DISK_RESERVED_MEMORY) {
Status = gBS->AllocatePool (
EfiReservedMemoryType,
(UINTN)Size,
- (VOID**)&StartingAddr
+ (VOID **)&StartingAddr
);
} else {
Status = EFI_INVALID_PARAMETER;
}
- if ((StartingAddr == NULL) || EFI_ERROR(Status)) {
+ if ((StartingAddr == NULL) || EFI_ERROR (Status)) {
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -390,11 +385,11 @@ HiiCreateRamDisk ( //
// Copy the file content to the RAM disk.
//
- BufferSize = (UINTN) Size;
+ BufferSize = (UINTN)Size;
FileHandle->Read (
FileHandle,
&BufferSize,
- (VOID *)(UINTN) StartingAddr
+ (VOID *)(UINTN)StartingAddr
);
if (BufferSize != FileInformation->FileSize) {
do {
@@ -417,7 +412,7 @@ HiiCreateRamDisk ( // Register the newly created RAM disk.
//
Status = RamDiskRegister (
- ((UINT64)(UINTN) StartingAddr),
+ ((UINT64)(UINTN)StartingAddr),
Size,
&gEfiVirtualDiskGuid,
NULL,
@@ -443,13 +438,12 @@ HiiCreateRamDisk ( // If RAM disk is created within HII, memory should be freed when the
// RAM disk is unregisterd.
//
- PrivateData = RAM_DISK_PRIVATE_FROM_THIS (RegisteredRamDisks.BackLink);
+ PrivateData = RAM_DISK_PRIVATE_FROM_THIS (RegisteredRamDisks.BackLink);
PrivateData->CreateMethod = RamDiskCreateHii;
return EFI_SUCCESS;
}
-
/**
This function updates the registered RAM disks list on the main form.
@@ -460,19 +454,19 @@ HiiCreateRamDisk ( **/
VOID
UpdateMainForm (
- IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate
+ IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate
)
{
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- EFI_IFR_GUID_LABEL *EndLabel;
- LIST_ENTRY *Entry;
- UINTN Index;
- RAM_DISK_PRIVATE_DATA *PrivateData;
- CHAR16 *String;
- CHAR16 RamDiskStr[128];
- EFI_STRING_ID StringId;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ LIST_ENTRY *Entry;
+ UINTN Index;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ CHAR16 *String;
+ CHAR16 RamDiskStr[128];
+ EFI_STRING_ID StringId;
//
// Init OpCode Handle
@@ -486,32 +480,32 @@ UpdateMainForm ( //
// Create Hii Extend Label OpCode as the start opcode
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- StartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ StartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartLabel->Number = MAIN_LABEL_LIST_START;
//
// Create Hii Extend Label OpCode as the end opcode
//
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- EndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ EndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndLabel->Number = MAIN_LABEL_LIST_END;
Index = 0;
BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
- PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
- PrivateData->CheckBoxId = (EFI_QUESTION_ID)
- (MAIN_CHECKBOX_QUESTION_ID_START + Index);
+ PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
+ PrivateData->CheckBoxId = (EFI_QUESTION_ID)
+ (MAIN_CHECKBOX_QUESTION_ID_START + Index);
//
// CheckBox is unchecked by default.
//
@@ -557,7 +551,6 @@ UpdateMainForm ( HiiFreeOpCodeHandle (EndOpCodeHandle);
}
-
/**
This function processes the results of changes in configuration.
@@ -583,21 +576,21 @@ UpdateMainForm ( EFI_STATUS
EFIAPI
RamDiskCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- EFI_STATUS Status;
- RAM_DISK_PRIVATE_DATA *PrivateData;
- RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
- EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
- EFI_FILE_HANDLE FileHandle;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
+ EFI_STATUS Status;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
+ EFI_FILE_HANDLE FileHandle;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -608,20 +601,22 @@ RamDiskCallback ( if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
Status = EFI_UNSUPPORTED;
if (QuestionId == CREATE_RAW_SIZE_QUESTION_ID) {
- Value->u64 = EFI_PAGE_SIZE;
+ Value->u64 = EFI_PAGE_SIZE;
ConfigPrivate->ConfigStore.Size = EFI_PAGE_SIZE;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
} else if (QuestionId == CREATE_RAW_MEMORY_TYPE_QUESTION_ID) {
- Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
+ Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
ConfigPrivate->ConfigStore.MemType = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
+
return Status;
}
if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
(Action != EFI_BROWSER_ACTION_CHANGING) &&
- (Action != EFI_BROWSER_ACTION_FORM_OPEN)) {
+ (Action != EFI_BROWSER_ACTION_FORM_OPEN))
+ {
return EFI_UNSUPPORTED;
}
@@ -634,6 +629,7 @@ RamDiskCallback ( UpdateMainForm (ConfigPrivate);
Status = EFI_SUCCESS;
}
+
return Status;
}
@@ -641,33 +637,85 @@ RamDiskCallback ( if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
- case MAIN_GOTO_FILE_EXPLORER_ID:
- Status = ChooseFile (NULL, NULL, NULL, &FileDevPath);
- if (EFI_ERROR (Status)) {
+ case MAIN_GOTO_FILE_EXPLORER_ID:
+ Status = ChooseFile (NULL, NULL, NULL, &FileDevPath);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ if (FileDevPath != NULL) {
+ //
+ // Open the file.
+ //
+ Status = EfiOpenFileByDevicePath (
+ &FileDevPath,
+ &FileHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ //
+ // Create from file, RAM disk size is zero. It will be updated
+ // according to the file size.
+ //
+ Status = HiiCreateRamDisk (
+ 0,
+ FileHandle,
+ ConfigPrivate->ConfigStore.MemType
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ //
+ // Refresh the registered RAM disks list.
+ //
+ UpdateMainForm (ConfigPrivate);
+ }
+
break;
- }
- if (FileDevPath != NULL) {
+ default:
+ break;
+ }
+ } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
+ switch (QuestionId) {
+ case MAIN_REMOVE_RD_QUESTION_ID:
//
- // Open the file.
+ // Remove the selected RAM disks
//
- Status = EfiOpenFileByDevicePath (
- &FileDevPath,
- &FileHandle,
- EFI_FILE_MODE_READ,
- 0
- );
- if (EFI_ERROR (Status)) {
- break;
+ BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
+ PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
+ if (PrivateData->CheckBoxChecked) {
+ RamDiskUnregister (
+ (EFI_DEVICE_PATH_PROTOCOL *)PrivateData->DevicePath
+ );
+ }
}
+ UpdateMainForm (ConfigPrivate);
+
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
+ break;
+
+ case CREATE_RAW_SIZE_QUESTION_ID:
+ ConfigPrivate->ConfigStore.Size = Value->u64;
+ break;
+
+ case CREATE_RAW_MEMORY_TYPE_QUESTION_ID:
+ ConfigPrivate->ConfigStore.MemType = Value->u8;
+ break;
+
+ case CREATE_RAW_SUBMIT_QUESTION_ID:
//
- // Create from file, RAM disk size is zero. It will be updated
- // according to the file size.
+ // Create raw, FileHandle is NULL.
//
Status = HiiCreateRamDisk (
- 0,
- FileHandle,
+ ConfigPrivate->ConfigStore.Size,
+ NULL,
ConfigPrivate->ConfigStore.MemType
);
if (EFI_ERROR (Status)) {
@@ -678,79 +726,30 @@ RamDiskCallback ( // Refresh the registered RAM disks list.
//
UpdateMainForm (ConfigPrivate);
- }
- break;
- default:
- break;
- }
- } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
- switch (QuestionId) {
- case MAIN_REMOVE_RD_QUESTION_ID:
- //
- // Remove the selected RAM disks
- //
- BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
- PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
- if (PrivateData->CheckBoxChecked) {
- RamDiskUnregister (
- (EFI_DEVICE_PATH_PROTOCOL *) PrivateData->DevicePath
- );
- }
- }
-
- UpdateMainForm (ConfigPrivate);
-
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
- break;
-
- case CREATE_RAW_SIZE_QUESTION_ID:
- ConfigPrivate->ConfigStore.Size = Value->u64;
- break;
-
- case CREATE_RAW_MEMORY_TYPE_QUESTION_ID:
- ConfigPrivate->ConfigStore.MemType = Value->u8;
- break;
-
- case CREATE_RAW_SUBMIT_QUESTION_ID:
- //
- // Create raw, FileHandle is NULL.
- //
- Status = HiiCreateRamDisk (
- ConfigPrivate->ConfigStore.Size,
- NULL,
- ConfigPrivate->ConfigStore.MemType
- );
- if (EFI_ERROR (Status)) {
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
break;
- }
-
- //
- // Refresh the registered RAM disks list.
- //
- UpdateMainForm (ConfigPrivate);
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- break;
-
- case CREATE_RAW_DISCARD_QUESTION_ID:
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- break;
+ case CREATE_RAW_DISCARD_QUESTION_ID:
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ break;
- default:
- //
- // QuestionIds for checkboxes
- //
- if ((QuestionId >= MAIN_CHECKBOX_QUESTION_ID_START) &&
- (QuestionId < CREATE_RAW_RAM_DISK_FORM_ID)) {
- BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
- PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
- if (PrivateData->CheckBoxId == QuestionId) {
- PrivateData->CheckBoxChecked = (BOOLEAN) (Value->u8 != 0);
+ default:
+ //
+ // QuestionIds for checkboxes
+ //
+ if ((QuestionId >= MAIN_CHECKBOX_QUESTION_ID_START) &&
+ (QuestionId < CREATE_RAW_RAM_DISK_FORM_ID))
+ {
+ BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
+ PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
+ if (PrivateData->CheckBoxId == QuestionId) {
+ PrivateData->CheckBoxChecked = (BOOLEAN)(Value->u8 != 0);
+ }
}
}
- }
- break;
+
+ break;
}
}
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h index ed80b47ccc..e194951805 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h @@ -46,24 +46,24 @@ //
// Default block size for RAM disk
//
-#define RAM_DISK_DEFAULT_BLOCK_SIZE 512
+#define RAM_DISK_DEFAULT_BLOCK_SIZE 512
//
// RamDiskDxe driver maintains a list of registered RAM disks.
//
-extern LIST_ENTRY RegisteredRamDisks;
+extern LIST_ENTRY RegisteredRamDisks;
//
// Pointers to the EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL.
//
-extern EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol;
-extern EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol;
+extern EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol;
+extern EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol;
//
// RAM Disk create method.
//
typedef enum _RAM_DISK_CREATE_METHOD {
- RamDiskCreateOthers = 0,
+ RamDiskCreateOthers = 0,
RamDiskCreateHii
} RAM_DISK_CREATE_METHOD;
@@ -73,31 +73,31 @@ typedef enum _RAM_DISK_CREATE_METHOD { // disk
//
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EFI_HANDLE Handle;
+ EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- EFI_BLOCK_IO2_PROTOCOL BlockIo2;
- EFI_BLOCK_IO_MEDIA Media;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_BLOCK_IO_PROTOCOL BlockIo;
+ EFI_BLOCK_IO2_PROTOCOL BlockIo2;
+ EFI_BLOCK_IO_MEDIA Media;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINT64 StartingAddr;
- UINT64 Size;
- EFI_GUID TypeGuid;
- UINT16 InstanceNumber;
- RAM_DISK_CREATE_METHOD CreateMethod;
- BOOLEAN InNfit;
- EFI_QUESTION_ID CheckBoxId;
- BOOLEAN CheckBoxChecked;
+ UINT64 StartingAddr;
+ UINT64 Size;
+ EFI_GUID TypeGuid;
+ UINT16 InstanceNumber;
+ RAM_DISK_CREATE_METHOD CreateMethod;
+ BOOLEAN InNfit;
+ EFI_QUESTION_ID CheckBoxId;
+ BOOLEAN CheckBoxChecked;
- LIST_ENTRY ThisInstance;
+ LIST_ENTRY ThisInstance;
} RAM_DISK_PRIVATE_DATA;
-#define RAM_DISK_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('R', 'D', 'S', 'K')
-#define RAM_DISK_PRIVATE_FROM_BLKIO(a) CR (a, RAM_DISK_PRIVATE_DATA, BlockIo, RAM_DISK_PRIVATE_DATA_SIGNATURE)
-#define RAM_DISK_PRIVATE_FROM_BLKIO2(a) CR (a, RAM_DISK_PRIVATE_DATA, BlockIo2, RAM_DISK_PRIVATE_DATA_SIGNATURE)
-#define RAM_DISK_PRIVATE_FROM_THIS(a) CR (a, RAM_DISK_PRIVATE_DATA, ThisInstance, RAM_DISK_PRIVATE_DATA_SIGNATURE)
+#define RAM_DISK_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('R', 'D', 'S', 'K')
+#define RAM_DISK_PRIVATE_FROM_BLKIO(a) CR (a, RAM_DISK_PRIVATE_DATA, BlockIo, RAM_DISK_PRIVATE_DATA_SIGNATURE)
+#define RAM_DISK_PRIVATE_FROM_BLKIO2(a) CR (a, RAM_DISK_PRIVATE_DATA, BlockIo2, RAM_DISK_PRIVATE_DATA_SIGNATURE)
+#define RAM_DISK_PRIVATE_FROM_THIS(a) CR (a, RAM_DISK_PRIVATE_DATA, ThisInstance, RAM_DISK_PRIVATE_DATA_SIGNATURE)
///
/// RAM disk HII-related definitions and declarations
@@ -106,28 +106,28 @@ typedef struct { //
// Tool generated IFR binary data and String package data
//
-extern UINT8 RamDiskHiiBin[];
-extern UINT8 RamDiskDxeStrings[];
+extern UINT8 RamDiskHiiBin[];
+extern UINT8 RamDiskDxeStrings[];
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- RAM_DISK_CONFIGURATION ConfigStore;
+ RAM_DISK_CONFIGURATION ConfigStore;
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
- EFI_HANDLE DriverHandle;
- EFI_HII_HANDLE HiiHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE HiiHandle;
} RAM_DISK_CONFIG_PRIVATE_DATA;
-extern RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate;
+extern RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate;
-#define RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('R', 'C', 'F', 'G')
-#define RAM_DISK_CONFIG_PRIVATE_FROM_THIS(a) CR (a, RAM_DISK_CONFIG_PRIVATE_DATA, ConfigAccess, RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE)
+#define RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('R', 'C', 'F', 'G')
+#define RAM_DISK_CONFIG_PRIVATE_FROM_THIS(a) CR (a, RAM_DISK_CONFIG_PRIVATE_DATA, ConfigAccess, RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE)
/**
Register a RAM disk with specified address, size and type.
@@ -162,11 +162,11 @@ extern RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate; EFI_STATUS
EFIAPI
RamDiskRegister (
- IN UINT64 RamDiskBase,
- IN UINT64 RamDiskSize,
- IN EFI_GUID *RamDiskType,
- IN EFI_DEVICE_PATH *ParentDevicePath OPTIONAL,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN UINT64 RamDiskBase,
+ IN UINT64 RamDiskSize,
+ IN EFI_GUID *RamDiskType,
+ IN EFI_DEVICE_PATH *ParentDevicePath OPTIONAL,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -187,7 +187,7 @@ RamDiskRegister ( EFI_STATUS
EFIAPI
RamDiskUnregister (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -198,7 +198,7 @@ RamDiskUnregister ( **/
VOID
RamDiskInitBlockIo (
- IN RAM_DISK_PRIVATE_DATA *PrivateData
+ IN RAM_DISK_PRIVATE_DATA *PrivateData
);
/**
@@ -216,8 +216,8 @@ RamDiskInitBlockIo ( EFI_STATUS
EFIAPI
RamDiskBlkIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -248,11 +248,11 @@ RamDiskBlkIoReset ( EFI_STATUS
EFIAPI
RamDiskBlkIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
/**
@@ -283,11 +283,11 @@ RamDiskBlkIoReadBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
/**
@@ -304,7 +304,7 @@ RamDiskBlkIoWriteBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
);
/**
@@ -321,8 +321,8 @@ RamDiskBlkIoFlushBlocks ( EFI_STATUS
EFIAPI
RamDiskBlkIo2Reset (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -361,12 +361,12 @@ RamDiskBlkIo2Reset ( EFI_STATUS
EFIAPI
RamDiskBlkIo2ReadBlocksEx (
- 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
+ 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
);
/**
@@ -404,12 +404,12 @@ RamDiskBlkIo2ReadBlocksEx ( EFI_STATUS
EFIAPI
RamDiskBlkIo2WriteBlocksEx (
- 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
+ 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
);
/**
@@ -434,8 +434,8 @@ RamDiskBlkIo2WriteBlocksEx ( EFI_STATUS
EFIAPI
RamDiskBlkIo2FlushBlocksEx (
- IN EFI_BLOCK_IO2_PROTOCOL *This,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+ IN EFI_BLOCK_IO2_PROTOCOL *This,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
/**
@@ -451,7 +451,7 @@ RamDiskBlkIo2FlushBlocksEx ( **/
EFI_STATUS
InstallRamDiskConfigForm (
- IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
+ IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
);
/**
@@ -463,7 +463,7 @@ InstallRamDiskConfigForm ( **/
VOID
UninstallRamDiskConfigForm (
- IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
+ IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
);
/**
@@ -505,10 +505,10 @@ UnregisterAllRamDisks ( EFI_STATUS
EFIAPI
RamDiskExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
);
/**
@@ -532,9 +532,9 @@ RamDiskExtractConfig ( EFI_STATUS
EFIAPI
RamDiskRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
);
/**
@@ -562,15 +562,14 @@ RamDiskRouteConfig ( EFI_STATUS
EFIAPI
RamDiskCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
-
/**
This function gets the file information from an open file descriptor,
and stores it in a buffer allocated from pool.
@@ -582,10 +581,9 @@ RamDiskCallback ( **/
EFI_FILE_INFO *
FileInfo (
- IN EFI_FILE_HANDLE FHand
+ IN EFI_FILE_HANDLE FHand
);
-
/**
Publish the RAM disk NVDIMM Firmware Interface Table (NFIT) to the ACPI
table.
@@ -598,7 +596,7 @@ FileInfo ( **/
EFI_STATUS
RamDiskPublishNfit (
- IN RAM_DISK_PRIVATE_DATA *PrivateData
+ IN RAM_DISK_PRIVATE_DATA *PrivateData
);
#endif
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h index 3293ec1d5b..71935f0152 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h @@ -13,12 +13,12 @@ #include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/RamDiskHii.h>
-#define MAIN_FORM_ID 0x1000
-#define MAIN_GOTO_FILE_EXPLORER_ID 0x1001
-#define MAIN_REMOVE_RD_QUESTION_ID 0x1002
-#define MAIN_LABEL_LIST_START 0x1003
-#define MAIN_LABEL_LIST_END 0x1004
-#define MAIN_CHECKBOX_QUESTION_ID_START 0x1100
+#define MAIN_FORM_ID 0x1000
+#define MAIN_GOTO_FILE_EXPLORER_ID 0x1001
+#define MAIN_REMOVE_RD_QUESTION_ID 0x1002
+#define MAIN_LABEL_LIST_START 0x1003
+#define MAIN_LABEL_LIST_END 0x1004
+#define MAIN_CHECKBOX_QUESTION_ID_START 0x1100
#define CREATE_RAW_RAM_DISK_FORM_ID 0x2000
#define CREATE_RAW_SIZE_QUESTION_ID 0x2001
@@ -26,19 +26,19 @@ #define CREATE_RAW_DISCARD_QUESTION_ID 0x2003
#define CREATE_RAW_MEMORY_TYPE_QUESTION_ID 0x2004
-#define RAM_DISK_BOOT_SERVICE_DATA_MEMORY 0x00
-#define RAM_DISK_RESERVED_MEMORY 0x01
-#define RAM_DISK_MEMORY_TYPE_MAX 0x02
+#define RAM_DISK_BOOT_SERVICE_DATA_MEMORY 0x00
+#define RAM_DISK_RESERVED_MEMORY 0x01
+#define RAM_DISK_MEMORY_TYPE_MAX 0x02
typedef struct {
//
// The size of the RAM disk to be created.
//
- UINT64 Size;
+ UINT64 Size;
//
// Selected RAM Disk Memory Type
//
- UINT8 MemType;
+ UINT8 MemType;
} RAM_DISK_CONFIGURATION;
#endif
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c index 329de17ff9..780cf0a016 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c @@ -10,7 +10,7 @@ #include "RamDiskImpl.h"
-RAM_DISK_PRIVATE_DATA mRamDiskPrivateDataTemplate = {
+RAM_DISK_PRIVATE_DATA mRamDiskPrivateDataTemplate = {
RAM_DISK_PRIVATE_DATA_SIGNATURE,
NULL
};
@@ -20,8 +20,8 @@ MEDIA_RAM_DISK_DEVICE_PATH mRamDiskDeviceNodeTemplate = { MEDIA_DEVICE_PATH,
MEDIA_RAM_DISK_DP,
{
- (UINT8) (sizeof (MEDIA_RAM_DISK_DEVICE_PATH)),
- (UINT8) ((sizeof (MEDIA_RAM_DISK_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (MEDIA_RAM_DISK_DEVICE_PATH)),
+ (UINT8)((sizeof (MEDIA_RAM_DISK_DEVICE_PATH)) >> 8)
}
}
};
@@ -29,7 +29,6 @@ MEDIA_RAM_DISK_DEVICE_PATH mRamDiskDeviceNodeTemplate = { BOOLEAN mRamDiskSsdtTableKeyValid = FALSE;
UINTN mRamDiskSsdtTableKey;
-
/**
Initialize the RAM disk device node.
@@ -39,23 +38,22 @@ UINTN mRamDiskSsdtTableKey; **/
VOID
RamDiskInitDeviceNode (
- IN RAM_DISK_PRIVATE_DATA *PrivateData,
- IN OUT MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode
+ IN RAM_DISK_PRIVATE_DATA *PrivateData,
+ IN OUT MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode
)
{
WriteUnaligned64 (
- (UINT64 *) &(RamDiskDevNode->StartingAddr[0]),
- (UINT64) PrivateData->StartingAddr
+ (UINT64 *)&(RamDiskDevNode->StartingAddr[0]),
+ (UINT64)PrivateData->StartingAddr
);
WriteUnaligned64 (
- (UINT64 *) &(RamDiskDevNode->EndingAddr[0]),
- (UINT64) PrivateData->StartingAddr + PrivateData->Size - 1
+ (UINT64 *)&(RamDiskDevNode->EndingAddr[0]),
+ (UINT64)PrivateData->StartingAddr + PrivateData->Size - 1
);
CopyGuid (&RamDiskDevNode->TypeGuid, &PrivateData->TypeGuid);
RamDiskDevNode->Instance = PrivateData->InstanceNumber;
}
-
/**
Initialize and publish NVDIMM root device SSDT in ACPI table.
@@ -68,10 +66,10 @@ RamDiskPublishSsdt ( VOID
)
{
- EFI_STATUS Status;
- EFI_ACPI_DESCRIPTION_HEADER *Table;
- UINTN SectionInstance;
- UINTN TableSize;
+ EFI_STATUS Status;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
+ UINTN SectionInstance;
+ UINTN TableSize;
Status = EFI_SUCCESS;
SectionInstance = 0;
@@ -85,7 +83,7 @@ RamDiskPublishSsdt ( &gEfiCallerIdGuid,
EFI_SECTION_RAW,
SectionInstance,
- (VOID **) &Table,
+ (VOID **)&Table,
&TableSize
);
if (EFI_ERROR (Status)) {
@@ -116,7 +114,6 @@ RamDiskPublishSsdt ( return Status;
}
-
/**
Publish the RAM disk NVDIMM Firmware Interface Table (NFIT) to the ACPI
table.
@@ -129,29 +126,29 @@ RamDiskPublishSsdt ( **/
EFI_STATUS
RamDiskPublishNfit (
- IN RAM_DISK_PRIVATE_DATA *PrivateData
+ IN RAM_DISK_PRIVATE_DATA *PrivateData
)
{
- EFI_STATUS Status;
- EFI_MEMORY_DESCRIPTOR *MemoryMap;
- EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
- EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
- UINTN TableIndex;
- VOID *TableHeader;
- EFI_ACPI_TABLE_VERSION TableVersion;
- UINTN TableKey;
- EFI_ACPI_DESCRIPTION_HEADER *NfitHeader;
+ EFI_STATUS Status;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
+ UINTN TableIndex;
+ VOID *TableHeader;
+ EFI_ACPI_TABLE_VERSION TableVersion;
+ UINTN TableKey;
+ EFI_ACPI_DESCRIPTION_HEADER *NfitHeader;
EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE
- *SpaRange;
- VOID *Nfit;
- UINT32 NfitLen;
- UINTN MemoryMapSize;
- UINTN MapKey;
- UINTN DescriptorSize;
- UINT32 DescriptorVersion;
- UINT64 CurrentData;
- UINT8 Checksum;
- BOOLEAN MemoryFound;
+ *SpaRange;
+ VOID *Nfit;
+ UINT32 NfitLen;
+ UINTN MemoryMapSize;
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINT64 CurrentData;
+ UINT8 Checksum;
+ BOOLEAN MemoryFound;
//
// Get the EFI memory map.
@@ -169,7 +166,7 @@ RamDiskPublishNfit ( );
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
do {
- MemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (MemoryMapSize);
+ MemoryMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool (MemoryMapSize);
ASSERT (MemoryMap != NULL);
Status = gBS->GetMemoryMap (
&MemoryMapSize,
@@ -182,16 +179,18 @@ RamDiskPublishNfit ( FreePool (MemoryMap);
}
} while (Status == EFI_BUFFER_TOO_SMALL);
+
ASSERT_EFI_ERROR (Status);
MemoryMapEntry = MemoryMap;
- MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
- while ((UINTN) MemoryMapEntry < (UINTN) MemoryMapEnd) {
+ MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + MemoryMapSize);
+ while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
if ((MemoryMapEntry->Type == EfiReservedMemoryType) &&
(MemoryMapEntry->PhysicalStart <= PrivateData->StartingAddr) &&
(MemoryMapEntry->PhysicalStart +
MultU64x32 (MemoryMapEntry->NumberOfPages, EFI_PAGE_SIZE)
- >= PrivateData->StartingAddr + PrivateData->Size)) {
+ >= PrivateData->StartingAddr + PrivateData->Size))
+ {
MemoryFound = TRUE;
DEBUG ((
DEBUG_INFO,
@@ -199,8 +198,10 @@ RamDiskPublishNfit ( ));
break;
}
+
MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
}
+
FreePool (MemoryMap);
if (!MemoryFound) {
@@ -226,7 +227,8 @@ RamDiskPublishNfit ( TableIndex++;
if (((EFI_ACPI_SDT_HEADER *)TableHeader)->Signature ==
- EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE_STRUCTURE_SIGNATURE) {
+ EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE_STRUCTURE_SIGNATURE)
+ {
break;
}
}
@@ -247,6 +249,7 @@ RamDiskPublishNfit ( if (Nfit == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (Nfit, TableHeader, NfitHeader->Length);
//
@@ -272,13 +275,13 @@ RamDiskPublishNfit ( // Append the System Physical Address (SPA) Range Structure at the end
// of the origin NFIT.
//
- SpaRange = (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE *)
- ((UINT8 *)Nfit + NfitHeader->Length);
+ SpaRange = (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE *)
+ ((UINT8 *)Nfit + NfitHeader->Length);
//
// Update the length field of the NFIT
//
- NfitHeader->Length = NfitLen;
+ NfitHeader->Length = NfitLen;
//
// The checksum will be updated after the new contents are appended.
@@ -306,7 +309,7 @@ RamDiskPublishNfit ( NfitLen = sizeof (EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE) +
sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE);
- Nfit = AllocateZeroPool (NfitLen);
+ Nfit = AllocateZeroPool (NfitLen);
if (Nfit == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -330,13 +333,13 @@ RamDiskPublishNfit ( //
// Fill in the content of the SPA Range Structure.
//
- SpaRange->Type = EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE_TYPE;
- SpaRange->Length = sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE);
+ SpaRange->Type = EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE_TYPE;
+ SpaRange->Length = sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE);
SpaRange->SystemPhysicalAddressRangeBase = PrivateData->StartingAddr;
SpaRange->SystemPhysicalAddressRangeLength = PrivateData->Size;
CopyGuid (&SpaRange->AddressRangeTypeGUID, &PrivateData->TypeGuid);
- Checksum = CalculateCheckSum8((UINT8 *)Nfit, NfitHeader->Length);
+ Checksum = CalculateCheckSum8 ((UINT8 *)Nfit, NfitHeader->Length);
NfitHeader->Checksum = Checksum;
//
@@ -363,7 +366,6 @@ RamDiskPublishNfit ( return EFI_SUCCESS;
}
-
/**
Unpublish the RAM disk NVDIMM Firmware Interface Table (NFIT) from the
ACPI table.
@@ -376,23 +378,23 @@ RamDiskPublishNfit ( **/
EFI_STATUS
RamDiskUnpublishNfit (
- IN RAM_DISK_PRIVATE_DATA *PrivateData
+ IN RAM_DISK_PRIVATE_DATA *PrivateData
)
{
- EFI_STATUS Status;
- UINTN TableIndex;
- VOID *TableHeader;
- EFI_ACPI_TABLE_VERSION TableVersion;
- UINTN TableKey;
- EFI_ACPI_DESCRIPTION_HEADER *NewNfitHeader;
+ EFI_STATUS Status;
+ UINTN TableIndex;
+ VOID *TableHeader;
+ EFI_ACPI_TABLE_VERSION TableVersion;
+ UINTN TableKey;
+ EFI_ACPI_DESCRIPTION_HEADER *NewNfitHeader;
EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE
- *SpaRange;
- VOID *NewNfit;
- VOID *NewNfitPtr;
- EFI_ACPI_6_1_NFIT_STRUCTURE_HEADER *NfitStructHeader;
- UINT32 NewNfitLen;
- UINT32 RemainLen;
- UINT8 Checksum;
+ *SpaRange;
+ VOID *NewNfit;
+ VOID *NewNfitPtr;
+ EFI_ACPI_6_1_NFIT_STRUCTURE_HEADER *NfitStructHeader;
+ UINT32 NewNfitLen;
+ UINT32 RemainLen;
+ UINT8 Checksum;
//
// Find the NFIT in the ACPI table.
@@ -413,7 +415,8 @@ RamDiskUnpublishNfit ( TableIndex++;
if (((EFI_ACPI_SDT_HEADER *)TableHeader)->Signature ==
- EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE_STRUCTURE_SIGNATURE) {
+ EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE_STRUCTURE_SIGNATURE)
+ {
break;
}
}
@@ -426,8 +429,8 @@ RamDiskUnpublishNfit ( return EFI_NOT_FOUND;
}
- NewNfitLen = ((EFI_ACPI_DESCRIPTION_HEADER *)TableHeader)->Length -
- sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE);
+ NewNfitLen = ((EFI_ACPI_DESCRIPTION_HEADER *)TableHeader)->Length -
+ sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE);
//
// After removing this RAM disk from the NFIT, if no other structure is in
@@ -488,12 +491,14 @@ RamDiskUnpublishNfit ( ((UINT8 *)TableHeader + sizeof (EFI_ACPI_6_1_NVDIMM_FIRMWARE_INTERFACE_TABLE));
while (RemainLen > 0) {
if ((NfitStructHeader->Type == EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE_TYPE) &&
- (NfitStructHeader->Length == sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE))) {
+ (NfitStructHeader->Length == sizeof (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE)))
+ {
SpaRange = (EFI_ACPI_6_1_NFIT_SYSTEM_PHYSICAL_ADDRESS_RANGE_STRUCTURE *)NfitStructHeader;
if ((SpaRange->SystemPhysicalAddressRangeBase == PrivateData->StartingAddr) &&
(SpaRange->SystemPhysicalAddressRangeLength == PrivateData->Size) &&
- (CompareGuid (&SpaRange->AddressRangeTypeGUID, &PrivateData->TypeGuid))) {
+ (CompareGuid (&SpaRange->AddressRangeTypeGUID, &PrivateData->TypeGuid)))
+ {
//
// Skip the SPA Range Structure for the RAM disk to be unpublished
// from NFIT.
@@ -518,7 +523,7 @@ RamDiskUnpublishNfit ( ((UINT8 *)NfitStructHeader + NfitStructHeader->Length);
}
- Checksum = CalculateCheckSum8((UINT8 *)NewNfit, NewNfitHeader->Length);
+ Checksum = CalculateCheckSum8 ((UINT8 *)NewNfit, NewNfitHeader->Length);
NewNfitHeader->Checksum = Checksum;
Status = mAcpiTableProtocol->UninstallAcpiTable (
@@ -553,7 +558,6 @@ RamDiskUnpublishNfit ( return EFI_SUCCESS;
}
-
/**
Register a RAM disk with specified address, size and type.
@@ -587,19 +591,19 @@ RamDiskUnpublishNfit ( EFI_STATUS
EFIAPI
RamDiskRegister (
- IN UINT64 RamDiskBase,
- IN UINT64 RamDiskSize,
- IN EFI_GUID *RamDiskType,
- IN EFI_DEVICE_PATH *ParentDevicePath OPTIONAL,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN UINT64 RamDiskBase,
+ IN UINT64 RamDiskSize,
+ IN EFI_GUID *RamDiskType,
+ IN EFI_DEVICE_PATH *ParentDevicePath OPTIONAL,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- EFI_STATUS Status;
- RAM_DISK_PRIVATE_DATA *PrivateData;
- RAM_DISK_PRIVATE_DATA *RegisteredPrivateData;
- MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode;
- UINTN DevicePathSize;
- LIST_ENTRY *Entry;
+ EFI_STATUS Status;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
+ RAM_DISK_PRIVATE_DATA *RegisteredPrivateData;
+ MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode;
+ UINTN DevicePathSize;
+ LIST_ENTRY *Entry;
if ((0 == RamDiskSize) || (NULL == RamDiskType) || (NULL == DevicePath)) {
return EFI_INVALID_PARAMETER;
@@ -609,7 +613,8 @@ RamDiskRegister ( // Add check to prevent data read across the memory boundary
//
if ((RamDiskSize > MAX_UINTN) ||
- (RamDiskBase > MAX_UINTN - RamDiskSize + 1)) {
+ (RamDiskBase > MAX_UINTN - RamDiskSize + 1))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -647,7 +652,7 @@ RamDiskRegister ( *DevicePath = AppendDevicePathNode (
ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) RamDiskDevNode
+ (EFI_DEVICE_PATH_PROTOCOL *)RamDiskDevNode
);
if (NULL == *DevicePath) {
Status = EFI_OUT_OF_RESOURCES;
@@ -660,7 +665,7 @@ RamDiskRegister ( // Check whether the created device path is already present in the handle
// database
//
- if (!IsListEmpty(&RegisteredRamDisks)) {
+ if (!IsListEmpty (&RegisteredRamDisks)) {
DevicePathSize = GetDevicePathSize (PrivateData->DevicePath);
BASE_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
@@ -672,7 +677,9 @@ RamDiskRegister ( if ((CompareMem (
PrivateData->DevicePath,
RegisteredPrivateData->DevicePath,
- DevicePathSize)) == 0) {
+ DevicePathSize
+ )) == 0)
+ {
*DevicePath = NULL;
Status = EFI_ALREADY_STARTED;
goto ErrorExit;
@@ -735,7 +742,6 @@ ErrorExit: return Status;
}
-
/**
Unregister a RAM disk specified by DevicePath.
@@ -754,17 +760,17 @@ ErrorExit: EFI_STATUS
EFIAPI
RamDiskUnregister (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- BOOLEAN Found;
- UINT64 StartingAddr;
- UINT64 EndingAddr;
- EFI_DEVICE_PATH_PROTOCOL *Header;
- MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode;
- RAM_DISK_PRIVATE_DATA *PrivateData;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
+ BOOLEAN Found;
+ UINT64 StartingAddr;
+ UINT64 EndingAddr;
+ EFI_DEVICE_PATH_PROTOCOL *Header;
+ MEDIA_RAM_DISK_DEVICE_PATH *RamDiskDevNode;
+ RAM_DISK_PRIVATE_DATA *PrivateData;
if (NULL == DevicePath) {
return EFI_INVALID_PARAMETER;
@@ -780,8 +786,9 @@ RamDiskUnregister ( // Test if the current device node is a RAM disk.
//
if ((MEDIA_DEVICE_PATH == Header->Type) &&
- (MEDIA_RAM_DISK_DP == Header->SubType)) {
- RamDiskDevNode = (MEDIA_RAM_DISK_DEVICE_PATH *) Header;
+ (MEDIA_RAM_DISK_DP == Header->SubType))
+ {
+ RamDiskDevNode = (MEDIA_RAM_DISK_DEVICE_PATH *)Header;
break;
}
@@ -793,11 +800,11 @@ RamDiskUnregister ( return EFI_UNSUPPORTED;
}
- Found = FALSE;
- StartingAddr = ReadUnaligned64 ((UINT64 *) &(RamDiskDevNode->StartingAddr[0]));
- EndingAddr = ReadUnaligned64 ((UINT64 *) &(RamDiskDevNode->EndingAddr[0]));
+ Found = FALSE;
+ StartingAddr = ReadUnaligned64 ((UINT64 *)&(RamDiskDevNode->StartingAddr[0]));
+ EndingAddr = ReadUnaligned64 ((UINT64 *)&(RamDiskDevNode->EndingAddr[0]));
- if (!IsListEmpty(&RegisteredRamDisks)) {
+ if (!IsListEmpty (&RegisteredRamDisks)) {
BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
@@ -807,7 +814,8 @@ RamDiskUnregister ( //
if ((StartingAddr == PrivateData->StartingAddr) &&
(EndingAddr == PrivateData->StartingAddr + PrivateData->Size - 1) &&
- (CompareGuid (&RamDiskDevNode->TypeGuid, &PrivateData->TypeGuid))) {
+ (CompareGuid (&RamDiskDevNode->TypeGuid, &PrivateData->TypeGuid)))
+ {
//
// Remove the content for this RAM disk in NFIT.
//
@@ -825,7 +833,7 @@ RamDiskUnregister ( &gEfiBlockIo2ProtocolGuid,
&PrivateData->BlockIo2,
&gEfiDevicePathProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL *) PrivateData->DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)PrivateData->DevicePath,
NULL
);
@@ -837,7 +845,7 @@ RamDiskUnregister ( // driver is responsible for freeing the allocated memory for the
// RAM disk.
//
- FreePool ((VOID *)(UINTN) PrivateData->StartingAddr);
+ FreePool ((VOID *)(UINTN)PrivateData->StartingAddr);
}
FreePool (PrivateData->DevicePath);
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c b/MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c index abbd4f7684..89d3eaf341 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/ComponentName.c @@ -20,9 +20,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUdfComponentName = { //
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UdfComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UdfComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UdfComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UdfComponentNameGetControllerName,
"en"
};
@@ -30,7 +30,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUdfComponentName2 = // Driver name table for Udf module.
// It is shared by the implementation of ComponentName & ComponentName2 Protocol.
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdfDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUdfDriverNameTable[] = {
{
"eng;en",
L"UDF File System Driver"
@@ -89,12 +89,12 @@ UdfComponentNameGetDriverName ( )
{
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mUdfDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gUdfComponentName)
- );
+ Language,
+ This->SupportedLanguages,
+ mUdfDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gUdfComponentName)
+ );
}
/**
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c index 4ad7bb93da..6cd197046f 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c @@ -9,7 +9,7 @@ #include "Udf.h"
-EFI_FILE_PROTOCOL gUdfFileIoOps = {
+EFI_FILE_PROTOCOL gUdfFileIoOps = {
EFI_FILE_PROTOCOL_REVISION,
UdfOpen,
UdfClose,
@@ -27,10 +27,10 @@ EFI_FILE_PROTOCOL gUdfFileIoOps = { NULL
};
-#define _ROOT_FILE(_PrivData) (_PrivData)->Root
+#define _ROOT_FILE(_PrivData) (_PrivData)->Root
#define _PARENT_FILE(_PrivData) \
((_PrivData)->IsRootDirectory ? (_PrivData)->Root : &(_PrivData)->File)
-#define _FILE(_PrivData) _PARENT_FILE(_PrivData)
+#define _FILE(_PrivData) _PARENT_FILE(_PrivData)
/**
Open the root directory on a volume.
@@ -62,7 +62,7 @@ UdfOpenVolume ( OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- if (This == NULL || Root == NULL) {
+ if ((This == NULL) || (Root == NULL)) {
Status = EFI_INVALID_PARAMETER;
goto Error_Invalid_Params;
}
@@ -75,10 +75,10 @@ UdfOpenVolume ( // cleaned up on the last UdfClose() call.
//
Status = ReadUdfVolumeInformation (
- PrivFsData->BlockIo,
- PrivFsData->DiskIo,
- &PrivFsData->Volume
- );
+ PrivFsData->BlockIo,
+ PrivFsData->DiskIo,
+ &PrivFsData->Volume
+ );
if (EFI_ERROR (Status)) {
goto Error_Read_Udf_Volume;
}
@@ -90,29 +90,32 @@ UdfOpenVolume ( // Find root directory file.
//
Status = FindRootDirectory (
- PrivFsData->BlockIo,
- PrivFsData->DiskIo,
- &PrivFsData->Volume,
- &PrivFsData->Root
- );
+ PrivFsData->BlockIo,
+ PrivFsData->DiskIo,
+ &PrivFsData->Volume,
+ &PrivFsData->Root
+ );
if (EFI_ERROR (Status)) {
goto Error_Find_Root_Dir;
}
PrivFileData =
- (PRIVATE_UDF_FILE_DATA *) AllocateZeroPool (sizeof (PRIVATE_UDF_FILE_DATA));
+ (PRIVATE_UDF_FILE_DATA *)AllocateZeroPool (sizeof (PRIVATE_UDF_FILE_DATA));
if (PrivFileData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error_Alloc_Priv_File_Data;
}
- PrivFileData->Signature = PRIVATE_UDF_FILE_DATA_SIGNATURE;
- PrivFileData->SimpleFs = This;
- PrivFileData->Root = &PrivFsData->Root;
- PrivFileData->IsRootDirectory = TRUE;
+ PrivFileData->Signature = PRIVATE_UDF_FILE_DATA_SIGNATURE;
+ PrivFileData->SimpleFs = This;
+ PrivFileData->Root = &PrivFsData->Root;
+ PrivFileData->IsRootDirectory = TRUE;
- CopyMem ((VOID *)&PrivFileData->FileIo, (VOID *)&gUdfFileIoOps,
- sizeof (EFI_FILE_PROTOCOL));
+ CopyMem (
+ (VOID *)&PrivFileData->FileIo,
+ (VOID *)&gUdfFileIoOps,
+ sizeof (EFI_FILE_PROTOCOL)
+ );
*Root = &PrivFileData->FileIo;
@@ -178,7 +181,7 @@ UdfOpen ( ZeroMem (FilePath, sizeof FilePath);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- if (This == NULL || NewHandle == NULL || FileName == NULL) {
+ if ((This == NULL) || (NewHandle == NULL) || (FileName == NULL)) {
Status = EFI_INVALID_PARAMETER;
goto Error_Invalid_Params;
}
@@ -210,15 +213,15 @@ UdfOpen ( }
Status = FindFile (
- PrivFsData->BlockIo,
- PrivFsData->DiskIo,
- &PrivFsData->Volume,
- FilePath,
- _ROOT_FILE (PrivFileData),
- _PARENT_FILE (PrivFileData),
- &_PARENT_FILE(PrivFileData)->FileIdentifierDesc->Icb,
- &File
- );
+ PrivFsData->BlockIo,
+ PrivFsData->DiskIo,
+ &PrivFsData->Volume,
+ FilePath,
+ _ROOT_FILE (PrivFileData),
+ _PARENT_FILE (PrivFileData),
+ &_PARENT_FILE (PrivFileData)->FileIdentifierDesc->Icb,
+ &File
+ );
if (EFI_ERROR (Status)) {
goto Error_Find_File;
}
@@ -230,8 +233,11 @@ UdfOpen ( goto Error_Alloc_New_Priv_File_Data;
}
- CopyMem ((VOID *)NewPrivFileData, (VOID *)PrivFileData,
- sizeof (PRIVATE_UDF_FILE_DATA));
+ CopyMem (
+ (VOID *)NewPrivFileData,
+ (VOID *)PrivFileData,
+ sizeof (PRIVATE_UDF_FILE_DATA)
+ );
CopyMem ((VOID *)&NewPrivFileData->File, &File, sizeof (UDF_FILE_INFO));
NewPrivFileData->IsRootDirectory = FALSE;
@@ -246,24 +252,27 @@ UdfOpen ( StrCpyS (NewPrivFileData->FileName, UDF_FILENAME_LENGTH, FileName);
Status = GetFileSize (
- PrivFsData->BlockIo,
- PrivFsData->DiskIo,
- &PrivFsData->Volume,
- &NewPrivFileData->File,
- &NewPrivFileData->FileSize
- );
+ PrivFsData->BlockIo,
+ PrivFsData->DiskIo,
+ &PrivFsData->Volume,
+ &NewPrivFileData->File,
+ &NewPrivFileData->FileSize
+ );
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: GetFileSize() fails with status - %r.\n",
- __FUNCTION__, Status
+ __FUNCTION__,
+ Status
));
goto Error_Get_File_Size;
}
NewPrivFileData->FilePosition = 0;
- ZeroMem ((VOID *)&NewPrivFileData->ReadDirInfo,
- sizeof (UDF_READ_DIRECTORY_INFO));
+ ZeroMem (
+ (VOID *)&NewPrivFileData->ReadDirInfo,
+ sizeof (UDF_READ_DIRECTORY_INFO)
+ );
*NewHandle = &NewPrivFileData->FileIo;
@@ -330,21 +339,22 @@ UdfRead ( ZeroMem (FileName, sizeof FileName);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- if (This == NULL || BufferSize == NULL || (*BufferSize != 0 &&
- Buffer == NULL)) {
+ if ((This == NULL) || (BufferSize == NULL) || ((*BufferSize != 0) &&
+ (Buffer == NULL)))
+ {
Status = EFI_INVALID_PARAMETER;
goto Error_Invalid_Params;
}
PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
- PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (PrivFileData->SimpleFs);
+ PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (PrivFileData->SimpleFs);
- BlockIo = PrivFsData->BlockIo;
- DiskIo = PrivFsData->DiskIo;
- Volume = &PrivFsData->Volume;
- ReadDirInfo = &PrivFileData->ReadDirInfo;
- NewFileIdentifierDesc = NULL;
- NewFileEntryData = NULL;
+ BlockIo = PrivFsData->BlockIo;
+ DiskIo = PrivFsData->DiskIo;
+ Volume = &PrivFsData->Volume;
+ ReadDirInfo = &PrivFileData->ReadDirInfo;
+ NewFileIdentifierDesc = NULL;
+ NewFileEntryData = NULL;
Parent = _PARENT_FILE (PrivFileData);
@@ -361,52 +371,53 @@ UdfRead ( if (PrivFileData->FilePosition == PrivFileData->FileSize) {
*BufferSize = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Done;
}
BufferSizeUint64 = *BufferSize;
Status = ReadFileData (
- BlockIo,
- DiskIo,
- Volume,
- Parent,
- PrivFileData->FileSize,
- &PrivFileData->FilePosition,
- Buffer,
- &BufferSizeUint64
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ Parent,
+ PrivFileData->FileSize,
+ &PrivFileData->FilePosition,
+ Buffer,
+ &BufferSizeUint64
+ );
ASSERT (BufferSizeUint64 <= MAX_UINTN);
*BufferSize = (UINTN)BufferSizeUint64;
} else if (IS_FID_DIRECTORY_FILE (Parent->FileIdentifierDesc)) {
- if (ReadDirInfo->FidOffset == 0 && PrivFileData->FilePosition > 0) {
- Status = EFI_DEVICE_ERROR;
+ if ((ReadDirInfo->FidOffset == 0) && (PrivFileData->FilePosition > 0)) {
+ Status = EFI_DEVICE_ERROR;
*BufferSize = 0;
goto Done;
}
- for (;;) {
+ for ( ; ;) {
Status = ReadDirectoryEntry (
- BlockIo,
- DiskIo,
- Volume,
- &Parent->FileIdentifierDesc->Icb,
- Parent->FileEntry,
- ReadDirInfo,
- &NewFileIdentifierDesc
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &Parent->FileIdentifierDesc->Icb,
+ Parent->FileEntry,
+ ReadDirInfo,
+ &NewFileIdentifierDesc
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
FreePool (ReadDirInfo->DirectoryData);
ZeroMem ((VOID *)ReadDirInfo, sizeof (UDF_READ_DIRECTORY_INFO));
*BufferSize = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
goto Done;
}
+
//
// After calling function ReadDirectoryEntry(), if 'NewFileIdentifierDesc'
// is NULL, then the 'Status' must be EFI_OUT_OF_RESOURCES. Hence, if the
@@ -425,26 +436,27 @@ UdfRead ( }
Status = FindFileEntry (
- BlockIo,
- DiskIo,
- Volume,
- &NewFileIdentifierDesc->Icb,
- &NewFileEntryData
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &NewFileIdentifierDesc->Icb,
+ &NewFileEntryData
+ );
if (EFI_ERROR (Status)) {
goto Error_Find_Fe;
}
+
ASSERT (NewFileEntryData != NULL);
if (FE_ICB_FILE_TYPE (NewFileEntryData) == UdfFileEntrySymlink) {
Status = ResolveSymlink (
- BlockIo,
- DiskIo,
- Volume,
- Parent,
- NewFileEntryData,
- &FoundFile
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ Parent,
+ NewFileEntryData,
+ &FoundFile
+ );
if (EFI_ERROR (Status)) {
goto Error_Resolve_Symlink;
}
@@ -461,8 +473,8 @@ UdfRead ( FreePool ((VOID *)NewFileIdentifierDesc);
NewFileIdentifierDesc = FoundFile.FileIdentifierDesc;
} else {
- FoundFile.FileIdentifierDesc = NewFileIdentifierDesc;
- FoundFile.FileEntry = NewFileEntryData;
+ FoundFile.FileIdentifierDesc = NewFileIdentifierDesc;
+ FoundFile.FileEntry = NewFileEntryData;
Status = GetFileNameFromFid (FoundFile.FileIdentifierDesc, ARRAY_SIZE (FileName), FileName);
if (EFI_ERROR (Status)) {
@@ -471,23 +483,23 @@ UdfRead ( }
Status = GetFileSize (
- BlockIo,
- DiskIo,
- Volume,
- &FoundFile,
- &FileSize
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &FoundFile,
+ &FileSize
+ );
if (EFI_ERROR (Status)) {
goto Error_Get_File_Size;
}
Status = SetFileInfo (
- &FoundFile,
- FileSize,
- FileName,
- BufferSize,
- Buffer
- );
+ &FoundFile,
+ FileSize,
+ FileName,
+ BufferSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
goto Error_Set_File_Info;
}
@@ -534,12 +546,12 @@ Error_Invalid_Params: EFI_STATUS
EFIAPI
UdfClose (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- PRIVATE_UDF_FILE_DATA *PrivFileData;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ PRIVATE_UDF_FILE_DATA *PrivFileData;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -584,7 +596,7 @@ UdfDelete ( IN EFI_FILE_PROTOCOL *This
)
{
- PRIVATE_UDF_FILE_DATA *PrivFileData;
+ PRIVATE_UDF_FILE_DATA *PrivFileData;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -592,7 +604,7 @@ UdfDelete ( PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
- (VOID)PrivFileData->FileIo.Close(This);
+ (VOID)PrivFileData->FileIo.Close (This);
return EFI_WARN_DELETE_FAILURE;
}
@@ -644,9 +656,9 @@ UdfGetPosition ( OUT UINT64 *Position
)
{
- PRIVATE_UDF_FILE_DATA *PrivFileData;
+ PRIVATE_UDF_FILE_DATA *PrivFileData;
- if (This == NULL || Position == NULL) {
+ if ((This == NULL) || (Position == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -657,7 +669,7 @@ UdfGetPosition ( // position has no meaning and the operation is not supported.
//
if (IS_FID_DIRECTORY_FILE (PrivFileData->File.FileIdentifierDesc)) {
- return EFI_UNSUPPORTED;
+ return EFI_UNSUPPORTED;
}
//
@@ -706,9 +718,9 @@ UdfSetPosition ( // entries over.
//
if (Position == 0) {
- PrivFileData->FilePosition = Position;
+ PrivFileData->FilePosition = Position;
PrivFileData->ReadDirInfo.FidOffset = 0;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
} else if (IS_FID_NORMAL_FILE (FileIdentifierDesc)) {
//
@@ -767,8 +779,9 @@ UdfGetInfo ( UINTN FileSystemVolumeLabelLength;
CHAR16 VolumeLabel[64];
- if (This == NULL || InformationType == NULL || BufferSize == NULL ||
- (*BufferSize != 0 && Buffer == NULL)) {
+ if ((This == NULL) || (InformationType == NULL) || (BufferSize == NULL) ||
+ ((*BufferSize != 0) && (Buffer == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -780,12 +793,12 @@ UdfGetInfo ( if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
Status = SetFileInfo (
- _FILE (PrivFileData),
- PrivFileData->FileSize,
- PrivFileData->FileName,
- BufferSize,
- Buffer
- );
+ _FILE (PrivFileData),
+ PrivFileData->FileSize,
+ PrivFileData->FileName,
+ BufferSize,
+ Buffer
+ );
} else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
Status = GetVolumeLabel (&PrivFsData->Volume, ARRAY_SIZE (VolumeLabel), VolumeLabel);
if (EFI_ERROR (Status)) {
@@ -806,25 +819,25 @@ UdfGetInfo ( VolumeLabel
);
Status = GetVolumeSize (
- PrivFsData->BlockIo,
- PrivFsData->DiskIo,
- &PrivFsData->Volume,
- &VolumeSize,
- &FreeSpaceSize
- );
+ PrivFsData->BlockIo,
+ PrivFsData->DiskIo,
+ &PrivFsData->Volume,
+ &VolumeSize,
+ &FreeSpaceSize
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- FileSystemInfo->Size = FileSystemInfoLength;
- FileSystemInfo->ReadOnly = TRUE;
- FileSystemInfo->BlockSize =
+ FileSystemInfo->Size = FileSystemInfoLength;
+ FileSystemInfo->ReadOnly = TRUE;
+ FileSystemInfo->BlockSize =
PrivFsData->Volume.LogicalVolDesc.LogicalBlockSize;
- FileSystemInfo->VolumeSize = VolumeSize;
- FileSystemInfo->FreeSpace = FreeSpaceSize;
+ FileSystemInfo->VolumeSize = VolumeSize;
+ FileSystemInfo->FreeSpace = FreeSpaceSize;
*BufferSize = FileSystemInfoLength;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
} else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
Status = GetVolumeLabel (&PrivFsData->Volume, ARRAY_SIZE (VolumeLabel), VolumeLabel);
if (EFI_ERROR (Status)) {
@@ -897,7 +910,7 @@ UdfSetInfo ( EFI_STATUS
EFIAPI
UdfFlush (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
return EFI_WRITE_PROTECTED;
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c index ee236ccde2..6db34a9c8c 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c @@ -18,13 +18,12 @@ **/
CHAR16 *
TrimString (
- IN CHAR16 *String
+ IN CHAR16 *String
)
{
- CHAR16 *TempString;
+ CHAR16 *TempString;
for ( ; *String != L'\0' && *String == L' '; String++) {
- ;
}
TempString = String + StrLen (String) - 1;
@@ -47,11 +46,11 @@ TrimString ( **/
VOID
ReplaceLeft (
- IN CHAR16 *Destination,
- IN CONST CHAR16 *Source
+ IN CHAR16 *Destination,
+ IN CONST CHAR16 *Source
)
{
- CONST CHAR16 *EndString;
+ CONST CHAR16 *EndString;
EndString = Source + StrLen (Source);
while (Source <= EndString) {
@@ -70,18 +69,18 @@ ReplaceLeft ( **/
CHAR16 *
ExcludeTrailingBackslashes (
- IN CHAR16 *String
+ IN CHAR16 *String
)
{
- CHAR16 *TempString;
+ CHAR16 *TempString;
switch (*(String + 1)) {
- case L'\\':
- break;
- case L'\0':
- default:
- String++;
- goto Exit;
+ case L'\\':
+ break;
+ case L'\0':
+ default:
+ String++;
+ goto Exit;
}
TempString = String;
@@ -109,14 +108,14 @@ Exit: **/
CHAR16 *
MangleFileName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
- CHAR16 *FileNameSavedPointer;
- CHAR16 *TempFileName;
- UINTN BackslashesNo;
+ CHAR16 *FileNameSavedPointer;
+ CHAR16 *TempFileName;
+ UINTN BackslashesNo;
- if (FileName == NULL || *FileName == L'\0') {
+ if ((FileName == NULL) || (*FileName == L'\0')) {
FileName = NULL;
goto Exit;
}
@@ -149,55 +148,56 @@ MangleFileName ( FileName = ExcludeTrailingBackslashes (FileName);
} else if (*FileName == L'.') {
switch (*(FileName + 1)) {
- case L'\0':
- *FileName = L'\0';
- break;
- case L'\\':
- TempFileName = FileName + 1;
- TempFileName = ExcludeTrailingBackslashes (TempFileName);
- ReplaceLeft (FileName, TempFileName);
- break;
- case '.':
- if ((*(FileName - 1) != L'\\') && ((*(FileName + 2) != L'\\') ||
- (*(FileName + 2) != L'\0'))) {
- FileName++;
- continue;
- }
-
- BackslashesNo = 0;
- TempFileName = FileName - 1;
- while (TempFileName >= FileNameSavedPointer) {
- if (*TempFileName == L'\\') {
- if (++BackslashesNo == 2) {
- break;
- }
+ case L'\0':
+ *FileName = L'\0';
+ break;
+ case L'\\':
+ TempFileName = FileName + 1;
+ TempFileName = ExcludeTrailingBackslashes (TempFileName);
+ ReplaceLeft (FileName, TempFileName);
+ break;
+ case '.':
+ if ((*(FileName - 1) != L'\\') && ((*(FileName + 2) != L'\\') ||
+ (*(FileName + 2) != L'\0')))
+ {
+ FileName++;
+ continue;
}
- TempFileName--;
- }
+ BackslashesNo = 0;
+ TempFileName = FileName - 1;
+ while (TempFileName >= FileNameSavedPointer) {
+ if (*TempFileName == L'\\') {
+ if (++BackslashesNo == 2) {
+ break;
+ }
+ }
- TempFileName++;
+ TempFileName--;
+ }
- if ((*TempFileName == L'.') && (*(TempFileName + 1) == L'.')) {
- FileName += 2;
- } else {
- if (*(FileName + 2) != L'\0') {
- ReplaceLeft (TempFileName, FileName + 3);
- if (*(TempFileName - 1) == L'\\') {
- FileName = TempFileName;
- ExcludeTrailingBackslashes (TempFileName - 1);
- TempFileName = FileName;
- }
+ TempFileName++;
+
+ if ((*TempFileName == L'.') && (*(TempFileName + 1) == L'.')) {
+ FileName += 2;
} else {
- *TempFileName = L'\0';
- }
+ if (*(FileName + 2) != L'\0') {
+ ReplaceLeft (TempFileName, FileName + 3);
+ if (*(TempFileName - 1) == L'\\') {
+ FileName = TempFileName;
+ ExcludeTrailingBackslashes (TempFileName - 1);
+ TempFileName = FileName;
+ }
+ } else {
+ *TempFileName = L'\0';
+ }
- FileName = TempFileName;
- }
+ FileName = TempFileName;
+ }
- break;
- default:
- FileName++;
+ break;
+ default:
+ FileName++;
}
} else {
FileName++;
@@ -205,8 +205,8 @@ MangleFileName ( }
FileName = FileNameSavedPointer;
- if ((StrLen (FileName) > 1) && (FileName [StrLen (FileName) - 1] == L'\\')) {
- FileName [StrLen (FileName) - 1] = L'\0';
+ if ((StrLen (FileName) > 1) && (FileName[StrLen (FileName) - 1] == L'\\')) {
+ FileName[StrLen (FileName) - 1] = L'\0';
}
Exit:
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index e9e55cb2ba..2998c3369c 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -12,7 +12,7 @@ //
// Vendor-Defined Device Path GUID for UDF file system
//
-EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
+EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
/**
Find the anchor volume descriptor pointer.
@@ -40,8 +40,8 @@ FindAnchorVolumeDescriptorPointer ( UINTN Index;
UDF_DESCRIPTOR_TAG *DescriptorTag;
- BlockSize = BlockIo->Media->BlockSize;
- EndLBA = BlockIo->Media->LastBlock;
+ BlockSize = BlockIo->Media->BlockSize;
+ EndLBA = BlockIo->Media->LastBlock;
DescriptorLBAs[0] = 256;
DescriptorLBAs[1] = EndLBA - 256;
DescriptorLBAs[2] = EndLBA;
@@ -49,12 +49,12 @@ FindAnchorVolumeDescriptorPointer ( for (Index = 0; Index < ARRAY_SIZE (DescriptorLBAs); Index++) {
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (DescriptorLBAs[Index], BlockSize),
- sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER),
- (VOID *)AnchorPoint
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (DescriptorLBAs[Index], BlockSize),
+ sizeof (UDF_ANCHOR_VOLUME_DESCRIPTOR_POINTER),
+ (VOID *)AnchorPoint
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -68,6 +68,7 @@ FindAnchorVolumeDescriptorPointer ( return EFI_SUCCESS;
}
}
+
//
// No AVDP found.
//
@@ -98,18 +99,18 @@ StartMainVolumeDescriptorSequence ( OUT UDF_VOLUME_INFO *Volume
)
{
- EFI_STATUS Status;
- UINT32 BlockSize;
- UDF_EXTENT_AD *ExtentAd;
- EFI_LBA SeqStartBlock;
- EFI_LBA SeqEndBlock;
- BOOLEAN StopSequence;
- VOID *Buffer;
- UDF_DESCRIPTOR_TAG *DescriptorTag;
- UINT32 LogicalBlockSize;
+ EFI_STATUS Status;
+ UINT32 BlockSize;
+ UDF_EXTENT_AD *ExtentAd;
+ EFI_LBA SeqStartBlock;
+ EFI_LBA SeqEndBlock;
+ BOOLEAN StopSequence;
+ VOID *Buffer;
+ UDF_DESCRIPTOR_TAG *DescriptorTag;
+ UINT32 LogicalBlockSize;
BlockSize = BlockIo->Media->BlockSize;
- ExtentAd = &AnchorPoint->MainVolumeDescriptorSequenceExtent;
+ ExtentAd = &AnchorPoint->MainVolumeDescriptorSequenceExtent;
//
// Allocate buffer for reading disk blocks
@@ -128,20 +129,22 @@ StartMainVolumeDescriptorSequence ( // Partition driver already did.
//
SeqStartBlock = 0;
- SeqEndBlock = SeqStartBlock + DivU64x32 ((UINT64)ExtentAd->ExtentLength,
- BlockSize);
+ SeqEndBlock = SeqStartBlock + DivU64x32 (
+ (UINT64)ExtentAd->ExtentLength,
+ BlockSize
+ );
StopSequence = FALSE;
- for (; SeqStartBlock < SeqEndBlock && !StopSequence; SeqStartBlock++) {
+ for ( ; SeqStartBlock < SeqEndBlock && !StopSequence; SeqStartBlock++) {
//
// Read disk block
//
Status = BlockIo->ReadBlocks (
- BlockIo,
- BlockIo->Media->MediaId,
- SeqStartBlock,
- BlockSize,
- Buffer
- );
+ BlockIo,
+ BlockIo->Media->MediaId,
+ SeqStartBlock,
+ BlockSize,
+ Buffer
+ );
if (EFI_ERROR (Status)) {
goto Out_Free;
}
@@ -149,26 +152,26 @@ StartMainVolumeDescriptorSequence ( DescriptorTag = Buffer;
switch (DescriptorTag->TagIdentifier) {
- case UdfPartitionDescriptor:
- //
- // Save Partition Descriptor
- //
- CopyMem (&Volume->PartitionDesc, Buffer, sizeof (Volume->PartitionDesc));
- break;
+ case UdfPartitionDescriptor:
+ //
+ // Save Partition Descriptor
+ //
+ CopyMem (&Volume->PartitionDesc, Buffer, sizeof (Volume->PartitionDesc));
+ break;
- case UdfLogicalVolumeDescriptor:
- //
- // Save Logical Volume Descriptor
- //
- CopyMem (&Volume->LogicalVolDesc, Buffer, sizeof (Volume->LogicalVolDesc));
- break;
+ case UdfLogicalVolumeDescriptor:
+ //
+ // Save Logical Volume Descriptor
+ //
+ CopyMem (&Volume->LogicalVolDesc, Buffer, sizeof (Volume->LogicalVolDesc));
+ break;
- case UdfTerminatingDescriptor:
- StopSequence = TRUE;
- break;
+ case UdfTerminatingDescriptor:
+ StopSequence = TRUE;
+ break;
- default:
- ;
+ default:
+ ;
}
}
@@ -216,45 +219,46 @@ GetPdFromLongAd ( LogicalVolDesc = &Volume->LogicalVolDesc;
switch (LogicalVolDesc->DomainIdentifier.Suffix.Domain.UdfRevision) {
- case 0x0102:
- case 0x0150:
- case 0x0200:
- case 0x0201:
- case 0x0250:
- case 0x0260:
- //
- // UDF 1.02 specification:
- //
- // There shall be exactly one prevailing Logical Volume Descriptor recorded
- // per Volume Set. The Partition Maps field shall contain only Type 1
- // Partition Maps.
- //
- // UDF 1.50 through 2.60 specs say:
- //
- // For the purpose of interchange partition maps shall be limited to
- // Partition Map type 1, except type 2 maps as described in the document.
- //
- // NOTE: Only one Type 1 (Physical) Partition is supported. It has been
- // checked already in Partition driver for existence of a single Type 1
- // Partition map. Hence, the 'PartitionReferenceNumber' field (the index
- // used to access Partition Maps data within the Logical Volume Descriptor)
- // in the Long Allocation Descriptor should be 0 to indicate there is only
- // one partition.
- //
- if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) {
- return NULL;
- }
- //
- // Since only one partition, get the first one directly.
- //
- PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]);
- break;
+ case 0x0102:
+ case 0x0150:
+ case 0x0200:
+ case 0x0201:
+ case 0x0250:
+ case 0x0260:
+ //
+ // UDF 1.02 specification:
+ //
+ // There shall be exactly one prevailing Logical Volume Descriptor recorded
+ // per Volume Set. The Partition Maps field shall contain only Type 1
+ // Partition Maps.
+ //
+ // UDF 1.50 through 2.60 specs say:
+ //
+ // For the purpose of interchange partition maps shall be limited to
+ // Partition Map type 1, except type 2 maps as described in the document.
+ //
+ // NOTE: Only one Type 1 (Physical) Partition is supported. It has been
+ // checked already in Partition driver for existence of a single Type 1
+ // Partition map. Hence, the 'PartitionReferenceNumber' field (the index
+ // used to access Partition Maps data within the Logical Volume Descriptor)
+ // in the Long Allocation Descriptor should be 0 to indicate there is only
+ // one partition.
+ //
+ if (LongAd->ExtentLocation.PartitionReferenceNumber != 0) {
+ return NULL;
+ }
- default:
- //
- // Unsupported UDF revision
- //
- return NULL;
+ //
+ // Since only one partition, get the first one directly.
+ //
+ PartitionNum = *(UINT16 *)((UINTN)&LogicalVolDesc->PartitionMaps[4]);
+ break;
+
+ default:
+ //
+ // Unsupported UDF revision
+ //
+ return NULL;
}
//
@@ -287,7 +291,7 @@ GetLongAdLsn ( OUT UINT64 *Lsn
)
{
- UDF_PARTITION_DESCRIPTOR *PartitionDesc;
+ UDF_PARTITION_DESCRIPTOR *PartitionDesc;
PartitionDesc = GetPdFromLongAd (Volume, LongAd);
if (PartitionDesc == NULL) {
@@ -324,7 +328,7 @@ GetShortAdLsn ( )
{
return (UINT64)PartitionDesc->PartitionStartingLocation -
- Volume->MainVdsStartLocation + ShortAd->ExtentPosition;
+ Volume->MainVdsStartLocation + ShortAd->ExtentPosition;
}
/**
@@ -344,9 +348,9 @@ GetShortAdLsn ( **/
EFI_STATUS
FindFileSetDescriptor (
- IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
- IN EFI_DISK_IO_PROTOCOL *DiskIo,
- IN UDF_VOLUME_INFO *Volume
+ IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
+ IN EFI_DISK_IO_PROTOCOL *DiskIo,
+ IN UDF_VOLUME_INFO *Volume
)
{
EFI_STATUS Status;
@@ -355,7 +359,7 @@ FindFileSetDescriptor ( UDF_DESCRIPTOR_TAG *DescriptorTag;
LogicalVolDesc = &Volume->LogicalVolDesc;
- Status = GetLongAdLsn (Volume, &LogicalVolDesc->LogicalVolumeContentsUse, &Lsn);
+ Status = GetLongAdLsn (Volume, &LogicalVolDesc->LogicalVolumeContentsUse, &Lsn);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -369,12 +373,12 @@ FindFileSetDescriptor ( // Read disk block
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (Lsn, LogicalVolDesc->LogicalBlockSize),
- sizeof (Volume->FileSetDesc),
- &Volume->FileSetDesc
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (Lsn, LogicalVolDesc->LogicalBlockSize),
+ sizeof (Volume->FileSetDesc),
+ &Volume->FileSetDesc
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -417,10 +421,10 @@ ReadVolumeFileStructure ( // Find Anchor Volume Descriptor Pointer
//
Status = FindAnchorVolumeDescriptorPointer (
- BlockIo,
- DiskIo,
- &AnchorPoint
- );
+ BlockIo,
+ DiskIo,
+ &AnchorPoint
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -436,11 +440,11 @@ ReadVolumeFileStructure ( // Start Main Volume Descriptor Sequence.
//
Status = StartMainVolumeDescriptorSequence (
- BlockIo,
- DiskIo,
- &AnchorPoint,
- Volume
- );
+ BlockIo,
+ DiskIo,
+ &AnchorPoint,
+ Volume
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -462,10 +466,10 @@ GetFidDescriptorLength ( )
{
return (UINT64)(
- (INTN)((OFFSET_OF (UDF_FILE_IDENTIFIER_DESCRIPTOR, Data[0]) + 3 +
- FileIdentifierDesc->LengthOfFileIdentifier +
- FileIdentifierDesc->LengthOfImplementationUse) >> 2) << 2
- );
+ (INTN)((OFFSET_OF (UDF_FILE_IDENTIFIER_DESCRIPTOR, Data[0]) + 3 +
+ FileIdentifierDesc->LengthOfFileIdentifier +
+ FileIdentifierDesc->LengthOfImplementationUse) >> 2) << 2
+ );
}
/**
@@ -483,7 +487,9 @@ DuplicateFid ( {
*NewFileIdentifierDesc =
(UDF_FILE_IDENTIFIER_DESCRIPTOR *)AllocateCopyPool (
- (UINTN) GetFidDescriptorLength (FileIdentifierDesc), FileIdentifierDesc);
+ (UINTN)GetFidDescriptorLength (FileIdentifierDesc),
+ FileIdentifierDesc
+ );
}
/**
@@ -549,22 +555,24 @@ GetFileEntryData ( if (DescriptorTag->TagIdentifier == UdfExtendedFileEntry) {
ExtendedFileEntry = (UDF_EXTENDED_FILE_ENTRY *)FileEntryData;
- *Length = ExtendedFileEntry->InformationLength;
- *Data = (VOID *)((UINT8 *)ExtendedFileEntry->Data +
- ExtendedFileEntry->LengthOfExtendedAttributes);
+ *Length = ExtendedFileEntry->InformationLength;
+ *Data = (VOID *)((UINT8 *)ExtendedFileEntry->Data +
+ ExtendedFileEntry->LengthOfExtendedAttributes);
} else if (DescriptorTag->TagIdentifier == UdfFileEntry) {
FileEntry = (UDF_FILE_ENTRY *)FileEntryData;
- *Length = FileEntry->InformationLength;
- *Data = (VOID *)((UINT8 *)FileEntry->Data +
- FileEntry->LengthOfExtendedAttributes);
+ *Length = FileEntry->InformationLength;
+ *Data = (VOID *)((UINT8 *)FileEntry->Data +
+ FileEntry->LengthOfExtendedAttributes);
}
if ((*Length > FileEntrySize) ||
((UINTN)FileEntryData > (UINTN)(*Data)) ||
- ((UINTN)(*Data) - (UINTN)FileEntryData > FileEntrySize - *Length)) {
+ ((UINTN)(*Data) - (UINTN)FileEntryData > FileEntrySize - *Length))
+ {
return EFI_VOLUME_CORRUPTED;
}
+
return EFI_SUCCESS;
}
@@ -606,22 +614,24 @@ GetAdsInformation ( if (DescriptorTag->TagIdentifier == UdfExtendedFileEntry) {
ExtendedFileEntry = (UDF_EXTENDED_FILE_ENTRY *)FileEntryData;
- *Length = ExtendedFileEntry->LengthOfAllocationDescriptors;
+ *Length = ExtendedFileEntry->LengthOfAllocationDescriptors;
*AdsData = (VOID *)((UINT8 *)ExtendedFileEntry->Data +
ExtendedFileEntry->LengthOfExtendedAttributes);
} else if (DescriptorTag->TagIdentifier == UdfFileEntry) {
FileEntry = (UDF_FILE_ENTRY *)FileEntryData;
- *Length = FileEntry->LengthOfAllocationDescriptors;
+ *Length = FileEntry->LengthOfAllocationDescriptors;
*AdsData = (VOID *)((UINT8 *)FileEntry->Data +
FileEntry->LengthOfExtendedAttributes);
}
if ((*Length > FileEntrySize) ||
((UINTN)FileEntryData > (UINTN)(*AdsData)) ||
- ((UINTN)(*AdsData) - (UINTN)FileEntryData > FileEntrySize - *Length)) {
+ ((UINTN)(*AdsData) - (UINTN)FileEntryData > FileEntrySize - *Length))
+ {
return EFI_VOLUME_CORRUPTED;
}
+
return EFI_SUCCESS;
}
@@ -648,7 +658,7 @@ GetLongAdFromAds ( UDF_LONG_ALLOCATION_DESCRIPTOR *LongAd;
UDF_EXTENT_FLAGS ExtentFlags;
- for (;;) {
+ for ( ; ;) {
if (*Offset >= Length) {
//
// No more Long Allocation Descriptors.
@@ -664,8 +674,9 @@ GetLongAdFromAds ( // allocated AD, then return it.
//
ExtentFlags = GET_EXTENT_FLAGS (LongAdsSequence, LongAd);
- if (ExtentFlags == ExtentIsNextExtent ||
- ExtentFlags == ExtentRecordedAndAllocated) {
+ if ((ExtentFlags == ExtentIsNextExtent) ||
+ (ExtentFlags == ExtentRecordedAndAllocated))
+ {
break;
}
@@ -701,10 +712,10 @@ GetShortAdFromAds ( OUT UDF_SHORT_ALLOCATION_DESCRIPTOR **FoundShortAd
)
{
- UDF_SHORT_ALLOCATION_DESCRIPTOR *ShortAd;
- UDF_EXTENT_FLAGS ExtentFlags;
+ UDF_SHORT_ALLOCATION_DESCRIPTOR *ShortAd;
+ UDF_EXTENT_FLAGS ExtentFlags;
- for (;;) {
+ for ( ; ;) {
if (*Offset >= Length) {
//
// No more Short Allocation Descriptors.
@@ -720,8 +731,9 @@ GetShortAdFromAds ( // allocated AD, then return it.
//
ExtentFlags = GET_EXTENT_FLAGS (ShortAdsSequence, ShortAd);
- if (ExtentFlags == ExtentIsNextExtent ||
- ExtentFlags == ExtentRecordedAndAllocated) {
+ if ((ExtentFlags == ExtentIsNextExtent) ||
+ (ExtentFlags == ExtentRecordedAndAllocated))
+ {
break;
}
@@ -763,18 +775,18 @@ GetAllocationDescriptor ( {
if (RecordingFlags == LongAdsSequence) {
return GetLongAdFromAds (
- Data,
- Offset,
- Length,
- (UDF_LONG_ALLOCATION_DESCRIPTOR **)FoundAd
- );
+ Data,
+ Offset,
+ Length,
+ (UDF_LONG_ALLOCATION_DESCRIPTOR **)FoundAd
+ );
} else if (RecordingFlags == ShortAdsSequence) {
return GetShortAdFromAds (
- Data,
- Offset,
- Length,
- (UDF_SHORT_ALLOCATION_DESCRIPTOR **)FoundAd
- );
+ Data,
+ Offset,
+ Length,
+ (UDF_SHORT_ALLOCATION_DESCRIPTOR **)FoundAd
+ );
}
//
@@ -809,7 +821,7 @@ GetAllocationDescriptorLsn ( OUT UINT64 *Lsn
)
{
- UDF_PARTITION_DESCRIPTOR *PartitionDesc;
+ UDF_PARTITION_DESCRIPTOR *PartitionDesc;
if (RecordingFlags == LongAdsSequence) {
return GetLongAdLsn (Volume, (UDF_LONG_ALLOCATION_DESCRIPTOR *)Ad, Lsn);
@@ -875,12 +887,14 @@ GetAedAdsOffset ( UDF_ALLOCATION_EXTENT_DESCRIPTOR *AllocExtDesc;
UDF_DESCRIPTOR_TAG *DescriptorTag;
- ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);
- Status = GetAllocationDescriptorLsn (RecordingFlags,
- Volume,
- ParentIcb,
- Ad,
- &Lsn);
+ ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);
+ Status = GetAllocationDescriptorLsn (
+ RecordingFlags,
+ Volume,
+ ParentIcb,
+ Ad,
+ &Lsn
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -896,12 +910,12 @@ GetAedAdsOffset ( // Read extent.
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (Lsn, LogicalBlockSize),
- ExtentLength,
- Data
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (Lsn, LogicalBlockSize),
+ ExtentLength,
+ Data
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -922,7 +936,7 @@ GetAedAdsOffset ( // Get AED's block offset and its length.
//
*Offset = MultU64x32 (Lsn, LogicalBlockSize) +
- sizeof (UDF_ALLOCATION_EXTENT_DESCRIPTOR);
+ sizeof (UDF_ALLOCATION_EXTENT_DESCRIPTOR);
*Length = AllocExtDesc->LengthOfAllocationDescriptors;
Exit:
@@ -969,15 +983,15 @@ GetAedAdsData ( // Get AED's offset + length.
//
Status = GetAedAdsOffset (
- BlockIo,
- DiskIo,
- Volume,
- ParentIcb,
- RecordingFlags,
- Ad,
- &Offset,
- Length
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ ParentIcb,
+ RecordingFlags,
+ Ad,
+ &Offset,
+ Length
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -985,18 +999,18 @@ GetAedAdsData ( //
// Allocate buffer to read in AED's data.
//
- *Data = AllocatePool ((UINTN) (*Length));
+ *Data = AllocatePool ((UINTN)(*Length));
if (*Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- Offset,
- (UINTN) (*Length),
- *Data
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ Offset,
+ (UINTN)(*Length),
+ *Data
+ );
}
/**
@@ -1020,7 +1034,7 @@ GrowUpBufferToNextAd ( IN UINT64 Length
)
{
- UINT32 ExtentLength;
+ UINT32 ExtentLength;
ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);
@@ -1030,7 +1044,7 @@ GrowUpBufferToNextAd ( return EFI_OUT_OF_RESOURCES;
}
} else {
- *Buffer = ReallocatePool ((UINTN) Length, (UINTN) (Length + ExtentLength), *Buffer);
+ *Buffer = ReallocatePool ((UINTN)Length, (UINTN)(Length + ExtentLength), *Buffer);
if (*Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1087,294 +1101,297 @@ ReadFile ( UINT32 ExtentLength;
UDF_FE_RECORDING_FLAGS RecordingFlags;
- LogicalBlockSize = Volume->LogicalVolDesc.LogicalBlockSize;
- DoFreeAed = FALSE;
+ LogicalBlockSize = Volume->LogicalVolDesc.LogicalBlockSize;
+ DoFreeAed = FALSE;
//
// set BytesLeft to suppress incorrect compiler/analyzer warnings
//
- BytesLeft = 0;
- DataOffset = 0;
- FilePosition = 0;
+ BytesLeft = 0;
+ DataOffset = 0;
+ FilePosition = 0;
FinishedSeeking = FALSE;
- Data = NULL;
+ Data = NULL;
switch (ReadFileInfo->Flags) {
- case ReadFileGetFileSize:
- case ReadFileAllocateAndRead:
- //
- // Initialise ReadFileInfo structure for either getting file size, or
- // reading file's recorded data.
- //
- ReadFileInfo->ReadLength = 0;
- ReadFileInfo->FileData = NULL;
- break;
- case ReadFileSeekAndRead:
- //
- // About to seek a file and/or read its data.
- //
- Length = ReadFileInfo->FileSize - ReadFileInfo->FilePosition;
- if (ReadFileInfo->FileDataSize > Length) {
+ case ReadFileGetFileSize:
+ case ReadFileAllocateAndRead:
//
- // About to read beyond the EOF -- truncate it.
+ // Initialise ReadFileInfo structure for either getting file size, or
+ // reading file's recorded data.
//
- ReadFileInfo->FileDataSize = Length;
- }
-
- //
- // Initialise data to start seeking and/or reading a file.
- //
- BytesLeft = ReadFileInfo->FileDataSize;
- DataOffset = 0;
- FilePosition = 0;
- FinishedSeeking = FALSE;
-
- break;
- }
-
- RecordingFlags = GET_FE_RECORDING_FLAGS (FileEntryData);
- switch (RecordingFlags) {
- case InlineData:
- //
- // There are no extents for this FE/EFE. All data is inline.
- //
- Status = GetFileEntryData (FileEntryData, Volume->FileEntrySize, &Data, &Length);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (ReadFileInfo->Flags == ReadFileGetFileSize) {
- ReadFileInfo->ReadLength = Length;
- } else if (ReadFileInfo->Flags == ReadFileAllocateAndRead) {
+ ReadFileInfo->ReadLength = 0;
+ ReadFileInfo->FileData = NULL;
+ break;
+ case ReadFileSeekAndRead:
//
- // Allocate buffer for starting read data.
+ // About to seek a file and/or read its data.
//
- ReadFileInfo->FileData = AllocatePool ((UINTN) Length);
- if (ReadFileInfo->FileData == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ Length = ReadFileInfo->FileSize - ReadFileInfo->FilePosition;
+ if (ReadFileInfo->FileDataSize > Length) {
+ //
+ // About to read beyond the EOF -- truncate it.
+ //
+ ReadFileInfo->FileDataSize = Length;
}
//
- // Read all inline data into ReadFileInfo->FileData
- //
- CopyMem (ReadFileInfo->FileData, Data, (UINTN) Length);
- ReadFileInfo->ReadLength = Length;
- } else if (ReadFileInfo->Flags == ReadFileSeekAndRead) {
- //
- // If FilePosition is non-zero, seek file to FilePosition, read
- // FileDataSize bytes and then updates FilePosition.
+ // Initialise data to start seeking and/or reading a file.
//
- CopyMem (
- ReadFileInfo->FileData,
- (VOID *)((UINT8 *)Data + ReadFileInfo->FilePosition),
- (UINTN) ReadFileInfo->FileDataSize
- );
-
- ReadFileInfo->FilePosition += ReadFileInfo->FileDataSize;
- } else {
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_SUCCESS;
- break;
-
- case LongAdsSequence:
- case ShortAdsSequence:
- //
- // This FE/EFE contains a run of Allocation Descriptors. Get data + size
- // for start reading them out.
- //
- Status = GetAdsInformation (FileEntryData, Volume->FileEntrySize, &Data, &Length);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ BytesLeft = ReadFileInfo->FileDataSize;
+ DataOffset = 0;
+ FilePosition = 0;
+ FinishedSeeking = FALSE;
- AdOffset = 0;
+ break;
+ }
- for (;;) {
+ RecordingFlags = GET_FE_RECORDING_FLAGS (FileEntryData);
+ switch (RecordingFlags) {
+ case InlineData:
//
- // Read AD.
+ // There are no extents for this FE/EFE. All data is inline.
//
- Status = GetAllocationDescriptor (
- RecordingFlags,
- Data,
- &AdOffset,
- Length,
- &Ad
- );
- if (Status == EFI_DEVICE_ERROR) {
- Status = EFI_SUCCESS;
- goto Done;
+ Status = GetFileEntryData (FileEntryData, Volume->FileEntrySize, &Data, &Length);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
- //
- // Check if AD is an indirect AD. If so, read Allocation Extent
- // Descriptor and its extents (ADs).
- //
- if (GET_EXTENT_FLAGS (RecordingFlags, Ad) == ExtentIsNextExtent) {
- DataBak = Data;
- Status = GetAedAdsData (
- BlockIo,
- DiskIo,
- Volume,
- ParentIcb,
- RecordingFlags,
- Ad,
- &Data,
- &Length
- );
-
- if (!DoFreeAed) {
- DoFreeAed = TRUE;
- } else {
- FreePool (DataBak);
+ if (ReadFileInfo->Flags == ReadFileGetFileSize) {
+ ReadFileInfo->ReadLength = Length;
+ } else if (ReadFileInfo->Flags == ReadFileAllocateAndRead) {
+ //
+ // Allocate buffer for starting read data.
+ //
+ ReadFileInfo->FileData = AllocatePool ((UINTN)Length);
+ if (ReadFileInfo->FileData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- if (EFI_ERROR (Status)) {
- goto Error_Get_Aed;
- }
- ASSERT (Data != NULL);
+ //
+ // Read all inline data into ReadFileInfo->FileData
+ //
+ CopyMem (ReadFileInfo->FileData, Data, (UINTN)Length);
+ ReadFileInfo->ReadLength = Length;
+ } else if (ReadFileInfo->Flags == ReadFileSeekAndRead) {
+ //
+ // If FilePosition is non-zero, seek file to FilePosition, read
+ // FileDataSize bytes and then updates FilePosition.
+ //
+ CopyMem (
+ ReadFileInfo->FileData,
+ (VOID *)((UINT8 *)Data + ReadFileInfo->FilePosition),
+ (UINTN)ReadFileInfo->FileDataSize
+ );
- AdOffset = 0;
- continue;
+ ReadFileInfo->FilePosition += ReadFileInfo->FileDataSize;
+ } else {
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
- ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);
+ Status = EFI_SUCCESS;
+ break;
- Status = GetAllocationDescriptorLsn (RecordingFlags,
- Volume,
- ParentIcb,
- Ad,
- &Lsn);
+ case LongAdsSequence:
+ case ShortAdsSequence:
+ //
+ // This FE/EFE contains a run of Allocation Descriptors. Get data + size
+ // for start reading them out.
+ //
+ Status = GetAdsInformation (FileEntryData, Volume->FileEntrySize, &Data, &Length);
if (EFI_ERROR (Status)) {
- goto Done;
+ return Status;
}
- switch (ReadFileInfo->Flags) {
- case ReadFileGetFileSize:
- ReadFileInfo->ReadLength += ExtentLength;
- break;
- case ReadFileAllocateAndRead:
- //
- // Increase FileData (if necessary) to read next extent.
- //
- Status = GrowUpBufferToNextAd (
- RecordingFlags,
- Ad,
- &ReadFileInfo->FileData,
- ReadFileInfo->ReadLength
- );
- if (EFI_ERROR (Status)) {
- goto Error_Alloc_Buffer_To_Next_Ad;
- }
+ AdOffset = 0;
+ for ( ; ;) {
//
- // Read extent's data into FileData.
+ // Read AD.
//
- Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (Lsn, LogicalBlockSize),
- ExtentLength,
- (VOID *)((UINT8 *)ReadFileInfo->FileData +
- ReadFileInfo->ReadLength)
- );
- if (EFI_ERROR (Status)) {
- goto Error_Read_Disk_Blk;
+ Status = GetAllocationDescriptor (
+ RecordingFlags,
+ Data,
+ &AdOffset,
+ Length,
+ &Ad
+ );
+ if (Status == EFI_DEVICE_ERROR) {
+ Status = EFI_SUCCESS;
+ goto Done;
}
- ReadFileInfo->ReadLength += ExtentLength;
- break;
- case ReadFileSeekAndRead:
//
- // Seek file first before reading in its data.
+ // Check if AD is an indirect AD. If so, read Allocation Extent
+ // Descriptor and its extents (ADs).
//
- if (FinishedSeeking) {
- Offset = 0;
- goto Skip_File_Seek;
- }
+ if (GET_EXTENT_FLAGS (RecordingFlags, Ad) == ExtentIsNextExtent) {
+ DataBak = Data;
+ Status = GetAedAdsData (
+ BlockIo,
+ DiskIo,
+ Volume,
+ ParentIcb,
+ RecordingFlags,
+ Ad,
+ &Data,
+ &Length
+ );
+
+ if (!DoFreeAed) {
+ DoFreeAed = TRUE;
+ } else {
+ FreePool (DataBak);
+ }
- if (FilePosition + ExtentLength < ReadFileInfo->FilePosition) {
- FilePosition += ExtentLength;
- goto Skip_Ad;
- }
+ if (EFI_ERROR (Status)) {
+ goto Error_Get_Aed;
+ }
- if (FilePosition + ExtentLength > ReadFileInfo->FilePosition) {
- Offset = ReadFileInfo->FilePosition - FilePosition;
- } else {
- Offset = 0;
+ ASSERT (Data != NULL);
+
+ AdOffset = 0;
+ continue;
}
- //
- // Done with seeking file. Start reading its data.
- //
- FinishedSeeking = TRUE;
+ ExtentLength = GET_EXTENT_LENGTH (RecordingFlags, Ad);
- Skip_File_Seek:
- //
- // Make sure we don't read more data than really wanted.
- //
- if (ExtentLength - Offset > BytesLeft) {
- DataLength = BytesLeft;
- } else {
- DataLength = ExtentLength - Offset;
+ Status = GetAllocationDescriptorLsn (
+ RecordingFlags,
+ Volume,
+ ParentIcb,
+ Ad,
+ &Lsn
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
}
- //
- // Read extent's data into FileData.
- //
- Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- Offset + MultU64x32 (Lsn, LogicalBlockSize),
- (UINTN) DataLength,
- (VOID *)((UINT8 *)ReadFileInfo->FileData +
- DataOffset)
- );
- if (EFI_ERROR (Status)) {
- goto Error_Read_Disk_Blk;
+ switch (ReadFileInfo->Flags) {
+ case ReadFileGetFileSize:
+ ReadFileInfo->ReadLength += ExtentLength;
+ break;
+ case ReadFileAllocateAndRead:
+ //
+ // Increase FileData (if necessary) to read next extent.
+ //
+ Status = GrowUpBufferToNextAd (
+ RecordingFlags,
+ Ad,
+ &ReadFileInfo->FileData,
+ ReadFileInfo->ReadLength
+ );
+ if (EFI_ERROR (Status)) {
+ goto Error_Alloc_Buffer_To_Next_Ad;
+ }
+
+ //
+ // Read extent's data into FileData.
+ //
+ Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (Lsn, LogicalBlockSize),
+ ExtentLength,
+ (VOID *)((UINT8 *)ReadFileInfo->FileData +
+ ReadFileInfo->ReadLength)
+ );
+ if (EFI_ERROR (Status)) {
+ goto Error_Read_Disk_Blk;
+ }
+
+ ReadFileInfo->ReadLength += ExtentLength;
+ break;
+ case ReadFileSeekAndRead:
+ //
+ // Seek file first before reading in its data.
+ //
+ if (FinishedSeeking) {
+ Offset = 0;
+ goto Skip_File_Seek;
+ }
+
+ if (FilePosition + ExtentLength < ReadFileInfo->FilePosition) {
+ FilePosition += ExtentLength;
+ goto Skip_Ad;
+ }
+
+ if (FilePosition + ExtentLength > ReadFileInfo->FilePosition) {
+ Offset = ReadFileInfo->FilePosition - FilePosition;
+ } else {
+ Offset = 0;
+ }
+
+ //
+ // Done with seeking file. Start reading its data.
+ //
+ FinishedSeeking = TRUE;
+
+Skip_File_Seek:
+ //
+ // Make sure we don't read more data than really wanted.
+ //
+ if (ExtentLength - Offset > BytesLeft) {
+ DataLength = BytesLeft;
+ } else {
+ DataLength = ExtentLength - Offset;
+ }
+
+ //
+ // Read extent's data into FileData.
+ //
+ Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ Offset + MultU64x32 (Lsn, LogicalBlockSize),
+ (UINTN)DataLength,
+ (VOID *)((UINT8 *)ReadFileInfo->FileData +
+ DataOffset)
+ );
+ if (EFI_ERROR (Status)) {
+ goto Error_Read_Disk_Blk;
+ }
+
+ //
+ // Update current file's position.
+ //
+ DataOffset += DataLength;
+ ReadFileInfo->FilePosition += DataLength;
+
+ BytesLeft -= DataLength;
+ if (BytesLeft == 0) {
+ //
+ // There is no more file data to read.
+ //
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+
+ break;
}
+Skip_Ad:
//
- // Update current file's position.
+ // Point to the next AD (extent).
//
- DataOffset += DataLength;
- ReadFileInfo->FilePosition += DataLength;
-
- BytesLeft -= DataLength;
- if (BytesLeft == 0) {
- //
- // There is no more file data to read.
- //
- Status = EFI_SUCCESS;
- goto Done;
- }
-
- break;
+ AdOffset += AD_LENGTH (RecordingFlags);
}
- Skip_Ad:
+ break;
+ case ExtendedAdsSequence:
+ // FIXME: Not supported. Got no volume with it, yet.
+ ASSERT (FALSE);
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ default:
//
- // Point to the next AD (extent).
+ // A flag value reserved by the ECMA-167 standard (3rd Edition - June
+ // 1997); 14.6 ICB Tag; 14.6.8 Flags (RBP 18); was found.
//
- AdOffset += AD_LENGTH (RecordingFlags);
- }
-
- break;
- case ExtendedAdsSequence:
- // FIXME: Not supported. Got no volume with it, yet.
- ASSERT (FALSE);
- Status = EFI_UNSUPPORTED;
- break;
-
- default:
- //
- // A flag value reserved by the ECMA-167 standard (3rd Edition - June
- // 1997); 14.6 ICB Tag; 14.6.8 Flags (RBP 18); was found.
- //
- Status = EFI_UNSUPPORTED;
- break;
+ Status = EFI_UNSUPPORTED;
+ break;
}
Done:
@@ -1475,18 +1492,18 @@ InternalFindFile ( ZeroMem ((VOID *)&ReadDirInfo, sizeof (UDF_READ_DIRECTORY_INFO));
Found = FALSE;
- for (;;) {
+ for ( ; ;) {
Status = ReadDirectoryEntry (
- BlockIo,
- DiskIo,
- Volume,
- (Parent->FileIdentifierDesc != NULL) ?
- &Parent->FileIdentifierDesc->Icb :
- Icb,
- Parent->FileEntry,
- &ReadDirInfo,
- &FileIdentifierDesc
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ (Parent->FileIdentifierDesc != NULL) ?
+ &Parent->FileIdentifierDesc->Icb :
+ Icb,
+ Parent->FileEntry,
+ &ReadDirInfo,
+ &FileIdentifierDesc
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_DEVICE_ERROR) {
Status = EFI_NOT_FOUND;
@@ -1494,6 +1511,7 @@ InternalFindFile ( break;
}
+
//
// After calling function ReadDirectoryEntry(), if 'FileIdentifierDesc' is
// NULL, then the 'Status' must be EFI_OUT_OF_RESOURCES. Hence, if the code
@@ -1510,7 +1528,7 @@ InternalFindFile ( // directory (Parent), and if FileName is either ".." or "\\", then it's
// the expected FID.
//
- if (StrCmp (FileName, L"..") == 0 || StrCmp (FileName, L"\\") == 0) {
+ if ((StrCmp (FileName, L"..") == 0) || (StrCmp (FileName, L"\\") == 0)) {
Found = TRUE;
break;
}
@@ -1552,12 +1570,12 @@ InternalFindFile ( //
if (StrCmp (FileName, L"\\") != 0) {
Status = FindFileEntry (
- BlockIo,
- DiskIo,
- Volume,
- &FileIdentifierDesc->Icb,
- &CompareFileEntry
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &FileIdentifierDesc->Icb,
+ &CompareFileEntry
+ );
if (EFI_ERROR (Status)) {
goto Error_Find_Fe;
}
@@ -1565,8 +1583,12 @@ InternalFindFile ( //
// Make sure that both Parent's FE/EFE and found FE/EFE are not equal.
//
- if (CompareMem ((VOID *)Parent->FileEntry, (VOID *)CompareFileEntry,
- Volume->FileEntrySize) != 0) {
+ if (CompareMem (
+ (VOID *)Parent->FileEntry,
+ (VOID *)CompareFileEntry,
+ Volume->FileEntrySize
+ ) != 0)
+ {
File->FileEntry = CompareFileEntry;
} else {
FreePool ((VOID *)FileIdentifierDesc);
@@ -1605,16 +1627,16 @@ ReadUdfVolumeInformation ( OUT UDF_VOLUME_INFO *Volume
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Read all necessary UDF volume information and keep it private to the driver
//
Status = ReadVolumeFileStructure (
- BlockIo,
- DiskIo,
- Volume
- );
+ BlockIo,
+ DiskIo,
+ Volume
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1658,29 +1680,29 @@ FindRootDirectory ( UDF_FILE_INFO Parent;
Status = FindFileEntry (
- BlockIo,
- DiskIo,
- Volume,
- &Volume->FileSetDesc.RootDirectoryIcb,
- &File->FileEntry
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &Volume->FileSetDesc.RootDirectoryIcb,
+ &File->FileEntry
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Parent.FileEntry = File->FileEntry;
+ Parent.FileEntry = File->FileEntry;
Parent.FileIdentifierDesc = NULL;
Status = FindFile (
- BlockIo,
- DiskIo,
- Volume,
- L"\\",
- NULL,
- &Parent,
- &Volume->FileSetDesc.RootDirectoryIcb,
- File
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ L"\\",
+ NULL,
+ &Parent,
+ &Volume->FileSetDesc.RootDirectoryIcb,
+ File
+ );
if (EFI_ERROR (Status)) {
FreePool (File->FileEntry);
}
@@ -1725,7 +1747,7 @@ FindFileEntry ( return Status;
}
- LogicalBlockSize = Volume->LogicalVolDesc.LogicalBlockSize;
+ LogicalBlockSize = Volume->LogicalVolDesc.LogicalBlockSize;
ReadBuffer = AllocateZeroPool (Volume->FileEntrySize);
if (ReadBuffer == NULL) {
@@ -1736,12 +1758,12 @@ FindFileEntry ( // Read extent.
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (Lsn, LogicalBlockSize),
- Volume->FileEntrySize,
- ReadBuffer
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (Lsn, LogicalBlockSize),
+ Volume->FileEntrySize,
+ ReadBuffer
+ );
if (EFI_ERROR (Status)) {
goto Error_Read_Disk_Blk;
}
@@ -1752,8 +1774,9 @@ FindFileEntry ( // Check if the read extent contains a valid Tag Identifier for the expected
// FE/EFE.
//
- if (DescriptorTag->TagIdentifier != UdfFileEntry &&
- DescriptorTag->TagIdentifier != UdfExtendedFileEntry) {
+ if ((DescriptorTag->TagIdentifier != UdfFileEntry) &&
+ (DescriptorTag->TagIdentifier != UdfExtendedFileEntry))
+ {
Status = EFI_VOLUME_CORRUPTED;
goto Error_Invalid_Fe;
}
@@ -1813,7 +1836,8 @@ FindFile ( FileNamePointer = FileName;
while (*FilePath != L'\0' && *FilePath != L'\\') {
if ((((UINTN)FileNamePointer - (UINTN)FileName) / sizeof (CHAR16)) >=
- (ARRAY_SIZE (FileName) - 1)) {
+ (ARRAY_SIZE (FileName) - 1))
+ {
return EFI_NOT_FOUND;
}
@@ -1832,13 +1856,15 @@ FindFile ( //
// See UdfOpenVolume() function.
//
- Status = InternalFindFile (BlockIo,
- DiskIo,
- Volume,
- L"\\",
- &PreviousFile,
- Icb,
- File);
+ Status = InternalFindFile (
+ BlockIo,
+ DiskIo,
+ Volume,
+ L"\\",
+ &PreviousFile,
+ Icb,
+ File
+ );
} else {
//
// We've already a file pointer (Root) for the root directory. Duplicate
@@ -1863,13 +1889,15 @@ FindFile ( //
// No root directory. Find filename from the current directory.
//
- Status = InternalFindFile (BlockIo,
- DiskIo,
- Volume,
- FileName,
- &PreviousFile,
- Icb,
- File);
+ Status = InternalFindFile (
+ BlockIo,
+ DiskIo,
+ Volume,
+ FileName,
+ &PreviousFile,
+ Icb,
+ File
+ );
}
if (EFI_ERROR (Status)) {
@@ -1885,12 +1913,14 @@ FindFile ( FileEntry = File->FileEntry;
- Status = ResolveSymlink (BlockIo,
- DiskIo,
- Volume,
- &PreviousFile,
- FileEntry,
- File);
+ Status = ResolveSymlink (
+ BlockIo,
+ DiskIo,
+ Volume,
+ &PreviousFile,
+ FileEntry,
+ File
+ );
FreePool (FileEntry);
@@ -1899,13 +1929,17 @@ FindFile ( }
}
- if (CompareMem ((VOID *)&PreviousFile, (VOID *)Parent,
- sizeof (UDF_FILE_INFO)) != 0) {
+ if (CompareMem (
+ (VOID *)&PreviousFile,
+ (VOID *)Parent,
+ sizeof (UDF_FILE_INFO)
+ ) != 0)
+ {
CleanupFileInformation (&PreviousFile);
}
CopyMem ((VOID *)&PreviousFile, (VOID *)File, sizeof (UDF_FILE_INFO));
- if (*FilePath != L'\0' && *FilePath == L'\\') {
+ if ((*FilePath != L'\0') && (*FilePath == L'\\')) {
FilePath++;
}
}
@@ -1957,13 +1991,13 @@ ReadDirectoryEntry ( ReadFileInfo.Flags = ReadFileAllocateAndRead;
Status = ReadFile (
- BlockIo,
- DiskIo,
- Volume,
- ParentIcb,
- FileEntryData,
- &ReadFileInfo
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ ParentIcb,
+ FileEntryData,
+ &ReadFileInfo
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1971,7 +2005,7 @@ ReadDirectoryEntry ( //
// Fill in ReadDirInfo structure with the read directory's data information.
//
- ReadDirInfo->DirectoryData = ReadFileInfo.FileData;
+ ReadDirInfo->DirectoryData = ReadFileInfo.FileData;
ReadDirInfo->DirectoryLength = ReadFileInfo.ReadLength;
}
@@ -1988,8 +2022,10 @@ ReadDirectoryEntry ( //
// Get FID for this entry.
//
- FileIdentifierDesc = GET_FID_FROM_ADS (ReadDirInfo->DirectoryData,
- ReadDirInfo->FidOffset);
+ FileIdentifierDesc = GET_FID_FROM_ADS (
+ ReadDirInfo->DirectoryData,
+ ReadDirInfo->FidOffset
+ );
//
// Update FidOffset to point to next FID.
//
@@ -2031,11 +2067,11 @@ GetFileNameFromFid ( OUT CHAR16 *FileName
)
{
- UINT8 *OstaCompressed;
- UINT8 CompressionId;
- UINT8 Length;
- UINTN Index;
- CHAR16 *FileNameBak;
+ UINT8 *OstaCompressed;
+ UINT8 CompressionId;
+ UINT8 Length;
+ UINTN Index;
+ CHAR16 *FileNameBak;
if (CharMax == 0) {
return EFI_BUFFER_TOO_SMALL;
@@ -2043,9 +2079,9 @@ GetFileNameFromFid ( OstaCompressed =
(UINT8 *)(
- (UINT8 *)FileIdentifierDesc->Data +
- FileIdentifierDesc->LengthOfImplementationUse
- );
+ (UINT8 *)FileIdentifierDesc->Data +
+ FileIdentifierDesc->LengthOfImplementationUse
+ );
CompressionId = OstaCompressed[0];
if (!IS_VALID_COMPRESSION_ID (CompressionId)) {
@@ -2086,6 +2122,7 @@ GetFileNameFromFid ( if (Index > CharMax - 1) {
Index = CharMax - 1;
}
+
FileNameBak[Index] = L'\0';
return EFI_SUCCESS;
@@ -2152,135 +2189,140 @@ ResolveSymlink ( ReadFileInfo.Flags = ReadFileAllocateAndRead;
Status = ReadFile (
- BlockIo,
- DiskIo,
- Volume,
- &Parent->FileIdentifierDesc->Icb,
- FileEntryData,
- &ReadFileInfo
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &Parent->FileIdentifierDesc->Icb,
+ FileEntryData,
+ &ReadFileInfo
+ );
if (EFI_ERROR (Status)) {
return Status;
}
Length = ReadFileInfo.ReadLength;
- Data = (UINT8 *)ReadFileInfo.FileData;
+ Data = (UINT8 *)ReadFileInfo.FileData;
EndData = Data + Length;
CopyMem ((VOID *)&PreviousFile, (VOID *)Parent, sizeof (UDF_FILE_INFO));
- for (;;) {
+ for ( ; ;) {
PathComp = (UDF_PATH_COMPONENT *)Data;
PathCompLength = PathComp->LengthOfComponentIdentifier;
switch (PathComp->ComponentType) {
- case 1:
+ case 1:
//
// This Path Component specifies the root directory hierarchy subject to
// agreement between the originator and recipient of the medium. Skip it.
//
// Fall through.
//
- case 2:
- //
- // "\\." of the current directory. Read next Path Component.
- //
- goto Next_Path_Component;
- case 3:
- //
- // ".." (parent directory). Go to it.
- //
- CopyMem ((VOID *)FileName, L"..", 6);
- break;
- case 4:
- //
- // "." (current file). Duplicate both FE/EFE and FID of this file.
- //
- DuplicateFe (BlockIo, Volume, PreviousFile.FileEntry, &File->FileEntry);
- if (File->FileEntry == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error_Find_File;
- }
+ case 2:
+ //
+ // "\\." of the current directory. Read next Path Component.
+ //
+ goto Next_Path_Component;
+ case 3:
+ //
+ // ".." (parent directory). Go to it.
+ //
+ CopyMem ((VOID *)FileName, L"..", 6);
+ break;
+ case 4:
+ //
+ // "." (current file). Duplicate both FE/EFE and FID of this file.
+ //
+ DuplicateFe (BlockIo, Volume, PreviousFile.FileEntry, &File->FileEntry);
+ if (File->FileEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error_Find_File;
+ }
- DuplicateFid (PreviousFile.FileIdentifierDesc,
- &File->FileIdentifierDesc);
- if (File->FileIdentifierDesc == NULL) {
- FreePool (File->FileEntry);
- Status = EFI_OUT_OF_RESOURCES;
- goto Error_Find_File;
- }
- goto Next_Path_Component;
- case 5:
- //
- // This Path Component identifies an object, either a file or a
- // directory or an alias.
- //
- // Decode it from the compressed data in ComponentIdentifier and find
- // respective path.
- //
- CompressionId = PathComp->ComponentIdentifier[0];
- if (!IS_VALID_COMPRESSION_ID (CompressionId)) {
- return EFI_VOLUME_CORRUPTED;
- }
+ DuplicateFid (
+ PreviousFile.FileIdentifierDesc,
+ &File->FileIdentifierDesc
+ );
+ if (File->FileIdentifierDesc == NULL) {
+ FreePool (File->FileEntry);
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error_Find_File;
+ }
- if ((UINTN)PathComp->ComponentIdentifier + PathCompLength > (UINTN)EndData) {
- return EFI_VOLUME_CORRUPTED;
- }
+ goto Next_Path_Component;
+ case 5:
+ //
+ // This Path Component identifies an object, either a file or a
+ // directory or an alias.
+ //
+ // Decode it from the compressed data in ComponentIdentifier and find
+ // respective path.
+ //
+ CompressionId = PathComp->ComponentIdentifier[0];
+ if (!IS_VALID_COMPRESSION_ID (CompressionId)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
- Char = FileName;
- for (Index = 1; Index < PathCompLength; Index++) {
- if (CompressionId == 16) {
- *Char = *(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier +
- Index) << 8;
- Index++;
- } else {
- if (Index > ARRAY_SIZE (FileName)) {
- return EFI_UNSUPPORTED;
- }
- *Char = 0;
+ if ((UINTN)PathComp->ComponentIdentifier + PathCompLength > (UINTN)EndData) {
+ return EFI_VOLUME_CORRUPTED;
}
- if (Index < Length) {
- *Char |= (CHAR16)(*(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier + Index));
+ Char = FileName;
+ for (Index = 1; Index < PathCompLength; Index++) {
+ if (CompressionId == 16) {
+ *Char = *(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier +
+ Index) << 8;
+ Index++;
+ } else {
+ if (Index > ARRAY_SIZE (FileName)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ *Char = 0;
+ }
+
+ if (Index < Length) {
+ *Char |= (CHAR16)(*(UINT8 *)((UINT8 *)PathComp->ComponentIdentifier + Index));
+ }
+
+ Char++;
}
- Char++;
- }
+ Index = ((UINTN)Char - (UINTN)FileName) / sizeof (CHAR16);
+ if (Index > ARRAY_SIZE (FileName) - 1) {
+ Index = ARRAY_SIZE (FileName) - 1;
+ }
- Index = ((UINTN)Char - (UINTN)FileName) / sizeof (CHAR16);
- if (Index > ARRAY_SIZE (FileName) - 1) {
- Index = ARRAY_SIZE (FileName) - 1;
- }
- FileName[Index] = L'\0';
- break;
- default:
- //
- // According to the ECMA-167 standard (3rd Edition - June 1997), Section
- // 14.16.1.1, all other values are reserved.
- //
- Status = EFI_VOLUME_CORRUPTED;
- goto Error_Find_File;
+ FileName[Index] = L'\0';
+ break;
+ default:
+ //
+ // According to the ECMA-167 standard (3rd Edition - June 1997), Section
+ // 14.16.1.1, all other values are reserved.
+ //
+ Status = EFI_VOLUME_CORRUPTED;
+ goto Error_Find_File;
}
//
// Find file from the read filename in symlink's file data.
//
Status = InternalFindFile (
- BlockIo,
- DiskIo,
- Volume,
- FileName,
- &PreviousFile,
- NULL,
- File
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ FileName,
+ &PreviousFile,
+ NULL,
+ File
+ );
if (EFI_ERROR (Status)) {
goto Error_Find_File;
}
- Next_Path_Component:
+Next_Path_Component:
Data += sizeof (UDF_PATH_COMPONENT) + PathCompLength;
if (Data >= EndData) {
break;
@@ -2294,10 +2336,16 @@ ResolveSymlink ( goto Error_Find_File;
}
- NotParent = (CompareMem ((VOID *)&PreviousFile, (VOID *)Parent,
- sizeof (UDF_FILE_INFO)) != 0);
- NotFile = (CompareMem ((VOID *)&PreviousFile, (VOID *)File,
- sizeof (UDF_FILE_INFO)) != 0);
+ NotParent = (CompareMem (
+ (VOID *)&PreviousFile,
+ (VOID *)Parent,
+ sizeof (UDF_FILE_INFO)
+ ) != 0);
+ NotFile = (CompareMem (
+ (VOID *)&PreviousFile,
+ (VOID *)File,
+ sizeof (UDF_FILE_INFO)
+ ) != 0);
if (NotParent && NotFile) {
CleanupFileInformation (&PreviousFile);
@@ -2323,8 +2371,12 @@ ResolveSymlink ( return EFI_SUCCESS;
Error_Find_File:
- if (CompareMem ((VOID *)&PreviousFile, (VOID *)Parent,
- sizeof (UDF_FILE_INFO)) != 0) {
+ if (CompareMem (
+ (VOID *)&PreviousFile,
+ (VOID *)Parent,
+ sizeof (UDF_FILE_INFO)
+ ) != 0)
+ {
CleanupFileInformation (&PreviousFile);
}
@@ -2341,12 +2393,13 @@ Error_Find_File: **/
VOID
CleanupFileInformation (
- IN UDF_FILE_INFO *File
+ IN UDF_FILE_INFO *File
)
{
if (File->FileEntry != NULL) {
FreePool (File->FileEntry);
}
+
if (File->FileIdentifierDesc != NULL) {
FreePool ((VOID *)File->FileIdentifierDesc);
}
@@ -2387,13 +2440,13 @@ GetFileSize ( ReadFileInfo.Flags = ReadFileGetFileSize;
Status = ReadFile (
- BlockIo,
- DiskIo,
- Volume,
- &File->FileIdentifierDesc->Icb,
- File->FileEntry,
- &ReadFileInfo
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &File->FileIdentifierDesc->Icb,
+ File->FileEntry,
+ &ReadFileInfo
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2453,10 +2506,10 @@ SetFileInfo ( // Buffer now contains room enough to store EFI_FILE_INFO structure.
// Now, fill it in with all necessary information about the file.
//
- FileInfo = (EFI_FILE_INFO *)Buffer;
- FileInfo->Size = FileInfoLength;
- FileInfo->Attribute &= ~EFI_FILE_VALID_ATTR;
- FileInfo->Attribute |= EFI_FILE_READ_ONLY;
+ FileInfo = (EFI_FILE_INFO *)Buffer;
+ FileInfo->Size = FileInfoLength;
+ FileInfo->Attribute &= ~EFI_FILE_VALID_ATTR;
+ FileInfo->Attribute |= EFI_FILE_READ_ONLY;
if (IS_FID_DIRECTORY_FILE (File->FileIdentifierDesc)) {
FileInfo->Attribute |= EFI_FILE_DIRECTORY;
@@ -2480,32 +2533,32 @@ SetFileInfo ( FileInfo->Attribute |= EFI_FILE_SYSTEM;
}
- FileInfo->FileSize = FileSize;
- FileInfo->PhysicalSize = FileSize;
-
- FileInfo->CreateTime.Year = FileEntry->AccessTime.Year;
- FileInfo->CreateTime.Month = FileEntry->AccessTime.Month;
- FileInfo->CreateTime.Day = FileEntry->AccessTime.Day;
- FileInfo->CreateTime.Hour = FileEntry->AccessTime.Hour;
- FileInfo->CreateTime.Minute = FileEntry->AccessTime.Minute;
- FileInfo->CreateTime.Second = FileEntry->AccessTime.Second;
- FileInfo->CreateTime.Nanosecond =
- FileEntry->AccessTime.HundredsOfMicroseconds;
-
- FileInfo->LastAccessTime.Year =
- FileEntry->AccessTime.Year;
- FileInfo->LastAccessTime.Month =
- FileEntry->AccessTime.Month;
- FileInfo->LastAccessTime.Day =
- FileEntry->AccessTime.Day;
- FileInfo->LastAccessTime.Hour =
- FileEntry->AccessTime.Hour;
- FileInfo->LastAccessTime.Minute =
- FileEntry->AccessTime.Minute;
- FileInfo->LastAccessTime.Second =
- FileEntry->AccessTime.Second;
- FileInfo->LastAccessTime.Nanosecond =
- FileEntry->AccessTime.HundredsOfMicroseconds;
+ FileInfo->FileSize = FileSize;
+ FileInfo->PhysicalSize = FileSize;
+
+ FileInfo->CreateTime.Year = FileEntry->AccessTime.Year;
+ FileInfo->CreateTime.Month = FileEntry->AccessTime.Month;
+ FileInfo->CreateTime.Day = FileEntry->AccessTime.Day;
+ FileInfo->CreateTime.Hour = FileEntry->AccessTime.Hour;
+ FileInfo->CreateTime.Minute = FileEntry->AccessTime.Minute;
+ FileInfo->CreateTime.Second = FileEntry->AccessTime.Second;
+ FileInfo->CreateTime.Nanosecond =
+ FileEntry->AccessTime.HundredsOfMicroseconds;
+
+ FileInfo->LastAccessTime.Year =
+ FileEntry->AccessTime.Year;
+ FileInfo->LastAccessTime.Month =
+ FileEntry->AccessTime.Month;
+ FileInfo->LastAccessTime.Day =
+ FileEntry->AccessTime.Day;
+ FileInfo->LastAccessTime.Hour =
+ FileEntry->AccessTime.Hour;
+ FileInfo->LastAccessTime.Minute =
+ FileEntry->AccessTime.Minute;
+ FileInfo->LastAccessTime.Second =
+ FileEntry->AccessTime.Second;
+ FileInfo->LastAccessTime.Nanosecond =
+ FileEntry->AccessTime.HundredsOfMicroseconds;
} else if (DescriptorTag->TagIdentifier == UdfExtendedFileEntry) {
ExtendedFileEntry = (UDF_EXTENDED_FILE_ENTRY *)File->FileEntry;
@@ -2516,42 +2569,44 @@ SetFileInfo ( FileInfo->Attribute |= EFI_FILE_SYSTEM;
}
- FileInfo->FileSize = FileSize;
- FileInfo->PhysicalSize = FileSize;
-
- FileInfo->CreateTime.Year = ExtendedFileEntry->CreationTime.Year;
- FileInfo->CreateTime.Month = ExtendedFileEntry->CreationTime.Month;
- FileInfo->CreateTime.Day = ExtendedFileEntry->CreationTime.Day;
- FileInfo->CreateTime.Hour = ExtendedFileEntry->CreationTime.Hour;
- FileInfo->CreateTime.Minute = ExtendedFileEntry->CreationTime.Second;
- FileInfo->CreateTime.Second = ExtendedFileEntry->CreationTime.Second;
- FileInfo->CreateTime.Nanosecond =
- ExtendedFileEntry->AccessTime.HundredsOfMicroseconds;
-
- FileInfo->LastAccessTime.Year =
- ExtendedFileEntry->AccessTime.Year;
- FileInfo->LastAccessTime.Month =
- ExtendedFileEntry->AccessTime.Month;
- FileInfo->LastAccessTime.Day =
- ExtendedFileEntry->AccessTime.Day;
- FileInfo->LastAccessTime.Hour =
- ExtendedFileEntry->AccessTime.Hour;
- FileInfo->LastAccessTime.Minute =
- ExtendedFileEntry->AccessTime.Minute;
- FileInfo->LastAccessTime.Second =
- ExtendedFileEntry->AccessTime.Second;
- FileInfo->LastAccessTime.Nanosecond =
- ExtendedFileEntry->AccessTime.HundredsOfMicroseconds;
- }
-
- FileInfo->CreateTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- FileInfo->CreateTime.Daylight = EFI_TIME_ADJUST_DAYLIGHT;
- FileInfo->LastAccessTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- FileInfo->LastAccessTime.Daylight = EFI_TIME_ADJUST_DAYLIGHT;
-
- CopyMem ((VOID *)&FileInfo->ModificationTime,
- (VOID *)&FileInfo->LastAccessTime,
- sizeof (EFI_TIME));
+ FileInfo->FileSize = FileSize;
+ FileInfo->PhysicalSize = FileSize;
+
+ FileInfo->CreateTime.Year = ExtendedFileEntry->CreationTime.Year;
+ FileInfo->CreateTime.Month = ExtendedFileEntry->CreationTime.Month;
+ FileInfo->CreateTime.Day = ExtendedFileEntry->CreationTime.Day;
+ FileInfo->CreateTime.Hour = ExtendedFileEntry->CreationTime.Hour;
+ FileInfo->CreateTime.Minute = ExtendedFileEntry->CreationTime.Second;
+ FileInfo->CreateTime.Second = ExtendedFileEntry->CreationTime.Second;
+ FileInfo->CreateTime.Nanosecond =
+ ExtendedFileEntry->AccessTime.HundredsOfMicroseconds;
+
+ FileInfo->LastAccessTime.Year =
+ ExtendedFileEntry->AccessTime.Year;
+ FileInfo->LastAccessTime.Month =
+ ExtendedFileEntry->AccessTime.Month;
+ FileInfo->LastAccessTime.Day =
+ ExtendedFileEntry->AccessTime.Day;
+ FileInfo->LastAccessTime.Hour =
+ ExtendedFileEntry->AccessTime.Hour;
+ FileInfo->LastAccessTime.Minute =
+ ExtendedFileEntry->AccessTime.Minute;
+ FileInfo->LastAccessTime.Second =
+ ExtendedFileEntry->AccessTime.Second;
+ FileInfo->LastAccessTime.Nanosecond =
+ ExtendedFileEntry->AccessTime.HundredsOfMicroseconds;
+ }
+
+ FileInfo->CreateTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
+ FileInfo->CreateTime.Daylight = EFI_TIME_ADJUST_DAYLIGHT;
+ FileInfo->LastAccessTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
+ FileInfo->LastAccessTime.Daylight = EFI_TIME_ADJUST_DAYLIGHT;
+
+ CopyMem (
+ (VOID *)&FileInfo->ModificationTime,
+ (VOID *)&FileInfo->LastAccessTime,
+ sizeof (EFI_TIME)
+ );
if (FileName != NULL) {
StrCpyS (FileInfo->FileName, StrLen (FileName) + 1, FileName);
@@ -2643,6 +2698,7 @@ GetVolumeLabel ( if (Index > CharMax - 1) {
Index = CharMax - 1;
}
+
StringBak[Index] = L'\0';
return EFI_SUCCESS;
@@ -2697,7 +2753,8 @@ GetVolumeSize ( ExtentAd = &LogicalVolDesc->IntegritySequenceExtent;
if ((ExtentAd->ExtentLength == 0) ||
- (ExtentAd->ExtentLength < sizeof (UDF_LOGICAL_VOLUME_INTEGRITY))) {
+ (ExtentAd->ExtentLength < sizeof (UDF_LOGICAL_VOLUME_INTEGRITY)))
+ {
return EFI_VOLUME_CORRUPTED;
}
@@ -2717,12 +2774,12 @@ GetVolumeSize ( // Read disk block
//
Status = DiskIo->ReadDisk (
- DiskIo,
- BlockIo->Media->MediaId,
- MultU64x32 (Lsn, LogicalBlockSize),
- ExtentAd->ExtentLength,
- LogicalVolInt
- );
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32 (Lsn, LogicalBlockSize),
+ ExtentAd->ExtentLength,
+ LogicalVolInt
+ );
if (EFI_ERROR (Status)) {
goto Out_Free;
}
@@ -2739,12 +2796,13 @@ GetVolumeSize ( if ((LogicalVolInt->NumberOfPartitions > MAX_UINT32 / sizeof (UINT32) / 2) ||
(LogicalVolInt->NumberOfPartitions * sizeof (UINT32) * 2 >
- ExtentAd->ExtentLength - sizeof (UDF_LOGICAL_VOLUME_INTEGRITY))) {
+ ExtentAd->ExtentLength - sizeof (UDF_LOGICAL_VOLUME_INTEGRITY)))
+ {
Status = EFI_VOLUME_CORRUPTED;
goto Out_Free;
}
- *VolumeSize = 0;
+ *VolumeSize = 0;
*FreeSpaceSize = 0;
Length = LogicalVolInt->NumberOfPartitions;
@@ -2756,6 +2814,7 @@ GetVolumeSize ( if (LsnsNo == 0xFFFFFFFFUL) {
continue;
}
+
//
// Accumulate free space size
//
@@ -2763,7 +2822,7 @@ GetVolumeSize ( }
Length = LogicalVolInt->NumberOfPartitions * sizeof (UINT32) * 2;
- for (; Index < Length; Index += sizeof (UINT32)) {
+ for ( ; Index < Length; Index += sizeof (UINT32)) {
LsnsNo = *(UINT32 *)((UINT8 *)LogicalVolInt->Data + Index);
//
// Check if size is not specified
@@ -2771,6 +2830,7 @@ GetVolumeSize ( if (LsnsNo == 0xFFFFFFFFUL) {
continue;
}
+
//
// Accumulate used volume space
//
@@ -2824,26 +2884,26 @@ ReadFileData ( EFI_STATUS Status;
UDF_READ_FILE_INFO ReadFileInfo;
- ReadFileInfo.Flags = ReadFileSeekAndRead;
- ReadFileInfo.FilePosition = *FilePosition;
- ReadFileInfo.FileData = Buffer;
- ReadFileInfo.FileDataSize = *BufferSize;
- ReadFileInfo.FileSize = FileSize;
+ ReadFileInfo.Flags = ReadFileSeekAndRead;
+ ReadFileInfo.FilePosition = *FilePosition;
+ ReadFileInfo.FileData = Buffer;
+ ReadFileInfo.FileDataSize = *BufferSize;
+ ReadFileInfo.FileSize = FileSize;
Status = ReadFile (
- BlockIo,
- DiskIo,
- Volume,
- &File->FileIdentifierDesc->Icb,
- File->FileEntry,
- &ReadFileInfo
- );
+ BlockIo,
+ DiskIo,
+ Volume,
+ &File->FileIdentifierDesc->Icb,
+ File->FileEntry,
+ &ReadFileInfo
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- *BufferSize = ReadFileInfo.FileDataSize;
- *FilePosition = ReadFileInfo.FilePosition;
+ *BufferSize = ReadFileInfo.FileDataSize;
+ *FilePosition = ReadFileInfo.FilePosition;
return EFI_SUCCESS;
}
@@ -2874,13 +2934,13 @@ SupportUdfFileSystem ( // Open Device Path protocol on ControllerHandle
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **)&DevicePath,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -2891,18 +2951,20 @@ SupportUdfFileSystem ( // Get last Device Path node
//
LastDevicePathNode = NULL;
- DevicePathNode = DevicePath;
+ DevicePathNode = DevicePath;
while (!IsDevicePathEnd (DevicePathNode)) {
LastDevicePathNode = DevicePathNode;
- DevicePathNode = NextDevicePathNode (DevicePathNode);
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
}
+
//
// Check if last Device Path node contains a Vendor-Defined Media Device Path
// of an UDF file system.
//
- if (LastDevicePathNode != NULL &&
- DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (LastDevicePathNode) == MEDIA_VENDOR_DP) {
+ if ((LastDevicePathNode != NULL) &&
+ (DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (LastDevicePathNode) == MEDIA_VENDOR_DP))
+ {
VendorDefinedGuid = (EFI_GUID *)((UINTN)LastDevicePathNode +
OFFSET_OF (VENDOR_DEVICE_PATH, Guid));
if (CompareGuid (VendorDefinedGuid, &gUdfDevPathGuid)) {
@@ -2914,11 +2976,11 @@ SupportUdfFileSystem ( // Close Device Path protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
return Status;
}
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c index d15f44971b..0be6ac0260 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.c @@ -11,7 +11,7 @@ //
// UDF filesystem driver's Global Variables.
//
-EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding = {
UdfDriverBindingSupported,
UdfDriverBindingStart,
UdfDriverBindingStop,
@@ -20,7 +20,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUdfDriverBinding = { NULL
};
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gUdfSimpleFsTemplate = {
+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gUdfSimpleFsTemplate = {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
UdfOpenVolume
};
@@ -55,13 +55,13 @@ UdfDriverBindingSupported ( // Open DiskIo protocol on ControllerHandle
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **)&DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ (VOID **)&DiskIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -70,23 +70,23 @@ UdfDriverBindingSupported ( // Close DiskIo protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Test whether ControllerHandle supports BlockIo protocol
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
return Status;
}
@@ -127,26 +127,26 @@ UdfDriverBindingStart ( // Open BlockIo protocol on ControllerHandle
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **)&BlockIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **)&BlockIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
ASSERT_EFI_ERROR (Status);
//
// Open DiskIo protocol on ControllerHandle
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **)&DiskIo,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ (VOID **)&DiskIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -179,18 +179,21 @@ UdfDriverBindingStart ( //
// Set up SimpleFs protocol
//
- CopyMem ((VOID *)&PrivFsData->SimpleFs, (VOID *)&gUdfSimpleFsTemplate,
- sizeof (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL));
+ CopyMem (
+ (VOID *)&PrivFsData->SimpleFs,
+ (VOID *)&gUdfSimpleFsTemplate,
+ sizeof (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL)
+ );
//
// Install child handle
//
Status = gBS->InstallMultipleProtocolInterfaces (
- &PrivFsData->Handle,
- &gEfiSimpleFileSystemProtocolGuid,
- &PrivFsData->SimpleFs,
- NULL
- );
+ &PrivFsData->Handle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &PrivFsData->SimpleFs,
+ NULL
+ );
Exit:
if (EFI_ERROR (Status)) {
@@ -198,20 +201,20 @@ Exit: // Close DiskIo protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Close BlockIo protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
gBS->RestoreTPL (OldTpl);
@@ -236,27 +239,27 @@ Exit: EFI_STATUS
EFIAPI
UdfDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData;
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
+ PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
//
// Open SimpleFs protocol on ControllerHandle
//
Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID **)&SimpleFs,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ ControllerHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ (VOID **)&SimpleFs,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
PrivFsData = PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS (SimpleFs);
@@ -264,11 +267,11 @@ UdfDriverBindingStop ( // Uninstall child handle
//
Status = gBS->UninstallMultipleProtocolInterfaces (
- PrivFsData->Handle,
- &gEfiSimpleFileSystemProtocolGuid,
- &PrivFsData->SimpleFs,
- NULL
- );
+ PrivFsData->Handle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &PrivFsData->SimpleFs,
+ NULL
+ );
FreePool ((VOID *)PrivFsData);
}
@@ -278,20 +281,20 @@ UdfDriverBindingStop ( // Close DiskIo protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
//
// Close BlockIo protocol on ControllerHandle
//
gBS->CloseProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ ControllerHandle,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
}
return Status;
@@ -311,20 +314,20 @@ UdfDriverBindingStop ( EFI_STATUS
EFIAPI
InitializeUdf (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gUdfDriverBinding,
- ImageHandle,
- &gUdfComponentName,
- &gUdfComponentName2
- );
+ ImageHandle,
+ SystemTable,
+ &gUdfDriverBinding,
+ ImageHandle,
+ &gUdfComponentName,
+ &gUdfComponentName2
+ );
ASSERT_EFI_ERROR (Status);
return Status;
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.h b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.h index 6c623a9040..8c0d551093 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/Udf.h +++ b/MdeModulePkg/Universal/Disk/UdfDxe/Udf.h @@ -51,9 +51,9 @@ ((UDF_EXTENDED_FILE_ENTRY *)(_Ptr))->IcbTag.FileType)
typedef enum {
- UdfFileEntryDirectory = 4,
+ UdfFileEntryDirectory = 4,
UdfFileEntryStandardFile = 5,
- UdfFileEntrySymlink = 12,
+ UdfFileEntrySymlink = 12,
} UDF_FILE_ENTRY_TYPE;
#define HIDDEN_FILE (1 << 0)
@@ -120,12 +120,12 @@ typedef enum { #define IS_VALID_COMPRESSION_ID(_CompId) \
((BOOLEAN)((_CompId) == 8 || (_CompId) == 16))
-#define UDF_STANDARD_IDENTIFIER_LENGTH 5
+#define UDF_STANDARD_IDENTIFIER_LENGTH 5
#pragma pack(1)
typedef struct {
- UINT8 StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
+ UINT8 StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
} UDF_STANDARD_IDENTIFIER;
#pragma pack()
@@ -137,174 +137,174 @@ typedef enum { } UDF_READ_FILE_FLAGS;
typedef struct {
- VOID *FileData;
- UDF_READ_FILE_FLAGS Flags;
- UINT64 FileDataSize;
- UINT64 FilePosition;
- UINT64 FileSize;
- UINT64 ReadLength;
+ VOID *FileData;
+ UDF_READ_FILE_FLAGS Flags;
+ UINT64 FileDataSize;
+ UINT64 FilePosition;
+ UINT64 FileSize;
+ UINT64 ReadLength;
} UDF_READ_FILE_INFO;
#pragma pack(1)
typedef struct {
- UINT16 TypeAndTimezone;
- INT16 Year;
- UINT8 Month;
- UINT8 Day;
- UINT8 Hour;
- UINT8 Minute;
- UINT8 Second;
- UINT8 Centiseconds;
- UINT8 HundredsOfMicroseconds;
- UINT8 Microseconds;
+ UINT16 TypeAndTimezone;
+ INT16 Year;
+ UINT8 Month;
+ UINT8 Day;
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+ UINT8 Centiseconds;
+ UINT8 HundredsOfMicroseconds;
+ UINT8 Microseconds;
} UDF_TIMESTAMP;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UINT32 PrevAllocationExtentDescriptor;
- UINT32 LengthOfAllocationDescriptors;
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UINT32 PrevAllocationExtentDescriptor;
+ UINT32 LengthOfAllocationDescriptors;
} UDF_ALLOCATION_EXTENT_DESCRIPTOR;
typedef struct {
- UINT8 StructureType;
- UINT8 StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
- UINT8 StructureVersion;
- UINT8 Reserved;
- UINT8 StructureData[2040];
+ UINT8 StructureType;
+ UINT8 StandardIdentifier[UDF_STANDARD_IDENTIFIER_LENGTH];
+ UINT8 StructureVersion;
+ UINT8 Reserved;
+ UINT8 StructureData[2040];
} UDF_VOLUME_DESCRIPTOR;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UDF_TIMESTAMP RecordingDateTime;
- UINT32 IntegrityType;
- UDF_EXTENT_AD NextIntegrityExtent;
- UINT8 LogicalVolumeContentsUse[32];
- UINT32 NumberOfPartitions;
- UINT32 LengthOfImplementationUse;
- UINT8 Data[0];
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UDF_TIMESTAMP RecordingDateTime;
+ UINT32 IntegrityType;
+ UDF_EXTENT_AD NextIntegrityExtent;
+ UINT8 LogicalVolumeContentsUse[32];
+ UINT32 NumberOfPartitions;
+ UINT32 LengthOfImplementationUse;
+ UINT8 Data[0];
} UDF_LOGICAL_VOLUME_INTEGRITY;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UINT32 VolumeDescriptorSequenceNumber;
- UINT16 PartitionFlags;
- UINT16 PartitionNumber;
- UDF_ENTITY_ID PartitionContents;
- UINT8 PartitionContentsUse[128];
- UINT32 AccessType;
- UINT32 PartitionStartingLocation;
- UINT32 PartitionLength;
- UDF_ENTITY_ID ImplementationIdentifier;
- UINT8 ImplementationUse[128];
- UINT8 Reserved[156];
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UINT32 VolumeDescriptorSequenceNumber;
+ UINT16 PartitionFlags;
+ UINT16 PartitionNumber;
+ UDF_ENTITY_ID PartitionContents;
+ UINT8 PartitionContentsUse[128];
+ UINT32 AccessType;
+ UINT32 PartitionStartingLocation;
+ UINT32 PartitionLength;
+ UDF_ENTITY_ID ImplementationIdentifier;
+ UINT8 ImplementationUse[128];
+ UINT8 Reserved[156];
} UDF_PARTITION_DESCRIPTOR;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UDF_TIMESTAMP RecordingDateAndTime;
- UINT16 InterchangeLevel;
- UINT16 MaximumInterchangeLevel;
- UINT32 CharacterSetList;
- UINT32 MaximumCharacterSetList;
- UINT32 FileSetNumber;
- UINT32 FileSetDescriptorNumber;
- UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet;
- UINT8 LogicalVolumeIdentifier[128];
- UDF_CHAR_SPEC FileSetCharacterSet;
- UINT8 FileSetIdentifier[32];
- UINT8 CopyrightFileIdentifier[32];
- UINT8 AbstractFileIdentifier[32];
- UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb;
- UDF_ENTITY_ID DomainIdentifier;
- UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent;
- UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb;
- UINT8 Reserved[32];
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UDF_TIMESTAMP RecordingDateAndTime;
+ UINT16 InterchangeLevel;
+ UINT16 MaximumInterchangeLevel;
+ UINT32 CharacterSetList;
+ UINT32 MaximumCharacterSetList;
+ UINT32 FileSetNumber;
+ UINT32 FileSetDescriptorNumber;
+ UDF_CHAR_SPEC LogicalVolumeIdentifierCharacterSet;
+ UINT8 LogicalVolumeIdentifier[128];
+ UDF_CHAR_SPEC FileSetCharacterSet;
+ UINT8 FileSetIdentifier[32];
+ UINT8 CopyrightFileIdentifier[32];
+ UINT8 AbstractFileIdentifier[32];
+ UDF_LONG_ALLOCATION_DESCRIPTOR RootDirectoryIcb;
+ UDF_ENTITY_ID DomainIdentifier;
+ UDF_LONG_ALLOCATION_DESCRIPTOR NextExtent;
+ UDF_LONG_ALLOCATION_DESCRIPTOR SystemStreamDirectoryIcb;
+ UINT8 Reserved[32];
} UDF_FILE_SET_DESCRIPTOR;
typedef struct {
- UINT32 ExtentLength;
- UINT32 ExtentPosition;
+ UINT32 ExtentLength;
+ UINT32 ExtentPosition;
} UDF_SHORT_ALLOCATION_DESCRIPTOR;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UINT16 FileVersionNumber;
- UINT8 FileCharacteristics;
- UINT8 LengthOfFileIdentifier;
- UDF_LONG_ALLOCATION_DESCRIPTOR Icb;
- UINT16 LengthOfImplementationUse;
- UINT8 Data[0];
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UINT16 FileVersionNumber;
+ UINT8 FileCharacteristics;
+ UINT8 LengthOfFileIdentifier;
+ UDF_LONG_ALLOCATION_DESCRIPTOR Icb;
+ UINT16 LengthOfImplementationUse;
+ UINT8 Data[0];
} UDF_FILE_IDENTIFIER_DESCRIPTOR;
typedef struct {
- UINT32 PriorRecordNumberOfDirectEntries;
- UINT16 StrategyType;
- UINT16 StrategyParameter;
- UINT16 MaximumNumberOfEntries;
- UINT8 Reserved;
- UINT8 FileType;
- UDF_LB_ADDR ParentIcbLocation;
- UINT16 Flags;
+ UINT32 PriorRecordNumberOfDirectEntries;
+ UINT16 StrategyType;
+ UINT16 StrategyParameter;
+ UINT16 MaximumNumberOfEntries;
+ UINT8 Reserved;
+ UINT8 FileType;
+ UDF_LB_ADDR ParentIcbLocation;
+ UINT16 Flags;
} UDF_ICB_TAG;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UDF_ICB_TAG IcbTag;
- UINT32 Uid;
- UINT32 Gid;
- UINT32 Permissions;
- UINT16 FileLinkCount;
- UINT8 RecordFormat;
- UINT8 RecordDisplayAttributes;
- UINT32 RecordLength;
- UINT64 InformationLength;
- UINT64 LogicalBlocksRecorded;
- UDF_TIMESTAMP AccessTime;
- UDF_TIMESTAMP ModificationTime;
- UDF_TIMESTAMP AttributeTime;
- UINT32 CheckPoint;
- UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb;
- UDF_ENTITY_ID ImplementationIdentifier;
- UINT64 UniqueId;
- UINT32 LengthOfExtendedAttributes;
- UINT32 LengthOfAllocationDescriptors;
- UINT8 Data[0]; // L_EA + L_AD
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UDF_ICB_TAG IcbTag;
+ UINT32 Uid;
+ UINT32 Gid;
+ UINT32 Permissions;
+ UINT16 FileLinkCount;
+ UINT8 RecordFormat;
+ UINT8 RecordDisplayAttributes;
+ UINT32 RecordLength;
+ UINT64 InformationLength;
+ UINT64 LogicalBlocksRecorded;
+ UDF_TIMESTAMP AccessTime;
+ UDF_TIMESTAMP ModificationTime;
+ UDF_TIMESTAMP AttributeTime;
+ UINT32 CheckPoint;
+ UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb;
+ UDF_ENTITY_ID ImplementationIdentifier;
+ UINT64 UniqueId;
+ UINT32 LengthOfExtendedAttributes;
+ UINT32 LengthOfAllocationDescriptors;
+ UINT8 Data[0]; // L_EA + L_AD
} UDF_FILE_ENTRY;
typedef struct {
- UDF_DESCRIPTOR_TAG DescriptorTag;
- UDF_ICB_TAG IcbTag;
- UINT32 Uid;
- UINT32 Gid;
- UINT32 Permissions;
- UINT16 FileLinkCount;
- UINT8 RecordFormat;
- UINT8 RecordDisplayAttributes;
- UINT32 RecordLength;
- UINT64 InformationLength;
- UINT64 ObjectSize;
- UINT64 LogicalBlocksRecorded;
- UDF_TIMESTAMP AccessTime;
- UDF_TIMESTAMP ModificationTime;
- UDF_TIMESTAMP CreationTime;
- UDF_TIMESTAMP AttributeTime;
- UINT32 CheckPoint;
- UINT32 Reserved;
- UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb;
- UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb;
- UDF_ENTITY_ID ImplementationIdentifier;
- UINT64 UniqueId;
- UINT32 LengthOfExtendedAttributes;
- UINT32 LengthOfAllocationDescriptors;
- UINT8 Data[0]; // L_EA + L_AD
+ UDF_DESCRIPTOR_TAG DescriptorTag;
+ UDF_ICB_TAG IcbTag;
+ UINT32 Uid;
+ UINT32 Gid;
+ UINT32 Permissions;
+ UINT16 FileLinkCount;
+ UINT8 RecordFormat;
+ UINT8 RecordDisplayAttributes;
+ UINT32 RecordLength;
+ UINT64 InformationLength;
+ UINT64 ObjectSize;
+ UINT64 LogicalBlocksRecorded;
+ UDF_TIMESTAMP AccessTime;
+ UDF_TIMESTAMP ModificationTime;
+ UDF_TIMESTAMP CreationTime;
+ UDF_TIMESTAMP AttributeTime;
+ UINT32 CheckPoint;
+ UINT32 Reserved;
+ UDF_LONG_ALLOCATION_DESCRIPTOR ExtendedAttributeIcb;
+ UDF_LONG_ALLOCATION_DESCRIPTOR StreamDirectoryIcb;
+ UDF_ENTITY_ID ImplementationIdentifier;
+ UINT64 UniqueId;
+ UINT32 LengthOfExtendedAttributes;
+ UINT32 LengthOfAllocationDescriptors;
+ UINT8 Data[0]; // L_EA + L_AD
} UDF_EXTENDED_FILE_ENTRY;
typedef struct {
- UINT8 ComponentType;
- UINT8 LengthOfComponentIdentifier;
- UINT16 ComponentFileVersionNumber;
- UINT8 ComponentIdentifier[0];
+ UINT8 ComponentType;
+ UINT8 LengthOfComponentIdentifier;
+ UINT16 ComponentFileVersionNumber;
+ UINT8 ComponentIdentifier[0];
} UDF_PATH_COMPONENT;
#pragma pack()
@@ -313,25 +313,25 @@ typedef struct { // UDF filesystem driver's private data
//
typedef struct {
- UINT64 MainVdsStartLocation;
- UDF_LOGICAL_VOLUME_DESCRIPTOR LogicalVolDesc;
- UDF_PARTITION_DESCRIPTOR PartitionDesc;
- UDF_FILE_SET_DESCRIPTOR FileSetDesc;
- UINTN FileEntrySize;
+ UINT64 MainVdsStartLocation;
+ UDF_LOGICAL_VOLUME_DESCRIPTOR LogicalVolDesc;
+ UDF_PARTITION_DESCRIPTOR PartitionDesc;
+ UDF_FILE_SET_DESCRIPTOR FileSetDesc;
+ UINTN FileEntrySize;
} UDF_VOLUME_INFO;
typedef struct {
- VOID *FileEntry;
- UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc;
+ VOID *FileEntry;
+ UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc;
} UDF_FILE_INFO;
typedef struct {
- VOID *DirectoryData;
- UINT64 DirectoryLength;
- UINT64 FidOffset;
+ VOID *DirectoryData;
+ UINT64 DirectoryLength;
+ UINT64 FidOffset;
} UDF_READ_DIRECTORY_INFO;
-#define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
+#define PRIVATE_UDF_FILE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 'f')
#define PRIVATE_UDF_FILE_DATA_FROM_THIS(a) \
CR ( \
@@ -342,20 +342,20 @@ typedef struct { )
typedef struct {
- UINTN Signature;
- BOOLEAN IsRootDirectory;
- UDF_FILE_INFO *Root;
- UDF_FILE_INFO File;
- UDF_READ_DIRECTORY_INFO ReadDirInfo;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
- EFI_FILE_PROTOCOL FileIo;
- CHAR16 AbsoluteFileName[UDF_PATH_LENGTH];
- CHAR16 FileName[UDF_FILENAME_LENGTH];
- UINT64 FileSize;
- UINT64 FilePosition;
+ UINTN Signature;
+ BOOLEAN IsRootDirectory;
+ UDF_FILE_INFO *Root;
+ UDF_FILE_INFO File;
+ UDF_READ_DIRECTORY_INFO ReadDirInfo;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
+ EFI_FILE_PROTOCOL FileIo;
+ CHAR16 AbsoluteFileName[UDF_PATH_LENGTH];
+ CHAR16 FileName[UDF_FILENAME_LENGTH];
+ UINT64 FileSize;
+ UINT64 FilePosition;
} PRIVATE_UDF_FILE_DATA;
-#define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
+#define PRIVATE_UDF_SIMPLE_FS_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'f', 's')
#define PRIVATE_UDF_SIMPLE_FS_DATA_FROM_THIS(a) \
CR ( \
@@ -366,14 +366,14 @@ typedef struct { )
typedef struct {
- UINTN Signature;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_DISK_IO_PROTOCOL *DiskIo;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs;
- UDF_VOLUME_INFO Volume;
- UDF_FILE_INFO Root;
- UINTN OpenFiles;
- EFI_HANDLE Handle;
+ UINTN Signature;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_DISK_IO_PROTOCOL *DiskIo;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFs;
+ UDF_VOLUME_INFO Volume;
+ UDF_FILE_INFO Root;
+ UINTN OpenFiles;
+ EFI_HANDLE Handle;
} PRIVATE_UDF_SIMPLE_FS_DATA;
//
@@ -472,7 +472,7 @@ UdfRead ( EFI_STATUS
EFIAPI
UdfClose (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
);
/**
@@ -630,7 +630,7 @@ UdfSetInfo ( EFI_STATUS
EFIAPI
UdfFlush (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
);
/**
@@ -838,7 +838,7 @@ ResolveSymlink ( **/
VOID
CleanupFileInformation (
- IN UDF_FILE_INFO *File
+ IN UDF_FILE_INFO *File
);
/**
@@ -1013,7 +1013,7 @@ SupportUdfFileSystem ( **/
CHAR16 *
MangleFileName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
);
/**
@@ -1078,15 +1078,16 @@ UdfDriverBindingStart ( EFI_STATUS
EFIAPI
UdfDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ 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.
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c index b959cb1e9c..ada4825181 100644 --- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c +++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.c @@ -6,14 +6,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "UnicodeCollationEng.h"
-CHAR8 mEngUpperMap[MAP_TABLE_SIZE];
-CHAR8 mEngLowerMap[MAP_TABLE_SIZE];
-CHAR8 mEngInfoMap[MAP_TABLE_SIZE];
+CHAR8 mEngUpperMap[MAP_TABLE_SIZE];
+CHAR8 mEngLowerMap[MAP_TABLE_SIZE];
+CHAR8 mEngInfoMap[MAP_TABLE_SIZE];
-CHAR8 mOtherChars[] = {
+CHAR8 mOtherChars[] = {
'0',
'1',
'2',
@@ -89,8 +88,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL Unicode2Eng = { EFI_STATUS
EFIAPI
InitializeUnicodeCollationEng (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -101,23 +100,22 @@ InitializeUnicodeCollationEng ( // Initialize mapping tables for the supported languages
//
for (Index = 0; Index < MAP_TABLE_SIZE; Index++) {
- mEngUpperMap[Index] = (CHAR8) Index;
- mEngLowerMap[Index] = (CHAR8) 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;
+ 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[Index] |= CHAR_FAT_VALID;
mEngInfoMap[Index2] |= CHAR_FAT_VALID;
}
}
for (Index = 0; mOtherChars[Index] != 0; Index++) {
- Index2 = mOtherChars[Index];
+ Index2 = mOtherChars[Index];
mEngInfoMap[Index2] |= CHAR_FAT_VALID;
}
@@ -163,7 +161,6 @@ InitializeUnicodeCollationEng ( return Status;
}
-
/**
Performs a case-insensitive comparison of two Null-terminated strings.
@@ -179,9 +176,9 @@ InitializeUnicodeCollationEng ( INTN
EFIAPI
EngStriColl (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *Str1,
- IN CHAR16 *Str2
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *Str1,
+ IN CHAR16 *Str2
)
{
while (*Str1 != 0) {
@@ -196,7 +193,6 @@ EngStriColl ( return TO_UPPER (*Str1) - TO_UPPER (*Str2);
}
-
/**
Converts all the characters in a Null-terminated string to
lower case characters.
@@ -208,8 +204,8 @@ EngStriColl ( VOID
EFIAPI
EngStrLwr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
)
{
while (*Str != 0) {
@@ -218,7 +214,6 @@ EngStrLwr ( }
}
-
/**
Converts all the characters in a Null-terminated string to upper
case characters.
@@ -230,8 +225,8 @@ EngStrLwr ( VOID
EFIAPI
EngStrUpr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
)
{
while (*Str != 0) {
@@ -255,128 +250,128 @@ EngStrUpr ( BOOLEAN
EFIAPI
EngMetaiMatch (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN CHAR16 *Pattern
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
)
{
CHAR16 CharC;
CHAR16 CharP;
CHAR16 Index3;
- for (;;) {
- CharP = *Pattern;
+ 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)) {
+ case 0:
+ //
+ // End of pattern. If end of string, TRUE match
+ //
+ if (*String != 0) {
+ return FALSE;
+ } else {
return TRUE;
}
- String += 1;
- }
-
- return EngMetaiMatch (This, String, Pattern);
+ case '*':
+ //
+ // Match zero or more chars
+ //
+ while (*String != 0) {
+ if (EngMetaiMatch (This, String, Pattern)) {
+ return TRUE;
+ }
- case '?':
- //
- // Match any one char
- //
- if (*String == 0) {
- return FALSE;
- }
+ String += 1;
+ }
- String += 1;
- break;
+ return EngMetaiMatch (This, String, Pattern);
- case '[':
- //
- // Match char set
- //
- CharC = *String;
- if (CharC == 0) {
+ case '?':
//
- // syntax problem
+ // Match any one char
//
- return FALSE;
- }
-
- Index3 = 0;
- CharP = *Pattern++;
- while (CharP != 0) {
- if (CharP == ']') {
+ if (*String == 0) {
return FALSE;
}
- if (CharP == '-') {
+ String += 1;
+ break;
+
+ case '[':
+ //
+ // Match char set
+ //
+ CharC = *String;
+ if (CharC == 0) {
//
- // if range of chars, get high range
+ // syntax problem
//
- CharP = *Pattern;
- if (CharP == 0 || CharP == ']') {
+ return FALSE;
+ }
+
+ Index3 = 0;
+ CharP = *Pattern++;
+ while (CharP != 0) {
+ if (CharP == ']') {
+ return FALSE;
+ }
+
+ if (CharP == '-') {
//
- // syntax problem
+ // if range of chars, get high range
//
- return FALSE;
+ 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;
+ }
}
- if (TO_UPPER (CharC) >= TO_UPPER (Index3) && TO_UPPER (CharC) <= TO_UPPER (CharP)) {
+ Index3 = CharP;
+ if (TO_UPPER (CharC) == TO_UPPER (CharP)) {
//
- // if in range, it's a match
+ // if char matches
//
break;
}
- }
- Index3 = CharP;
- if (TO_UPPER (CharC) == TO_UPPER (CharP)) {
- //
- // if char matches
- //
- break;
+ CharP = *Pattern++;
}
- CharP = *Pattern++;
- }
- //
- // skip to end of match char set
- //
- while ((CharP != 0) && (CharP != ']')) {
- CharP = *Pattern;
- Pattern += 1;
- }
+ //
+ // skip to end of match char set
+ //
+ while ((CharP != 0) && (CharP != ']')) {
+ CharP = *Pattern;
+ Pattern += 1;
+ }
- String += 1;
- break;
+ String += 1;
+ break;
- default:
- CharC = *String;
- if (TO_UPPER (CharC) != TO_UPPER (CharP)) {
- return FALSE;
- }
+ default:
+ CharC = *String;
+ if (TO_UPPER (CharC) != TO_UPPER (CharP)) {
+ return FALSE;
+ }
- String += 1;
- break;
+ String += 1;
+ break;
}
}
}
-
/**
Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
@@ -391,26 +386,25 @@ EngMetaiMatch ( VOID
EFIAPI
EngFatToStr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN UINTN FatSize,
- IN CHAR8 *Fat,
- OUT CHAR16 *String
+ 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;
+ *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.
@@ -429,37 +423,38 @@ EngFatToStr ( BOOLEAN
EFIAPI
EngStrToFat (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN UINTN FatSize,
- OUT CHAR8 *Fat
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
)
{
- BOOLEAN SpecialCharExist;
+ BOOLEAN SpecialCharExist;
SpecialCharExist = FALSE;
while ((*String != 0) && (FatSize != 0)) {
//
// Skip '.' or ' ' when making a fat name
//
- if (*String != '.' && *String != ' ') {
+ 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)) {
+ if ((*String < MAP_TABLE_SIZE) && ((mEngInfoMap[*String] & CHAR_FAT_VALID) != 0)) {
*Fat = mEngUpperMap[*String];
} else {
- *Fat = '_';
- SpecialCharExist = TRUE;
+ *Fat = '_';
+ SpecialCharExist = TRUE;
}
- Fat += 1;
+ Fat += 1;
FatSize -= 1;
}
String += 1;
}
+
//
// Do not terminate that fat string
//
diff --git a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h index 8a38909e63..bc32e29596 100644 --- a/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h +++ b/MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/UnicodeCollationEng.h @@ -9,8 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _UNICODE_COLLATION_ENG_H_
#define _UNICODE_COLLATION_ENG_H_
-
-
#include <Uefi.h>
#include <Protocol/UnicodeCollation.h>
@@ -33,16 +31,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Macro to map character a to upper case.
//
-#define TO_UPPER(a) (CHAR16) ((a) <= 0xFF ? mEngUpperMap[a] : (a))
+#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))
+#define TO_LOWER(a) (CHAR16) ((a) <= 0xFF ? mEngLowerMap[a] : (a))
//
// Prototypes
//
+
/**
Performs a case-insensitive comparison of two Null-terminated strings.
@@ -58,9 +57,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent INTN
EFIAPI
EngStriColl (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *Str1,
- IN CHAR16 *Str2
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *Str1,
+ IN CHAR16 *Str2
);
/**
@@ -78,9 +77,9 @@ EngStriColl ( BOOLEAN
EFIAPI
EngMetaiMatch (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN CHAR16 *Pattern
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
);
/**
@@ -94,8 +93,8 @@ EngMetaiMatch ( VOID
EFIAPI
EngStrLwr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
);
/**
@@ -109,8 +108,8 @@ EngStrLwr ( VOID
EFIAPI
EngStrUpr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN OUT CHAR16 *Str
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN OUT CHAR16 *Str
);
/**
@@ -127,10 +126,10 @@ EngStrUpr ( VOID
EFIAPI
EngFatToStr (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN UINTN FatSize,
- IN CHAR8 *Fat,
- OUT CHAR16 *String
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN UINTN FatSize,
+ IN CHAR8 *Fat,
+ OUT CHAR16 *String
);
/**
@@ -151,10 +150,10 @@ EngFatToStr ( BOOLEAN
EFIAPI
EngStrToFat (
- IN EFI_UNICODE_COLLATION_PROTOCOL *This,
- IN CHAR16 *String,
- IN UINTN FatSize,
- OUT CHAR8 *Fat
+ IN EFI_UNICODE_COLLATION_PROTOCOL *This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
);
/**
@@ -173,9 +172,8 @@ EngStrToFat ( EFI_STATUS
EFIAPI
InitializeUnicodeCollationEng (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
#endif
-
|