ARM Packages: Fixed line endings
This large code change only modifies the line endings to be CRLF to be compliant with the EDK2 coding convention document. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14088 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,46 +1,46 @@
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI (i.e. PEI part of SEC)
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PI_PEI_H_
|
||||
#define _PI_PEI_H_
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrePiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiDecompressLib.h>
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
|
||||
|
||||
#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
|
||||
#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
|
||||
#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
|
||||
#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)
|
||||
|
||||
//
|
||||
// Get the data and data size field of GUID
|
||||
//
|
||||
#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
|
||||
#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
|
||||
|
||||
#endif
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI (i.e. PEI part of SEC)
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PI_PEI_H_
|
||||
#define _PI_PEI_H_
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrePiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiDecompressLib.h>
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
|
||||
#include <Guid/MemoryAllocationHob.h>
|
||||
|
||||
|
||||
#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
|
||||
#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
|
||||
#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
|
||||
#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)
|
||||
|
||||
//
|
||||
// Get the data and data size field of GUID
|
||||
//
|
||||
#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
|
||||
#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
|
||||
|
||||
#endif
|
||||
|
@@ -1,226 +1,226 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
|
||||
//
|
||||
// Hack to work in NT32
|
||||
//
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
SecWinNtPeiLoadFile (
|
||||
IN VOID *Pe32Data,
|
||||
IN EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
IN UINT64 *ImageSize,
|
||||
IN EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadPeCoffImage (
|
||||
IN VOID *PeCoffImage,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
OUT UINT64 *ImageSize,
|
||||
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
VOID *Buffer;
|
||||
|
||||
ZeroMem (&ImageContext, sizeof (ImageContext));
|
||||
|
||||
ImageContext.Handle = PeCoffImage;
|
||||
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||
|
||||
Status = PeCoffLoaderGetImageInfo (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
//
|
||||
// Allocate Memory for the image
|
||||
//
|
||||
Buffer = AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
|
||||
ASSERT (Buffer != 0);
|
||||
|
||||
|
||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
|
||||
//
|
||||
// Load the image to our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Relocate the image in our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
*ImageAddress = ImageContext.ImageAddress;
|
||||
*ImageSize = ImageContext.ImageSize;
|
||||
*EntryPoint = ImageContext.EntryPoint;
|
||||
|
||||
//
|
||||
// Flush not needed for all architectures. We could have a processor specific
|
||||
// function in this library that does the no-op if needed.
|
||||
//
|
||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)*ImageAddress, (UINTN)*ImageSize);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *DXE_CORE_ENTRY_POINT) (
|
||||
IN VOID *HobStart
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFfsFile (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *PeCoffImage;
|
||||
EFI_PHYSICAL_ADDRESS ImageAddress;
|
||||
UINT64 ImageSize;
|
||||
EFI_PHYSICAL_ADDRESS EntryPoint;
|
||||
VOID *BaseOfStack;
|
||||
VOID *TopOfStack;
|
||||
VOID *Hob;
|
||||
EFI_FV_FILE_INFO FvFileInfo;
|
||||
|
||||
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Extract the DxeCore GUID file name.
|
||||
//
|
||||
Status = FfsGetFileInfo (FileHandle, &FvFileInfo);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);
|
||||
|
||||
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));
|
||||
|
||||
Hob = GetHobList ();
|
||||
if (StackSize == 0) {
|
||||
// User the current stack
|
||||
|
||||
((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);
|
||||
} else {
|
||||
|
||||
//
|
||||
// Allocate 128KB for the Stack
|
||||
//
|
||||
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (StackSize));
|
||||
ASSERT (BaseOfStack != NULL);
|
||||
|
||||
//
|
||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||
// for safety.
|
||||
//
|
||||
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||
|
||||
//
|
||||
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
|
||||
//
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);
|
||||
|
||||
SwitchStack (
|
||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)EntryPoint,
|
||||
Hob,
|
||||
NULL,
|
||||
TopOfStack
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Should never get here as DXE Core does not return
|
||||
DEBUG ((EFI_D_ERROR, "DxeCore returned\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFv (
|
||||
IN UINTN *FvInstance, OPTIONAL
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle = NULL;
|
||||
|
||||
if (FvInstance != NULL) {
|
||||
//
|
||||
// Caller passed in a specific FV to try, so only try that one
|
||||
//
|
||||
Status = FfsFindNextVolume (*FvInstance, &VolumeHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
|
||||
}
|
||||
} else {
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, &VolumeHandle, &FileHandle);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return LoadDxeCoreFromFfsFile (FileHandle, StackSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DecompressFirstFv (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle;
|
||||
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &VolumeHandle, &FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsProcessFvFile (FileHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
|
||||
//
|
||||
// Hack to work in NT32
|
||||
//
|
||||
EFI_STATUS
|
||||
|
||||
EFIAPI
|
||||
|
||||
SecWinNtPeiLoadFile (
|
||||
IN VOID *Pe32Data,
|
||||
IN EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
IN UINT64 *ImageSize,
|
||||
IN EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadPeCoffImage (
|
||||
IN VOID *PeCoffImage,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
|
||||
OUT UINT64 *ImageSize,
|
||||
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
VOID *Buffer;
|
||||
|
||||
ZeroMem (&ImageContext, sizeof (ImageContext));
|
||||
|
||||
ImageContext.Handle = PeCoffImage;
|
||||
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||
|
||||
Status = PeCoffLoaderGetImageInfo (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
//
|
||||
// Allocate Memory for the image
|
||||
//
|
||||
Buffer = AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
|
||||
ASSERT (Buffer != 0);
|
||||
|
||||
|
||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
|
||||
//
|
||||
// Load the image to our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Relocate the image in our new buffer
|
||||
//
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
*ImageAddress = ImageContext.ImageAddress;
|
||||
*ImageSize = ImageContext.ImageSize;
|
||||
*EntryPoint = ImageContext.EntryPoint;
|
||||
|
||||
//
|
||||
// Flush not needed for all architectures. We could have a processor specific
|
||||
// function in this library that does the no-op if needed.
|
||||
//
|
||||
InvalidateInstructionCacheRange ((VOID *)(UINTN)*ImageAddress, (UINTN)*ImageSize);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *DXE_CORE_ENTRY_POINT) (
|
||||
IN VOID *HobStart
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFfsFile (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *PeCoffImage;
|
||||
EFI_PHYSICAL_ADDRESS ImageAddress;
|
||||
UINT64 ImageSize;
|
||||
EFI_PHYSICAL_ADDRESS EntryPoint;
|
||||
VOID *BaseOfStack;
|
||||
VOID *TopOfStack;
|
||||
VOID *Hob;
|
||||
EFI_FV_FILE_INFO FvFileInfo;
|
||||
|
||||
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Extract the DxeCore GUID file name.
|
||||
//
|
||||
Status = FfsGetFileInfo (FileHandle, &FvFileInfo);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);
|
||||
|
||||
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));
|
||||
|
||||
Hob = GetHobList ();
|
||||
if (StackSize == 0) {
|
||||
// User the current stack
|
||||
|
||||
((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);
|
||||
} else {
|
||||
|
||||
//
|
||||
// Allocate 128KB for the Stack
|
||||
//
|
||||
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (StackSize));
|
||||
ASSERT (BaseOfStack != NULL);
|
||||
|
||||
//
|
||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||
// for safety.
|
||||
//
|
||||
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||
|
||||
//
|
||||
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
|
||||
//
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);
|
||||
|
||||
SwitchStack (
|
||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)EntryPoint,
|
||||
Hob,
|
||||
NULL,
|
||||
TopOfStack
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Should never get here as DXE Core does not return
|
||||
DEBUG ((EFI_D_ERROR, "DxeCore returned\n"));
|
||||
ASSERT (FALSE);
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LoadDxeCoreFromFv (
|
||||
IN UINTN *FvInstance, OPTIONAL
|
||||
IN UINTN StackSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle = NULL;
|
||||
|
||||
if (FvInstance != NULL) {
|
||||
//
|
||||
// Caller passed in a specific FV to try, so only try that one
|
||||
//
|
||||
Status = FfsFindNextVolume (*FvInstance, &VolumeHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandle, &FileHandle);
|
||||
}
|
||||
} else {
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, &VolumeHandle, &FileHandle);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return LoadDxeCoreFromFfsFile (FileHandle, StackSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DecompressFirstFv (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PEI_FV_HANDLE VolumeHandle;
|
||||
EFI_PEI_FILE_HANDLE FileHandle;
|
||||
|
||||
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &VolumeHandle, &FileHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FfsProcessFvFile (FileHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,327 +1,327 @@
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include <Protocol/StatusCode.h>
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
#include <Guid/StatusCodeDataTypeDebug.h>
|
||||
#include <FrameworkPei.h>
|
||||
|
||||
#define EFI_STATUS_CODE_DATA_MAX_SIZE 200
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS_CODE_PROTOCOL gStatusCode = {
|
||||
(EFI_REPORT_STATUS_CODE)SerialReportStatusCode
|
||||
};
|
||||
|
||||
/**
|
||||
Extracts ASSERT() information from a status code structure.
|
||||
|
||||
Converts the status code specified by CodeType, Value, and Data to the ASSERT()
|
||||
arguments specified by Filename, Description, and LineNumber. If CodeType is
|
||||
an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
|
||||
Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
|
||||
Filename, Description, and LineNumber from the optional data area of the
|
||||
status code buffer specified by Data. The optional data area of Data contains
|
||||
a Null-terminated ASCII string for the FileName, followed by a Null-terminated
|
||||
ASCII string for the Description, followed by a 32-bit LineNumber. If the
|
||||
ASSERT() information could be extracted from Data, then return TRUE.
|
||||
Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If Filename is NULL, then ASSERT().
|
||||
If Description is NULL, then ASSERT().
|
||||
If LineNumber is NULL, then ASSERT().
|
||||
|
||||
@param CodeType The type of status code being converted.
|
||||
@param Value The status code value being converted.
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param Filename Pointer to the source file name that generated the ASSERT().
|
||||
@param Description Pointer to the description of the ASSERT().
|
||||
@param LineNumber Pointer to source line number that generated the ASSERT().
|
||||
|
||||
@retval TRUE The status code specified by CodeType, Value, and Data was
|
||||
converted ASSERT() arguments specified by Filename, Description,
|
||||
and LineNumber.
|
||||
@retval FALSE The status code specified by CodeType, Value, and Data could
|
||||
not be converted to ASSERT() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractAssertInfo (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT CHAR8 **Filename,
|
||||
OUT CHAR8 **Description,
|
||||
OUT UINT32 *LineNumber
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_ASSERT_DATA *AssertData;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (Filename != NULL);
|
||||
ASSERT (Description != NULL);
|
||||
ASSERT (LineNumber != NULL);
|
||||
|
||||
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
|
||||
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
|
||||
((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
|
||||
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
|
||||
*Filename = (CHAR8 *)(AssertData + 1);
|
||||
*Description = *Filename + AsciiStrLen (*Filename) + 1;
|
||||
*LineNumber = AssertData->LineNumber;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extracts DEBUG() information from a status code structure.
|
||||
|
||||
Converts the status code specified by Data to the DEBUG() arguments specified
|
||||
by ErrorLevel, Marker, and Format. If type GUID in Data is
|
||||
EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
|
||||
Format from the optional data area of the status code buffer specified by Data.
|
||||
The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
|
||||
which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
|
||||
the Format. If the DEBUG() information could be extracted from Data, then
|
||||
return TRUE. Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If ErrorLevel is NULL, then ASSERT().
|
||||
If Marker is NULL, then ASSERT().
|
||||
If Format is NULL, then ASSERT().
|
||||
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param ErrorLevel Pointer to error level mask for a debug message.
|
||||
@param Marker Pointer to the variable argument list associated with Format.
|
||||
@param Format Pointer to a Null-terminated ASCII format string of a
|
||||
debug message.
|
||||
|
||||
@retval TRUE The status code specified by Data was converted DEBUG() arguments
|
||||
specified by ErrorLevel, Marker, and Format.
|
||||
@retval FALSE The status code specified by Data could not be converted to
|
||||
DEBUG() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractDebugInfo (
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT UINT32 *ErrorLevel,
|
||||
OUT BASE_LIST *Marker,
|
||||
OUT CHAR8 **Format
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (ErrorLevel != NULL);
|
||||
ASSERT (Marker != NULL);
|
||||
ASSERT (Format != NULL);
|
||||
|
||||
//
|
||||
// If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
|
||||
//
|
||||
if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the debug information from the status code record
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
|
||||
|
||||
*ErrorLevel = DebugInfo->ErrorLevel;
|
||||
|
||||
//
|
||||
// The first 12 * UINTN bytes of the string are really an
|
||||
// argument stack to support varargs on the Format string.
|
||||
//
|
||||
*Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
)
|
||||
{
|
||||
CHAR8 *Filename;
|
||||
CHAR8 *Description;
|
||||
CHAR8 *Format;
|
||||
CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
|
||||
UINT32 ErrorLevel;
|
||||
UINT32 LineNumber;
|
||||
UINTN CharCount;
|
||||
BASE_LIST Marker;
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
Buffer[0] = '\0';
|
||||
|
||||
|
||||
if (Data != NULL &&
|
||||
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
|
||||
|
||||
//
|
||||
// Print ASSERT() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"\n\rASSERT!: %a (%d): %a\n\r",
|
||||
Filename,
|
||||
LineNumber,
|
||||
Description
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Callout to standard output.
|
||||
//
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (Data != NULL &&
|
||||
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
||||
|
||||
//
|
||||
// Print DEBUG() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiBSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
Format,
|
||||
Marker
|
||||
);
|
||||
|
||||
} else if (Data != NULL &&
|
||||
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
|
||||
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
|
||||
|
||||
//
|
||||
// Print specific data into output buffer.
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
|
||||
Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
Format = (CHAR8 *) (((UINT64 *) (DebugInfo + 1)) + 12);
|
||||
|
||||
CharCount = AsciiBSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
|
||||
//
|
||||
// Print ERROR information into output buffer.
|
||||
//
|
||||
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"ERROR: C%x:V%x I%x",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
//
|
||||
// Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
|
||||
//
|
||||
if (CallerId != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %g",
|
||||
CallerId
|
||||
);
|
||||
}
|
||||
|
||||
if (Data != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %x",
|
||||
Data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
"\n\r"
|
||||
);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"PROGRESS CODE: V%x I%x\n\r",
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
} else {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"Undefined: C%x:V%x I%x\n\r",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AddDxeCoreReportStatusCodeCallback (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BuildGuidDataHob (&gEfiStatusCodeRuntimeProtocolGuid, &gStatusCode, sizeof(VOID *));
|
||||
}
|
||||
|
||||
/** @file
|
||||
Library that helps implement monolithic PEI
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PrePi.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include <Protocol/StatusCode.h>
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
#include <Guid/StatusCodeDataTypeDebug.h>
|
||||
#include <FrameworkPei.h>
|
||||
|
||||
#define EFI_STATUS_CODE_DATA_MAX_SIZE 200
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
EFI_STATUS_CODE_PROTOCOL gStatusCode = {
|
||||
(EFI_REPORT_STATUS_CODE)SerialReportStatusCode
|
||||
};
|
||||
|
||||
/**
|
||||
Extracts ASSERT() information from a status code structure.
|
||||
|
||||
Converts the status code specified by CodeType, Value, and Data to the ASSERT()
|
||||
arguments specified by Filename, Description, and LineNumber. If CodeType is
|
||||
an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
|
||||
Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
|
||||
Filename, Description, and LineNumber from the optional data area of the
|
||||
status code buffer specified by Data. The optional data area of Data contains
|
||||
a Null-terminated ASCII string for the FileName, followed by a Null-terminated
|
||||
ASCII string for the Description, followed by a 32-bit LineNumber. If the
|
||||
ASSERT() information could be extracted from Data, then return TRUE.
|
||||
Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If Filename is NULL, then ASSERT().
|
||||
If Description is NULL, then ASSERT().
|
||||
If LineNumber is NULL, then ASSERT().
|
||||
|
||||
@param CodeType The type of status code being converted.
|
||||
@param Value The status code value being converted.
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param Filename Pointer to the source file name that generated the ASSERT().
|
||||
@param Description Pointer to the description of the ASSERT().
|
||||
@param LineNumber Pointer to source line number that generated the ASSERT().
|
||||
|
||||
@retval TRUE The status code specified by CodeType, Value, and Data was
|
||||
converted ASSERT() arguments specified by Filename, Description,
|
||||
and LineNumber.
|
||||
@retval FALSE The status code specified by CodeType, Value, and Data could
|
||||
not be converted to ASSERT() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractAssertInfo (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT CHAR8 **Filename,
|
||||
OUT CHAR8 **Description,
|
||||
OUT UINT32 *LineNumber
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_ASSERT_DATA *AssertData;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (Filename != NULL);
|
||||
ASSERT (Description != NULL);
|
||||
ASSERT (LineNumber != NULL);
|
||||
|
||||
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
|
||||
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
|
||||
((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
|
||||
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
|
||||
*Filename = (CHAR8 *)(AssertData + 1);
|
||||
*Description = *Filename + AsciiStrLen (*Filename) + 1;
|
||||
*LineNumber = AssertData->LineNumber;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extracts DEBUG() information from a status code structure.
|
||||
|
||||
Converts the status code specified by Data to the DEBUG() arguments specified
|
||||
by ErrorLevel, Marker, and Format. If type GUID in Data is
|
||||
EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
|
||||
Format from the optional data area of the status code buffer specified by Data.
|
||||
The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
|
||||
which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
|
||||
the Format. If the DEBUG() information could be extracted from Data, then
|
||||
return TRUE. Otherwise, FALSE is returned.
|
||||
|
||||
If Data is NULL, then ASSERT().
|
||||
If ErrorLevel is NULL, then ASSERT().
|
||||
If Marker is NULL, then ASSERT().
|
||||
If Format is NULL, then ASSERT().
|
||||
|
||||
@param Data Pointer to status code data buffer.
|
||||
@param ErrorLevel Pointer to error level mask for a debug message.
|
||||
@param Marker Pointer to the variable argument list associated with Format.
|
||||
@param Format Pointer to a Null-terminated ASCII format string of a
|
||||
debug message.
|
||||
|
||||
@retval TRUE The status code specified by Data was converted DEBUG() arguments
|
||||
specified by ErrorLevel, Marker, and Format.
|
||||
@retval FALSE The status code specified by Data could not be converted to
|
||||
DEBUG() arguments.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ReportStatusCodeExtractDebugInfo (
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data,
|
||||
OUT UINT32 *ErrorLevel,
|
||||
OUT BASE_LIST *Marker,
|
||||
OUT CHAR8 **Format
|
||||
)
|
||||
{
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
ASSERT (Data != NULL);
|
||||
ASSERT (ErrorLevel != NULL);
|
||||
ASSERT (Marker != NULL);
|
||||
ASSERT (Format != NULL);
|
||||
|
||||
//
|
||||
// If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
|
||||
//
|
||||
if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the debug information from the status code record
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
|
||||
|
||||
*ErrorLevel = DebugInfo->ErrorLevel;
|
||||
|
||||
//
|
||||
// The first 12 * UINTN bytes of the string are really an
|
||||
// argument stack to support varargs on the Format string.
|
||||
//
|
||||
*Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SerialReportStatusCode (
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
)
|
||||
{
|
||||
CHAR8 *Filename;
|
||||
CHAR8 *Description;
|
||||
CHAR8 *Format;
|
||||
CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
|
||||
UINT32 ErrorLevel;
|
||||
UINT32 LineNumber;
|
||||
UINTN CharCount;
|
||||
BASE_LIST Marker;
|
||||
EFI_DEBUG_INFO *DebugInfo;
|
||||
|
||||
Buffer[0] = '\0';
|
||||
|
||||
|
||||
if (Data != NULL &&
|
||||
ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
|
||||
|
||||
//
|
||||
// Print ASSERT() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"\n\rASSERT!: %a (%d): %a\n\r",
|
||||
Filename,
|
||||
LineNumber,
|
||||
Description
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Callout to standard output.
|
||||
//
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (Data != NULL &&
|
||||
ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
||||
|
||||
//
|
||||
// Print DEBUG() information into output buffer.
|
||||
//
|
||||
CharCount = AsciiBSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
Format,
|
||||
Marker
|
||||
);
|
||||
|
||||
} else if (Data != NULL &&
|
||||
CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
|
||||
(CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
|
||||
|
||||
//
|
||||
// Print specific data into output buffer.
|
||||
//
|
||||
DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
|
||||
Marker = (BASE_LIST) (DebugInfo + 1);
|
||||
Format = (CHAR8 *) (((UINT64 *) (DebugInfo + 1)) + 12);
|
||||
|
||||
CharCount = AsciiBSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
|
||||
//
|
||||
// Print ERROR information into output buffer.
|
||||
//
|
||||
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"ERROR: C%x:V%x I%x",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
//
|
||||
// Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
|
||||
//
|
||||
if (CallerId != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %g",
|
||||
CallerId
|
||||
);
|
||||
}
|
||||
|
||||
if (Data != NULL) {
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
" %x",
|
||||
Data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CharCount += AsciiSPrint (
|
||||
&Buffer[CharCount - 1],
|
||||
(EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
|
||||
"\n\r"
|
||||
);
|
||||
|
||||
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"PROGRESS CODE: V%x I%x\n\r",
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
} else {
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
EFI_STATUS_CODE_DATA_MAX_SIZE,
|
||||
"Undefined: C%x:V%x I%x\n\r",
|
||||
CodeType,
|
||||
Value,
|
||||
Instance
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
AddDxeCoreReportStatusCodeCallback (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BuildGuidDataHob (&gEfiStatusCodeRuntimeProtocolGuid, &gStatusCode, sizeof(VOID *));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user