Skip to content

Commit

Permalink
Added additional comments describing the new libraries functionality …
Browse files Browse the repository at this point in the history
…better and renamed BasePanicLib to BasePanicLibSerialPort
  • Loading branch information
kenlautner committed Sep 29, 2023
1 parent 0c1eadd commit 335fa66
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
18 changes: 12 additions & 6 deletions MdePkg/Include/Library/PanicLib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/** @file
Provides services to print panic messages to a debug output device.
Provides an API that can be used to halt boot during a critical error and
leave a message describing what went wrong. This should be used for unrecoverable
errors in boot that usually occur in early in boot.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

Expand All @@ -18,9 +21,9 @@ Copyright (c) Microsoft Corporation.
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.
@param[in] FileName The pointer to the name of the source file that generated the panic condition.
@param[in] LineNumber The line number in the source file that generated the panic condition
@param[in] Description The pointer to the description of the panic condition.
**/
VOID
Expand All @@ -35,16 +38,19 @@ PanicReport (
// Source file line number.
// Default is use the to compiler provided __LINE__ macro value. The __LINE__
// mapping can be overriden by predefining PANIC_LINE_NUMBER

//
// Defining PANIC_LINE_NUMBER to a fixed value is useful when comparing builds
// across source code formatting changes that may add/remove lines in a source
// file.
//
#ifdef PANIC_LINE_NUMBER
#else
#ifndef PANIC_LINE_NUMBER
#define PANIC_LINE_NUMBER __LINE__
#endif

// File name being printed out.
// Default is the compiler provided __FILE__ macro value. You can overwrite this
// by defining __FILE_NAME__
#if defined (__clang__) && defined (__FILE_NAME__)
#define _PANIC(Message) PanicReport (__FILE_NAME__, PANIC_LINE_NUMBER, Message)
#else
Expand Down
2 changes: 1 addition & 1 deletion MdePkg/Library/BasePanicLibNull/BasePanicLibNull.inf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Panic Library with empty functions.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BasePanicLibNull
MODULE_UNI_FILE = BasePanicLibNull.uni
FILE_GUID = 0A097ABB-3869-4CF8-B5C0-AE798F135C46
MODULE_TYPE = BASE
VERSION_STRING = 1.0
Expand Down
6 changes: 1 addition & 5 deletions MdePkg/Library/BasePanicLibNull/PanicLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
Base Panic Library with empty functions.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <Base.h>
#include <Library/PanicLib.h>

//
// Define the maximum panic message length that this library supports
//
#define MAX_PANIC_MESSAGE_LENGTH 0x100

/**
This would usually print a panic message containing a filename, line number,
and description. For the NULL implementation nothing is done when panicking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Panic Library.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BasePanicLib
MODULE_UNI_FILE = BasePanicLib.uni
BASE_NAME = BasePanicLibSerialPort
FILE_GUID = DF456972-AF4A-4F3A-B33C-DD31368BF490
MODULE_TYPE = BASE
VERSION_STRING = 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @file
Base Panic Library.
Base Serial Port Panic Library.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

Expand Down Expand Up @@ -41,6 +42,14 @@ PanicReport (
{
CHAR8 Buffer[MAX_PANIC_MESSAGE_LENGTH];

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

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

//
// Generate the PANIC message in ASCII format
//
Expand Down
2 changes: 1 addition & 1 deletion MdePkg/MdePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLibSegmentInfo.inf
MdePkg/Library/BaseS3PciSegmentLib/BaseS3PciSegmentLib.inf
MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf
MdePkg/Library/BasePanicLib/BasePanicLib.inf # MU_CHANGE
MdePkg/Library/BasePanicLibSerialPort/BasePanicLibSerialPort.inf # MU_CHANGE
MdePkg/Library/BasePanicLibNull/BasePanicLibNull.inf # MU_CHANGE
MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
Expand Down

0 comments on commit 335fa66

Please sign in to comment.