2 Reset Architectural Protocol implementation.
4 Copyright (c) 2006 - 2010, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Use ACPI method to reset the sytem. If fail, use legacy 8042 method to reset the system
20 @param[in] AcpiDescription Global variable to record reset info
25 IN EFI_ACPI_DESCRIPTION
*AcpiDescription
32 if ((AcpiDescription
->RESET_REG
.Address
!= 0) &&
33 ((AcpiDescription
->RESET_REG
.AddressSpaceId
== EFI_ACPI_3_0_SYSTEM_IO
) ||
34 (AcpiDescription
->RESET_REG
.AddressSpaceId
== EFI_ACPI_3_0_SYSTEM_MEMORY
) ||
35 (AcpiDescription
->RESET_REG
.AddressSpaceId
== EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE
))) {
37 // Use ACPI System Reset
39 switch (AcpiDescription
->RESET_REG
.AddressSpaceId
) {
40 case EFI_ACPI_3_0_SYSTEM_IO
:
41 IoWrite8 ((UINTN
) AcpiDescription
->RESET_REG
.Address
, AcpiDescription
->RESET_VALUE
);
43 case EFI_ACPI_3_0_SYSTEM_MEMORY
:
44 MmioWrite8 ((UINTN
) AcpiDescription
->RESET_REG
.Address
, AcpiDescription
->RESET_VALUE
);
46 case EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE
:
47 Register
= (UINT8
) AcpiDescription
->RESET_REG
.Address
;
48 Func
= (UINT8
) (RShiftU64 (AcpiDescription
->RESET_REG
.Address
, 16) & 0x7);
49 Dev
= (UINT8
) (RShiftU64 (AcpiDescription
->RESET_REG
.Address
, 32) & 0x1F);
50 PciWrite8 (PCI_LIB_ADDRESS (0, Dev
, Func
, Register
), AcpiDescription
->RESET_VALUE
);
56 // If system comes here, means ACPI reset fail, do Legacy System Reset, assume 8042 available
59 IoWrite8 (0x64, Register
);
62 // System should reset now
69 Use ACPI method to shutdown the sytem
71 @param[in] AcpiDescription Global variable to record reset info
73 @retval EFI_UNSUPPORTED Shutdown fails
78 IN EFI_ACPI_DESCRIPTION
*AcpiDescription
86 if ((AcpiDescription
->PM1a_CNT_BLK
.Address
!= 0) && (AcpiDescription
->SLP_TYPa
!= 0)) {
87 switch (AcpiDescription
->PM1a_CNT_BLK
.AddressSpaceId
) {
88 case EFI_ACPI_3_0_SYSTEM_IO
:
89 Value
= IoRead16 ((UINTN
) AcpiDescription
->PM1a_CNT_BLK
.Address
);
90 Value
= (Value
& 0xc3ff) | 0x2000 | (AcpiDescription
->SLP_TYPa
<< 10);
91 IoWrite16 ((UINTN
) AcpiDescription
->PM1a_CNT_BLK
.Address
, Value
);
93 case EFI_ACPI_3_0_SYSTEM_MEMORY
:
94 Value
= MmioRead16 ((UINTN
) AcpiDescription
->PM1a_CNT_BLK
.Address
);
95 Value
= (Value
& 0xc3ff) | 0x2000 | (AcpiDescription
->SLP_TYPa
<< 10);
96 MmioWrite16 ((UINTN
) AcpiDescription
->PM1a_CNT_BLK
.Address
, Value
);
104 if ((AcpiDescription
->PM1b_CNT_BLK
.Address
!= 0) && (AcpiDescription
->SLP_TYPb
!= 0)) {
105 switch (AcpiDescription
->PM1b_CNT_BLK
.AddressSpaceId
) {
106 case EFI_ACPI_3_0_SYSTEM_IO
:
107 Value
= IoRead16 ((UINTN
) AcpiDescription
->PM1b_CNT_BLK
.Address
);
108 Value
= (Value
& 0xc3ff) | 0x2000 | (AcpiDescription
->SLP_TYPb
<< 10);
109 IoWrite16 ((UINTN
) AcpiDescription
->PM1b_CNT_BLK
.Address
, Value
);
111 case EFI_ACPI_3_0_SYSTEM_MEMORY
:
112 Value
= MmioRead16 ((UINTN
) AcpiDescription
->PM1b_CNT_BLK
.Address
);
113 Value
= (Value
& 0xc3ff) | 0x2000 | (AcpiDescription
->SLP_TYPb
<< 10);
114 MmioWrite16 ((UINTN
) AcpiDescription
->PM1b_CNT_BLK
.Address
, Value
);
120 // Done, if code runs here, mean not shutdown correctly
122 return EFI_UNSUPPORTED
;
128 @param[in] ResetType Warm or cold
129 @param[in] ResetStatus Possible cause of reset
130 @param[in] DataSize Size of ResetData in bytes
131 @param[in] ResetData Optional Unicode string
132 @param[in] AcpiDescription Global variable to record reset info
138 IN EFI_RESET_TYPE ResetType
,
139 IN EFI_STATUS ResetStatus
,
141 IN CHAR16
*ResetData
, OPTIONAL
142 IN EFI_ACPI_DESCRIPTION
*AcpiDescription
150 SystemReset (AcpiDescription
);
153 case EfiResetShutdown
:
154 Status
= SystemShutdown (AcpiDescription
);
155 if (EFI_ERROR (Status
)) {
156 SystemReset (AcpiDescription
);
165 // Given we should have reset getting here would be bad
172 IN EFI_ACPI_DESCRIPTION
*AcpiDescription
175 EFI_HOB_GUID_TYPE
*HobAcpiDescription
;
177 // Get AcpiDescription Hob
179 HobAcpiDescription
= GetFirstGuidHob (&gEfiAcpiDescriptionGuid
);
180 if (HobAcpiDescription
== NULL
) {
185 // Copy it to Runtime Memory
187 ASSERT (sizeof (EFI_ACPI_DESCRIPTION
) == GET_GUID_HOB_DATA_SIZE (HobAcpiDescription
));
188 CopyMem (AcpiDescription
, GET_GUID_HOB_DATA (HobAcpiDescription
), sizeof (EFI_ACPI_DESCRIPTION
));
190 DEBUG ((EFI_D_ERROR
, "ACPI Reset Base - %lx\n", AcpiDescription
->RESET_REG
.Address
));
191 DEBUG ((EFI_D_ERROR
, "ACPI Reset Value - %02x\n", (UINTN
)AcpiDescription
->RESET_VALUE
));
192 DEBUG ((EFI_D_ERROR
, "IAPC support - %x\n", (UINTN
)(AcpiDescription
->IAPC_BOOT_ARCH
)));