2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/misc/debug.c
5 * PURPOSE: Boot Library Debug Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
13 /* DATA VARIABLES ************************************************************/
15 CHAR AnsiBuffer
[1024];
16 BOOLEAN BdDebuggerNotPresent
;
17 BOOLEAN BdSubsystemInitialized
;
18 BOOLEAN BdArchBlockDebuggerOperation
;
19 BOOLEAN BlpStatusErrorInProgress
;
20 PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
;
22 /* FUNCTIONS *****************************************************************/
25 BdDebuggerInitialized (
29 /* Check if BD was initialized, and is currently usable */
30 return BdSubsystemInitialized
&& !BdArchBlockDebuggerOperation
;
36 _Out_ PVOID BaseAddress
,
37 _Out_ PULONGLONG FileSize
40 /* Is the boot debugger enabled? */
41 if (!BlBdDebuggerEnabled())
44 return STATUS_DEBUGGER_INACTIVE
;
48 EfiPrintf(L
"Todo\r\n");
49 return STATUS_NOT_IMPLEMENTED
;
57 BOOLEAN Initialized
, Enabled
;
59 /* Check if the debugger is initialized */
60 Initialized
= BdDebuggerInitialized();
62 /* Check if it's currently active */
64 if ((Initialized
) && !(BdDebuggerNotPresent
))
70 /* Return enabled state */
80 ANSI_STRING AnsiString
;
81 UNICODE_STRING UnicodeString
;
87 /* Check if the boot debugger is enabled */
88 if (BlBdDebuggerEnabled()
94 /* Print the string out into a buffer */
95 if (vswprintf(BlScratchBuffer
, Format
, va
) > 0)
98 EfiPrintf(BlScratchBuffer
);
101 /* Make it a UNICODE_STRING */
102 RtlInitUnicodeString(&UnicodeString
, BlScratchBuffer
);
104 /* Then convert it into an ANSI_STRING */
105 AnsiString
.Length
= 0;
106 AnsiString
.MaximumLength
= sizeof(AnsiBuffer
);
107 AnsiString
.Buffer
= AnsiBuffer
;
108 Status
= RtlUnicodeStringToAnsiString(&AnsiString
, &UnicodeString
, FALSE
);
109 if (NT_SUCCESS(Status
))
111 /* Print it out to the debugger if that worked */
112 DbgPrint(AnsiString
.Buffer
);
122 _In_ ULONG ErrorCode
,
123 _In_ ULONG Parameter1
,
124 _In_ ULONG_PTR Parameter2
,
125 _In_ ULONG_PTR Parameter3
,
126 _In_ ULONG_PTR Parameter4
131 /* Is this a non-boot error? */
134 /* Is one already ongoing? */
135 if (!BlpStatusErrorInProgress
)
137 /* Do we have a custom error handler registered? */
138 if (BlpStatusErrorHandler
)
140 /* Call it, making sure to avoid recursion */
141 BlpStatusErrorInProgress
= TRUE
;
142 Status
= BlpStatusErrorHandler(ErrorCode
,
147 BlpStatusErrorInProgress
= FALSE
;
149 /* If the error handler consumed the error, we're done */
150 if (NT_SUCCESS(Status
))
158 /* Check if the boot debugger is enabled */
159 if (BlBdDebuggerEnabled())
161 /* Print out the fatal error */
163 L
"*** Fatal Error 0x%08x :\n"
164 L
" (0x%p, 0x%p, 0x%p, 0x%p)\n"
172 /* Issue a breakpoint */