VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c@ 80924

Last change on this file since 80924 was 80721, checked in by vboxsync, 6 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
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>
10
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
13#include <Library/IoLib.h>
14#include <Library/PciLib.h>
15#include <Library/TimerLib.h>
16#include <OvmfPlatforms.h>
17
18VOID
19AcpiPmControl (
20 UINTN SuspendType
21 )
22{
23 UINT16 AcpiPmBaseAddress;
24 UINT16 HostBridgeDevId;
25
26 ASSERT (SuspendType < 6);
27
28 AcpiPmBaseAddress = 0;
29 HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
30 switch (HostBridgeDevId) {
31 case INTEL_82441_DEVICE_ID:
32 AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
33 break;
34 case INTEL_Q35_MCH_DEVICE_ID:
35 AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
36 break;
37 default:
38 ASSERT (FALSE);
39 CpuDeadLoop ();
40 }
41
42 IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);
43 IoOr16 (AcpiPmBaseAddress + 4, BIT13);
44 CpuDeadLoop ();
45}
46
47/**
48 Calling this function causes a system-wide reset. This sets
49 all circuitry within the system to its initial state. This type of reset
50 is asynchronous to system operation and operates without regard to
51 cycle boundaries.
52
53 System reset should not return, if it returns, it means the system does
54 not support cold reset.
55**/
56VOID
57EFIAPI
58ResetCold (
59 VOID
60 )
61{
62 IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST
63 MicroSecondDelay (50);
64
65 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
66 CpuDeadLoop ();
67}
68
69/**
70 Calling this function causes a system-wide initialization. The processors
71 are set to their initial state, and pending cycles are not corrupted.
72
73 System reset should not return, if it returns, it means the system does
74 not support warm reset.
75**/
76VOID
77EFIAPI
78ResetWarm (
79 VOID
80 )
81{
82 IoWrite8 (0x64, 0xfe);
83 CpuDeadLoop ();
84}
85
86/**
87 Calling this function causes the system to enter a power state equivalent
88 to the ACPI G2/S5 or G3 states.
89
90 System shutdown should not return, if it returns, it means the system does
91 not support shut down reset.
92**/
93VOID
94EFIAPI
95ResetShutdown (
96 VOID
97 )
98{
99 AcpiPmControl (0);
100 ASSERT (FALSE);
101}
102
103
104/**
105 Calling this function causes the system to enter a power state for capsule
106 update.
107
108 Reset update should not return, if it returns, it means the system does
109 not support capsule update.
110
111**/
112VOID
113EFIAPI
114EnterS3WithImmediateWake (
115 VOID
116 )
117{
118 AcpiPmControl (1);
119 ASSERT (FALSE);
120}
121
122/**
123 This function causes a systemwide reset. The exact type of the reset is
124 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
125 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
126 the platform must pick a supported reset type to perform.The platform may
127 optionally log the parameters from any non-normal reset that occurs.
128
129 @param[in] DataSize The size, in bytes, of ResetData.
130 @param[in] ResetData The data buffer starts with a Null-terminated string,
131 followed by the EFI_GUID.
132**/
133VOID
134EFIAPI
135ResetPlatformSpecific (
136 IN UINTN DataSize,
137 IN VOID *ResetData
138 )
139{
140 ResetCold ();
141}
142
143/**
144 The ResetSystem function resets the entire platform.
145
146 @param[in] ResetType The type of reset to perform.
147 @param[in] ResetStatus The status code for the reset.
148 @param[in] DataSize The size, in bytes, of ResetData.
149 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
150 the data buffer starts with a Null-terminated string, optionally
151 followed by additional binary data. The string is a description
152 that the caller may use to further indicate the reason for the
153 system reset.
154**/
155VOID
156EFIAPI
157ResetSystem (
158 IN EFI_RESET_TYPE ResetType,
159 IN EFI_STATUS ResetStatus,
160 IN UINTN DataSize,
161 IN VOID *ResetData OPTIONAL
162 )
163{
164 switch (ResetType) {
165 case EfiResetWarm:
166 ResetWarm ();
167 break;
168
169 case EfiResetCold:
170 ResetCold ();
171 break;
172
173 case EfiResetShutdown:
174 ResetShutdown ();
175 return;
176
177 case EfiResetPlatformSpecific:
178 ResetPlatformSpecific (DataSize, ResetData);
179 return;
180
181 default:
182 return;
183 }
184}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette