]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific
[mirror_edk2.git] / MdeModulePkg / Universal / ResetSystemRuntimeDxe / ResetSystem.c
CommitLineData
51a0c5f2 1/** @file\r
2 Reset Architectural Protocol implementation\r
3\r
37078045 4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
51a0c5f2 5\r
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
13\r
14**/\r
15\r
16#include "ResetSystem.h"\r
17\r
18//\r
19// The handle onto which the Reset Architectural Protocol is installed\r
20//\r
21EFI_HANDLE mResetHandle = NULL;\r
22\r
23/**\r
24 The driver's entry point.\r
25\r
26 It initializes the Reset Architectural Protocol.\r
27\r
28 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
29 @param[in] SystemTable A pointer to the EFI System Table.\r
30 \r
31 @retval EFI_SUCCESS The entry point is executed successfully.\r
32 @retval other Cannot install ResetArch protocol.\r
33\r
34**/\r
35EFI_STATUS\r
36EFIAPI\r
37InitializeResetSystem (\r
38 IN EFI_HANDLE ImageHandle,\r
39 IN EFI_SYSTEM_TABLE *SystemTable\r
40 )\r
41{\r
42 EFI_STATUS Status;\r
43\r
44 //\r
45 // Make sure the Reset Architectural Protocol is not already installed in the system\r
46 //\r
47 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);\r
48\r
49 //\r
50 // Hook the runtime service table\r
51 //\r
52 gRT->ResetSystem = ResetSystem;\r
53\r
54 //\r
55 // Now install the Reset RT AP on a new handle\r
56 //\r
57 Status = gBS->InstallMultipleProtocolInterfaces (\r
58 &mResetHandle,\r
59 &gEfiResetArchProtocolGuid,\r
60 NULL,\r
61 NULL\r
62 );\r
63 ASSERT_EFI_ERROR (Status);\r
64\r
65 return Status;\r
66}\r
67\r
51a0c5f2 68/**\r
69 Put the system into S3 power state. \r
70**/\r
71VOID\r
72DoS3 (\r
73 VOID\r
74 )\r
75{\r
76 EnterS3WithImmediateWake ();\r
77\r
78 //\r
79 // Should not return\r
80 //\r
81 CpuDeadLoop ();\r
82}\r
83\r
84/**\r
85 Resets the entire platform.\r
86\r
87 @param[in] ResetType The type of reset to perform.\r
88 @param[in] ResetStatus The status code for the reset.\r
37078045 89 @param[in] DataSize The size, in bytes, of ResetData.\r
51a0c5f2 90 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
91 EfiResetShutdown the data buffer starts with a Null-terminated\r
92 string, optionally followed by additional binary data.\r
37078045
RN
93 The string is a description that the caller may use to further\r
94 indicate the reason for the system reset. ResetData is only\r
95 valid if ResetStatus is something other than EFI_SUCCESS\r
96 unless the ResetType is EfiResetPlatformSpecific\r
97 where a minimum amount of ResetData is always required.\r
51a0c5f2 98**/\r
99VOID\r
100EFIAPI\r
101ResetSystem (\r
102 IN EFI_RESET_TYPE ResetType,\r
103 IN EFI_STATUS ResetStatus,\r
104 IN UINTN DataSize,\r
105 IN VOID *ResetData OPTIONAL\r
106 )\r
107{\r
108 EFI_STATUS Status;\r
109 UINTN Size;\r
110 UINTN CapsuleDataPtr;\r
37623a5c 111 \r
112 //\r
113 // Indicate reset system runtime service is called.\r
114 //\r
115 REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));\r
51a0c5f2 116\r
117 switch (ResetType) {\r
118 case EfiResetWarm:\r
119\r
120 //\r
121 //Check if there are pending capsules to process\r
122 //\r
123 Size = sizeof (CapsuleDataPtr);\r
124 Status = EfiGetVariable (\r
125 EFI_CAPSULE_VARIABLE_NAME,\r
126 &gEfiCapsuleVendorGuid,\r
127 NULL,\r
128 &Size,\r
129 (VOID *) &CapsuleDataPtr\r
130 );\r
131\r
132 if (Status == EFI_SUCCESS) {\r
133 //\r
134 //Process capsules across a system reset.\r
135 //\r
136 DoS3();\r
137 }\r
138\r
139 ResetWarm ();\r
140\r
141 break;\r
142\r
143 case EfiResetCold:\r
144 ResetCold ();\r
145 break;\r
146\r
147 case EfiResetShutdown:\r
148 ResetShutdown ();\r
149 return ;\r
150\r
37078045
RN
151 case EfiResetPlatformSpecific:\r
152 ResetPlatformSpecific (DataSize, ResetData);\r
153 return;\r
154\r
51a0c5f2 155 default:\r
156 return ;\r
157 }\r
158\r
159 //\r
160 // Given we should have reset getting here would be bad\r
161 //\r
162 ASSERT (FALSE);\r
163}\r