Home | History | Annotate | Download | only in DxeReportStatusCodeLib
      1 /** @file
      2   Report Status Code Library for DXE Phase.
      3 
      4   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
      5   This program and the accompanying materials
      6   are licensed and made available under the terms and conditions of the BSD License
      7   which accompanies this distribution.  The full text of the license may be found at
      8   http://opensource.org/licenses/bsd-license.php
      9 
     10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 #include <Library/ReportStatusCodeLib.h>
     16 #include <Library/BaseLib.h>
     17 #include <Library/DebugLib.h>
     18 #include <Library/UefiBootServicesTableLib.h>
     19 #include <Library/BaseMemoryLib.h>
     20 #include <Library/PcdLib.h>
     21 #include <Library/DevicePathLib.h>
     22 
     23 #include <Protocol/StatusCode.h>
     24 
     25 #include <Guid/StatusCodeDataTypeId.h>
     26 #include <Guid/StatusCodeDataTypeDebug.h>
     27 
     28 //
     29 // Define the maximum extended data size that is supported when a status code is
     30 // reported at TPL_HIGH_LEVEL.
     31 //
     32 #define MAX_EXTENDED_DATA_SIZE  0x200
     33 
     34 EFI_STATUS_CODE_PROTOCOL  *mReportStatusCodeLibStatusCodeProtocol = NULL;
     35 
     36 /**
     37   Locate the report status code service.
     38 
     39   Retrieve ReportStatusCode() API of Report Status Code Protocol.
     40 
     41 **/
     42 VOID
     43 InternalGetReportStatusCode (
     44   VOID
     45   )
     46 {
     47   EFI_STATUS  Status;
     48 
     49   if (mReportStatusCodeLibStatusCodeProtocol != NULL) {
     50     return;
     51   }
     52 
     53   //
     54   // Check gBS just in case ReportStatusCode is called before gBS is initialized.
     55   //
     56   if (gBS != NULL && gBS->LocateProtocol != NULL) {
     57     Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);
     58     if (EFI_ERROR (Status)) {
     59       mReportStatusCodeLibStatusCodeProtocol = NULL;
     60     }
     61   }
     62 }
     63 
     64 /**
     65   Internal worker function that reports a status code through the Report Status Code Protocol.
     66 
     67   If status code service is not cached, then this function checks if Report Status Code
     68   Protocol is available in system.  If Report Status Code Protocol is not available, then
     69   EFI_UNSUPPORTED is returned.  If Report Status Code Protocol is present, then it is
     70   cached in mReportStatusCodeLibStatusCodeProtocol. Finally this function reports status
     71   code through the Report Status Code Protocol.
     72 
     73   @param  Type              Status code type.
     74   @param  Value             Status code value.
     75   @param  Instance          Status code instance number.
     76   @param  CallerId          Pointer to a GUID that identifies the caller of this
     77                             function.  This is an optional parameter that may be
     78                             NULL.
     79   @param  Data              Pointer to the extended data buffer.  This is an
     80                             optional parameter that may be NULL.
     81 
     82   @retval EFI_SUCCESS       The status code was reported.
     83   @retval EFI_UNSUPPORTED   Report Status Code Protocol is not available.
     84   @retval EFI_UNSUPPORTED   Status code type is not supported.
     85 
     86 **/
     87 EFI_STATUS
     88 InternalReportStatusCode (
     89   IN EFI_STATUS_CODE_TYPE     Type,
     90   IN EFI_STATUS_CODE_VALUE    Value,
     91   IN UINT32                   Instance,
     92   IN CONST EFI_GUID           *CallerId OPTIONAL,
     93   IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL
     94   )
     95 {
     96   if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
     97       (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
     98       (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
     99     //
    100     // If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.
    101     //
    102     InternalGetReportStatusCode ();
    103     if (mReportStatusCodeLibStatusCodeProtocol == NULL) {
    104       return EFI_UNSUPPORTED;
    105     }
    106 
    107     //
    108     // A Report Status Code Protocol is present in system, so pass in all the parameters to the service.
    109     //
    110     return mReportStatusCodeLibStatusCodeProtocol->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);
    111   }
    112 
    113   return EFI_UNSUPPORTED;
    114 }
    115 
    116 
    117 /**
    118   Converts a status code to an 8-bit POST code value.
    119 
    120   Converts the status code specified by CodeType and Value to an 8-bit POST code
    121   and returns the 8-bit POST code in PostCode.  If CodeType is an
    122   EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
    123   are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
    124   24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.
    125 
    126   If PostCode is NULL, then ASSERT().
    127 
    128   @param  CodeType  The type of status code being converted.
    129   @param  Value     The status code value being converted.
    130   @param  PostCode  A pointer to the 8-bit POST code value to return.
    131 
    132   @retval  TRUE   The status code specified by CodeType and Value was converted
    133                   to an 8-bit POST code and returned in  PostCode.
    134   @retval  FALSE  The status code specified by CodeType and Value could not be
    135                   converted to an 8-bit POST code value.
    136 
    137 **/
    138 BOOLEAN
    139 EFIAPI
    140 CodeTypeToPostCode (
    141   IN  EFI_STATUS_CODE_TYPE   CodeType,
    142   IN  EFI_STATUS_CODE_VALUE  Value,
    143   OUT UINT8                  *PostCode
    144   )
    145 {
    146   //
    147   // If PostCode is NULL, then ASSERT()
    148   //
    149   ASSERT (PostCode != NULL);
    150 
    151   //
    152   // Convert Value to an 8 bit post code
    153   //
    154   if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
    155       ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {
    156     *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
    157                           (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
    158     return TRUE;
    159   }
    160   return FALSE;
    161 }
    162 
    163 
    164 /**
    165   Extracts ASSERT() information from a status code structure.
    166 
    167   Converts the status code specified by CodeType, Value, and Data to the ASSERT()
    168   arguments specified by Filename, Description, and LineNumber.  If CodeType is
    169   an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
    170   Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
    171   Filename, Description, and LineNumber from the optional data area of the
    172   status code buffer specified by Data.  The optional data area of Data contains
    173   a Null-terminated ASCII string for the FileName, followed by a Null-terminated
    174   ASCII string for the Description, followed by a 32-bit LineNumber.  If the
    175   ASSERT() information could be extracted from Data, then return TRUE.
    176   Otherwise, FALSE is returned.
    177 
    178   If Data is NULL, then ASSERT().
    179   If Filename is NULL, then ASSERT().
    180   If Description is NULL, then ASSERT().
    181   If LineNumber is NULL, then ASSERT().
    182 
    183   @param  CodeType     The type of status code being converted.
    184   @param  Value        The status code value being converted.
    185   @param  Data         Pointer to status code data buffer.
    186   @param  Filename     Pointer to the source file name that generated the ASSERT().
    187   @param  Description  Pointer to the description of the ASSERT().
    188   @param  LineNumber   Pointer to source line number that generated the ASSERT().
    189 
    190   @retval  TRUE   The status code specified by CodeType, Value, and Data was
    191                   converted ASSERT() arguments specified by Filename, Description,
    192                   and LineNumber.
    193   @retval  FALSE  The status code specified by CodeType, Value, and Data could
    194                   not be converted to ASSERT() arguments.
    195 
    196 **/
    197 BOOLEAN
    198 EFIAPI
    199 ReportStatusCodeExtractAssertInfo (
    200   IN EFI_STATUS_CODE_TYPE        CodeType,
    201   IN EFI_STATUS_CODE_VALUE       Value,
    202   IN CONST EFI_STATUS_CODE_DATA  *Data,
    203   OUT CHAR8                      **Filename,
    204   OUT CHAR8                      **Description,
    205   OUT UINT32                     *LineNumber
    206   )
    207 {
    208   EFI_DEBUG_ASSERT_DATA  *AssertData;
    209 
    210   ASSERT (Data        != NULL);
    211   ASSERT (Filename    != NULL);
    212   ASSERT (Description != NULL);
    213   ASSERT (LineNumber  != NULL);
    214 
    215   if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) &&
    216       ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&
    217       ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
    218     AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
    219     *Filename    = (CHAR8 *)(AssertData + 1);
    220     *Description = *Filename + AsciiStrLen (*Filename) + 1;
    221     *LineNumber  = AssertData->LineNumber;
    222     return TRUE;
    223   }
    224   return FALSE;
    225 }
    226 
    227 
    228 /**
    229   Extracts DEBUG() information from a status code structure.
    230 
    231   Converts the status code specified by Data to the DEBUG() arguments specified
    232   by ErrorLevel, Marker, and Format.  If type GUID in Data is
    233   EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
    234   Format from the optional data area of the status code buffer specified by Data.
    235   The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
    236   which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
    237   the Format.  If the DEBUG() information could be extracted from Data, then
    238   return TRUE.  Otherwise, FALSE is returned.
    239 
    240   If Data is NULL, then ASSERT().
    241   If ErrorLevel is NULL, then ASSERT().
    242   If Marker is NULL, then ASSERT().
    243   If Format is NULL, then ASSERT().
    244 
    245   @param  Data        Pointer to status code data buffer.
    246   @param  ErrorLevel  Pointer to error level mask for a debug message.
    247   @param  Marker      Pointer to the variable argument list associated with Format.
    248   @param  Format      Pointer to a Null-terminated ASCII format string of a
    249                       debug message.
    250 
    251   @retval  TRUE   The status code specified by Data was converted DEBUG() arguments
    252                   specified by ErrorLevel, Marker, and Format.
    253   @retval  FALSE  The status code specified by Data could not be converted to
    254                   DEBUG() arguments.
    255 
    256 **/
    257 BOOLEAN
    258 EFIAPI
    259 ReportStatusCodeExtractDebugInfo (
    260   IN CONST EFI_STATUS_CODE_DATA  *Data,
    261   OUT UINT32                     *ErrorLevel,
    262   OUT BASE_LIST                  *Marker,
    263   OUT CHAR8                      **Format
    264   )
    265 {
    266   EFI_DEBUG_INFO  *DebugInfo;
    267 
    268   ASSERT (Data       != NULL);
    269   ASSERT (ErrorLevel != NULL);
    270   ASSERT (Marker     != NULL);
    271   ASSERT (Format     != NULL);
    272 
    273   //
    274   // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
    275   //
    276   if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
    277     return FALSE;
    278   }
    279 
    280   //
    281   // Retrieve the debug information from the status code record
    282   //
    283   DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
    284 
    285   *ErrorLevel = DebugInfo->ErrorLevel;
    286 
    287   //
    288   // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments
    289   // of format in DEBUG string. Its address is returned in Marker and has to be 64-bit aligned.
    290   // It must be noticed that EFI_DEBUG_INFO follows EFI_STATUS_CODE_DATA, whose size is
    291   // 20 bytes. The size of EFI_DEBUG_INFO is 4 bytes, so we can ensure that Marker
    292   // returned is 64-bit aligned.
    293   // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will
    294   // cause unalignment exception.
    295   //
    296   *Marker = (BASE_LIST) (DebugInfo + 1);
    297   *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
    298 
    299   return TRUE;
    300 }
    301 
    302 
    303 /**
    304   Reports a status code.
    305 
    306   Reports the status code specified by the parameters Type and Value.  Status
    307   code also require an instance, caller ID, and extended data.  This function
    308   passed in a zero instance, NULL extended data, and a caller ID of
    309   gEfiCallerIdGuid, which is the GUID for the module.
    310 
    311   ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode()
    312   is called while processing another any other Report Status Code Library function,
    313   then ReportStatusCode() must return immediately.
    314 
    315   @param  Type   Status code type.
    316   @param  Value  Status code value.
    317 
    318   @retval  EFI_SUCCESS       The status code was reported.
    319   @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a
    320                              device error.
    321   @retval  EFI_UNSUPPORTED   Report status code is not supported
    322 
    323 **/
    324 EFI_STATUS
    325 EFIAPI
    326 ReportStatusCode (
    327   IN EFI_STATUS_CODE_TYPE   Type,
    328   IN EFI_STATUS_CODE_VALUE  Value
    329   )
    330 {
    331   return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
    332 }
    333 
    334 
    335 /**
    336   Reports a status code with a Device Path Protocol as the extended data.
    337 
    338   Allocates and fills in the extended data section of a status code with the
    339   Device Path Protocol specified by DevicePath.  This function is responsible
    340   for allocating a buffer large enough for the standard header and the device
    341   path.  The standard header is filled in with a GUID of
    342   gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero
    343   instance and a caller ID of gEfiCallerIdGuid.
    344 
    345   ReportStatusCodeWithDevicePath()must actively prevent recursion.  If
    346   ReportStatusCodeWithDevicePath() is called while processing another any other
    347   Report Status Code Library function, then ReportStatusCodeWithDevicePath()
    348   must return EFI_DEVICE_ERROR immediately.
    349 
    350   If DevicePath is NULL, then ASSERT().
    351 
    352   @param  Type        Status code type.
    353   @param  Value       Status code value.
    354   @param  DevicePath  Pointer to the Device Path Protocol to be reported.
    355 
    356   @retval  EFI_SUCCESS           The status code was reported with the extended
    357                                  data specified by DevicePath.
    358   @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the
    359                                  extended data section.
    360   @retval  EFI_UNSUPPORTED       Report status code is not supported
    361 
    362 **/
    363 EFI_STATUS
    364 EFIAPI
    365 ReportStatusCodeWithDevicePath (
    366   IN EFI_STATUS_CODE_TYPE            Type,
    367   IN EFI_STATUS_CODE_VALUE           Value,
    368   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath
    369   )
    370 {
    371   ASSERT (DevicePath != NULL);
    372   return ReportStatusCodeWithExtendedData (
    373            Type,
    374            Value,
    375            (VOID *)DevicePath,
    376            GetDevicePathSize (DevicePath)
    377            );
    378 }
    379 
    380 
    381 /**
    382   Reports a status code with an extended data buffer.
    383 
    384   Allocates and fills in the extended data section of a status code with the
    385   extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData
    386   is assumed to be one of the data structures specified in Related Definitions.
    387   These data structure do not have the standard header, so this function is
    388   responsible for allocating a buffer large enough for the standard header and
    389   the extended data passed into this function.  The standard header is filled
    390   in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported
    391   with a zero instance and a caller ID of gEfiCallerIdGuid.
    392 
    393   ReportStatusCodeWithExtendedData()must actively prevent recursion.  If
    394   ReportStatusCodeWithExtendedData() is called while processing another any other
    395   Report Status Code Library function, then ReportStatusCodeWithExtendedData()
    396   must return EFI_DEVICE_ERROR immediately.
    397 
    398   If ExtendedData is NULL, then ASSERT().
    399   If ExtendedDataSize is 0, then ASSERT().
    400 
    401   @param  Type              Status code type.
    402   @param  Value             Status code value.
    403   @param  ExtendedData      Pointer to the extended data buffer to be reported.
    404   @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to
    405                             be reported.
    406 
    407   @retval  EFI_SUCCESS           The status code was reported with the extended
    408                                  data specified by ExtendedData and ExtendedDataSize.
    409   @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the
    410                                  extended data section.
    411   @retval  EFI_UNSUPPORTED       Report status code is not supported
    412 
    413 **/
    414 EFI_STATUS
    415 EFIAPI
    416 ReportStatusCodeWithExtendedData (
    417   IN EFI_STATUS_CODE_TYPE   Type,
    418   IN EFI_STATUS_CODE_VALUE  Value,
    419   IN CONST VOID             *ExtendedData,
    420   IN UINTN                  ExtendedDataSize
    421   )
    422 {
    423   ASSERT (ExtendedData     != NULL);
    424   ASSERT (ExtendedDataSize != 0);
    425   return ReportStatusCodeEx (
    426            Type,
    427            Value,
    428            0,
    429            NULL,
    430            NULL,
    431            ExtendedData,
    432            ExtendedDataSize
    433            );
    434 }
    435 
    436 
    437 /**
    438   Reports a status code with full parameters.
    439 
    440   The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize
    441   is 0, then an extended data buffer is not reported.  If ExtendedData is not
    442   NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
    443   ExtendedData is assumed not have the standard status code header, so this function
    444   is responsible for allocating a buffer large enough for the standard header and
    445   the extended data passed into this function.  The standard header is filled in
    446   with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a
    447   GUID of gEfiStatusCodeSpecificDataGuid is used.  The status code is reported with
    448   an instance specified by Instance and a caller ID specified by CallerId.  If
    449   CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
    450 
    451   ReportStatusCodeEx()must actively prevent recursion. If
    452   ReportStatusCodeEx() is called while processing another any
    453   other Report Status Code Library function, then
    454   ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
    455 
    456   If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
    457   If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
    458 
    459   @param  Type              Status code type.
    460   @param  Value             Status code value.
    461   @param  Instance          Status code instance number.
    462   @param  CallerId          Pointer to a GUID that identifies the caller of this
    463                             function.  If this parameter is NULL, then a caller
    464                             ID of gEfiCallerIdGuid is used.
    465   @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.
    466                             If this parameter is NULL, then a the status code
    467                             standard header is filled in with
    468                             gEfiStatusCodeSpecificDataGuid.
    469   @param  ExtendedData      Pointer to the extended data buffer.  This is an
    470                             optional parameter that may be NULL.
    471   @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.
    472 
    473   @retval  EFI_SUCCESS           The status code was reported.
    474   @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate
    475                                  the extended data section if it was specified.
    476   @retval  EFI_UNSUPPORTED       Report status code is not supported
    477 
    478 **/
    479 EFI_STATUS
    480 EFIAPI
    481 ReportStatusCodeEx (
    482   IN EFI_STATUS_CODE_TYPE   Type,
    483   IN EFI_STATUS_CODE_VALUE  Value,
    484   IN UINT32                 Instance,
    485   IN CONST EFI_GUID         *CallerId          OPTIONAL,
    486   IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,
    487   IN CONST VOID             *ExtendedData      OPTIONAL,
    488   IN UINTN                  ExtendedDataSize
    489   )
    490 {
    491   EFI_STATUS            Status;
    492   EFI_STATUS_CODE_DATA  *StatusCodeData;
    493   EFI_TPL               Tpl;
    494   UINT64                Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
    495 
    496   ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
    497   ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
    498 
    499   if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
    500     return EFI_UNSUPPORTED;
    501   }
    502 
    503   //
    504   // Retrieve the current TPL
    505   //
    506   Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
    507   gBS->RestoreTPL (Tpl);
    508 
    509   StatusCodeData = NULL;
    510   if (Tpl <= TPL_NOTIFY) {
    511     //
    512     // Allocate space for the Status Code Header and its buffer
    513     //
    514     gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);
    515   }
    516 
    517   if (StatusCodeData == NULL) {
    518     //
    519     // If a buffer could not be allocated, then see if the local variable Buffer can be used
    520     //
    521     if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
    522       //
    523       // The local variable Buffer not large enough to hold the extended data associated
    524       // with the status code being reported.
    525       //
    526       DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));
    527       return EFI_OUT_OF_RESOURCES;
    528     }
    529     StatusCodeData = (EFI_STATUS_CODE_DATA  *)Buffer;
    530   }
    531 
    532   //
    533   // Fill in the extended data header
    534   //
    535   StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
    536   StatusCodeData->Size = (UINT16) ExtendedDataSize;
    537   if (ExtendedDataGuid == NULL) {
    538     ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
    539   }
    540   CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
    541 
    542   //
    543   // Fill in the extended data buffer
    544   //
    545   if (ExtendedData != NULL) {
    546     CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);
    547   }
    548 
    549   //
    550   // Report the status code
    551   //
    552   if (CallerId == NULL) {
    553     CallerId = &gEfiCallerIdGuid;
    554   }
    555   Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
    556 
    557   //
    558   // Free the allocated buffer
    559   //
    560   if (StatusCodeData != (EFI_STATUS_CODE_DATA  *)Buffer) {
    561     gBS->FreePool (StatusCodeData);
    562   }
    563 
    564   return Status;
    565 }
    566 
    567 
    568 /**
    569   Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
    570 
    571   This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
    572   bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.
    573 
    574   @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
    575                   PcdReportStatusCodeProperyMask is set.
    576   @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
    577                   PcdReportStatusCodeProperyMask is clear.
    578 
    579 **/
    580 BOOLEAN
    581 EFIAPI
    582 ReportProgressCodeEnabled (
    583   VOID
    584   )
    585 {
    586   return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
    587 }
    588 
    589 
    590 /**
    591   Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
    592 
    593   This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
    594   bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.
    595 
    596   @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
    597                   PcdReportStatusCodeProperyMask is set.
    598   @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
    599                   PcdReportStatusCodeProperyMask is clear.
    600 
    601 **/
    602 BOOLEAN
    603 EFIAPI
    604 ReportErrorCodeEnabled (
    605   VOID
    606   )
    607 {
    608   return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
    609 }
    610 
    611 
    612 /**
    613   Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
    614 
    615   This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
    616   bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.
    617 
    618   @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
    619                   PcdReportStatusCodeProperyMask is set.
    620   @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
    621                   PcdReportStatusCodeProperyMask is clear.
    622 
    623 **/
    624 BOOLEAN
    625 EFIAPI
    626 ReportDebugCodeEnabled (
    627   VOID
    628   )
    629 {
    630   return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
    631 }
    632