TianoCore EDK2 master
Loading...
Searching...
No Matches
DebugLibPosix.c
Go to the documentation of this file.
1
10#include <stdio.h>
11
12#include <Base.h>
13#include <Library/DebugLib.h>
14#include <Library/BaseLib.h>
15#include <Library/PrintLib.h>
17
21#define MAX_DEBUG_MESSAGE_LENGTH 0x100
22
38VOID
39EFIAPI
41 IN UINTN ErrorLevel,
42 IN CONST CHAR8 *Format,
43 ...
44 )
45{
46 VA_LIST Marker;
47
48 VA_START (Marker, Format);
49 DebugVPrint (ErrorLevel, Format, Marker);
50 VA_END (Marker);
51}
52
68VOID
69EFIAPI
71 IN UINTN ErrorLevel,
72 IN CONST CHAR8 *Format,
73 IN VA_LIST VaListMarker
74 )
75{
76 CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
77
78 AsciiVSPrint (Buffer, sizeof (Buffer), Format, VaListMarker);
79 printf ("%s", Buffer);
80}
81
99VOID
100EFIAPI
102 IN UINTN ErrorLevel,
103 IN CONST CHAR8 *Format,
104 IN BASE_LIST BaseListMarker
105 )
106{
107 CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
108
109 AsciiBSPrint (Buffer, sizeof (Buffer), Format, BaseListMarker);
110 printf ("%s", Buffer);
111}
112
134VOID
135EFIAPI
137 IN CONST CHAR8 *FileName,
138 IN UINTN LineNumber,
139 IN CONST CHAR8 *Description
140 )
141{
142 printf ("ASSERT: %s(%d): %s\n", FileName, (INT32)(UINT32)LineNumber, Description);
143
144 //
145 // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
146 //
147 if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
148 CpuBreakpoint ();
149 } else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
150 CpuDeadLoop ();
151 }
152}
153
169VOID *
170EFIAPI
172 OUT VOID *Buffer,
173 IN UINTN Length
174 )
175{
176 //
177 // If Buffer is NULL, then ASSERT().
178 //
179 ASSERT (Buffer != NULL);
180
181 //
182 // SetMem() checks for the the ASSERT() condition on Length and returns Buffer
183 //
184 return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
185}
186
197BOOLEAN
198EFIAPI
200 VOID
201 )
202{
203 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
204}
205
216BOOLEAN
217EFIAPI
219 VOID
220 )
221{
222 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
223}
224
235BOOLEAN
236EFIAPI
238 VOID
239 )
240{
241 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
242}
243
254BOOLEAN
255EFIAPI
257 VOID
258 )
259{
260 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
261}
262
272BOOLEAN
273EFIAPI
275 IN CONST UINTN ErrorLevel
276 )
277{
278 return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
279}
UINT64 UINTN
VOID EFIAPI CpuDeadLoop(VOID)
Definition: CpuDeadLoop.c:25
VOID EFIAPI CpuBreakpoint(VOID)
Definition: CpuBreakpoint.c:26
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
Definition: SetMemWrapper.c:38
VOID EFIAPI DebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
VOID EFIAPI DebugVPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, IN VA_LIST VaListMarker)
Definition: DebugLibPosix.c:70
BOOLEAN EFIAPI DebugPrintLevelEnabled(IN CONST UINTN ErrorLevel)
VOID EFIAPI DebugBPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, IN BASE_LIST BaseListMarker)
VOID *EFIAPI DebugClearMemory(OUT VOID *Buffer, IN UINTN Length)
#define MAX_DEBUG_MESSAGE_LENGTH
Definition: DebugLibPosix.c:21
VOID EFIAPI DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format,...)
Definition: DebugLibPosix.c:40
BOOLEAN EFIAPI DebugCodeEnabled(VOID)
BOOLEAN EFIAPI DebugClearMemoryEnabled(VOID)
BOOLEAN EFIAPI DebugPrintEnabled(VOID)
BOOLEAN EFIAPI DebugAssertEnabled(VOID)
UINTN EFIAPI AsciiBSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN BASE_LIST Marker)
Definition: PrintLib.c:763
UINTN EFIAPI AsciiVSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
Definition: PrintLib.c:702
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define VA_START(Marker, Parameter)
Definition: Base.h:661
CHAR8 * VA_LIST
Definition: Base.h:643
#define IN
Definition: Base.h:279
UINTN * BASE_LIST
Definition: Base.h:711
#define OUT
Definition: Base.h:284
#define VA_END(Marker)
Definition: Base.h:691
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PcdGet32(TokenName)
Definition: PcdLib.h:362