Home | History | Annotate | Download | only in Pei
      1 /*++
      2 
      3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
      4 This program and the accompanying materials
      5 are licensed and made available under the terms and conditions of the BSD License
      6 which accompanies this distribution.  The full text of the license may be found at
      7 http://opensource.org/licenses/bsd-license.php
      8 
      9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14   PeiDebug.h
     15 
     16 Abstract:
     17 
     18   PEI Debug macros. The work needs to be done in library. The Debug
     19   macros them selves are standard for all files, including the core.
     20 
     21   There needs to be code linked in that produces the following macros:
     22 
     23   PeiDebugAssert(file, linenumber, assertion string) - worker function for
     24       ASSERT. filename and line number of where this ASSERT() is located
     25       is passed in along with the stringized version of the assertion.
     26 
     27   PeiDebugPrint - Worker function for debug print
     28 
     29   _DEBUG_SET_MEM(address, length, value) - Set memory at address to value
     30     for legnth bytes. This macro is used to initialzed uninitialized memory
     31     or memory that is free'ed, so it will not be used by mistake.
     32 
     33 --*/
     34 
     35 #ifndef _PEIDEBUG_H_
     36 #define _PEIDEBUG_H_
     37 
     38 #ifdef EFI_DEBUG
     39 
     40   VOID
     41   PeiDebugAssert (
     42     IN CONST EFI_PEI_SERVICES   **PeiServices,
     43     IN CHAR8              *FileName,
     44     IN INTN               LineNumber,
     45     IN CHAR8              *Description
     46     );
     47 
     48   VOID
     49   PeiDebugPrint (
     50     IN CONST EFI_PEI_SERVICES   **PeiServices,
     51     IN UINTN              ErrorLevel,
     52     IN CHAR8              *Format,
     53     ...
     54     );
     55 
     56   #define _PEI_DEBUG_ASSERT(PeiST, assertion)  \
     57             PeiDebugAssert (PeiST, __FILE__, __LINE__, #assertion)
     58 
     59   #define _PEI_DEBUG(PeiST, arg) PeiDebugPrint (PeiST, arg)
     60 
     61   //
     62   // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT
     63   //
     64   #define PEI_ASSERT(PeiST, assertion)   if(!(assertion))  \
     65                                             _PEI_DEBUG_ASSERT(PeiST, assertion)
     66 
     67   #define PEI_ASSERT_LOCKED(PeiST, l)    if(!(l)->Lock) _PEI_DEBUG_ASSERT(PeiST, l not locked)
     68 
     69   //
     70   // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do
     71   //   the a debug print.
     72   //
     73 
     74   #define PEI_DEBUG(arg)        PeiDebugPrint arg
     75 
     76   #define PEI_DEBUG_CODE(code)  code
     77 
     78   #define PEI_CR(Record, TYPE, Field, Signature)   \
     79             _CR(Record, TYPE, Field)
     80 
     81 
     82   #define _PEI_DEBUG_SET_MEM(address, length, data) SetMem(address, length, data)
     83 
     84 #else
     85   #define PEI_ASSERT(PeiST, a)
     86   #define PEI_ASSERT_LOCKED(PeiST, l)
     87   #define PEI_DEBUG(arg)
     88   #define PEI_DEBUG_CODE(code)
     89   #define PEI_CR(Record, TYPE, Field, Signature)   \
     90             _CR(Record, TYPE, Field)
     91   #define _PEI_DEBUG_SET_MEM(address, length, data)
     92 #endif
     93 
     94 #define ASSERT_PEI_ERROR(PeiST, status)  PEI_ASSERT(PeiST, !EFI_ERROR(status))
     95 
     96 #ifdef EFI_DEBUG_CLEAR_MEMORY
     97   #define PEI_DEBUG_SET_MEMORY(address,length)  \
     98             _PEI_DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)
     99 #else
    100   #define PEI_DEBUG_SET_MEMORY(address,length)
    101 #endif
    102 
    103 
    104 #endif
    105