]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
9824cd8a3bfb496b34a8a0d13f58533053ecad5d
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / Debug.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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 "EfiDriverLib.h"
24 #include "EfiPrintLib.h"
25 #include "EfiStatusCode.h"
26 #include EFI_GUID_DEFINITION (StatusCodeCallerId)
27 #include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
28 #include EFI_PROTOCOL_DEFINITION (DebugMask)
29
30 //
31 // You would think you should divid by sizeof (UINT64), but EBC does not like
32 // that!
33 //
34 #define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)
35
36 VOID
37 EfiDebugAssert (
38 IN CHAR8 *FileName,
39 IN INTN LineNumber,
40 IN CHAR8 *Description
41 )
42 /*++
43
44 Routine Description:
45
46 Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT
47 information. If Error Logging hub is not loaded BREAKPOINT().
48
49 We use UINT64 buffers due to IPF alignment concerns.
50
51 Arguments:
52
53 FileName - File name of failing routine.
54
55 LineNumber - Line number of failing ASSERT().
56
57 Description - Descritption, usally the assertion,
58
59 Returns:
60
61 None
62
63 --*/
64 {
65 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
66
67 EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);
68
69 EfiLibReportStatusCode (
70 (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
71 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
72 0,
73 &gEfiCallerIdGuid,
74 (EFI_STATUS_CODE_DATA *) Buffer
75 );
76
77 //
78 // Put break point in module that contained the error.
79 //
80 EFI_DEADLOOP ();
81 }
82
83 VOID
84 EfiDebugVPrint (
85 IN UINTN ErrorLevel,
86 IN CHAR8 *Format,
87 IN VA_LIST Marker
88 )
89 /*++
90
91 Routine Description:
92
93 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
94 information. If Error Logging hub is not loaded do nothing.
95
96 We use UINT64 buffers due to IPF alignment concerns.
97
98 Arguments:
99
100 ErrorLevel - If error level is set do the debug print.
101
102 Format - String to use for the print, followed by Print arguments.
103
104 Marker - VarArgs
105
106 Returns:
107
108 None
109
110 --*/
111 {
112 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
113 UINTN ImageDebugMask;
114
115 //
116 // Check driver debug mask value and global mask
117 //
118 if (gDebugMaskInterface != NULL) {
119 gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);
120 if (!(ErrorLevel & ImageDebugMask)) {
121 return ;
122 }
123 } else if (!(gErrorLevel & ErrorLevel)) {
124 return ;
125 }
126
127 EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
128
129 EfiLibReportStatusCode (
130 EFI_DEBUG_CODE,
131 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
132 (UINT32) ErrorLevel,
133 &gEfiCallerIdGuid,
134 (EFI_STATUS_CODE_DATA *) Buffer
135 );
136
137 return ;
138 }
139
140 VOID
141 EfiDebugPrint (
142 IN UINTN ErrorLevel,
143 IN CHAR8 *Format,
144 ...
145 )
146 /*++
147
148 Routine Description:
149
150 Wrapper for EfiDebugVPrint ()
151
152 Arguments:
153
154 ErrorLevel - If error level is set do the debug print.
155
156 Format - String to use for the print, followed by Print arguments.
157
158 ... - Print arguments.
159
160
161 Returns:
162
163 None
164
165 --*/
166 {
167 VA_LIST Marker;
168
169 VA_START (Marker, Format);
170 EfiDebugVPrint (ErrorLevel, Format, Marker);
171 VA_END (Marker);
172 }