]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/ResetRuntimeDxe/Reset.c
IntelFsp2WrapperPkg: Convert files to CRLF line ending
[mirror_edk2.git] / EmulatorPkg / ResetRuntimeDxe / Reset.c
CommitLineData
949f388f 1/*++ @file\r
2 Reset Architectural Protocol as defined in UEFI/PI under Emulation\r
3\r
4Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
5Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
d18d8a1d 6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT 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
29VOID\r
30EFIAPI\r
31EmuResetSystem (\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
77EFI_STATUS\r
78EFIAPI\r
79InitializeEmuReset (\r
80 IN EFI_HANDLE ImageHandle,\r
81 IN EFI_SYSTEM_TABLE *SystemTable\r
82 )\r
83/*++\r
84\r
85Routine Description:\r
86\r
87\r
88Arguments:\r
89\r
90 ImageHandle of the loaded driver\r
91 Pointer to the System Table\r
92\r
93Returns:\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