]> git.proxmox.com Git - mirror_edk2.git/blob - PcAtChipsetPkg/Library/ResetSystemLib/ResetSystemLib.c
PcAtChipsetPkg/ResetSystemLib: Add new API ResetSystem
[mirror_edk2.git] / PcAtChipsetPkg / Library / ResetSystemLib / ResetSystemLib.c
1 /** @file
2 Reset System Library functions for PCAT platforms
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <Base.h>
10
11 #include <Uefi/UefiBaseType.h>
12 #include <Uefi/UefiMultiPhase.h>
13
14 #include <Library/DebugLib.h>
15 #include <Library/IoLib.h>
16
17 /**
18 Calling this function causes a system-wide reset. This sets
19 all circuitry within the system to its initial state. This type of reset
20 is asynchronous to system operation and operates without regard to
21 cycle boundaries.
22
23 System reset should not return, if it returns, it means the system does
24 not support cold reset.
25 **/
26 VOID
27 EFIAPI
28 ResetCold (
29 VOID
30 )
31 {
32 IoWrite8 ((UINTN) PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
33 }
34
35 /**
36 Calling this function causes a system-wide initialization. The processors
37 are set to their initial state, and pending cycles are not corrupted.
38
39 System reset should not return, if it returns, it means the system does
40 not support warm reset.
41 **/
42 VOID
43 EFIAPI
44 ResetWarm (
45 VOID
46 )
47 {
48 IoWrite8 ((UINTN) PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
49 }
50
51 /**
52 Calling this function causes the system to enter a power state equivalent
53 to the ACPI G2/S5 or G3 states.
54
55 System shutdown should not return, if it returns, it means the system does
56 not support shut down reset.
57 **/
58 VOID
59 EFIAPI
60 ResetShutdown (
61 VOID
62 )
63 {
64 ASSERT (FALSE);
65 }
66
67
68 /**
69 Calling this function causes the system to enter a power state for capsule
70 update.
71
72 Reset update should not return, if it returns, it means the system does
73 not support capsule update.
74
75 **/
76 VOID
77 EFIAPI
78 EnterS3WithImmediateWake (
79 VOID
80 )
81 {
82 ASSERT (FALSE);
83 }
84
85 /**
86 This function causes a systemwide reset. The exact type of the reset is
87 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
88 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
89 the platform must pick a supported reset type to perform.The platform may
90 optionally log the parameters from any non-normal reset that occurs.
91
92 @param[in] DataSize The size, in bytes, of ResetData.
93 @param[in] ResetData The data buffer starts with a Null-terminated string,
94 followed by the EFI_GUID.
95 **/
96 VOID
97 EFIAPI
98 ResetPlatformSpecific (
99 IN UINTN DataSize,
100 IN VOID *ResetData
101 )
102 {
103 ResetCold ();
104 }
105
106 /**
107 The ResetSystem function resets the entire platform.
108
109 @param[in] ResetType The type of reset to perform.
110 @param[in] ResetStatus The status code for the reset.
111 @param[in] DataSize The size, in bytes, of ResetData.
112 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
113 the data buffer starts with a Null-terminated string, optionally
114 followed by additional binary data. The string is a description
115 that the caller may use to further indicate the reason for the
116 system reset.
117 **/
118 VOID
119 EFIAPI
120 ResetSystem (
121 IN EFI_RESET_TYPE ResetType,
122 IN EFI_STATUS ResetStatus,
123 IN UINTN DataSize,
124 IN VOID *ResetData OPTIONAL
125 )
126 {
127 switch (ResetType) {
128 case EfiResetWarm:
129 ResetWarm ();
130 break;
131
132 case EfiResetCold:
133 ResetCold ();
134 break;
135
136 case EfiResetShutdown:
137 ResetShutdown ();
138 return;
139
140 case EfiResetPlatformSpecific:
141 ResetPlatformSpecific (DataSize, ResetData);
142 return;
143
144 default:
145 return;
146 }
147 }