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