2 DXE Reset System Library instance that calls gRT->ResetSystem().
4 Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/ResetSystemLib.h>
11 #include <Library/UefiRuntimeServicesTableLib.h>
12 #include <Library/UefiBootServicesTableLib.h>
13 #include <Library/DebugLib.h>
15 EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent
;
16 EFI_RUNTIME_SERVICES
*mInternalRT
;
19 This function causes a system-wide reset (cold reset), in which
20 all circuitry within the system returns to its initial state. This type of reset
21 is asynchronous to system operation and operates without regard to
24 If this function returns, it means that the system does not support cold reset.
32 mInternalRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
36 This function causes a system-wide initialization (warm reset), in which all processors
37 are set to their initial state. Pending cycles are not corrupted.
39 If this function returns, it means that the system does not support warm reset.
47 mInternalRT
->ResetSystem (EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
51 This function causes the system to enter a power state equivalent
52 to the ACPI G2/S5 or G3 states.
54 If this function returns, it means that the system does not support shut down reset.
62 mInternalRT
->ResetSystem (EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
66 This function causes a systemwide reset. The exact type of the reset is
67 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
68 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
69 the platform must pick a supported reset type to perform.The platform may
70 optionally log the parameters from any non-normal reset that occurs.
72 @param[in] DataSize The size, in bytes, of ResetData.
73 @param[in] ResetData The data buffer starts with a Null-terminated string,
74 followed by the EFI_GUID.
78 ResetPlatformSpecific (
83 mInternalRT
->ResetSystem (EfiResetPlatformSpecific
, EFI_SUCCESS
, DataSize
, ResetData
);
87 The ResetSystem function resets the entire platform.
89 @param[in] ResetType The type of reset to perform.
90 @param[in] ResetStatus The status code for the reset.
91 @param[in] DataSize The size, in bytes, of ResetData.
92 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
93 the data buffer starts with a Null-terminated string, optionally
94 followed by additional binary data. The string is a description
95 that the caller may use to further indicate the reason for the
101 IN EFI_RESET_TYPE ResetType
,
102 IN EFI_STATUS ResetStatus
,
104 IN VOID
*ResetData OPTIONAL
107 mInternalRT
->ResetSystem (ResetType
, ResetStatus
, DataSize
, ResetData
);
111 Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
113 @param Event Event whose notification function is being invoked.
114 @param Context Pointer to the notification function's context
119 RuntimeResetSystemLibVirtualAddressChange (
124 mInternalRT
->ConvertPointer (0, (VOID
**)&mInternalRT
);
128 The constructor function of Runtime Reset System Lib.
130 This function allocates memory for extended status code data, caches
131 the report status code service, and registers events.
133 @param ImageHandle The firmware allocated handle for the EFI image.
134 @param SystemTable A pointer to the EFI System Table.
136 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
141 RuntimeResetSystemLibConstruct (
142 IN EFI_HANDLE ImageHandle
,
143 IN EFI_SYSTEM_TABLE
*SystemTable
149 // Library should not use the gRT directly, for it may be converted by other library instance.
154 // Register notify function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
156 Status
= gBS
->CreateEventEx (
159 RuntimeResetSystemLibVirtualAddressChange
,
161 &gEfiEventVirtualAddressChangeGuid
,
162 &mRuntimeResetSystemLibVirtualAddressChangeEvent
164 ASSERT_EFI_ERROR (Status
);
170 The Deconstructor function of Runtime Reset System Lib.
172 The destructor function frees memory allocated by constructor, and closes related events.
173 It will ASSERT() if that related operation fails and it will always return EFI_SUCCESS.
175 @param ImageHandle The firmware allocated handle for the EFI image.
176 @param SystemTable A pointer to the EFI System Table.
178 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
183 RuntimeResetSystemLibDeconstruct (
184 IN EFI_HANDLE ImageHandle
,
185 IN EFI_SYSTEM_TABLE
*SystemTable
190 ASSERT (gBS
!= NULL
);
191 Status
= gBS
->CloseEvent (mRuntimeResetSystemLibVirtualAddressChangeEvent
);
192 ASSERT_EFI_ERROR (Status
);