]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
edk2/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h:
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / Debug.c
CommitLineData
3eb9473e 1/*++\r
2\r
3Copyright (c) 2004 - 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 Debug.c\r
15\r
16Abstract:\r
17\r
18 Support for Debug primatives. \r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23#include "EfiDriverLib.h"\r
24#include "EfiPrintLib.h"\r
25#include "EfiStatusCode.h"\r
26#include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
27#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
28#include EFI_PROTOCOL_DEFINITION (DEBUGMASK)\r
29\r
30//\r
31// You would think you should divid by sizeof (UINT64), but EBC does not like\r
32// that!\r
33//\r
34#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)\r
35\r
36VOID\r
37EfiDebugAssert (\r
38 IN CHAR8 *FileName,\r
39 IN INTN LineNumber,\r
40 IN CHAR8 *Description\r
41 )\r
42/*++\r
43\r
44Routine Description:\r
45\r
46 Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT\r
47 information. If Error Logging hub is not loaded BREAKPOINT().\r
48\r
49 We use UINT64 buffers due to IPF alignment concerns.\r
50\r
51Arguments:\r
52\r
53 FileName - File name of failing routine.\r
54\r
55 LineNumber - Line number of failing ASSERT().\r
56\r
57 Description - Descritption, usally the assertion,\r
58 \r
59Returns:\r
60 \r
61 None\r
62\r
63--*/\r
64{\r
65 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
66\r
67 EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);\r
68\r
69 EfiLibReportStatusCode (\r
70 (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
71 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
72 0,\r
73 &gEfiCallerIdGuid,\r
74 (EFI_STATUS_CODE_DATA *) Buffer\r
75 );\r
76\r
77 //\r
78 // Put break point in module that contained the error.\r
79 //\r
57d40fe2 80#ifndef __GNUC__\r
3eb9473e 81 EFI_BREAKPOINT ();\r
57d40fe2 82#else\r
83 //\r
84 // Bugbug: Need to fix a GNC style cpu break point\r
85 // \r
86 EFI_DEADLOOP ();\r
87#endif\r
3eb9473e 88}\r
89\r
90VOID\r
91EfiDebugVPrint (\r
92 IN UINTN ErrorLevel,\r
93 IN CHAR8 *Format,\r
94 IN VA_LIST Marker\r
95 )\r
96/*++\r
97\r
98Routine Description:\r
99\r
100 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT\r
101 information. If Error Logging hub is not loaded do nothing.\r
102\r
103 We use UINT64 buffers due to IPF alignment concerns.\r
104\r
105Arguments:\r
106\r
107 ErrorLevel - If error level is set do the debug print.\r
108\r
109 Format - String to use for the print, followed by Print arguments.\r
110\r
111 Marker - VarArgs\r
112 \r
113Returns:\r
114 \r
115 None\r
116\r
117--*/\r
118{\r
119 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
120 UINTN ImageDebugMask;\r
121\r
122 //\r
123 // Check driver debug mask value and global mask\r
124 //\r
125 if (gDebugMaskInterface != NULL) {\r
126 gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);\r
127 if (!(ErrorLevel & ImageDebugMask)) {\r
128 return ;\r
129 }\r
130 } else if (!(gErrorLevel & ErrorLevel)) {\r
131 return ;\r
132 }\r
133\r
134 EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);\r
135\r
136 EfiLibReportStatusCode (\r
137 EFI_DEBUG_CODE,\r
138 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r
139 (UINT32) ErrorLevel,\r
140 &gEfiCallerIdGuid,\r
141 (EFI_STATUS_CODE_DATA *) Buffer\r
142 );\r
143\r
144 return ;\r
145}\r
146\r
147VOID\r
148EfiDebugPrint (\r
149 IN UINTN ErrorLevel,\r
150 IN CHAR8 *Format,\r
151 ...\r
152 )\r
153/*++\r
154\r
155Routine Description:\r
156\r
157 Wrapper for EfiDebugVPrint ()\r
158 \r
159Arguments:\r
160\r
161 ErrorLevel - If error level is set do the debug print.\r
162\r
163 Format - String to use for the print, followed by Print arguments.\r
164\r
165 ... - Print arguments.\r
166\r
167 \r
168Returns:\r
169 \r
170 None\r
171\r
172--*/\r
173{\r
174 VA_LIST Marker;\r
175\r
176 VA_START (Marker, Format);\r
177 EfiDebugVPrint (ErrorLevel, Format, Marker);\r
178 VA_END (Marker);\r
179}\r