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