3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/DebugLib.h>
18 #include <Library/HobLib.h>
19 #include <Library/EmuThunkLib.h>
20 #include <Library/BaseMemoryLib.h>
22 EMU_THUNK_PROTOCOL
*gEmuThunk
= NULL
;
26 The constructor function caches the pointer of EMU Thunk protocol.
28 @param ImageHandle The firmware allocated handle for the EFI image.
29 @param SystemTable A pointer to the EFI System Table.
31 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
36 DxeEmuLibConstructor (
37 IN EFI_HANDLE ImageHandle
,
38 IN EFI_SYSTEM_TABLE
*SystemTable
41 EFI_HOB_GUID_TYPE
*GuidHob
;
43 GuidHob
= GetFirstGuidHob (&gEmuThunkProtocolGuid
);
44 ASSERT (GuidHob
!= NULL
);
46 gEmuThunk
= (EMU_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
47 ASSERT (gEmuThunk
!= NULL
);
54 Serach the EMU IO Thunk database for a matching EMU IO Thunk
57 @param Protocol Protocol to search for.
58 @param Instance Instance of protocol to search for.
60 @retval NULL Protocol and Instance not found.
61 @retval other EMU IO Thunk protocol that matched.
64 EMU_IO_THUNK_PROTOCOL
*
67 IN EFI_GUID
*Protocol
,
72 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
74 for (Status
= EFI_SUCCESS
, EmuIoThunk
= NULL
; !EFI_ERROR (Status
); ) {
75 Status
= gEmuThunk
->GetNextProtocol (FALSE
, &EmuIoThunk
);
76 if (EFI_ERROR (Status
)) {
80 if (EmuIoThunk
->Instance
== Instance
) {
81 if (CompareGuid (EmuIoThunk
->Protocol
, Protocol
)) {