VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c@ 109019

Last change on this file since 109019 was 108794, checked in by vboxsync, 4 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/** @file
2 Reset System Library functions for bootloader
3
4 Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <PiDxe.h>
10#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
12#include <Library/IoLib.h>
13#include <Library/HobLib.h>
14#include <Library/BaseMemoryLib.h>
15#include <Guid/AcpiBoardInfoGuid.h>
16
17ACPI_BOARD_INFO mAcpiBoardInfo;
18
19/**
20 The constructor function to initialize mAcpiBoardInfo.
21
22 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
23
24**/
25RETURN_STATUS
26EFIAPI
27ResetSystemLibConstructor (
28 VOID
29 )
30{
31 EFI_HOB_GUID_TYPE *GuidHob;
32 ACPI_BOARD_INFO *AcpiBoardInfoPtr;
33
34 //
35 // Find the acpi board information guid hob
36 //
37 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
38 ASSERT (GuidHob != NULL);
39
40 AcpiBoardInfoPtr = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
41 CopyMem (&mAcpiBoardInfo, AcpiBoardInfoPtr, sizeof (ACPI_BOARD_INFO));
42
43 ASSERT (mAcpiBoardInfo.ResetRegAddress != 0);
44 ASSERT (mAcpiBoardInfo.ResetValue != 0);
45 ASSERT (mAcpiBoardInfo.PmGpeEnBase != 0);
46 ASSERT (mAcpiBoardInfo.PmEvtBase != 0);
47 ASSERT (mAcpiBoardInfo.PmCtrlRegBase != 0);
48
49 return EFI_SUCCESS;
50}
51
52/**
53 Calling this function causes a system-wide reset. This sets
54 all circuitry within the system to its initial state. This type of reset
55 is asynchronous to system operation and operates without regard to
56 cycle boundaries.
57
58 System reset should not return, if it returns, it means the system does
59 not support cold reset.
60**/
61VOID
62EFIAPI
63ResetCold (
64 VOID
65 )
66{
67 IoWrite8 ((UINTN)mAcpiBoardInfo.ResetRegAddress, mAcpiBoardInfo.ResetValue);
68 CpuDeadLoop ();
69}
70
71/**
72 Calling this function causes a system-wide initialization. The processors
73 are set to their initial state, and pending cycles are not corrupted.
74
75 System reset should not return, if it returns, it means the system does
76 not support warm reset.
77**/
78VOID
79EFIAPI
80ResetWarm (
81 VOID
82 )
83{
84 IoWrite8 ((UINTN)mAcpiBoardInfo.ResetRegAddress, mAcpiBoardInfo.ResetValue);
85 CpuDeadLoop ();
86}
87
88/**
89 Calling this function causes the system to enter a power state equivalent
90 to the ACPI G2/S5 or G3 states.
91
92 System shutdown should not return, if it returns, it means the system does
93 not support shut down reset.
94**/
95VOID
96EFIAPI
97ResetShutdown (
98 VOID
99 )
100{
101 UINTN PmCtrlReg;
102
103 //
104 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
105 //
106 IoWrite16 ((UINTN)mAcpiBoardInfo.PmGpeEnBase, 0);
107
108 //
109 // Clear Power Button Status
110 //
111 IoWrite16 ((UINTN)mAcpiBoardInfo.PmEvtBase, BIT8);
112
113 //
114 // Transform system into S5 sleep state
115 //
116 PmCtrlReg = (UINTN)mAcpiBoardInfo.PmCtrlRegBase;
117 IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16)(7 << 10));
118 IoOr16 (PmCtrlReg, BIT13);
119 CpuDeadLoop ();
120
121 ASSERT (FALSE);
122}
123
124/**
125 This function causes a systemwide reset. The exact type of the reset is
126 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
127 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
128 the platform must pick a supported reset type to perform.The platform may
129 optionally log the parameters from any non-normal reset that occurs.
130
131 @param[in] DataSize The size, in bytes, of ResetData.
132 @param[in] ResetData The data buffer starts with a Null-terminated string,
133 followed by the EFI_GUID.
134**/
135VOID
136EFIAPI
137ResetPlatformSpecific (
138 IN UINTN DataSize,
139 IN VOID *ResetData
140 )
141{
142 ResetCold ();
143}
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