ReactOS  0.4.14-dev-57-g333b8f1
debug.c File Reference
#include "bl.h"
Include dependency graph for debug.c:

Go to the source code of this file.

Functions

BOOLEAN BdDebuggerInitialized (VOID)
 
NTSTATUS BlBdPullRemoteFile (_In_ PWCHAR FilePath, _Out_ PVOID BaseAddress, _Out_ PULONGLONG FileSize)
 
BOOLEAN BlBdDebuggerEnabled (VOID)
 
VOID BlStatusPrint (_In_ PCWCH Format,...)
 
VOID BlStatusError (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
 

Variables

CHAR AnsiBuffer [1024]
 
BOOLEAN BdDebuggerNotPresent
 
BOOLEAN BdSubsystemInitialized
 
BOOLEAN BdArchBlockDebuggerOperation
 
BOOLEAN BlpStatusErrorInProgress
 
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
 

Function Documentation

◆ BdDebuggerInitialized()

BOOLEAN BdDebuggerInitialized ( VOID  )

Definition at line 25 of file debug.c.

28 {
29  /* Check if BD was initialized, and is currently usable */
31 }
BOOLEAN BdArchBlockDebuggerOperation
Definition: debug.c:18
BOOLEAN BdSubsystemInitialized
Definition: debug.c:17

Referenced by BlBdDebuggerEnabled().

◆ BlBdDebuggerEnabled()

BOOLEAN BlBdDebuggerEnabled ( VOID  )

Definition at line 53 of file debug.c.

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 }
#define TRUE
Definition: types.h:120
BOOLEAN BdDebuggerInitialized(VOID)
Definition: debug.c:25
unsigned char BOOLEAN
BOOLEAN BdDebuggerNotPresent
Definition: debug.c:16

Referenced by BlBdPullRemoteFile(), BlImgLoadBootApplication(), BlStatusError(), BlStatusPrint(), and MmHapReportHeapCorruption().

◆ BlBdPullRemoteFile()

NTSTATUS BlBdPullRemoteFile ( _In_ PWCHAR  FilePath,
_Out_ PVOID  BaseAddress,
_Out_ PULONGLONG  FileSize 
)

Definition at line 34 of file debug.c.

39 {
40  /* Is the boot debugger enabled? */
41  if (!BlBdDebuggerEnabled())
42  {
43  /* Nothing to pull */
45  }
46 
47  /* TODO */
48  EfiPrintf(L"Todo\r\n");
50 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
#define STATUS_DEBUGGER_INACTIVE
Definition: debugger.c:30
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126

Referenced by ImgpOpenFile().

◆ BlStatusError()

VOID BlStatusError ( _In_ ULONG  ErrorCode,
_In_ ULONG  Parameter1,
_In_ ULONG_PTR  Parameter2,
_In_ ULONG_PTR  Parameter3,
_In_ ULONG_PTR  Parameter4 
)

Definition at line 121 of file debug.c.

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 */
159  if (BlBdDebuggerEnabled())
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 }
#define TRUE
Definition: types.h:120
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
Definition: debug.c:20
LONG NTSTATUS
Definition: precomp.h:26
VOID BlStatusPrint(_In_ PCWCH Format,...)
Definition: debug.c:75
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
BOOLEAN BlpStatusErrorInProgress
Definition: debug.c:19
Status
Definition: gdiplustypes.h:24

Referenced by BmFatalErrorEx().

◆ BlStatusPrint()

VOID BlStatusPrint ( _In_ PCWCH  Format,
  ... 
)

Definition at line 75 of file debug.c.

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 }
ULONG DbgPrint(PCCH Format,...)
Definition: debug.c:416
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
WCHAR BlScratchBuffer[8192]
Definition: firmware.c:39
LONG NTSTATUS
Definition: precomp.h:26
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define DBG(x)
Definition: moztest.c:12
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CHAR AnsiBuffer[1024]
Definition: debug.c:15
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
Status
Definition: gdiplustypes.h:24
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_CRTIMP int __cdecl vswprintf(_Out_ wchar_t *, const wchar_t *, va_list)

Referenced by BiEnumerateSubObjectElements(), BlStatusError(), BmFatalErrorEx(), BmFwMemoryInitialize(), MmHapReportHeapCorruption(), OslAbortBoot(), and OslFatalErrorEx().

Variable Documentation

◆ AnsiBuffer

CHAR AnsiBuffer[1024]

◆ BdArchBlockDebuggerOperation

BOOLEAN BdArchBlockDebuggerOperation

Definition at line 18 of file debug.c.

Referenced by BdDebuggerInitialized().

◆ BdDebuggerNotPresent

BOOLEAN BdDebuggerNotPresent

Definition at line 16 of file debug.c.

Referenced by BlBdDebuggerEnabled(), and BlImgLoadBootApplication().

◆ BdSubsystemInitialized

BOOLEAN BdSubsystemInitialized

Definition at line 17 of file debug.c.

Referenced by BdDebuggerInitialized().

◆ BlpStatusErrorHandler

PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler

Definition at line 20 of file debug.c.

Referenced by BlStatusError(), and OslPrepareTarget().

◆ BlpStatusErrorInProgress

BOOLEAN BlpStatusErrorInProgress

Definition at line 19 of file debug.c.

Referenced by BlStatusError().