]>
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 | |
04af8bf2 DG |
46 | /**\r |
47 | Calling this function causes a system-wide reset. This sets\r | |
48 | all circuitry within the system to its initial state. This type of reset\r | |
49 | is asynchronous to system operation and operates without regard to\r | |
50 | cycle boundaries.\r | |
51 | \r | |
52 | System reset should not return, if it returns, it means the system does\r | |
53 | not support cold reset.\r | |
54 | **/\r | |
55 | VOID\r | |
56 | EFIAPI\r | |
57 | ResetCold (\r | |
58 | VOID\r | |
59 | )\r | |
60 | {\r | |
61 | IoWrite8 ((UINTN)mAcpiBoardInfo.ResetRegAddress, mAcpiBoardInfo.ResetValue);\r | |
62 | CpuDeadLoop ();\r | |
63 | }\r | |
64 | \r | |
65 | /**\r | |
66 | Calling this function causes a system-wide initialization. The processors\r | |
67 | are set to their initial state, and pending cycles are not corrupted.\r | |
68 | \r | |
69 | System reset should not return, if it returns, it means the system does\r | |
70 | not support warm reset.\r | |
71 | **/\r | |
72 | VOID\r | |
73 | EFIAPI\r | |
74 | ResetWarm (\r | |
75 | VOID\r | |
76 | )\r | |
77 | {\r | |
78 | IoWrite8 ((UINTN)mAcpiBoardInfo.ResetRegAddress, mAcpiBoardInfo.ResetValue);\r | |
79 | CpuDeadLoop ();\r | |
80 | }\r | |
81 | \r | |
82 | /**\r | |
83 | Calling this function causes the system to enter a power state equivalent\r | |
84 | to the ACPI G2/S5 or G3 states.\r | |
85 | \r | |
86 | System shutdown should not return, if it returns, it means the system does\r | |
87 | not support shut down reset.\r | |
88 | **/\r | |
89 | VOID\r | |
90 | EFIAPI\r | |
91 | ResetShutdown (\r | |
92 | VOID\r | |
93 | )\r | |
94 | {\r | |
95 | UINTN PmCtrlReg;\r | |
96 | \r | |
97 | //\r | |
98 | // GPE0_EN should be disabled to avoid any GPI waking up the system from S5\r | |
99 | //\r | |
100 | IoWrite16 ((UINTN)mAcpiBoardInfo.PmGpeEnBase, 0);\r | |
101 | \r | |
102 | //\r | |
103 | // Clear Power Button Status\r | |
104 | //\r | |
105 | IoWrite16((UINTN) mAcpiBoardInfo.PmEvtBase, BIT8);\r | |
106 | \r | |
107 | //\r | |
108 | // Transform system into S5 sleep state\r | |
109 | //\r | |
110 | PmCtrlReg = (UINTN)mAcpiBoardInfo.PmCtrlRegBase;\r | |
111 | IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));\r | |
112 | IoOr16 (PmCtrlReg, BIT13);\r | |
113 | CpuDeadLoop ();\r | |
114 | \r | |
115 | ASSERT (FALSE);\r | |
116 | }\r | |
117 | \r | |
04af8bf2 DG |
118 | /**\r |
119 | This function causes a systemwide reset. The exact type of the reset is\r | |
120 | defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r | |
121 | into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r | |
122 | the platform must pick a supported reset type to perform.The platform may\r | |
123 | optionally log the parameters from any non-normal reset that occurs.\r | |
124 | \r | |
125 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
126 | @param[in] ResetData The data buffer starts with a Null-terminated string,\r | |
127 | followed by the EFI_GUID.\r | |
128 | **/\r | |
129 | VOID\r | |
130 | EFIAPI\r | |
131 | ResetPlatformSpecific (\r | |
132 | IN UINTN DataSize,\r | |
133 | IN VOID *ResetData\r | |
134 | )\r | |
135 | {\r | |
136 | ResetCold ();\r | |
137 | }\r |