ReactOS 0.4.15-dev-7961-gdcf9eb0
debug.c
Go to the documentation of this file.
1/*
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)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "bl.h"
12
13/* DATA VARIABLES ************************************************************/
14
21
22/* FUNCTIONS *****************************************************************/
23
26 VOID
27 )
28{
29 /* Check if BD was initialized, and is currently usable */
31}
32
38 )
39{
40 /* Is the boot debugger enabled? */
42 {
43 /* Nothing to pull */
45 }
46
47 /* TODO */
48 EfiPrintf(L"Todo\r\n");
50}
51
54 VOID
55 )
56{
58
59 /* Check if the debugger is initialized */
61
62 /* Check if it's currently active */
63 Enabled = FALSE;
65 {
66 /* Yep! */
67 Enabled = TRUE;
68 }
69
70 /* Return enabled state */
71 return Enabled;
72}
73
74VOID
77 ...
78 )
79{
82 va_list va;
84
85 va_start(va, Format);
86
87 /* Check if the boot debugger is enabled */
89#if DBG
90 || TRUE
91#endif
92 )
93 {
94 /* Print the string out into a buffer */
95 if (vswprintf(BlScratchBuffer, Format, va) > 0)
96 {
97#if DBG
99 EfiPrintf(L"\r\n");
100#endif
101 /* Make it a UNICODE_STRING */
103
104 /* Then convert it into an ANSI_STRING */
105 AnsiString.Length = 0;
106 AnsiString.MaximumLength = sizeof(AnsiBuffer);
107 AnsiString.Buffer = AnsiBuffer;
109 if (NT_SUCCESS(Status))
110 {
111 /* Print it out to the debugger if that worked */
112 DbgPrint(AnsiString.Buffer);
113 }
114 }
115 }
116
117 va_end(va);
118}
119
120VOID
123 _In_ ULONG Parameter1,
124 _In_ ULONG_PTR Parameter2,
125 _In_ ULONG_PTR Parameter3,
126 _In_ ULONG_PTR Parameter4
127 )
128{
130
131 /* Is this a non-boot error? */
132 if (ErrorCode != 1)
133 {
134 /* Is one already ongoing? */
136 {
137 /* Do we have a custom error handler registered? */
139 {
140 /* Call it, making sure to avoid recursion */
143 Parameter1,
144 Parameter2,
145 Parameter3,
146 Parameter4);
148
149 /* If the error handler consumed the error, we're done */
150 if (NT_SUCCESS(Status))
151 {
152 return;
153 }
154 }
155 }
156 }
157
158 /* Check if the boot debugger is enabled */
160 {
161 /* Print out the fatal error */
162 BlStatusPrint(L"\n"
163 L"*** Fatal Error 0x%08x :\n"
164 L" (0x%p, 0x%p, 0x%p, 0x%p)\n"
165 L"\n",
166 ErrorCode,
167 Parameter1,
168 Parameter2,
169 Parameter3,
170 Parameter4);
171
172 /* Issue a breakpoint */
173 __debugbreak();
174 }
175}
176
PCWSTR FilePath
unsigned char BOOLEAN
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
LONG NTSTATUS
Definition: precomp.h:26
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
WCHAR BlScratchBuffer[8192]
Definition: firmware.c:39
NTSTATUS(* PBL_STATUS_ERROR_HANDLER)(_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
Definition: bl.h:745
BOOLEAN BdDebuggerInitialized(VOID)
Definition: debug.c:25
NTSTATUS BlBdPullRemoteFile(_In_ PWCHAR FilePath, _Out_ PVOID BaseAddress, _Out_ PULONGLONG FileSize)
Definition: debug.c:34
BOOLEAN BlpStatusErrorInProgress
Definition: debug.c:19
BOOLEAN BdDebuggerNotPresent
Definition: debug.c:16
BOOLEAN BdArchBlockDebuggerOperation
Definition: debug.c:18
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
Definition: debug.c:20
CHAR AnsiBuffer[1024]
Definition: debug.c:15
BOOLEAN BdSubsystemInitialized
Definition: debug.c:17
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
VOID BlStatusPrint(_In_ PCWCH Format,...)
Definition: debug.c:75
VOID BlStatusError(_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
Definition: debug.c:121
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
@ AnsiString
Definition: dnslib.h:19
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
static _Check_return_opt_ int __cdecl vswprintf(_Out_writes_z_(_SizeInWords) wchar_t *_DstBuf, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
Definition: stdio.h:977
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
#define STATUS_DEBUGGER_INACTIVE
Definition: debugger.c:30
@ Enabled
Definition: mountmgr.h:159
#define DBG(x)
Definition: moztest.c:12
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
@ Initialized
Definition: ketypes.h:388
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
CONST WCHAR * PCWCH
Definition: ntbasedef.h:411
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
char CHAR
Definition: xmlstorage.h:175