]>
Commit | Line | Data |
---|---|---|
7ca30a6a | 1 | /** @file\r |
2 | Reset System Library functions for OVMF\r | |
3 | \r | |
84c0b80d | 4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
b26f0cf9 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
7ca30a6a | 6 | \r |
7 | **/\r | |
8 | \r | |
002f38a4 LE |
9 | #include <Base.h> // BIT1\r |
10 | \r | |
11 | #include <Library/BaseLib.h> // CpuDeadLoop()\r | |
002f38a4 | 12 | #include <Library/IoLib.h> // IoWrite8()\r |
002f38a4 LE |
13 | #include <Library/ResetSystemLib.h> // ResetCold()\r |
14 | #include <Library/TimerLib.h> // MicroSecondDelay()\r | |
7ca30a6a | 15 | \r |
16 | /**\r | |
17 | Calling this function causes a system-wide reset. This sets\r | |
18 | all circuitry within the system to its initial state. This type of reset\r | |
19 | is asynchronous to system operation and operates without regard to\r | |
20 | cycle boundaries.\r | |
21 | \r | |
22 | System reset should not return, if it returns, it means the system does\r | |
23 | not support cold reset.\r | |
24 | **/\r | |
25 | VOID\r | |
26 | EFIAPI\r | |
27 | ResetCold (\r | |
28 | VOID\r | |
29 | )\r | |
30 | {\r | |
cb7b12ee | 31 | IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r |
fb2ae5fd | 32 | MicroSecondDelay (50);\r |
33 | \r | |
cb7b12ee | 34 | IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r |
fb2ae5fd | 35 | CpuDeadLoop ();\r |
7ca30a6a | 36 | }\r |
37 | \r | |
38 | /**\r | |
39 | Calling this function causes a system-wide initialization. The processors\r | |
40 | are set to their initial state, and pending cycles are not corrupted.\r | |
41 | \r | |
42 | System reset should not return, if it returns, it means the system does\r | |
43 | not support warm reset.\r | |
44 | **/\r | |
45 | VOID\r | |
46 | EFIAPI\r | |
47 | ResetWarm (\r | |
48 | VOID\r | |
49 | )\r | |
50 | {\r | |
51 | IoWrite8 (0x64, 0xfe);\r | |
fb2ae5fd | 52 | CpuDeadLoop ();\r |
7ca30a6a | 53 | }\r |
54 | \r | |
7ca30a6a | 55 | \r |
2b9020f0 RN |
56 | /**\r |
57 | This function causes a systemwide reset. The exact type of the reset is\r | |
b36fbd36 LE |
58 | defined by the EFI_GUID that follows the Null-terminated Unicode string\r |
59 | passed into ResetData. If the platform does not recognize the EFI_GUID in\r | |
60 | ResetData the platform must pick a supported reset type to perform.The\r | |
61 | platform may optionally log the parameters from any non-normal reset that\r | |
62 | occurs.\r | |
2b9020f0 RN |
63 | \r |
64 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
65 | @param[in] ResetData The data buffer starts with a Null-terminated string,\r | |
66 | followed by the EFI_GUID.\r | |
67 | **/\r | |
68 | VOID\r | |
69 | EFIAPI\r | |
70 | ResetPlatformSpecific (\r | |
71 | IN UINTN DataSize,\r | |
72 | IN VOID *ResetData\r | |
73 | )\r | |
74 | {\r | |
75 | ResetCold ();\r | |
76 | }\r | |
84c0b80d ZG |
77 | \r |
78 | /**\r | |
79 | The ResetSystem function resets the entire platform.\r | |
80 | \r | |
81 | @param[in] ResetType The type of reset to perform.\r | |
82 | @param[in] ResetStatus The status code for the reset.\r | |
83 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
b36fbd36 LE |
84 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r |
85 | EfiResetShutdown the data buffer starts with a\r | |
86 | Null-terminated string, optionally followed by\r | |
87 | additional binary data. The string is a description\r | |
88 | that the caller may use to further indicate the\r | |
89 | reason for the system reset.\r | |
84c0b80d ZG |
90 | **/\r |
91 | VOID\r | |
92 | EFIAPI\r | |
93 | ResetSystem (\r | |
94 | IN EFI_RESET_TYPE ResetType,\r | |
95 | IN EFI_STATUS ResetStatus,\r | |
96 | IN UINTN DataSize,\r | |
97 | IN VOID *ResetData OPTIONAL\r | |
98 | )\r | |
99 | {\r | |
100 | switch (ResetType) {\r | |
101 | case EfiResetWarm:\r | |
102 | ResetWarm ();\r | |
103 | break;\r | |
104 | \r | |
105 | case EfiResetCold:\r | |
106 | ResetCold ();\r | |
107 | break;\r | |
108 | \r | |
109 | case EfiResetShutdown:\r | |
110 | ResetShutdown ();\r | |
92958abf | 111 | break;\r |
84c0b80d ZG |
112 | \r |
113 | case EfiResetPlatformSpecific:\r | |
114 | ResetPlatformSpecific (DataSize, ResetData);\r | |
92958abf | 115 | break;\r |
84c0b80d ZG |
116 | \r |
117 | default:\r | |
92958abf | 118 | break;\r |
84c0b80d ZG |
119 | }\r |
120 | }\r |