1
/* $Id: VBoxOemHookStatusCodeLib.c $ */
3
* DxeVBoxOemHookStatusCodeLib.c - Logging.
8
* Copyright (C) 2009-2010 Sun Microsystems, Inc.
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
* available from http://www.virtualbox.org. This file is free software;
12
* you can redistribute it and/or modify it under the terms of the GNU
13
* General Public License (GPL) as published by the Free Software
14
* Foundation, in version 2 as it comes in the "COPYING" file of the
15
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19
* Clara, CA 95054 USA or visit http://www.sun.com if you need
20
* additional information or have any questions.
24
/*******************************************************************************
26
*******************************************************************************/
27
#include <Library/ReportStatusCodeLib.h>
28
#include <Library/OemHookStatusCodeLib.h>
29
#include <Library/PrintLib.h>
30
#include <Library/BaseMemoryLib.h>
31
#include <Guid/StatusCodeDataTypeId.h>
32
#include <Guid/StatusCodeDataTypeDebug.h>
33
#if 0 /* See VBoxSecExtractDebugInfo */
34
# include <DebugInfo.h>
37
#include "VBoxDebugLib.h"
43
OemHookStatusCodeInitialize(VOID)
45
VBoxPrintString("OemHookStatusCodeInitialize\n");
50
#if 0 /* vvl: With thbe new version the API changed a bit and VA_LIST isn't used any more. Before applying
51
* any changes here I would like to understand in which cases we need this help function.
52
* bird: Some components sent information in this format. Search for the UUID or EFI_DEBUG_INFO usage.
55
* Helper VBoxSecPeiReportStatusCode uses for catching some odd reports.
58
VBoxSecExtractDebugInfo(IN CONST EFI_STATUS_CODE_DATA *pData,
59
OUT UINT32 *puErrorLevel,
61
OUT CHAR8 **ppszFormat)
63
EFI_DEBUG_INFO *pDebugInfo;
65
if ( !CompareGuid(&pData->Type, &gEfiStatusCodeSpecificDataGuid)
66
|| pData->HeaderSize != sizeof(*pData)
67
|| pData->Size <= sizeof(UINT64) * 12 + sizeof(EFI_DEBUG_INFO) + 1)
70
pDebugInfo = (EFI_DEBUG_INFO *)(pData + 1);
71
*pVa = (VA_LIST)(pDebugInfo + 1);
72
*ppszFormat = (CHAR8 *)((UINT64 *)pVa + 12);
77
/** Worker that dumps the raw data. */
79
VBoxOemHookStatusCodeReportRawDump(EFI_STATUS_CODE_TYPE Type,
80
EFI_STATUS_CODE_VALUE Value,
82
CONST EFI_GUID *CallerId)
84
VBoxPrintString("Report: Type=");
85
VBoxPrintHex(Type, sizeof(Type));
86
VBoxPrintString(" Value=");
87
VBoxPrintHex(Value, sizeof(Value));
89
VBoxPrintString(" Instance=");
90
VBoxPrintHex(Instance, sizeof(Instance));
93
VBoxPrintString(" CallerId=");
94
VBoxPrintGuid(CallerId);
97
#define CASE_PRINT(Head,Print,Tail) \
98
case Head ## Print ## Tail : VBoxPrintString(" " #Print); break
99
switch (Type & EFI_STATUS_CODE_SEVERITY_MASK) /* quick guess work... */
101
CASE_PRINT(EFI_ERROR_,MINOR,);
102
CASE_PRINT(EFI_ERROR_,MAJOR,);
103
CASE_PRINT(EFI_ERROR_,UNRECOVERED,);
104
CASE_PRINT(EFI_ERROR_,UNCONTAINED,);
106
switch (Type & EFI_STATUS_CODE_TYPE_MASK) /* quick guess work... */
108
CASE_PRINT(EFI_,PROGRESS,_CODE);
109
CASE_PRINT(EFI_,ERROR,_CODE);
110
CASE_PRINT(EFI_,DEBUG,_CODE);
118
OemHookStatusCodeReport(IN EFI_STATUS_CODE_TYPE Type,
119
IN EFI_STATUS_CODE_VALUE Value,
121
IN EFI_GUID *CallerId OPTIONAL,
122
IN EFI_STATUS_CODE_DATA *Data OPTIONAL)
125
* Try figure out the data payload
130
CHAR8 *pszDescription;
136
if (ReportStatusCodeExtractAssertInfo(Type, Value, Data, &pszFilename,
137
&pszDescription, &uLine))
139
VBoxPrintString("Assertion Failed! Line=0x");
140
VBoxPrintHex(uLine, sizeof(uLine));
143
VBoxPrintString(" File=");
144
VBoxPrintString(pszFilename);
148
VBoxPrintString(" Desc=");
149
VBoxPrintString(pszDescription);
153
else if ( ReportStatusCodeExtractDebugInfo(Data, &uErrorLevel, &bs, &pszFormat)
154
#if 0 /* See question at VBoxSecExtractDebugInfo. */
155
|| VBoxSecExtractDebugInfo(Data, &uErrorLevel, &va, &pszFormat)
162
cch = AsciiBSPrint(szBuf, sizeof(szBuf), pszFormat, bs);
163
if (cch >= sizeof(szBuf))
164
cch = sizeof(szBuf) - 1;
166
&& ( szBuf[cch - 1] == '\n'
167
|| szBuf[cch - 1] == '\r'))
171
VBoxPrintString("DBG/");
172
VBoxPrintHex(uErrorLevel, sizeof(uErrorLevel));
173
VBoxPrintString(": ");
174
VBoxPrintString(szBuf);
180
* Unknown data, resort to raw dump of everything.
182
VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);
184
VBoxPrintString("OemReport: Unknown data type ");
185
VBoxPrintGuid(&Data->Type);
186
VBoxPrintString(" (Size=");
187
VBoxPrintHex(Data->Size, sizeof(Data->Size));
188
VBoxPrintString(" HeaderSize=");
189
VBoxPrintHex(Data->HeaderSize, sizeof(Data->HeaderSize));
190
VBoxPrintString(")\n");
191
if (Data->Size > 0 && Data->Size <= 128)
192
VBoxPrintHexDump(Data + 1, Data->Size);
196
* No data, do a raw dump.
199
VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);