VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxPeCoffExtraActionLib/VBoxPeCoffExtraActionLib.c@ 62501

Last change on this file since 62501 was 62500, checked in by vboxsync, 9 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: VBoxPeCoffExtraActionLib.c 62500 2016-07-22 19:06:59Z vboxsync $ */
2/** @file
3 * VBox implementation of DebugAgentLib that reports EFI state transitions
4 * to DevEFI for debugging purposes.
5 */
6
7/*
8 * Copyright (C) 2013-2016 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 <Base.h>
33#include <Library/PeCoffExtraActionLib.h>
34#include <Library/DebugLib.h>
35
36#include "VBoxPkg.h"
37#include "../../../../DevEFI.h"
38
39
40
41static void vboxImageEvtU64(uint32_t uCmd, uint64_t uValue)
42{
43 RTUINT64U u; /* 64-bit shift builtins. */
44 u.u = uValue;
45 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_MAKE(uCmd, u.au16[3]));
46 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_MAKE(uCmd, u.au16[2]));
47 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_MAKE(uCmd, u.au16[1]));
48 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_MAKE(uCmd, u.au16[0]));
49}
50
51static void vboxImageEvtString(uint32_t uCmd, const char *pszName)
52{
53 unsigned char uch;
54 while ((uch = *pszName++) != '\0')
55 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_MAKE(uCmd, uch));
56}
57
58static void vboxImageEvtEmitOne(PE_COFF_LOADER_IMAGE_CONTEXT const *pImageCtx, uint32_t uEvt)
59{
60 ASMOutU32(EFI_PORT_IMAGE_EVENT, uEvt);
61 if (pImageCtx->DestinationAddress)
62 vboxImageEvtU64(EFI_IMAGE_EVT_CMD_ADDR0, pImageCtx->DestinationAddress);
63 else
64 vboxImageEvtU64(EFI_IMAGE_EVT_CMD_ADDR0, pImageCtx->ImageAddress);
65 vboxImageEvtU64(EFI_IMAGE_EVT_CMD_SIZE0, pImageCtx->ImageSize);
66 if (pImageCtx->PdbPointer)
67 vboxImageEvtString(EFI_IMAGE_EVT_CMD_NAME, pImageCtx->PdbPointer);
68 ASMOutU32(EFI_PORT_IMAGE_EVENT, EFI_IMAGE_EVT_CMD_COMPLETE);
69}
70
71
72/* Note! Despite this saying relocate, it's always called immediately after
73 loading an image. So, treating it as a pure load event until we find
74 evidence of other usage. */
75VOID
76EFIAPI
77PeCoffLoaderRelocateImageExtraAction(
78 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
79 )
80{
81 ASSERT(ImageContext != NULL);
82#if ARCH_BITS == 32
83 vboxImageEvtEmitOne(ImageContext, EFI_IMAGE_EVT_CMD_START_LOAD32);
84#else
85 vboxImageEvtEmitOne(ImageContext, EFI_IMAGE_EVT_CMD_START_LOAD64);
86#endif
87}
88
89VOID
90EFIAPI
91PeCoffLoaderUnloadImageExtraAction(
92 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
93 )
94{
95 ASSERT(ImageContext != NULL);
96#if ARCH_BITS == 32
97 vboxImageEvtEmitOne(ImageContext, EFI_IMAGE_EVT_CMD_START_UNLOAD32);
98#else
99 vboxImageEvtEmitOne(ImageContext, EFI_IMAGE_EVT_CMD_START_UNLOAD64);
100#endif
101}
102
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