]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Reset System Library functions for OVMF\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include <Base.h> // BIT1\r | |
10 | \r | |
11 | #include <Library/BaseLib.h> // CpuDeadLoop()\r | |
12 | #include <Library/IoLib.h> // IoWrite8()\r | |
13 | #include <Library/ResetSystemLib.h> // ResetCold()\r | |
14 | #include <Library/TimerLib.h> // MicroSecondDelay()\r | |
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 | |
31 | IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r | |
32 | MicroSecondDelay (50);\r | |
33 | \r | |
34 | IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r | |
35 | CpuDeadLoop ();\r | |
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 | |
52 | CpuDeadLoop ();\r | |
53 | }\r | |
54 | \r | |
55 | \r | |
56 | /**\r | |
57 | This function causes a systemwide reset. The exact type of the reset is\r | |
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 | |
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 | |
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 | |
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 | |
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 | |
111 | break;\r | |
112 | \r | |
113 | case EfiResetPlatformSpecific:\r | |
114 | ResetPlatformSpecific (DataSize, ResetData);\r | |
115 | break;\r | |
116 | \r | |
117 | default:\r | |
118 | break;\r | |
119 | }\r | |
120 | }\r |