~ubuntu-branches/ubuntu/vivid/virtualbox-ose/vivid

« back to all changes in this revision

Viewing changes to src/VBox/Devices/EFI/Firmware2/VBoxPkg/Library/VBoxOemHookStatusCodeLib/VBoxOemHookStatusCodeLib.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-03-11 17:16:37 UTC
  • mfrom: (0.3.4 upstream) (0.4.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100311171637-43z64ia3ccpj8vqn
Tags: 3.1.4-dfsg-2ubuntu1
* Merge from Debian unstable (LP: #528561), remaining changes:
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
  - Replace *-source packages with transitional packages for *-dkms
* Fix crash in vboxvideo_drm with kernel 2.6.33 / backported drm code
  (LP: #535297)
* Add a list of linux-headers packages to the apport hook
* Update debian/patches/u02-lp-integration.dpatch with a
  DEP-3 compliant header
* Add ${misc:Depends} to virtualbox-ose-source and virtualbox-ose-guest-source
  Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: VBoxOemHookStatusCodeLib.c $ */
 
2
/** @file
 
3
 * DxeVBoxOemHookStatusCodeLib.c - Logging.
 
4
 */
 
5
 
 
6
 
 
7
/*
 
8
 * Copyright (C) 2009-2010 Sun Microsystems, Inc.
 
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
 * 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.
 
21
 */
 
22
 
 
23
 
 
24
/*******************************************************************************
 
25
*   Header Files                                                               *
 
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>
 
35
#endif
 
36
 
 
37
#include "VBoxDebugLib.h"
 
38
#include "DevEFI.h"
 
39
 
 
40
 
 
41
 
 
42
EFI_STATUS EFIAPI
 
43
OemHookStatusCodeInitialize(VOID)
 
44
{
 
45
    VBoxPrintString("OemHookStatusCodeInitialize\n");
 
46
    return EFI_SUCCESS;
 
47
}
 
48
 
 
49
 
 
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.
 
53
       */
 
54
/**
 
55
 * Helper VBoxSecPeiReportStatusCode uses for catching some odd reports.
 
56
 */
 
57
static BOOLEAN
 
58
VBoxSecExtractDebugInfo(IN CONST EFI_STATUS_CODE_DATA *pData,
 
59
                        OUT UINT32 *puErrorLevel,
 
60
                        OUT VA_LIST *pVa,
 
61
                        OUT CHAR8 **ppszFormat)
 
62
{
 
63
    EFI_DEBUG_INFO *pDebugInfo;
 
64
 
 
65
    if (    !CompareGuid(&pData->Type, &gEfiStatusCodeSpecificDataGuid)
 
66
        ||  pData->HeaderSize != sizeof(*pData)
 
67
        ||  pData->Size <= sizeof(UINT64) * 12 + sizeof(EFI_DEBUG_INFO) + 1)
 
68
        return FALSE;
 
69
 
 
70
    pDebugInfo  = (EFI_DEBUG_INFO *)(pData + 1);
 
71
    *pVa        = (VA_LIST)(pDebugInfo + 1);
 
72
    *ppszFormat = (CHAR8 *)((UINT64 *)pVa + 12);
 
73
    return TRUE;
 
74
}
 
75
#endif
 
76
 
 
77
/** Worker that dumps the raw data. */
 
78
static void
 
79
VBoxOemHookStatusCodeReportRawDump(EFI_STATUS_CODE_TYPE Type,
 
80
                                   EFI_STATUS_CODE_VALUE Value,
 
81
                                   UINT32 Instance,
 
82
                                   CONST EFI_GUID *CallerId)
 
83
{
 
84
    VBoxPrintString("Report: Type=");
 
85
    VBoxPrintHex(Type, sizeof(Type));
 
86
    VBoxPrintString(" Value=");
 
87
    VBoxPrintHex(Value, sizeof(Value));
 
88
 
 
89
    VBoxPrintString(" Instance=");
 
90
    VBoxPrintHex(Instance, sizeof(Instance));
 
91
    if (CallerId)
 
92
    {
 
93
        VBoxPrintString(" CallerId=");
 
94
        VBoxPrintGuid(CallerId);
 
95
    }
 
96
 
 
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... */
 
100
    {
 
101
        CASE_PRINT(EFI_ERROR_,MINOR,);
 
102
        CASE_PRINT(EFI_ERROR_,MAJOR,);
 
103
        CASE_PRINT(EFI_ERROR_,UNRECOVERED,);
 
104
        CASE_PRINT(EFI_ERROR_,UNCONTAINED,);
 
105
    }
 
106
    switch (Type & EFI_STATUS_CODE_TYPE_MASK) /* quick guess work... */
 
107
    {
 
108
        CASE_PRINT(EFI_,PROGRESS,_CODE);
 
109
        CASE_PRINT(EFI_,ERROR,_CODE);
 
110
        CASE_PRINT(EFI_,DEBUG,_CODE);
 
111
    }
 
112
#undef CASE_PRINT
 
113
    VBoxPrintChar('\n');
 
114
}
 
115
 
 
116
 
 
117
EFI_STATUS EFIAPI
 
118
OemHookStatusCodeReport(IN EFI_STATUS_CODE_TYPE Type,
 
119
                        IN EFI_STATUS_CODE_VALUE Value,
 
120
                        IN UINT32 Instance,
 
121
                        IN EFI_GUID *CallerId OPTIONAL,
 
122
                        IN EFI_STATUS_CODE_DATA *Data OPTIONAL)
 
123
{
 
124
    /*
 
125
     * Try figure out the data payload
 
126
     */
 
127
    if (Data != NULL)
 
128
    {
 
129
        CHAR8      *pszFilename;
 
130
        CHAR8      *pszDescription;
 
131
        UINT32      uLine;
 
132
        UINT32      uErrorLevel;
 
133
        BASE_LIST   bs;
 
134
        CHAR8      *pszFormat;
 
135
 
 
136
        if (ReportStatusCodeExtractAssertInfo(Type, Value, Data, &pszFilename,
 
137
                                              &pszDescription, &uLine))
 
138
        {
 
139
            VBoxPrintString("Assertion Failed! Line=0x");
 
140
            VBoxPrintHex(uLine, sizeof(uLine));
 
141
            if (pszFilename)
 
142
            {
 
143
                VBoxPrintString(" File=");
 
144
                VBoxPrintString(pszFilename);
 
145
            }
 
146
            if (pszDescription)
 
147
            {
 
148
                VBoxPrintString(" Desc=");
 
149
                VBoxPrintString(pszDescription);
 
150
            }
 
151
            VBoxPrintChar('\n');
 
152
        }
 
153
        else if (   ReportStatusCodeExtractDebugInfo(Data, &uErrorLevel, &bs, &pszFormat)
 
154
#if 0 /* See question at VBoxSecExtractDebugInfo. */
 
155
                 || VBoxSecExtractDebugInfo(Data, &uErrorLevel, &va, &pszFormat)
 
156
#endif
 
157
        )
 
158
        {
 
159
            CHAR8   szBuf[128];
 
160
            UINTN   cch;
 
161
 
 
162
            cch = AsciiBSPrint(szBuf, sizeof(szBuf), pszFormat, bs);
 
163
            if (cch >= sizeof(szBuf))
 
164
                cch = sizeof(szBuf) - 1;
 
165
            while (     cch > 0
 
166
                   &&   (   szBuf[cch - 1] == '\n'
 
167
                         || szBuf[cch - 1] == '\r'))
 
168
                cch--;
 
169
            szBuf[cch] = '\0';
 
170
 
 
171
            VBoxPrintString("DBG/");
 
172
            VBoxPrintHex(uErrorLevel, sizeof(uErrorLevel));
 
173
            VBoxPrintString(": ");
 
174
            VBoxPrintString(szBuf);
 
175
            VBoxPrintChar('\n');
 
176
        }
 
177
        else
 
178
        {
 
179
            /*
 
180
             * Unknown data, resort to raw dump of everything.
 
181
             */
 
182
            VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);
 
183
 
 
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);
 
193
        }
 
194
    }
 
195
    /*
 
196
     * No data, do a raw dump.
 
197
     */
 
198
    else
 
199
        VBoxOemHookStatusCodeReportRawDump(Type, Value, Instance, CallerId);
 
200
 
 
201
    return EFI_SUCCESS;
 
202
}
 
203