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

« back to all changes in this revision

Viewing changes to src/VBox/Devices/EFI/Firmware2/VBoxPkg/Library/VBoxDebugLib/VBoxPrintHex.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: VBoxPrintHex.c $ */
 
2
/** @file
 
3
 * VBoxPrintHex.c - Implementation of the VBoxPrintHex() debug logging routine.
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 2009-2010 Sun Microsystems, Inc.
 
8
 *
 
9
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
10
 * available from http://www.virtualbox.org. This file is free software;
 
11
 * you can redistribute it and/or modify it under the terms of the GNU
 
12
 * General Public License (GPL) as published by the Free Software
 
13
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
14
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
15
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
16
 *
 
17
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 
18
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 
19
 * additional information or have any questions.
 
20
 */
 
21
 
 
22
 
 
23
 
 
24
/*******************************************************************************
 
25
*   Header Files                                                               *
 
26
*******************************************************************************/
 
27
#include "VBoxDebugLib.h"
 
28
#include "DevEFI.h"
 
29
 
 
30
 
 
31
/**
 
32
 * Prints a char.
 
33
 * @param   ch              The char to print.
 
34
 */
 
35
DECLINLINE(void) vboxPrintHexChar(int ch)
 
36
{
 
37
    ASMOutU8(EFI_DEBUG_PORT, (uint8_t)ch);
 
38
}
 
39
 
 
40
 
 
41
/**
 
42
 * Print a hex number, up to 64-bit long.
 
43
 *
 
44
 * @returns Number of chars printed.
 
45
 *
 
46
 * @param   uValue          The value.
 
47
 * @param   cbType          The size of the value type.
 
48
 */
 
49
size_t VBoxPrintHex(UINT64 uValue, size_t cbType)
 
50
{
 
51
    static const char s_szHex[17] = "0123456789abcdef";
 
52
    switch (cbType)
 
53
    {
 
54
        case 8:
 
55
            vboxPrintHexChar(s_szHex[(uValue >> 60) & 0xf]);
 
56
            vboxPrintHexChar(s_szHex[(uValue >> 56) & 0xf]);
 
57
            vboxPrintHexChar(s_szHex[(uValue >> 52) & 0xf]);
 
58
            vboxPrintHexChar(s_szHex[(uValue >> 48) & 0xf]);
 
59
            vboxPrintHexChar(s_szHex[(uValue >> 44) & 0xf]);
 
60
            vboxPrintHexChar(s_szHex[(uValue >> 40) & 0xf]);
 
61
            vboxPrintHexChar(s_szHex[(uValue >> 36) & 0xf]);
 
62
            vboxPrintHexChar(s_szHex[(uValue >> 32) & 0xf]);
 
63
        case 4:
 
64
            vboxPrintHexChar(s_szHex[(uValue >> 28) & 0xf]);
 
65
            vboxPrintHexChar(s_szHex[(uValue >> 24) & 0xf]);
 
66
            vboxPrintHexChar(s_szHex[(uValue >> 20) & 0xf]);
 
67
            vboxPrintHexChar(s_szHex[(uValue >> 16) & 0xf]);
 
68
        case 2:
 
69
            vboxPrintHexChar(s_szHex[(uValue >> 12) & 0xf]);
 
70
            vboxPrintHexChar(s_szHex[(uValue >>  8) & 0xf]);
 
71
        case 1:
 
72
            vboxPrintHexChar(s_szHex[(uValue >>  4) & 0xf]);
 
73
            vboxPrintHexChar(s_szHex[(uValue      ) & 0xf]);
 
74
            break;
 
75
    }
 
76
    return cbType * 2;
 
77
}
 
78