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