3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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.
31 #include <Protocol/SmmBase.h>
32 #include <Protocol/FirmwareVolume.h>
33 #include <Protocol/SmmPowerButtonDispatch.h>
34 #include <Protocol/SmmSxDispatch.h>
35 #include <Protocol/SmmSwDispatch.h>
36 #include <Protocol/SmmSwDispatch2.h>
37 #include <Protocol/SmmIchnDispatch.h>
38 #include <Protocol/SmmAccess.h>
39 #include <Protocol/SmmVariable.h>
40 #include <Protocol/PciRootBridgeIo.h>
41 #include <Protocol/LoadedImage.h>
42 #include "Protocol/GlobalNvsArea.h"
43 #include <Guid/AcpiVariableCompatibility.h>
44 #include <Guid/SetupVariable.h>
45 #include <Guid/EfiVpdData.h>
46 #include <Guid/PciLanInfo.h>
47 #include <IndustryStandard/Pci22.h>
49 #include "PchAccess.h"
50 #include "PlatformBaseAddresses.h"
52 #include <Library/UefiBootServicesTableLib.h>
53 #include <Library/S3BootScriptLib.h>
54 #include <Library/IoLib.h>
55 #include <Library/DebugLib.h>
56 #include <Library/HobLib.h>
57 #include <Library/BaseLib.h>
58 #include <Library/BaseMemoryLib.h>
59 #include <Library/DevicePathLib.h>
60 #include <Library/PcdLib.h>
61 #include <Library/PchPlatformLib.h>
62 #include <Library/StallSmmLib.h>
71 UINT32 ExtendedRegister
;
75 CHAR8 BoardAaNumber
[7];
77 } BOARD_AA_NUMBER_DECODE
;
80 // BugBug -- Need to get these two values from acpi.h, but right now, they are
81 // declared in platform-specific variants of this file, so no easy
82 // way to pick-up the include file and work across platforms.
83 // Need these definitions to go into a file like common\acpi.h.
85 #define ACPI_ENABLE 0xA0
86 #define ACPI_DISABLE 0xA1
88 #define APM_12_FUNCS 0x50
89 #define SMI_SET_SMMVARIABLE_PROTOCOL 0x51 // this is used in Cpu\Pentium\Smm\Base\SmmBase.c
91 #define SMI_CMD_GET_MSEG_STATUS 0x70
92 #define SMI_CMD_UPDATE_MSEG_SIZE 0x71
93 #define SMI_CMD_LOAD_STM 0x72
94 #define SMI_CMD_UNLOAD_STM 0x73
95 #define SMI_CMD_GET_SMRAM_RANGES 0x74
98 #define PCAT_RTC_ADDRESS_REGISTER 0x74
99 #define PCAT_RTC_DATA_REGISTER 0x75
101 #define RTC_ADDRESS_SECOND 0x00
102 #define RTC_ADDRESS_SECOND_ALARM 0x01
103 #define RTC_ADDRESS_MINUTE 0x02
104 #define RTC_ADDRESS_MINUTE_ALARM 0x03
105 #define RTC_ADDRESS_HOUR 0x04
106 #define RTC_ADDRESS_HOUR_ALARM 0x05
108 #define RTC_ADDRESS_REGISTER_A 0x0A
109 #define RTC_ADDRESS_REGISTER_B 0x0B
110 #define RTC_ADDRESS_REGISTER_C 0x0C
111 #define RTC_ADDRESS_REGISTER_D 0x0D
113 #define B_RTC_ALARM_INT_ENABLE 0x20
114 #define B_RTC_ALARM_INT_STATUS 0x20
116 #define B_RTC_DATE_ALARM_MASK 0x3F
118 #define PCAT_CMOS_2_ADDRESS_REGISTER 0x72
119 #define PCAT_CMOS_2_DATA_REGISTER 0x73
121 #define EC_C_PORT 0x66
122 #define SMC_SMI_DISABLE 0xBC
123 #define SMC_ENABLE_ACPI_MODE 0xAA // Enable ACPI mode
128 #define MAXIMUM_NUMBER_OF_PSTATES 12
129 #define ICH_SMM_DATA_PORT 0xB3
131 #define EFI_IA32_PMG_CST_CONFIG 0x000000E2
132 #define B_EFI_CST_CONTROL_LOCK BIT15
133 #define B_EFI_IO_MWAIT_REDIRECTION_ENABLE BIT10
134 #define EFI_IA32_PMG_IO_CAPTURE_ADDR 0x000000E4
136 extern EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*mPciRootBridgeIo
;
139 // Callback function prototypes
143 PowerButtonCallback (
144 IN EFI_HANDLE DispatchHandle
,
145 IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT
*DispatchContext
149 S5SleepWakeOnLanCallBack (
150 IN EFI_HANDLE DispatchHandle
,
151 IN EFI_SMM_SX_DISPATCH_CONTEXT
*DispatchContext
156 S5SleepAcLossCallBack (
157 IN EFI_HANDLE DispatchHandle
,
158 IN EFI_SMM_SX_DISPATCH_CONTEXT
*DispatchContext
165 IN EFI_HANDLE DispatchHandle
,
166 IN EFI_SMM_SX_DISPATCH_CONTEXT
*DispatchContext
172 IN EFI_HANDLE DispatchHandle
,
173 IN EFI_SMM_SW_DISPATCH_CONTEXT
*DispatchContext
178 DisableAcpiCallback (
179 IN EFI_HANDLE DispatchHandle
,
180 IN EFI_SMM_SW_DISPATCH_CONTEXT
*DispatchContext
185 SmmReadyToBootCallback (
186 IN EFI_HANDLE DispatchHandle
,
187 IN EFI_SMM_SW_DISPATCH_CONTEXT
*DispatchContext
192 IN EFI_HANDLE DispatchHandle
,
193 IN EFI_SMM_ICHN_DISPATCH_CONTEXT
*DispatchContext
199 IN EFI_HANDLE DispatchHandle
,
200 IN EFI_SMM_ICHN_DISPATCH_CONTEXT
*DispatchContext
205 IN EFI_HANDLE DispatchHandle
,
206 IN EFI_SMM_ICHN_DISPATCH_CONTEXT
*DispatchContext
220 PStateSupportCallback (
221 IN EFI_HANDLE DispatchHandle
,
222 IN EFI_SMM_SW_DISPATCH_CONTEXT
*DispatchContext
226 PStateTransitionCallback (
227 IN EFI_HANDLE DispatchHandle
,
228 IN EFI_SMM_SW_DISPATCH_CONTEXT
*DispatchContext
233 SxSleepEntryCallBack (
234 IN EFI_HANDLE DispatchHandle
,
235 IN EFI_SMM_SX_DISPATCH_CONTEXT
*DispatchContext
239 SaveRuntimeScriptTable (