]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
GCC cleanup for all EDK I DXE libraries.
[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 #ifndef __GNUC__
81 EFI_BREAKPOINT ();
82 #else
83 //
84 // Bugbug: Need to fix a GNC style cpu break point
85 //
86 EFI_DEADLOOP ();
87 #endif
88 }
89
90 VOID
91 EfiDebugVPrint (
92 IN UINTN ErrorLevel,
93 IN CHAR8 *Format,
94 IN VA_LIST Marker
95 )
96 /*++
97
98 Routine Description:
99
100 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
101 information. If Error Logging hub is not loaded do nothing.
102
103 We use UINT64 buffers due to IPF alignment concerns.
104
105 Arguments:
106
107 ErrorLevel - If error level is set do the debug print.
108
109 Format - String to use for the print, followed by Print arguments.
110
111 Marker - VarArgs
112
113 Returns:
114
115 None
116
117 --*/
118 {
119 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
120 UINTN ImageDebugMask;
121
122 //
123 // Check driver debug mask value and global mask
124 //
125 if (gDebugMaskInterface != NULL) {
126 gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);
127 if (!(ErrorLevel & ImageDebugMask)) {
128 return ;
129 }
130 } else if (!(gErrorLevel & ErrorLevel)) {
131 return ;
132 }
133
134 EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
135
136 EfiLibReportStatusCode (
137 EFI_DEBUG_CODE,
138 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
139 (UINT32) ErrorLevel,
140 &gEfiCallerIdGuid,
141 (EFI_STATUS_CODE_DATA *) Buffer
142 );
143
144 return ;
145 }
146
147 VOID
148 EfiDebugPrint (
149 IN UINTN ErrorLevel,
150 IN CHAR8 *Format,
151 ...
152 )
153 /*++
154
155 Routine Description:
156
157 Wrapper for EfiDebugVPrint ()
158
159 Arguments:
160
161 ErrorLevel - If error level is set do the debug print.
162
163 Format - String to use for the print, followed by Print arguments.
164
165 ... - Print arguments.
166
167
168 Returns:
169
170 None
171
172 --*/
173 {
174 VA_LIST Marker;
175
176 VA_START (Marker, Format);
177 EfiDebugVPrint (ErrorLevel, Format, Marker);
178 VA_END (Marker);
179 }