Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdvLoggerPkg: Add PanicLib instance #348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AdvLoggerPkg/AdvLoggerPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@

[Components]
AdvLoggerPkg/Library/BaseDebugLibAdvancedLogger/BaseDebugLibAdvancedLogger.inf
AdvLoggerPkg/Library/BasePanicLibAdvancedLogger/BasePanicLibAdvancedLogger.inf

[Components.IA32]
AdvLoggerPkg/Library/AdvancedLoggerLib/Pei/AdvancedLoggerLib.inf
Expand Down
3 changes: 2 additions & 1 deletion AdvLoggerPkg/Docs/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following libraries are used with AdvancedLogger:
| AdvancedLoggerLib | One per module type - used to provide access to the in memory log buffer |
| AdvLoggerSmmAccessLib | Used to intercept GetVariable in order to provide an OS utility the ability to read the log |
| BaseDebugLibAdvancedLogger | Basic Dxe etc DebugLib |
| BasePanicLibAdvancedLogger | Basic PanicLib that applies to all PI boot phases that AdvancedLoggerLib supports. |
| DebugAgent | Used to intercept SEC initialization |
| PeiDebugLibAdvancedLogger | Basic Pei DebugLib |
| AdvancedLoggerHdwPortLib | Hook for a hardware port to capture debug messages as they are written to the log. |
Expand Down Expand Up @@ -267,5 +268,5 @@ result in hardware printing not functional.

## Copyright

Copyright (C) Microsoft Corporation. All rights reserved.
makubacki marked this conversation as resolved.
Show resolved Hide resolved
Copyright (C) Microsoft Corporation. All rights reserved. \
SPDX-License-Identifier: BSD-2-Clause-Patent
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/** @file
An instance of the Panic Library that outputs to advanced logger.

Copyright (c) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/PrintLib.h>
#include <Library/AdvancedLoggerLib.h>
#include <Library/PanicLib.h>

//
// Define the maximum panic message length that this library supports
//
#define MAX_PANIC_MESSAGE_LENGTH 0x100
makubacki marked this conversation as resolved.
Show resolved Hide resolved

/**
Prints a panic message containing a filename, line number, and description.
This is always followed by a dead loop.

Print a message of the form "PANIC <FileName>(<LineNumber>): <Description>\n"
to the debug output device. Immediately after that CpuDeadLoop() is called.

If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
If Description is NULL, then a <Description> string of "(NULL) Description" is printed.

@param FileName The pointer to the name of the source file that generated the panic condition.
@param LineNumber The line number in the source file that generated the panic condition
@param Description The pointer to the description of the panic condition.

**/
VOID
EFIAPI
PanicReport (
IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *Description
)
{
CHAR8 Buffer[MAX_PANIC_MESSAGE_LENGTH];

if (FileName == NULL) {
FileName = "(NULL) Filename";
}

if (Description == NULL) {
Description = "(NULL) Description";
}

AsciiSPrint (Buffer, sizeof (Buffer), "PANIC [%a] %a(%d): %a\n", gEfiCallerBaseName, FileName, LineNumber, Description);

// Note: 0x80000000 is used instead of DEBUG_ERROR to avoid a dependency on DebugLib.h just for that value.
// The high bit being set for error status codes is defined per the UEFI Specification (2.10 section below).
// https://uefi.org/specs/UEFI/2.10/Apx_D_Status_Codes.html#status-codes
AdvancedLoggerWrite (0x80000000, Buffer, AsciiStrnLenS (Buffer, sizeof (Buffer)));
makubacki marked this conversation as resolved.
Show resolved Hide resolved

//
// Deadloop since the system is in an unrecoverable state.
//
CpuDeadLoop ();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## @file
# An instance of the Panic Library that outputs to advanced logger.
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BasePanicLibAdvancedLogger
FILE_GUID = 536D781D-A6A6-4831-AAB8-1E391DA2DD06
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = PanicLib

#
# VALID_ARCHITECTURES = ANY
#

[Packages]
MdePkg/MdePkg.dec
AdvLoggerPkg/AdvLoggerPkg.dec

[LibraryClasses]
AdvancedLoggerLib
BaseLib
PrintLib

[Sources]
BasePanicLibAdvancedLogger.c