summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c')
-rw-r--r--OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c363
1 files changed, 205 insertions, 158 deletions
diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
index 6832d563bc..d4f3cd9225 100644
--- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
+++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c
@@ -39,29 +39,29 @@ typedef enum {
} KERNEL_BLOB_TYPE;
typedef struct {
- CONST CHAR16 Name[8];
+ CONST CHAR16 Name[8];
struct {
- FIRMWARE_CONFIG_ITEM CONST SizeKey;
- FIRMWARE_CONFIG_ITEM CONST DataKey;
- UINT32 Size;
+ FIRMWARE_CONFIG_ITEM CONST SizeKey;
+ FIRMWARE_CONFIG_ITEM CONST DataKey;
+ UINT32 Size;
} FwCfgItem[2];
- UINT32 Size;
- UINT8 *Data;
+ UINT32 Size;
+ UINT8 *Data;
} KERNEL_BLOB;
-STATIC KERNEL_BLOB mKernelBlob[KernelBlobTypeMax] = {
+STATIC KERNEL_BLOB mKernelBlob[KernelBlobTypeMax] = {
{
L"kernel",
{
{ QemuFwCfgItemKernelSetupSize, QemuFwCfgItemKernelSetupData, },
{ QemuFwCfgItemKernelSize, QemuFwCfgItemKernelData, },
}
- }, {
+ }, {
L"initrd",
{
{ QemuFwCfgItemInitrdSize, QemuFwCfgItemInitrdData, },
}
- }, {
+ }, {
L"cmdline",
{
{ QemuFwCfgItemCommandLineSize, QemuFwCfgItemCommandLineData, },
@@ -69,39 +69,39 @@ STATIC KERNEL_BLOB mKernelBlob[KernelBlobTypeMax] = {
}
};
-STATIC UINT64 mTotalBlobBytes;
+STATIC UINT64 mTotalBlobBytes;
//
// Device path for the handle that incorporates our "EFI stub filesystem".
//
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH VenMediaNode;
- EFI_DEVICE_PATH_PROTOCOL EndNode;
+ VENDOR_DEVICE_PATH VenMediaNode;
+ EFI_DEVICE_PATH_PROTOCOL EndNode;
} SINGLE_VENMEDIA_NODE_DEVPATH;
#pragma pack ()
-STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mFileSystemDevicePath = {
+STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mFileSystemDevicePath = {
{
{
MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
- { sizeof (VENDOR_DEVICE_PATH) }
+ { sizeof (VENDOR_DEVICE_PATH) }
},
QEMU_KERNEL_LOADER_FS_MEDIA_GUID
- }, {
+ }, {
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ sizeof (EFI_DEVICE_PATH_PROTOCOL) }
}
};
-STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mInitrdDevicePath = {
+STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mInitrdDevicePath = {
{
{
MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP,
- { sizeof (VENDOR_DEVICE_PATH) }
+ { sizeof (VENDOR_DEVICE_PATH) }
},
LINUX_EFI_INITRD_MEDIA_GUID
- }, {
+ }, {
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ sizeof (EFI_DEVICE_PATH_PROTOCOL) }
}
@@ -110,21 +110,21 @@ STATIC CONST SINGLE_VENMEDIA_NODE_DEVPATH mInitrdDevicePath = {
//
// The "file in the EFI stub filesystem" abstraction.
//
-STATIC EFI_TIME mInitTime;
+STATIC EFI_TIME mInitTime;
-#define STUB_FILE_SIG SIGNATURE_64 ('S', 'T', 'U', 'B', 'F', 'I', 'L', 'E')
+#define STUB_FILE_SIG SIGNATURE_64 ('S', 'T', 'U', 'B', 'F', 'I', 'L', 'E')
typedef struct {
- UINT64 Signature; // Carries STUB_FILE_SIG.
+ UINT64 Signature; // Carries STUB_FILE_SIG.
- KERNEL_BLOB_TYPE BlobType; // Index into mKernelBlob. KernelBlobTypeMax
- // denotes the root directory of the filesystem.
+ KERNEL_BLOB_TYPE BlobType; // Index into mKernelBlob. KernelBlobTypeMax
+ // denotes the root directory of the filesystem.
- UINT64 Position; // Byte position for regular files;
- // next directory entry to return for the root
- // directory.
+ UINT64 Position; // Byte position for regular files;
+ // next directory entry to return for the root
+ // directory.
- EFI_FILE_PROTOCOL File; // Standard protocol interface.
+ EFI_FILE_PROTOCOL File; // Standard protocol interface.
} STUB_FILE;
#define STUB_FILE_FROM_FILE(FilePointer) \
@@ -178,11 +178,11 @@ STATIC
EFI_STATUS
EFIAPI
StubFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
);
/**
@@ -197,14 +197,13 @@ STATIC
EFI_STATUS
EFIAPI
StubFileClose (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
FreePool (STUB_FILE_FROM_FILE (This));
return EFI_SUCCESS;
}
-
/**
Close and delete the file handle.
@@ -221,14 +220,13 @@ STATIC
EFI_STATUS
EFIAPI
StubFileDelete (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
FreePool (STUB_FILE_FROM_FILE (This));
return EFI_WARN_DELETE_FAILURE;
}
-
/**
Helper function that formats an EFI_FILE_INFO structure into the
user-allocated buffer, for any valid KERNEL_BLOB_TYPE value (including
@@ -260,19 +258,19 @@ StubFileDelete (
STATIC
EFI_STATUS
ConvertKernelBlobTypeToFileInfo (
- IN KERNEL_BLOB_TYPE BlobType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN KERNEL_BLOB_TYPE BlobType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
CONST CHAR16 *Name;
UINT64 FileSize;
UINT64 Attribute;
- UINTN NameSize;
- UINTN FileInfoSize;
- EFI_FILE_INFO *FileInfo;
- UINTN OriginalBufferSize;
+ UINTN NameSize;
+ UINTN FileInfoSize;
+ EFI_FILE_INFO *FileInfo;
+ UINTN OriginalBufferSize;
if (BlobType == KernelBlobTypeMax) {
//
@@ -282,7 +280,7 @@ ConvertKernelBlobTypeToFileInfo (
FileSize = KernelBlobTypeMax;
Attribute = EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY;
} else {
- CONST KERNEL_BLOB *Blob;
+ CONST KERNEL_BLOB *Blob;
Blob = &mKernelBlob[BlobType];
Name = Blob->Name;
@@ -290,7 +288,7 @@ ConvertKernelBlobTypeToFileInfo (
Attribute = EFI_FILE_READ_ONLY;
}
- NameSize = (StrLen(Name) + 1) * 2;
+ NameSize = (StrLen (Name) + 1) * 2;
FileInfoSize = OFFSET_OF (EFI_FILE_INFO, FileName) + NameSize;
ASSERT (FileInfoSize >= sizeof *FileInfo);
@@ -306,15 +304,14 @@ ConvertKernelBlobTypeToFileInfo (
FileInfo->PhysicalSize = FileSize;
FileInfo->Attribute = Attribute;
- CopyMem (&FileInfo->CreateTime, &mInitTime, sizeof mInitTime);
- CopyMem (&FileInfo->LastAccessTime, &mInitTime, sizeof mInitTime);
+ CopyMem (&FileInfo->CreateTime, &mInitTime, sizeof mInitTime);
+ CopyMem (&FileInfo->LastAccessTime, &mInitTime, sizeof mInitTime);
CopyMem (&FileInfo->ModificationTime, &mInitTime, sizeof mInitTime);
- CopyMem (FileInfo->FileName, Name, NameSize);
+ CopyMem (FileInfo->FileName, Name, NameSize);
return EFI_SUCCESS;
}
-
/**
Reads data from a file, or continues scanning a directory.
@@ -353,14 +350,14 @@ STATIC
EFI_STATUS
EFIAPI
StubFileRead (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- STUB_FILE *StubFile;
- CONST KERNEL_BLOB *Blob;
- UINT64 Left;
+ STUB_FILE *StubFile;
+ CONST KERNEL_BLOB *Blob;
+ UINT64 Left;
StubFile = STUB_FILE_FROM_FILE (This);
@@ -368,7 +365,7 @@ StubFileRead (
// Scanning the root directory?
//
if (StubFile->BlobType == KernelBlobTypeMax) {
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (StubFile->Position == KernelBlobTypeMax) {
//
@@ -381,7 +378,8 @@ StubFileRead (
Status = ConvertKernelBlobTypeToFileInfo (
(KERNEL_BLOB_TYPE)StubFile->Position,
BufferSize,
- Buffer);
+ Buffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -402,14 +400,15 @@ StubFileRead (
if (*BufferSize > Left) {
*BufferSize = (UINTN)Left;
}
+
if (Blob->Data != NULL) {
CopyMem (Buffer, Blob->Data + StubFile->Position, *BufferSize);
}
+
StubFile->Position += *BufferSize;
return EFI_SUCCESS;
}
-
/**
Writes data to a file.
@@ -437,12 +436,12 @@ STATIC
EFI_STATUS
EFIAPI
StubFileWrite (
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- STUB_FILE *StubFile;
+ STUB_FILE *StubFile;
StubFile = STUB_FILE_FROM_FILE (This);
return (StubFile->BlobType == KernelBlobTypeMax) ?
@@ -450,7 +449,6 @@ StubFileWrite (
EFI_WRITE_PROTECTED;
}
-
/**
Returns a file's current position.
@@ -469,11 +467,11 @@ STATIC
EFI_STATUS
EFIAPI
StubFileGetPosition (
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
- STUB_FILE *StubFile;
+ STUB_FILE *StubFile;
StubFile = STUB_FILE_FROM_FILE (This);
if (StubFile->BlobType == KernelBlobTypeMax) {
@@ -484,7 +482,6 @@ StubFileGetPosition (
return EFI_SUCCESS;
}
-
/**
Sets a file's current position.
@@ -505,12 +502,12 @@ STATIC
EFI_STATUS
EFIAPI
StubFileSetPosition (
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
- STUB_FILE *StubFile;
- KERNEL_BLOB *Blob;
+ STUB_FILE *StubFile;
+ KERNEL_BLOB *Blob;
StubFile = STUB_FILE_FROM_FILE (This);
@@ -522,6 +519,7 @@ StubFileSetPosition (
StubFile->Position = 0;
return EFI_SUCCESS;
}
+
return EFI_UNSUPPORTED;
}
@@ -540,10 +538,10 @@ StubFileSetPosition (
//
StubFile->Position = Position;
}
+
return EFI_SUCCESS;
}
-
/**
Returns information about a file.
@@ -586,26 +584,29 @@ STATIC
EFI_STATUS
EFIAPI
StubFileGetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- CONST STUB_FILE *StubFile;
- UINTN OriginalBufferSize;
+ CONST STUB_FILE *StubFile;
+ UINTN OriginalBufferSize;
StubFile = STUB_FILE_FROM_FILE (This);
if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
- return ConvertKernelBlobTypeToFileInfo (StubFile->BlobType, BufferSize,
- Buffer);
+ return ConvertKernelBlobTypeToFileInfo (
+ StubFile->BlobType,
+ BufferSize,
+ Buffer
+ );
}
OriginalBufferSize = *BufferSize;
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
- EFI_FILE_SYSTEM_INFO *FileSystemInfo;
+ EFI_FILE_SYSTEM_INFO *FileSystemInfo;
*BufferSize = sizeof *FileSystemInfo;
if (OriginalBufferSize < *BufferSize) {
@@ -624,14 +625,14 @@ StubFileGetInfo (
}
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
- EFI_FILE_SYSTEM_VOLUME_LABEL *FileSystemVolumeLabel;
+ EFI_FILE_SYSTEM_VOLUME_LABEL *FileSystemVolumeLabel;
*BufferSize = sizeof *FileSystemVolumeLabel;
if (OriginalBufferSize < *BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
- FileSystemVolumeLabel = (EFI_FILE_SYSTEM_VOLUME_LABEL *)Buffer;
+ FileSystemVolumeLabel = (EFI_FILE_SYSTEM_VOLUME_LABEL *)Buffer;
FileSystemVolumeLabel->VolumeLabel[0] = L'\0';
return EFI_SUCCESS;
@@ -640,7 +641,6 @@ StubFileGetInfo (
return EFI_UNSUPPORTED;
}
-
/**
Sets information about a file.
@@ -686,16 +686,15 @@ STATIC
EFI_STATUS
EFIAPI
StubFileSetInfo (
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
return EFI_WRITE_PROTECTED;
}
-
/**
Flushes all modified data associated with a file to a device.
@@ -714,7 +713,7 @@ STATIC
EFI_STATUS
EFIAPI
StubFileFlush (
- IN EFI_FILE_PROTOCOL *This
+ IN EFI_FILE_PROTOCOL *This
)
{
return EFI_WRITE_PROTECTED;
@@ -723,7 +722,7 @@ StubFileFlush (
//
// External definition of the file protocol template.
//
-STATIC CONST EFI_FILE_PROTOCOL mEfiFileProtocolTemplate = {
+STATIC CONST EFI_FILE_PROTOCOL mEfiFileProtocolTemplate = {
EFI_FILE_PROTOCOL_REVISION, // revision 1
StubFileOpen,
StubFileClose,
@@ -745,16 +744,16 @@ STATIC
EFI_STATUS
EFIAPI
StubFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- CONST STUB_FILE *StubFile;
- UINTN BlobType;
- STUB_FILE *NewStubFile;
+ CONST STUB_FILE *StubFile;
+ UINTN BlobType;
+ STUB_FILE *NewStubFile;
//
// We're read-only.
@@ -787,6 +786,7 @@ StubFileOpen (
break;
}
}
+
if (BlobType == KernelBlobTypeMax) {
return EFI_NOT_FOUND;
}
@@ -802,14 +802,16 @@ StubFileOpen (
NewStubFile->Signature = STUB_FILE_SIG;
NewStubFile->BlobType = (KERNEL_BLOB_TYPE)BlobType;
NewStubFile->Position = 0;
- CopyMem (&NewStubFile->File, &mEfiFileProtocolTemplate,
- sizeof mEfiFileProtocolTemplate);
+ CopyMem (
+ &NewStubFile->File,
+ &mEfiFileProtocolTemplate,
+ sizeof mEfiFileProtocolTemplate
+ );
*NewHandle = &NewStubFile->File;
return EFI_SUCCESS;
}
-
//
// Protocol member functions for SimpleFileSystem.
//
@@ -841,11 +843,11 @@ STATIC
EFI_STATUS
EFIAPI
StubFileSystemOpenVolume (
- IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **Root
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **Root
)
{
- STUB_FILE *StubFile;
+ STUB_FILE *StubFile;
StubFile = AllocatePool (sizeof *StubFile);
if (StubFile == NULL) {
@@ -855,14 +857,17 @@ StubFileSystemOpenVolume (
StubFile->Signature = STUB_FILE_SIG;
StubFile->BlobType = KernelBlobTypeMax;
StubFile->Position = 0;
- CopyMem (&StubFile->File, &mEfiFileProtocolTemplate,
- sizeof mEfiFileProtocolTemplate);
+ CopyMem (
+ &StubFile->File,
+ &mEfiFileProtocolTemplate,
+ sizeof mEfiFileProtocolTemplate
+ );
*Root = &StubFile->File;
return EFI_SUCCESS;
}
-STATIC CONST EFI_SIMPLE_FILE_SYSTEM_PROTOCOL mFileSystem = {
+STATIC CONST EFI_SIMPLE_FILE_SYSTEM_PROTOCOL mFileSystem = {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
StubFileSystemOpenVolume
};
@@ -871,14 +876,14 @@ STATIC
EFI_STATUS
EFIAPI
InitrdLoadFile2 (
- IN EFI_LOAD_FILE2_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN BOOLEAN BootPolicy,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer OPTIONAL
+ IN EFI_LOAD_FILE2_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer OPTIONAL
)
{
- CONST KERNEL_BLOB *InitrdBlob = &mKernelBlob[KernelBlobTypeInitrd];
+ CONST KERNEL_BLOB *InitrdBlob = &mKernelBlob[KernelBlobTypeInitrd];
ASSERT (InitrdBlob->Size > 0);
@@ -886,16 +891,17 @@ InitrdLoadFile2 (
return EFI_UNSUPPORTED;
}
- if (BufferSize == NULL || !IsDevicePathValid (FilePath, 0)) {
+ if ((BufferSize == NULL) || !IsDevicePathValid (FilePath, 0)) {
return EFI_INVALID_PARAMETER;
}
- if (FilePath->Type != END_DEVICE_PATH_TYPE ||
- FilePath->SubType != END_ENTIRE_DEVICE_PATH_SUBTYPE) {
+ if ((FilePath->Type != END_DEVICE_PATH_TYPE) ||
+ (FilePath->SubType != END_ENTIRE_DEVICE_PATH_SUBTYPE))
+ {
return EFI_NOT_FOUND;
}
- if (Buffer == NULL || *BufferSize < InitrdBlob->Size) {
+ if ((Buffer == NULL) || (*BufferSize < InitrdBlob->Size)) {
*BufferSize = InitrdBlob->Size;
return EFI_BUFFER_TOO_SMALL;
}
@@ -906,7 +912,7 @@ InitrdLoadFile2 (
return EFI_SUCCESS;
}
-STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 = {
+STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 = {
InitrdLoadFile2,
};
@@ -929,12 +935,12 @@ STATIC CONST EFI_LOAD_FILE2_PROTOCOL mInitrdLoadFile2 = {
STATIC
EFI_STATUS
FetchBlob (
- IN OUT KERNEL_BLOB *Blob
+ IN OUT KERNEL_BLOB *Blob
)
{
- UINT32 Left;
- UINTN Idx;
- UINT8 *ChunkData;
+ UINT32 Left;
+ UINTN Idx;
+ UINT8 *ChunkData;
//
// Read blob size.
@@ -944,10 +950,12 @@ FetchBlob (
if (Blob->FwCfgItem[Idx].SizeKey == 0) {
break;
}
+
QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].SizeKey);
Blob->FwCfgItem[Idx].Size = QemuFwCfgRead32 ();
- Blob->Size += Blob->FwCfgItem[Idx].Size;
+ Blob->Size += Blob->FwCfgItem[Idx].Size;
}
+
if (Blob->Size == 0) {
return EFI_SUCCESS;
}
@@ -957,30 +965,47 @@ FetchBlob (
//
Blob->Data = AllocatePool (Blob->Size);
if (Blob->Data == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: failed to allocate %Ld bytes for \"%s\"\n",
- __FUNCTION__, (INT64)Blob->Size, Blob->Name));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: failed to allocate %Ld bytes for \"%s\"\n",
+ __FUNCTION__,
+ (INT64)Blob->Size,
+ Blob->Name
+ ));
return EFI_OUT_OF_RESOURCES;
}
- DEBUG ((DEBUG_INFO, "%a: loading %Ld bytes for \"%s\"\n", __FUNCTION__,
- (INT64)Blob->Size, Blob->Name));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: loading %Ld bytes for \"%s\"\n",
+ __FUNCTION__,
+ (INT64)Blob->Size,
+ Blob->Name
+ ));
ChunkData = Blob->Data;
for (Idx = 0; Idx < ARRAY_SIZE (Blob->FwCfgItem); Idx++) {
if (Blob->FwCfgItem[Idx].DataKey == 0) {
break;
}
+
QemuFwCfgSelectItem (Blob->FwCfgItem[Idx].DataKey);
Left = Blob->FwCfgItem[Idx].Size;
while (Left > 0) {
- UINT32 Chunk;
+ UINT32 Chunk;
Chunk = (Left < SIZE_1MB) ? Left : SIZE_1MB;
QemuFwCfgReadBytes (Chunk, ChunkData + Blob->FwCfgItem[Idx].Size - Left);
Left -= Chunk;
- DEBUG ((DEBUG_VERBOSE, "%a: %Ld bytes remaining for \"%s\" (%d)\n",
- __FUNCTION__, (INT64)Left, Blob->Name, (INT32)Idx));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: %Ld bytes remaining for \"%s\" (%d)\n",
+ __FUNCTION__,
+ (INT64)Left,
+ Blob->Name,
+ (INT32)Idx
+ ));
}
ChunkData += Blob->FwCfgItem[Idx].Size;
@@ -989,7 +1014,6 @@ FetchBlob (
return EFI_SUCCESS;
}
-
//
// The entry point of the feature.
//
@@ -1010,16 +1034,16 @@ FetchBlob (
EFI_STATUS
EFIAPI
QemuKernelLoaderFsDxeEntrypoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINTN BlobType;
- KERNEL_BLOB *CurrentBlob;
- KERNEL_BLOB *KernelBlob;
- EFI_STATUS Status;
- EFI_HANDLE FileSystemHandle;
- EFI_HANDLE InitrdLoadFile2Handle;
+ UINTN BlobType;
+ KERNEL_BLOB *CurrentBlob;
+ KERNEL_BLOB *KernelBlob;
+ EFI_STATUS Status;
+ EFI_HANDLE FileSystemHandle;
+ EFI_HANDLE InitrdLoadFile2Handle;
if (!QemuFwCfgIsAvailable ()) {
return EFI_NOT_FOUND;
@@ -1036,10 +1060,11 @@ QemuKernelLoaderFsDxeEntrypoint (
//
for (BlobType = 0; BlobType < KernelBlobTypeMax; ++BlobType) {
CurrentBlob = &mKernelBlob[BlobType];
- Status = FetchBlob (CurrentBlob);
+ Status = FetchBlob (CurrentBlob);
if (EFI_ERROR (Status)) {
goto FreeBlobs;
}
+
Status = VerifyBlob (
CurrentBlob->Name,
CurrentBlob->Data,
@@ -1048,9 +1073,11 @@ QemuKernelLoaderFsDxeEntrypoint (
if (EFI_ERROR (Status)) {
goto FreeBlobs;
}
+
mTotalBlobBytes += CurrentBlob->Size;
}
- KernelBlob = &mKernelBlob[KernelBlobTypeKernel];
+
+ KernelBlob = &mKernelBlob[KernelBlobTypeKernel];
if (KernelBlob->Data == NULL) {
Status = EFI_NOT_FOUND;
@@ -1062,25 +1089,41 @@ QemuKernelLoaderFsDxeEntrypoint (
// it, plus a custom SimpleFileSystem protocol on it.
//
FileSystemHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&FileSystemHandle,
- &gEfiDevicePathProtocolGuid, &mFileSystemDevicePath,
- &gEfiSimpleFileSystemProtocolGuid, &mFileSystem,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &FileSystemHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mFileSystemDevicePath,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &mFileSystem,
+ NULL
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: InstallMultipleProtocolInterfaces(): %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: InstallMultipleProtocolInterfaces(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
goto FreeBlobs;
}
if (KernelBlob[KernelBlobTypeInitrd].Size > 0) {
InitrdLoadFile2Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&InitrdLoadFile2Handle,
- &gEfiDevicePathProtocolGuid, &mInitrdDevicePath,
- &gEfiLoadFile2ProtocolGuid, &mInitrdLoadFile2,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &InitrdLoadFile2Handle,
+ &gEfiDevicePathProtocolGuid,
+ &mInitrdDevicePath,
+ &gEfiLoadFile2ProtocolGuid,
+ &mInitrdLoadFile2,
+ NULL
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: InstallMultipleProtocolInterfaces(): %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: InstallMultipleProtocolInterfaces(): %r\n",
+ __FUNCTION__,
+ Status
+ ));
goto UninstallFileSystemHandle;
}
}
@@ -1088,10 +1131,14 @@ QemuKernelLoaderFsDxeEntrypoint (
return EFI_SUCCESS;
UninstallFileSystemHandle:
- Status = gBS->UninstallMultipleProtocolInterfaces (FileSystemHandle,
- &gEfiDevicePathProtocolGuid, &mFileSystemDevicePath,
- &gEfiSimpleFileSystemProtocolGuid, &mFileSystem,
- NULL);
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ FileSystemHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mFileSystemDevicePath,
+ &gEfiSimpleFileSystemProtocolGuid,
+ &mFileSystem,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
FreeBlobs: