1 /*++ 2 3 Copyright (c) 2004 - 2012, 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 Debug.c 15 16 Abstract: 17 18 Support for Debug primatives. 19 20 --*/ 21 22 #include "Tiano.h" 23 #include "Pei.h" 24 #include "EfiPrintLib.h" 25 #include "EfiStatusCode.h" 26 #include "EfiCommonLib.h" 27 #include EFI_GUID_DEFINITION (StatusCodeCallerId) 28 #include EFI_GUID_DEFINITION (StatusCodeDataTypeId) 29 30 VOID 31 PeiDebugAssert ( 32 IN CONST EFI_PEI_SERVICES **PeiServices, 33 IN CHAR8 *FileName, 34 IN INTN LineNumber, 35 IN CHAR8 *Description 36 ) 37 /*++ 38 39 Routine Description: 40 41 Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT 42 information. If Error Logging hub is not loaded DEADLOOP (). 43 44 Arguments: 45 46 PeiServices - The PEI core services table. 47 48 FileName - File name of failing routine. 49 50 LineNumber - Line number of failing ASSERT(). 51 52 Description - Description, usually the assertion, 53 54 Returns: 55 56 None 57 58 --*/ 59 { 60 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; 61 62 EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer); 63 64 // 65 // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, 66 // we want get enough information if assert. 67 // 68 (**PeiServices).PeiReportStatusCode ( 69 (EFI_PEI_SERVICES**)PeiServices, 70 (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), 71 (EFI_SOFTWARE_PEI_MODULE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), 72 0, 73 &gEfiCallerIdGuid, 74 (EFI_STATUS_CODE_DATA *) Buffer 75 ); 76 77 EFI_DEADLOOP (); 78 } 79 80 81 VOID 82 PeiDebugPrint ( 83 IN CONST EFI_PEI_SERVICES **PeiServices, 84 IN UINTN ErrorLevel, 85 IN CHAR8 *Format, 86 ... 87 ) 88 /*++ 89 90 Routine Description: 91 92 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT 93 information. If Error Logging hub is not loaded do nothing. 94 95 Arguments: 96 97 PeiServices - The PEI core services table. 98 99 ErrorLevel - If error level is set do the debug print. 100 101 Format - String to use for the print, followed by Print arguments. 102 103 ... - Print arguments 104 105 Returns: 106 107 None 108 109 --*/ 110 { 111 VA_LIST Marker; 112 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE]; 113 114 VA_START (Marker, Format); 115 EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer); 116 VA_END (Marker); 117 118 // 119 // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable, 120 // we want get enough information if assert. 121 // 122 (**PeiServices).PeiReportStatusCode ( 123 (EFI_PEI_SERVICES**)PeiServices, 124 EFI_DEBUG_CODE, 125 (EFI_SOFTWARE_PEI_MODULE | EFI_DC_UNSPECIFIED), 126 0, 127 &gEfiCallerIdGuid, 128 (EFI_STATUS_CODE_DATA *) Buffer 129 ); 130 131 } 132