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