/** @file\r
Report Status Code Library for DXE Phase.\r
\r
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
)\r
{\r
EFI_STATUS Status;\r
- EFI_TPL Tpl;\r
\r
if (mReportStatusCodeLibStatusCodeProtocol != NULL) {\r
return;\r
//\r
// Check gBS just in case ReportStatusCode is called before gBS is initialized.\r
//\r
- if ((gBS != NULL) && (gBS->LocateProtocol != NULL) && (gBS->RaiseTPL != NULL) && (gBS->RestoreTPL != NULL)) {\r
- //\r
- // Retrieve the current TPL\r
- //\r
- Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
- gBS->RestoreTPL (Tpl);\r
-\r
- if (Tpl < TPL_NOTIFY) {\r
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);\r
- if (EFI_ERROR (Status)) {\r
- mReportStatusCodeLibStatusCodeProtocol = NULL;\r
- }\r
+ if (gBS != NULL && gBS->LocateProtocol != NULL) {\r
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);\r
+ if (EFI_ERROR (Status)) {\r
+ mReportStatusCodeLibStatusCodeProtocol = NULL;\r
}\r
}\r
}\r
//\r
return mReportStatusCodeLibStatusCodeProtocol->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
}\r
- \r
+\r
return EFI_UNSUPPORTED;\r
}\r
\r
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
\r
- if ((gBS == NULL) ||\r
- (gBS->AllocatePool == NULL) || (gBS->FreePool == NULL) ||\r
- (gBS->RaiseTPL == NULL) || (gBS->RestoreTPL == NULL)\r
- ) {\r
- return EFI_UNSUPPORTED;\r
- }\r
+ if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {\r
+ //\r
+ // Use Buffer instead of allocating if possible.\r
+ //\r
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;\r
+ } else {\r
+ if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
- //\r
- // Retrieve the current TPL\r
- //\r
- Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
- gBS->RestoreTPL (Tpl);\r
- \r
- StatusCodeData = NULL;\r
- if (Tpl <= TPL_NOTIFY) {\r
//\r
- // Allocate space for the Status Code Header and its buffer\r
+ // Retrieve the current TPL\r
//\r
- gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
- }\r
+ Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+ gBS->RestoreTPL (Tpl);\r
+\r
+ if (Tpl > TPL_NOTIFY) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
\r
- if (StatusCodeData == NULL) {\r
//\r
- // If a buffer could not be allocated, then see if the local variable Buffer can be used\r
+ // Allocate space for the Status Code Header and its buffer\r
//\r
- if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {\r
- //\r
- // The local variable Buffer not large enough to hold the extended data associated\r
- // with the status code being reported.\r
- //\r
- DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));\r
+ StatusCodeData = NULL;\r
+ gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
+ if (StatusCodeData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;\r
}\r
\r
//\r