]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmulatorPkg / Library / DxeEmuLib / DxeEmuLib.c
... / ...
CommitLineData
1/*++ @file\r
2\r
3Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16\r
17#include <Library/DebugLib.h>\r
18#include <Library/HobLib.h>\r
19#include <Library/EmuThunkLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21\r
22EMU_THUNK_PROTOCOL *gEmuThunk = NULL;\r
23\r
24\r
25/**\r
26 The constructor function caches the pointer of EMU Thunk protocol.\r
27\r
28 @param ImageHandle The firmware allocated handle for the EFI image.\r
29 @param SystemTable A pointer to the EFI System Table.\r
30\r
31 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
32\r
33**/\r
34EFI_STATUS\r
35EFIAPI\r
36DxeEmuLibConstructor (\r
37 IN EFI_HANDLE ImageHandle,\r
38 IN EFI_SYSTEM_TABLE *SystemTable\r
39 )\r
40{\r
41 EFI_HOB_GUID_TYPE *GuidHob;\r
42\r
43 GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
44 ASSERT (GuidHob != NULL);\r
45\r
46 gEmuThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
47 ASSERT (gEmuThunk != NULL);\r
48\r
49 return EFI_SUCCESS;\r
50}\r
51\r
52\r
53/**\r
54 Serach the EMU IO Thunk database for a matching EMU IO Thunk\r
55 Protocol instance.\r
56\r
57 @param Protocol Protocol to search for.\r
58 @param Instance Instance of protocol to search for.\r
59\r
60 @retval NULL Protocol and Instance not found.\r
61 @retval other EMU IO Thunk protocol that matched.\r
62\r
63**/\r
64EMU_IO_THUNK_PROTOCOL *\r
65EFIAPI\r
66GetIoThunkInstance (\r
67 IN EFI_GUID *Protocol,\r
68 IN UINTN Instance\r
69 )\r
70{\r
71 EFI_STATUS Status;\r
72 EMU_IO_THUNK_PROTOCOL *EmuIoThunk;\r
73\r
74 for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
75 Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);\r
76 if (EFI_ERROR (Status)) {\r
77 break;\r
78 }\r
79\r
80 if (EmuIoThunk->Instance == Instance) {\r
81 if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {\r
82 return EmuIoThunk;\r
83 }\r
84 }\r
85 }\r
86\r
87 return NULL;\r
88}