20#include <Library/BaseLib.h>
21#include <Library/BaseMemoryLib.h>
22#include <Library/DebugLib.h>
23#include <Library/DebugPrintErrorLevelLib.h>
24#include <Library/MemoryAllocationLib.h>
25#include <Library/PcdLib.h>
26#include <Library/PrintLib.h>
27#include <Library/UefiBootServicesTableLib.h>
29#define OC_LOG_BUFFER_SIZE (2 * EFI_PAGE_SIZE)
45 if (mInternalOcLog == NULL) {
46 Status =
gBS->LocateProtocol (
49 (VOID **)&mInternalOcLog
52 if (EFI_ERROR (Status) || (mInternalOcLog->Revision !=
OC_LOG_REVISION)) {
53 mInternalOcLog = NULL;
57 return mInternalOcLog;
77 gBS->CloseEvent (Event);
89 OcLog->
Options &= ~OC_LOG_CONSOLE;
92 for (Index = 0; Index <
mLogCount; ++Index) {
96 CopyMem (&ErrorLevel, Walker,
sizeof (ErrorLevel));
97 Walker +=
sizeof (ErrorLevel);
104 while (*Walker !=
'\0') {
145 Status =
gBS->CreateEvent (
153 if (!EFI_ERROR (Status)) {
154 Status =
gBS->RegisterProtocolNotify (
160 if (EFI_ERROR (Status)) {
161 gBS->CloseEvent (Event);
180 while (*
Buffer != CHAR_NULL) {
208 IN CONST CHAR8 *Format,
215 BOOLEAN IsBufferEarlyLogEnabled;
216 BOOLEAN ShouldPrintConsole;
221 IsBufferEarlyLogEnabled = PcdGetBool (PcdDebugLibProtocolBufferEarlyLog);
222 ShouldPrintConsole = (ErrorLevel & GetDebugPrintErrorLevel ()) != 0;
224 VA_START (Marker, Format);
227 OcLog->
AddEntry (OcLog, ErrorLevel, Format, Marker);
228 }
else if (IsBufferEarlyLogEnabled || ShouldPrintConsole) {
229 UnicodeVSPrintAsciiFormat (
Buffer,
sizeof (
Buffer), Format, Marker);
231 if (IsBufferEarlyLogEnabled) {
235 if (ShouldPrintConsole) {
269 IN CONST CHAR8 *FileName,
271 IN CONST CHAR8 *Description
279 "ASSERT [%a] %a(%d): %a\n",
289 if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
291 }
else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
344 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
363 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
382 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
401 return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
416 IN CONST UINTN ErrorLevel
419 return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
432 IN CONST CHAR16 *Format,
439 VA_START (Marker, Format);
440 UnicodeVSPrint (
Buffer,
sizeof (
Buffer), Format, Marker);
VOID EFIAPI DebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
BOOLEAN EFIAPI DebugPrintLevelEnabled(IN CONST UINTN ErrorLevel)
VOID *EFIAPI DebugClearMemory(OUT VOID *Buffer, IN UINTN Length)
#define OC_LOG_BUFFER_SIZE
STATIC VOID OcBufferEarlyLog(IN UINTN ErrorLevel, IN CONST CHAR16 *Buffer)
STATIC VOID EFIAPI LogProtocolArrivedNotify(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format,...)
VOID EFIAPI OcPrintScreen(IN CONST CHAR16 *Format,...)
BOOLEAN EFIAPI DebugCodeEnabled(VOID)
STATIC UINT8 * mLogBuffer
STATIC OC_LOG_PROTOCOL * InternalGetOcLog(VOID)
STATIC UINT8 * mLogWalker
BOOLEAN EFIAPI DebugClearMemoryEnabled(VOID)
BOOLEAN EFIAPI DebugPrintEnabled(VOID)
BOOLEAN EFIAPI DebugAssertEnabled(VOID)
EFI_GUID gOcLogProtocolGuid
A global variable storing the GUID of the OC_LOG_PROTOCOL.
OC_TYPING_BUFFER_ENTRY Buffer[OC_TYPING_BUFFER_SIZE]
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
CONST CHAR8 * gEfiCallerBaseName
VOID EFIAPI CpuBreakpoint(VOID)
OC_LOG_ADD_ENTRY AddEntry
A pointer to the AddEntry function.
OC_LOG_OPTIONS Options
The current options of the installed protocol.