This commit is contained in:
ydong10 2011-03-15 00:52:27 +00:00
parent 640dfdc31d
commit d4e0afd826
1 changed files with 44 additions and 13 deletions

View File

@ -25,6 +25,22 @@
/// ///
/// Debug Mask Protocol function prototypes /// Debug Mask Protocol function prototypes
/// ///
/**
Retrieves the current debug print error level mask for a module are returns
it in CurrentDebugMask.
@param This The protocol instance pointer.
@param CurrentDebugMask Pointer to the debug print error level mask that
is returned.
@retval EFI_SUCCESS The current debug print error level mask was
returned in CurrentDebugMask.
@retval EFI_INVALID_PARAMETER CurrentDebugMask is NULL.
@retval EFI_DEVICE_ERROR The current debug print error level mask could
not be retrieved.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GetDebugMask ( GetDebugMask (
@ -32,6 +48,19 @@ GetDebugMask (
IN OUT UINTN *CurrentDebugMask IN OUT UINTN *CurrentDebugMask
); );
/**
Sets the current debug print error level mask for a module to the value
specified by NewDebugMask.
@param This The protocol instance pointer.
@param NewDebugMask The new debug print error level mask for this module.
@retval EFI_SUCCESS The current debug print error level mask was
set to the value specified by NewDebugMask.
@retval EFI_DEVICE_ERROR The current debug print error level mask could
not be set to the value specified by NewDebugMask.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SetDebugMask ( SetDebugMask (
@ -73,7 +102,7 @@ UINT32 mDebugPrintErrorLevel = 0;
/// the global debug print error level mask value. The UefiBootServicesTableLib /// the global debug print error level mask value. The UefiBootServicesTableLib
/// is not used to prevent a circular dependency between these libraries. /// is not used to prevent a circular dependency between these libraries.
/// ///
EFI_SYSTEM_TABLE *mST = NULL; EFI_SYSTEM_TABLE *mSystemTable = NULL;
/** /**
The constructor function caches the PCI Express Base Address and creates a The constructor function caches the PCI Express Base Address and creates a
@ -103,7 +132,7 @@ DxeDebugPrintErrorLevelLibConstructor (
// //
// Install Debug Mask Protocol onto ImageHandle // Install Debug Mask Protocol onto ImageHandle
// //
mST = SystemTable; mSystemTable = SystemTable;
Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces ( Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces (
&ImageHandle, &ImageHandle,
&gEfiDebugMaskProtocolGuid, &mDebugMaskProtocol, &gEfiDebugMaskProtocolGuid, &mDebugMaskProtocol,
@ -171,7 +200,7 @@ GetDebugPrintErrorLevel (
// This case should only occur if debug print is generated by a library // This case should only occur if debug print is generated by a library
// constructor for this module // constructor for this module
// //
if (mST == NULL) { if (mSystemTable == NULL) {
return PcdGet32 (PcdDebugPrintErrorLevel); return PcdGet32 (PcdDebugPrintErrorLevel);
} }
@ -185,15 +214,15 @@ GetDebugPrintErrorLevel (
// //
// Make sure the TPL Level is low enough for EFI Variable Services to be called // Make sure the TPL Level is low enough for EFI Variable Services to be called
// //
CurrentTpl = mST->BootServices->RaiseTPL (TPL_HIGH_LEVEL); CurrentTpl = mSystemTable->BootServices->RaiseTPL (TPL_HIGH_LEVEL);
mST->BootServices->RestoreTPL (CurrentTpl); mSystemTable->BootServices->RestoreTPL (CurrentTpl);
if (CurrentTpl <= TPL_CALLBACK) { if (CurrentTpl <= TPL_CALLBACK) {
// //
// Attempt to retrieve the global debug print error level mask from the // Attempt to retrieve the global debug print error level mask from the
// EFI Variable // EFI Variable
// //
Size = sizeof (GlobalErrorLevel); Size = sizeof (GlobalErrorLevel);
Status = mST->RuntimeServices->GetVariable ( Status = mSystemTable->RuntimeServices->GetVariable (
DEBUG_MASK_VARIABLE_NAME, DEBUG_MASK_VARIABLE_NAME,
&gEfiGenericVariableGuid, &gEfiGenericVariableGuid,
NULL, NULL,
@ -225,9 +254,11 @@ GetDebugPrintErrorLevel (
/** /**
Sets the global debug print error level mask fpr the entire platform. Sets the global debug print error level mask fpr the entire platform.
@retval TRUE The debug print error level mask was sucessfully set. @param ErrorLevel Global debug print error level
@retval FALSE The debug print error level mask could not be set.
@retval TRUE The debug print error level mask was sucessfully set.
@retval FALSE The debug print error level mask could not be set.
**/ **/
BOOLEAN BOOLEAN
@ -244,19 +275,19 @@ SetDebugPrintErrorLevel (
// //
// Make sure the constructor has been executed // Make sure the constructor has been executed
// //
if (mST != NULL) { if (mSystemTable != NULL) {
// //
// Make sure the TPL Level is low enough for EFI Variable Services // Make sure the TPL Level is low enough for EFI Variable Services
// //
CurrentTpl = mST->BootServices->RaiseTPL (TPL_HIGH_LEVEL); CurrentTpl = mSystemTable->BootServices->RaiseTPL (TPL_HIGH_LEVEL);
mST->BootServices->RestoreTPL (CurrentTpl); mSystemTable->BootServices->RestoreTPL (CurrentTpl);
if (CurrentTpl <= TPL_CALLBACK) { if (CurrentTpl <= TPL_CALLBACK) {
// //
// Attempt to store the global debug print error level mask in an EFI Variable // Attempt to store the global debug print error level mask in an EFI Variable
// //
GlobalErrorLevel = (UINTN)ErrorLevel; GlobalErrorLevel = (UINTN)ErrorLevel;
Size = sizeof (GlobalErrorLevel); Size = sizeof (GlobalErrorLevel);
Status = mST->RuntimeServices->SetVariable ( Status = mSystemTable->RuntimeServices->SetVariable (
DEBUG_MASK_VARIABLE_NAME, DEBUG_MASK_VARIABLE_NAME,
&gEfiGenericVariableGuid, &gEfiGenericVariableGuid,
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS), (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),