]>
Commit | Line | Data |
---|---|---|
949f388f | 1 | /*++ @file\r |
2 | Reset Architectural Protocol as defined in UEFI/PI under Emulation\r | |
3 | \r | |
4 | Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r | |
5 | Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r | |
e3ba31da | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
949f388f | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include <PiDxe.h>\r | |
11 | \r | |
12 | #include <Library/BaseLib.h>\r | |
13 | #include <Library/DebugLib.h>\r | |
14 | #include <Library/UefiLib.h>\r | |
15 | #include <Library/UefiDriverEntryPoint.h>\r | |
16 | #include <Library/MemoryAllocationLib.h>\r | |
17 | #include <Library/UefiBootServicesTableLib.h>\r | |
18 | #include <Library/EmuThunkLib.h>\r | |
19 | \r | |
20 | #include <Protocol/Reset.h>\r | |
21 | \r | |
22 | \r | |
23 | VOID\r | |
24 | EFIAPI\r | |
25 | EmuResetSystem (\r | |
26 | IN EFI_RESET_TYPE ResetType,\r | |
27 | IN EFI_STATUS ResetStatus,\r | |
28 | IN UINTN DataSize,\r | |
29 | IN VOID *ResetData OPTIONAL\r | |
30 | )\r | |
31 | {\r | |
32 | EFI_STATUS Status;\r | |
33 | UINTN HandleCount;\r | |
34 | EFI_HANDLE *HandleBuffer;\r | |
35 | UINTN Index;\r | |
36 | \r | |
37 | //\r | |
38 | // Disconnect all\r | |
39 | //\r | |
40 | Status = gBS->LocateHandleBuffer (\r | |
41 | AllHandles,\r | |
42 | NULL,\r | |
43 | NULL,\r | |
44 | &HandleCount,\r | |
45 | &HandleBuffer\r | |
46 | );\r | |
47 | if (!EFI_ERROR (Status)) {\r | |
48 | for (Index = 0; Index < HandleCount; Index++) {\r | |
49 | Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r | |
50 | }\r | |
d18d8a1d | 51 | \r |
949f388f | 52 | gBS->FreePool (HandleBuffer);\r |
53 | }\r | |
54 | \r | |
55 | \r | |
56 | //\r | |
57 | // Discard ResetType, always return 0 as exit code\r | |
58 | //\r | |
59 | gEmuThunk->Exit (0);\r | |
60 | \r | |
61 | //\r | |
62 | // Should never go here\r | |
63 | //\r | |
64 | ASSERT (FALSE);\r | |
65 | \r | |
66 | return;\r | |
67 | }\r | |
68 | \r | |
69 | \r | |
70 | \r | |
71 | EFI_STATUS\r | |
72 | EFIAPI\r | |
73 | InitializeEmuReset (\r | |
74 | IN EFI_HANDLE ImageHandle,\r | |
75 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
76 | )\r | |
77 | /*++\r | |
78 | \r | |
79 | Routine Description:\r | |
80 | \r | |
81 | \r | |
82 | Arguments:\r | |
83 | \r | |
84 | ImageHandle of the loaded driver\r | |
85 | Pointer to the System Table\r | |
86 | \r | |
87 | Returns:\r | |
88 | \r | |
89 | Status\r | |
90 | **/\r | |
91 | {\r | |
92 | EFI_STATUS Status;\r | |
93 | EFI_HANDLE Handle;\r | |
94 | \r | |
95 | SystemTable->RuntimeServices->ResetSystem = EmuResetSystem;\r | |
96 | \r | |
97 | Handle = NULL;\r | |
98 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
99 | &Handle,\r | |
100 | &gEfiResetArchProtocolGuid,\r | |
101 | NULL,\r | |
102 | NULL\r | |
103 | );\r | |
104 | ASSERT_EFI_ERROR (Status);\r | |
105 | \r | |
106 | return Status;\r | |
107 | }\r | |
108 | \r |