]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
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
25VOID\r
26EFIAPI\r
27ResetCold (\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
45VOID\r
46EFIAPI\r
47ResetWarm (\r
48 VOID\r
49 )\r
50{\r
51 IoWrite8 (0x64, 0xfe);\r
fb2ae5fd 52 CpuDeadLoop ();\r
7ca30a6a 53}\r
54\r
2b9020f0
RN
55/**\r
56 This function causes a systemwide reset. The exact type of the reset is\r
b36fbd36
LE
57 defined by the EFI_GUID that follows the Null-terminated Unicode string\r
58 passed into ResetData. If the platform does not recognize the EFI_GUID in\r
59 ResetData the platform must pick a supported reset type to perform.The\r
60 platform may optionally log the parameters from any non-normal reset that\r
61 occurs.\r
2b9020f0
RN
62\r
63 @param[in] DataSize The size, in bytes, of ResetData.\r
64 @param[in] ResetData The data buffer starts with a Null-terminated string,\r
65 followed by the EFI_GUID.\r
66**/\r
67VOID\r
68EFIAPI\r
69ResetPlatformSpecific (\r
ac0a286f
MK
70 IN UINTN DataSize,\r
71 IN VOID *ResetData\r
2b9020f0
RN
72 )\r
73{\r
74 ResetCold ();\r
75}\r
84c0b80d
ZG
76\r
77/**\r
78 The ResetSystem function resets the entire platform.\r
79\r
80 @param[in] ResetType The type of reset to perform.\r
81 @param[in] ResetStatus The status code for the reset.\r
82 @param[in] DataSize The size, in bytes, of ResetData.\r
b36fbd36
LE
83 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
84 EfiResetShutdown the data buffer starts with a\r
85 Null-terminated string, optionally followed by\r
86 additional binary data. The string is a description\r
87 that the caller may use to further indicate the\r
88 reason for the system reset.\r
84c0b80d
ZG
89**/\r
90VOID\r
91EFIAPI\r
92ResetSystem (\r
ac0a286f
MK
93 IN EFI_RESET_TYPE ResetType,\r
94 IN EFI_STATUS ResetStatus,\r
95 IN UINTN DataSize,\r
96 IN VOID *ResetData OPTIONAL\r
84c0b80d
ZG
97 )\r
98{\r
99 switch (ResetType) {\r
ac0a286f
MK
100 case EfiResetWarm:\r
101 ResetWarm ();\r
102 break;\r
84c0b80d 103\r
ac0a286f
MK
104 case EfiResetCold:\r
105 ResetCold ();\r
106 break;\r
84c0b80d 107\r
ac0a286f
MK
108 case EfiResetShutdown:\r
109 ResetShutdown ();\r
110 break;\r
84c0b80d 111\r
ac0a286f
MK
112 case EfiResetPlatformSpecific:\r
113 ResetPlatformSpecific (DataSize, ResetData);\r
114 break;\r
84c0b80d 115\r
ac0a286f
MK
116 default:\r
117 break;\r
84c0b80d
ZG
118 }\r
119}\r