]>
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 | |
d18d8a1d | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
949f388f | 13 | \r |
14 | **/\r | |
15 | \r | |
16 | #include <PiDxe.h>\r | |
17 | \r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/UefiLib.h>\r | |
21 | #include <Library/UefiDriverEntryPoint.h>\r | |
22 | #include <Library/MemoryAllocationLib.h>\r | |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
24 | #include <Library/EmuThunkLib.h>\r | |
25 | \r | |
26 | #include <Protocol/Reset.h>\r | |
27 | \r | |
28 | \r | |
29 | VOID\r | |
30 | EFIAPI\r | |
31 | EmuResetSystem (\r | |
32 | IN EFI_RESET_TYPE ResetType,\r | |
33 | IN EFI_STATUS ResetStatus,\r | |
34 | IN UINTN DataSize,\r | |
35 | IN VOID *ResetData OPTIONAL\r | |
36 | )\r | |
37 | {\r | |
38 | EFI_STATUS Status;\r | |
39 | UINTN HandleCount;\r | |
40 | EFI_HANDLE *HandleBuffer;\r | |
41 | UINTN Index;\r | |
42 | \r | |
43 | //\r | |
44 | // Disconnect all\r | |
45 | //\r | |
46 | Status = gBS->LocateHandleBuffer (\r | |
47 | AllHandles,\r | |
48 | NULL,\r | |
49 | NULL,\r | |
50 | &HandleCount,\r | |
51 | &HandleBuffer\r | |
52 | );\r | |
53 | if (!EFI_ERROR (Status)) {\r | |
54 | for (Index = 0; Index < HandleCount; Index++) {\r | |
55 | Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r | |
56 | }\r | |
d18d8a1d | 57 | \r |
949f388f | 58 | gBS->FreePool (HandleBuffer);\r |
59 | }\r | |
60 | \r | |
61 | \r | |
62 | //\r | |
63 | // Discard ResetType, always return 0 as exit code\r | |
64 | //\r | |
65 | gEmuThunk->Exit (0);\r | |
66 | \r | |
67 | //\r | |
68 | // Should never go here\r | |
69 | //\r | |
70 | ASSERT (FALSE);\r | |
71 | \r | |
72 | return;\r | |
73 | }\r | |
74 | \r | |
75 | \r | |
76 | \r | |
77 | EFI_STATUS\r | |
78 | EFIAPI\r | |
79 | InitializeEmuReset (\r | |
80 | IN EFI_HANDLE ImageHandle,\r | |
81 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
82 | )\r | |
83 | /*++\r | |
84 | \r | |
85 | Routine Description:\r | |
86 | \r | |
87 | \r | |
88 | Arguments:\r | |
89 | \r | |
90 | ImageHandle of the loaded driver\r | |
91 | Pointer to the System Table\r | |
92 | \r | |
93 | Returns:\r | |
94 | \r | |
95 | Status\r | |
96 | **/\r | |
97 | {\r | |
98 | EFI_STATUS Status;\r | |
99 | EFI_HANDLE Handle;\r | |
100 | \r | |
101 | SystemTable->RuntimeServices->ResetSystem = EmuResetSystem;\r | |
102 | \r | |
103 | Handle = NULL;\r | |
104 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
105 | &Handle,\r | |
106 | &gEfiResetArchProtocolGuid,\r | |
107 | NULL,\r | |
108 | NULL\r | |
109 | );\r | |
110 | ASSERT_EFI_ERROR (Status);\r | |
111 | \r | |
112 | return Status;\r | |
113 | }\r | |
114 | \r |