]>
Commit | Line | Data |
---|---|---|
51a0c5f2 | 1 | /** @file\r |
2 | Reset Architectural Protocol implementation\r | |
3 | \r | |
7a0c1361 | 4 | Copyright (c) 2006 - 2012, 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 | |
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 | |
51a0c5f2 | 68 | /**\r |
69 | Put the system into S3 power state. \r | |
70 | **/\r | |
71 | VOID\r | |
72 | DoS3 (\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 | |
89 | @param[in] DataSize The size, in bytes, of WatchdogData.\r | |
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 | |
93 | \r | |
94 | **/\r | |
95 | VOID\r | |
96 | EFIAPI\r | |
97 | ResetSystem (\r | |
98 | IN EFI_RESET_TYPE ResetType,\r | |
99 | IN EFI_STATUS ResetStatus,\r | |
100 | IN UINTN DataSize,\r | |
101 | IN VOID *ResetData OPTIONAL\r | |
102 | )\r | |
103 | {\r | |
104 | EFI_STATUS Status;\r | |
105 | UINTN Size;\r | |
106 | UINTN CapsuleDataPtr;\r | |
37623a5c | 107 | \r |
108 | //\r | |
109 | // Indicate reset system runtime service is called.\r | |
110 | //\r | |
111 | REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));\r | |
51a0c5f2 | 112 | \r |
113 | switch (ResetType) {\r | |
114 | case EfiResetWarm:\r | |
115 | \r | |
116 | //\r | |
117 | //Check if there are pending capsules to process\r | |
118 | //\r | |
119 | Size = sizeof (CapsuleDataPtr);\r | |
120 | Status = EfiGetVariable (\r | |
121 | EFI_CAPSULE_VARIABLE_NAME,\r | |
122 | &gEfiCapsuleVendorGuid,\r | |
123 | NULL,\r | |
124 | &Size,\r | |
125 | (VOID *) &CapsuleDataPtr\r | |
126 | );\r | |
127 | \r | |
128 | if (Status == EFI_SUCCESS) {\r | |
129 | //\r | |
130 | //Process capsules across a system reset.\r | |
131 | //\r | |
132 | DoS3();\r | |
133 | }\r | |
134 | \r | |
135 | ResetWarm ();\r | |
136 | \r | |
137 | break;\r | |
138 | \r | |
139 | case EfiResetCold:\r | |
140 | ResetCold ();\r | |
141 | break;\r | |
142 | \r | |
143 | case EfiResetShutdown:\r | |
144 | ResetShutdown ();\r | |
145 | return ;\r | |
146 | \r | |
147 | default:\r | |
148 | return ;\r | |
149 | }\r | |
150 | \r | |
151 | //\r | |
152 | // Given we should have reset getting here would be bad\r | |
153 | //\r | |
154 | ASSERT (FALSE);\r | |
155 | }\r |