]> git.proxmox.com Git - mirror_edk2.git/blob - PcAtChipsetPkg/Library/ResetSystemLib/ResetSystemLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / PcAtChipsetPkg / Library / ResetSystemLib / ResetSystemLib.c
1 /** @file
2 Reset System Library functions for PCAT platforms
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 <Uefi/UefiBaseType.h>
12 #include <Uefi/UefiMultiPhase.h>
13
14 #include <Library/DebugLib.h>
15 #include <Library/IoLib.h>
16
17 /**
18 Calling this function causes a system-wide reset. This sets
19 all circuitry within the system to its initial state. This type of reset
20 is asynchronous to system operation and operates without regard to
21 cycle boundaries.
22
23 System reset should not return, if it returns, it means the system does
24 not support cold reset.
25 **/
26 VOID
27 EFIAPI
28 ResetCold (
29 VOID
30 )
31 {
32 IoWrite8 ((UINTN)PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
33 }
34
35 /**
36 Calling this function causes a system-wide initialization. The processors
37 are set to their initial state, and pending cycles are not corrupted.
38
39 System reset should not return, if it returns, it means the system does
40 not support warm reset.
41 **/
42 VOID
43 EFIAPI
44 ResetWarm (
45 VOID
46 )
47 {
48 IoWrite8 ((UINTN)PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
49 }
50
51 /**
52 Calling this function causes the system to enter a power state equivalent
53 to the ACPI G2/S5 or G3 states.
54
55 System shutdown should not return, if it returns, it means the system does
56 not support shut down reset.
57 **/
58 VOID
59 EFIAPI
60 ResetShutdown (
61 VOID
62 )
63 {
64 ASSERT (FALSE);
65 }
66
67 /**
68 This function causes a systemwide reset. The exact type of the reset is
69 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
70 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
71 the platform must pick a supported reset type to perform.The platform may
72 optionally log the parameters from any non-normal reset that occurs.
73
74 @param[in] DataSize The size, in bytes, of ResetData.
75 @param[in] ResetData The data buffer starts with a Null-terminated string,
76 followed by the EFI_GUID.
77 **/
78 VOID
79 EFIAPI
80 ResetPlatformSpecific (
81 IN UINTN DataSize,
82 IN VOID *ResetData
83 )
84 {
85 ResetCold ();
86 }
87
88 /**
89 The ResetSystem function resets the entire platform.
90
91 @param[in] ResetType The type of reset to perform.
92 @param[in] ResetStatus The status code for the reset.
93 @param[in] DataSize The size, in bytes, of ResetData.
94 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
95 the data buffer starts with a Null-terminated string, optionally
96 followed by additional binary data. The string is a description
97 that the caller may use to further indicate the reason for the
98 system reset.
99 **/
100 VOID
101 EFIAPI
102 ResetSystem (
103 IN EFI_RESET_TYPE ResetType,
104 IN EFI_STATUS ResetStatus,
105 IN UINTN DataSize,
106 IN VOID *ResetData OPTIONAL
107 )
108 {
109 switch (ResetType) {
110 case EfiResetWarm:
111 ResetWarm ();
112 break;
113
114 case EfiResetCold:
115 ResetCold ();
116 break;
117
118 case EfiResetShutdown:
119 ResetShutdown ();
120 return;
121
122 case EfiResetPlatformSpecific:
123 ResetPlatformSpecific (DataSize, ResetData);
124 return;
125
126 default:
127 return;
128 }
129 }