edkiigluedebuglib.h

来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C头文件 代码 · 共 531 行 · 第 1/2 页

H
531
字号
      } while (FALSE)
  #else
    #define ASSERT(Expression) do{} while(0)
  #endif    

#else
  // External usage

  #ifdef EFI_DEBUG
    #define ASSERT(Expression)        \
      do {                            \
        if (DebugAssertEnabled ()) {  \
          if (!(Expression)) {        \
            _ASSERT (Expression);     \
          }                           \
        }                             \
      } while (FALSE)
  #else
    #define ASSERT(Expression) do{} while(0)
  #endif

#endif

/**
  
  Macro that calls DebugPrint().

  If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set, 
  then this macro passes Expression to DebugPrint().

  @param  Expression  Expression containing an error level, a format string, 
                      and a variable argument list based on the format string.
  

**/
#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION
  // Glue Library internal
  
  #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE
    #define DEBUG(Expression)        \
      do {                           \
        if (DebugPrintEnabled ()) {  \
          _DEBUG (Expression);       \
        }                            \
      } while (FALSE)
  #else
    #define DEBUG(Expression) do{} while(0)
  #endif    

#else
  // External usage

  #ifdef EFI_DEBUG
    #define DEBUG(Expression)        \
      do {                           \
        if (DebugPrintEnabled ()) {  \
          _DEBUG (Expression);       \
        }                            \
      } while (FALSE)
  #else
    #define DEBUG(Expression) do{} while(0)
  #endif

#endif


/**
  
  Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.

  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, 
  then this macro evaluates the EFI_STATUS value specified by StatusParameter.  
  If StatusParameter is an error code, then DebugAssert() is called passing in 
  the source filename, source line number, and StatusParameter.

  @param  StatusParameter  EFI_STATUS value to evaluate.

**/
#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION
  // Glue Library internal
  
  #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE
    #define ASSERT_EFI_ERROR(StatusParameter)                                              \
      do {                                                                                 \
        if (DebugAssertEnabled ()) {                                                       \
          if (EFI_ERROR (StatusParameter)) {                                               \
            DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter));  \
            _ASSERT (!EFI_ERROR (StatusParameter));                                        \
          }                                                                                \
        }                                                                                  \
      } while (FALSE)
  #else
    #define ASSERT_EFI_ERROR(Expression) do{} while(0)
  #endif    

#else
  // External usage

  #ifdef EFI_DEBUG
    #define ASSERT_EFI_ERROR(StatusParameter)                                              \
      do {                                                                                 \
        if (DebugAssertEnabled ()) {                                                       \
          if (EFI_ERROR (StatusParameter)) {                                               \
            DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter));  \
            _ASSERT (!EFI_ERROR (StatusParameter));                                        \
          }                                                                                \
        }                                                                                  \
      } while (FALSE)
  #else
    #define ASSERT_EFI_ERROR(Expression) do{} while(0)
  #endif

#endif


/**
  
  Macro that calls DebugAssert() if a protocol is already installed in the 
  handle database.

  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, 
  then return.

  If Handle is NULL, then a check is made to see if the protocol specified by Guid 
  is present on any handle in the handle database.  If Handle is not NULL, then 
  a check is made to see if the protocol specified by Guid is present on the 
  handle specified by Handle.  If the check finds the protocol, then DebugAssert() 
  is called passing in the source filename, source line number, and Guid.

  If Guid is NULL, then ASSERT().

  @param  Handle  The handle to check for the protocol.  This is an optional 
                  parameter that may be NULL.  If it is NULL, then the entire 
                  handle database is searched.

  @param  Guid    Pointer to a protocol GUID.

**/
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)                               \
  do {                                                                                \
    if (DebugAssertEnabled ()) {                                                      \
      VOID  *Instance;                                                                \
      ASSERT (Guid != NULL);                                                          \
      if (Handle == NULL) {                                                           \
        if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) {   \
          _ASSERT (Guid already installed in database);                               \
        }                                                                             \
      } else {                                                                        \
        if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \
          _ASSERT (Guid already installed on Handle);                                 \
        }                                                                             \
      }                                                                               \
    }                                                                                 \
  } while (FALSE)


/**
  Macro that marks the beginning of debug source code.

  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, 
  then this macro marks the beginning of source code that is included in a module.
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() 
  are not included in a module.

**/
#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  __DebugCodeLocal


/**
  
  Macro that marks the end of debug source code.

  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, 
  then this macro marks the end of source code that is included in a module.  
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() 
  are not included in a module.

**/
#define DEBUG_CODE_END()    __DebugCodeLocal = 0; } } while (FALSE)


/**
  
  Macro that declares a section of debug source code.

  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, 
  then the source code specified by Expression is included in a module.  
  Otherwise, the source specified by Expression is not included in a module.

**/
#define DEBUG_CODE(Expression)  \
  DEBUG_CODE_BEGIN ();          \
  Expression                    \
  DEBUG_CODE_END ()


/**
  
  Macro that calls DebugClearMemory() to clear a buffer to a default value.

  If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, 
  then this macro calls DebugClearMemory() passing in Address and Length.

  @param  Address  Pointer to a buffer.
  @param  Length   The number of bytes in the buffer to set.

**/
#define DEBUG_CLEAR_MEMORY(Address, Length)  \
  do {                                       \
    if (DebugClearMemoryEnabled ()) {        \
      DebugClearMemory (Address, Length);    \
    }                                        \
  } while (FALSE)


/**

  Macro that calls DebugAssert() if the containing record does not have a 
  matching signature.  If the signatures matches, then a pointer to the data 
  structure that contains a specified field of that data structure is returned.  
  This is a light weight method hide information by placing a public data 
  structure inside a larger private data structure and using a pointer to the 
  public data structure to retrieve a pointer to the private data structure.

  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, 
  then this macro computes the offset, in bytes, of field specified by Field 
  from the beginning of the  data structure specified by TYPE.  This offset is 
  subtracted from Record, and is used to return a pointer to a data structure 
  of the type specified by TYPE.

  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,  
  then this macro computes the offset, in bytes, of field specified by Field from 
  the beginning of the data structure specified by TYPE.  This offset is 
  subtracted from Record, and is used to compute a pointer to a data structure of 
  the type specified by TYPE.  The Signature field of the data structure specified 
  by TYPE is compared to TestSignature.  If the signatures match, then a pointer 
  to the pointer to a data structure of the type specified by TYPE is returned.  
  If the signatures do not match, then DebugAssert() is called with a description 
  of "CR has a bad signature" and Record is returned.  

  If the data type specified by TYPE does not contain the field specified by Field, 
  then the module will not compile.

  If TYPE does not contain a field called Signature, then the module will not 
  compile.

  @param  Record         Pointer to the field specified by Field within a data 
                         structure of type TYPE.

  @param  TYPE           The name of the data structure type to return  This 
                         data structure must contain the field specified by Field. 

  @param  Field          The name of the field in the data structure specified 
                         by TYPE to which Record points.

  @param  TestSignature  The 32-bit signature value to match.

**/
#define CR(Record, TYPE, Field, TestSignature)                                          \
  (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ?  \
  (TYPE *) (_ASSERT (CR has Bad Signature), Record) :                                   \
  _CR (Record, TYPE, Field)
    
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?