VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxOemHookStatusCodeLib/VBoxOemHookStatusCodeLib.c@ 56292

Last change on this file since 56292 was 56292, checked in by vboxsync, 10 years ago

Devices: Updated (C) year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/* $Id: VBoxOemHookStatusCodeLib.c 56292 2015-06-09 14:20:46Z vboxsync $ */
2/** @file
3 * DxeVBoxOemHookStatusCodeLib.c - Logging.
4 */
5
6
7/*
8 * Copyright (C) 2009-2015 Oracle Corporation
9 *
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.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29/*******************************************************************************
30* Header Files *
31*******************************************************************************/
32#include <Library/ReportStatusCodeLib.h>
33#include <Library/OemHookStatusCodeLib.h>
34#include <Library/PrintLib.h>
35#include <Library/BaseMemoryLib.h>
36#include <Guid/StatusCodeDataTypeId.h>
37#include <Guid/StatusCodeDataTypeDebug.h>
38#if 0 /* See VBoxSecExtractDebugInfo */
39# include <DebugInfo.h>
40#endif
41
42#include "VBoxDebugLib.h"
43#include "DevEFI.h"
44
45
46
47EFI_STATUS EFIAPI
48OemHookStatusCodeInitialize(VOID)
49{
50 VBoxPrintString("OemHookStatusCodeInitialize\n");
51 return EFI_SUCCESS;
52}
53
54
55#if 0 /* vvl: With thbe new version the API changed a bit and VA_LIST isn't used any more. Before applying
56 * any changes here I would like to understand in which cases we need this help function.
57 * bird: Some components sent information in this format. Search for the UUID or EFI_DEBUG_INFO usage.
58 */
59/**
60 * Helper VBoxSecPeiReportStatusCode uses for catching some odd reports.
61 */
62static BOOLEAN
63VBoxSecExtractDebugInfo(IN CONST EFI_STATUS_CODE_DATA *pData,
64 OUT UINT32 *puErrorLevel,
65 OUT VA_LIST *pVa,
66 OUT CHAR8 **ppszFormat)
67{
68 EFI_DEBUG_INFO *pDebugInfo;
69
70 if ( !CompareGuid(&pData->Type, &gEfiStatusCodeSpecificDataGuid)
71 || pData->HeaderSize != sizeof(*pData)
72 || pData->Size <= sizeof(UINT64) * 12 + sizeof(EFI_DEBUG_INFO) + 1)
73 return FALSE;
74
75 pDebugInfo = (EFI_DEBUG_INFO *)(pData + 1);
76 *pVa = (VA_LIST)(pDebugInfo + 1);
77 *ppszFormat = (CHAR8 *)((UINT64 *)pVa + 12);
78 return TRUE;
79}
80#endif
81
82/** Worker that dumps the raw data. */
83static void
84VBoxOemHookStatusCodeReportRawDump(EFI_STATUS_CODE_TYPE Type,
85 EFI_STATUS_CODE_VALUE Value,
86 UINT32 Instance,
87 CONST EFI_GUID *CallerId)
88{
89 VBoxPrintString("Report: Type=");
90 VBoxPrintHex(Type, sizeof(Type));
91 VBoxPrintString(" Value=");
92 VBoxPrintHex(Value, sizeof(Value));
93
94 VBoxPrintString(" Instance=");
95 VBoxPrintHex(Instance, sizeof(Instance));
96 if (CallerId)
97 {
98 VBoxPrintString(" CallerId=");
99 VBoxPrintGuid(CallerId);
100 }
101
102#define CASE_PRINT(Head,Print,Tail) \
103 case Head ## Print ## Tail : VBoxPrintString(" " #Print); break
104 switch (Type & EFI_STATUS_CODE_SEVERITY_MASK) /* quick guess work... */
105 {
106 CASE_PRINT(EFI_ERROR_,MINOR,);
107 CASE_PRINT(EFI_ERROR_,MAJOR,);
108 CASE_PRINT(EFI_ERROR_,UNRECOVERED,);
109 CASE_PRINT(EFI_ERROR_,UNCONTAINED,);
110 }
111 switch (Type & EFI_STATUS_CODE_TYPE_MASK) /* quick guess work... */
112 {
113 CASE_PRINT(EFI_,PROGRESS,_CODE);
114 CASE_PRINT(EFI_,ERROR,_CODE);
115 CASE_PRINT(EFI_,DEBUG,_CODE);
116 }
117#undef CASE_PRINT
118 VBoxPrintChar('\n');
119}
120
121
122EFI_STATUS EFIAPI
123OemHookStatusCodeReport(IN EFI_STATUS_CODE_TYPE Type,
124 IN EFI_STATUS_CODE_VALUE Value,
125 IN UINT32 Instance,
126 IN EFI_GUID *CallerId OPTIONAL,
127 IN EFI_STATUS_CODE_DATA *Data OPTIONAL)
128{
129 /*
130 * Try figure out the data payload
131 */
132 if (Data != NULL)
133 {
134 CHAR8 *pszFilename;
135 CHAR8 *pszDescription;
136 UINT32 uLine;
137 UINT32 uErrorLevel;
138 BASE_LIST bs;
139 CHAR8 *pszFormat;
140
141 if (ReportStatusCodeExtractAssertInfo(Type, Value, Data, &pszFilename,
142 &pszDescription, &uLine))
143 {
144 VBoxPrintString("Assertion Failed! Line=0x");
145 VBoxPrintHex(uLine, sizeof(uLine));
146 if (pszFilename)
147 {
148 VBoxPrintString(" File=");
149 VBoxPrintString(pszFilename);
150 }
151 if (pszDescription)
152 {
153 VBoxPrintString(" Desc=");
154 VBoxPrintString(pszDescription);
155 }
156 VBoxPrintChar('\n');
157 }
158 else if ( ReportStatusCodeExtractDebugInfo(Data, &uErrorLevel, &bs, &pszFormat)
159#if 0 /* See question at VBoxSecExtractDebugInfo. */
160 || VBoxSecExtractDebugInfo(Data, &uErrorLevel, &va, &pszFormat)
161#endif
162 )
163 {
164 CHAR8 szBuf[128];
165 UINTN cch;
166
167 cch = AsciiBSPrint(szBuf, sizeof(szBuf), pszFormat, bs);
168 if (cch >= sizeof(szBuf))
169 cch = sizeof(szBuf) - 1;
170 while ( cch > 0
171 && ( szBuf[cch - 1] == '\n'
172 || szBuf[cch - 1] == '\r'))
173 cch--;
174 szBuf[cch] = '\0';
175
176 VBoxPrintString("DBG/");
177 VBoxPrintHex(uErrorLevel, sizeof(uErrorLevel));
178 VBoxPrintString(": ");
179 VBoxPrintString(szBuf);
180 VBoxPrintChar('\n');
181 }
182 else
183 {
184 /*
185 * Unknown data, resort to raw dump of everything.
186 */
187 VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);
188
189 VBoxPrintString("OemReport: Unknown data type ");
190 VBoxPrintGuid(&Data->Type);
191 VBoxPrintString(" (Size=");
192 VBoxPrintHex(Data->Size, sizeof(Data->Size));
193 VBoxPrintString(" HeaderSize=");
194 VBoxPrintHex(Data->HeaderSize, sizeof(Data->HeaderSize));
195 VBoxPrintString(")\n");
196 if (Data->Size > 0 && Data->Size <= 128)
197 VBoxPrintHexDump(Data + 1, Data->Size);
198 }
199 }
200 /*
201 * No data, do a raw dump.
202 */
203 else
204 VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);
205
206 return EFI_SUCCESS;
207}
208
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette