]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Reset Architectural Protocol implementation\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
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 | |
21 | EFI_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 | |
35 | EFI_STATUS\r | |
36 | EFIAPI\r | |
37 | InitializeResetSystem (\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 | |
68 | /**\r | |
69 | Reset system for capsule update.\r | |
70 | \r | |
71 | @param[in] CapsuleDataPtr Pointer to the capsule block descriptors.\r | |
72 | \r | |
73 | **/\r | |
74 | VOID\r | |
75 | CapsuleReset (\r | |
76 | IN UINTN CapsuleDataPtr\r | |
77 | )\r | |
78 | {\r | |
79 | //\r | |
80 | // This implementation assumes that we're using a variable\r | |
81 | // to indicate capsule updates.\r | |
82 | //\r | |
83 | gRT->SetVariable (\r | |
84 | EFI_CAPSULE_VARIABLE_NAME,\r | |
85 | &gEfiCapsuleVendorGuid,\r | |
86 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
87 | sizeof (UINTN),\r | |
88 | (VOID *) &CapsuleDataPtr\r | |
89 | );\r | |
90 | \r | |
91 | EnterS3WithImmediateWake ();\r | |
92 | \r | |
93 | //\r | |
94 | // Should not return\r | |
95 | //\r | |
96 | CpuDeadLoop ();\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | Put the system into S3 power state. \r | |
101 | **/\r | |
102 | VOID\r | |
103 | DoS3 (\r | |
104 | VOID\r | |
105 | )\r | |
106 | {\r | |
107 | EnterS3WithImmediateWake ();\r | |
108 | \r | |
109 | //\r | |
110 | // Should not return\r | |
111 | //\r | |
112 | CpuDeadLoop ();\r | |
113 | }\r | |
114 | \r | |
115 | /**\r | |
116 | Resets the entire platform.\r | |
117 | \r | |
118 | @param[in] ResetType The type of reset to perform.\r | |
119 | @param[in] ResetStatus The status code for the reset.\r | |
120 | @param[in] DataSize The size, in bytes, of WatchdogData.\r | |
121 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r | |
122 | EfiResetShutdown the data buffer starts with a Null-terminated\r | |
123 | string, optionally followed by additional binary data.\r | |
124 | \r | |
125 | **/\r | |
126 | VOID\r | |
127 | EFIAPI\r | |
128 | ResetSystem (\r | |
129 | IN EFI_RESET_TYPE ResetType,\r | |
130 | IN EFI_STATUS ResetStatus,\r | |
131 | IN UINTN DataSize,\r | |
132 | IN VOID *ResetData OPTIONAL\r | |
133 | )\r | |
134 | {\r | |
135 | EFI_STATUS Status;\r | |
136 | UINTN Size;\r | |
137 | UINTN CapsuleDataPtr;\r | |
138 | \r | |
139 | switch (ResetType) {\r | |
140 | case EfiResetWarm:\r | |
141 | \r | |
142 | //\r | |
143 | //Check if there are pending capsules to process\r | |
144 | //\r | |
145 | Size = sizeof (CapsuleDataPtr);\r | |
146 | Status = EfiGetVariable (\r | |
147 | EFI_CAPSULE_VARIABLE_NAME,\r | |
148 | &gEfiCapsuleVendorGuid,\r | |
149 | NULL,\r | |
150 | &Size,\r | |
151 | (VOID *) &CapsuleDataPtr\r | |
152 | );\r | |
153 | \r | |
154 | if (Status == EFI_SUCCESS) {\r | |
155 | //\r | |
156 | //Process capsules across a system reset.\r | |
157 | //\r | |
158 | DoS3();\r | |
159 | }\r | |
160 | \r | |
161 | ResetWarm ();\r | |
162 | \r | |
163 | break;\r | |
164 | \r | |
165 | case EfiResetCold:\r | |
166 | ResetCold ();\r | |
167 | break;\r | |
168 | \r | |
169 | case EfiResetShutdown:\r | |
170 | ResetShutdown ();\r | |
171 | return ;\r | |
172 | \r | |
173 | default:\r | |
174 | return ;\r | |
175 | }\r | |
176 | \r | |
177 | //\r | |
178 | // Given we should have reset getting here would be bad\r | |
179 | //\r | |
180 | ASSERT (FALSE);\r | |
181 | }\r |