]> git.proxmox.com Git - mirror_edk2.git/blob - BeagleBoardPkg/Library/ResetSystemLib/ResetSystemLib.c
BeagleBoardPkg/ResetSystemLib: Add new API ResetSystem
[mirror_edk2.git] / BeagleBoardPkg / Library / ResetSystemLib / ResetSystemLib.c
1 /** @file
2 Do a generic Cold Reset for OMAP3550 and BeagleBoard specific Warm reset
3
4 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
5 Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
6 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12
13 #include <Uefi.h>
14
15 #include <Library/IoLib.h>
16 #include <Library/ResetSystemLib.h>
17
18 #include <Omap3530/Omap3530.h>
19
20 /**
21 This function causes a system-wide reset (cold reset), in which
22 all circuitry within the system returns to its initial state. This type of
23 reset is asynchronous to system operation and operates without regard to
24 cycle boundaries.
25
26 If this function returns, it means that the system does not support cold
27 reset.
28 **/
29 VOID
30 EFIAPI
31 ResetCold (
32 VOID
33 )
34 {
35 //Perform cold reset of the system.
36 MmioOr32 (PRM_RSTCTRL, RST_DPLL3);
37 while ((MmioRead32(PRM_RSTST) & GLOBAL_COLD_RST) != 0x1);
38 }
39
40 /**
41 This function causes a system-wide initialization (warm reset), in which all
42 processors are set to their initial state. Pending cycles are not corrupted.
43
44 If this function returns, it means that the system does not support warm
45 reset.
46 **/
47 VOID
48 EFIAPI
49 ResetWarm (
50 VOID
51 )
52 {
53 ResetCold ();
54 }
55
56 /**
57 This function causes the system to enter a power state equivalent
58 to the ACPI G2/S5 or G3 states.
59
60 If this function returns, it means that the system does not support shut down
61 reset.
62 **/
63 VOID
64 EFIAPI
65 ResetShutdown (
66 VOID
67 )
68 {
69 // not implemented
70 }
71
72 /**
73 This function causes the system to enter S3 and then wake up immediately.
74
75 If this function returns, it means that the system does not support S3
76 feature.
77 **/
78 VOID
79 EFIAPI
80 EnterS3WithImmediateWake (
81 VOID
82 )
83 {
84 // not implemented
85 }
86
87 /**
88 This function causes a systemwide reset. The exact type of the reset is
89 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
90 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
91 the platform must pick a supported reset type to perform.The platform may
92 optionally log the parameters from any non-normal reset that occurs.
93
94 @param[in] DataSize The size, in bytes, of ResetData.
95 @param[in] ResetData The data buffer starts with a Null-terminated string,
96 followed by the EFI_GUID.
97 **/
98 VOID
99 EFIAPI
100 ResetPlatformSpecific (
101 IN UINTN DataSize,
102 IN VOID *ResetData
103 )
104 {
105 ResetCold ();
106 }
107
108 /**
109 The ResetSystem function resets the entire platform.
110
111 @param[in] ResetType The type of reset to perform.
112 @param[in] ResetStatus The status code for the reset.
113 @param[in] DataSize The size, in bytes, of ResetData.
114 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
115 the data buffer starts with a Null-terminated string, optionally
116 followed by additional binary data. The string is a description
117 that the caller may use to further indicate the reason for the
118 system reset.
119 **/
120 VOID
121 EFIAPI
122 ResetSystem (
123 IN EFI_RESET_TYPE ResetType,
124 IN EFI_STATUS ResetStatus,
125 IN UINTN DataSize,
126 IN VOID *ResetData OPTIONAL
127 )
128 {
129 switch (ResetType) {
130 case EfiResetWarm:
131 ResetWarm ();
132 break;
133
134 case EfiResetCold:
135 ResetCold ();
136 break;
137
138 case EfiResetShutdown:
139 ResetShutdown ();
140 return;
141
142 case EfiResetPlatformSpecific:
143 ResetPlatformSpecific (DataSize, ResetData);
144 return;
145
146 default:
147 return;
148 }
149 }