TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeEmuLib.c
1/*++ @file
2
3Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4Portions copyright (c) 2011, Apple Inc. All rights reserved.
5SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <PiDxe.h>
10
11#include <Library/DebugLib.h>
12#include <Library/HobLib.h>
13#include <Library/EmuThunkLib.h>
15
16EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
17
28EFIAPI
29DxeEmuLibConstructor (
30 IN EFI_HANDLE ImageHandle,
31 IN EFI_SYSTEM_TABLE *SystemTable
32 )
33{
34 EFI_HOB_GUID_TYPE *GuidHob;
35
36 GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);
37 ASSERT (GuidHob != NULL);
38
39 gEmuThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
40 ASSERT (gEmuThunk != NULL);
41
42 return EFI_SUCCESS;
43}
44
57EFIAPI
58GetIoThunkInstance (
59 IN EFI_GUID *Protocol,
60 IN UINTN Instance
61 )
62{
63 EFI_STATUS Status;
64 EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
65
66 for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
67 Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);
68 if (EFI_ERROR (Status)) {
69 break;
70 }
71
72 if (EmuIoThunk->Instance == Instance) {
73 if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {
74 return EmuIoThunk;
75 }
76 }
77 }
78
79 return NULL;
80}
UINT64 UINTN
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EMU_GET_NEXT_PROTOCOL GetNextProtocol
Definition: EmuThunk.h:242
Definition: Base.h:213