1 /*++ 2 3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 4 5 This program and the accompanying materials are licensed and made available under 7 the terms and conditions of the BSD License that accompanies this distribution. 9 The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php. 13 15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 21 23 Module Name: 24 25 SmmPlatform.h 26 27 Abstract: 28 29 Header file for 30 31 ++*/ 32 33 #ifndef _PLATFORM_H 34 #define _PLATFORM_H 35 36 #include <PiSmm.h> 37 38 39 40 #include <Protocol/SmmBase.h> 41 #include <Protocol/FirmwareVolume.h> 42 #include <Protocol/SmmPowerButtonDispatch.h> 43 #include <Protocol/SmmSxDispatch.h> 44 #include <Protocol/SmmSwDispatch.h> 45 #include <Protocol/SmmSwDispatch2.h> 46 #include <Protocol/SmmIchnDispatch.h> 47 #include <Protocol/SmmAccess.h> 48 #include <Protocol/SmmVariable.h> 49 #include <Protocol/PciRootBridgeIo.h> 50 #include <Protocol/LoadedImage.h> 51 #include "Protocol/GlobalNvsArea.h" 52 #include <Guid/AcpiVariableCompatibility.h> 53 #include <Guid/SetupVariable.h> 54 #include <Guid/EfiVpdData.h> 55 #include <Guid/PciLanInfo.h> 56 #include <IndustryStandard/Pci22.h> 57 58 #include "PchAccess.h" 59 #include "PlatformBaseAddresses.h" 60 61 #include <Library/UefiBootServicesTableLib.h> 62 #include <Library/S3BootScriptLib.h> 63 #include <Library/IoLib.h> 64 #include <Library/DebugLib.h> 65 #include <Library/HobLib.h> 66 #include <Library/BaseLib.h> 67 #include <Library/BaseMemoryLib.h> 68 #include <Library/DevicePathLib.h> 69 #include <Library/PcdLib.h> 70 #include <Library/PchPlatformLib.h> 71 #include <Library/StallSmmLib.h> 72 73 74 75 typedef struct { 76 UINT8 Register; 77 UINT8 Function; 78 UINT8 Device; 79 UINT8 Bus; 80 UINT32 ExtendedRegister; 81 } SMM_PCI_IO_ADDRESS; 82 83 typedef struct { 84 CHAR8 BoardAaNumber[7]; 85 UINTN BoardFabNumber; 86 } BOARD_AA_NUMBER_DECODE; 87 88 // 89 // BugBug -- Need to get these two values from acpi.h, but right now, they are 90 // declared in platform-specific variants of this file, so no easy 91 // way to pick-up the include file and work across platforms. 92 // Need these definitions to go into a file like common\acpi.h. 93 // 94 #define ACPI_ENABLE 0xA0 95 #define ACPI_DISABLE 0xA1 96 97 #define APM_12_FUNCS 0x50 98 #define SMI_SET_SMMVARIABLE_PROTOCOL 0x51 // this is used in Cpu\Pentium\Smm\Base\SmmBase.c 99 100 #define SMI_CMD_GET_MSEG_STATUS 0x70 101 #define SMI_CMD_UPDATE_MSEG_SIZE 0x71 102 #define SMI_CMD_LOAD_STM 0x72 103 #define SMI_CMD_UNLOAD_STM 0x73 104 #define SMI_CMD_GET_SMRAM_RANGES 0x74 105 106 107 #define PCAT_RTC_ADDRESS_REGISTER 0x74 108 #define PCAT_RTC_DATA_REGISTER 0x75 109 110 #define RTC_ADDRESS_SECOND 0x00 111 #define RTC_ADDRESS_SECOND_ALARM 0x01 112 #define RTC_ADDRESS_MINUTE 0x02 113 #define RTC_ADDRESS_MINUTE_ALARM 0x03 114 #define RTC_ADDRESS_HOUR 0x04 115 #define RTC_ADDRESS_HOUR_ALARM 0x05 116 117 #define RTC_ADDRESS_REGISTER_A 0x0A 118 #define RTC_ADDRESS_REGISTER_B 0x0B 119 #define RTC_ADDRESS_REGISTER_C 0x0C 120 #define RTC_ADDRESS_REGISTER_D 0x0D 121 122 #define B_RTC_ALARM_INT_ENABLE 0x20 123 #define B_RTC_ALARM_INT_STATUS 0x20 124 125 #define B_RTC_DATE_ALARM_MASK 0x3F 126 127 #define PCAT_CMOS_2_ADDRESS_REGISTER 0x72 128 #define PCAT_CMOS_2_DATA_REGISTER 0x73 129 130 #define EC_C_PORT 0x66 131 #define SMC_SMI_DISABLE 0xBC 132 #define SMC_ENABLE_ACPI_MODE 0xAA // Enable ACPI mode 133 134 #define IO_MISC 156 135 136 137 #define MAXIMUM_NUMBER_OF_PSTATES 12 138 #define ICH_SMM_DATA_PORT 0xB3 139 140 #define EFI_IA32_PMG_CST_CONFIG 0x000000E2 141 #define B_EFI_CST_CONTROL_LOCK BIT15 142 #define B_EFI_IO_MWAIT_REDIRECTION_ENABLE BIT10 143 #define EFI_IA32_PMG_IO_CAPTURE_ADDR 0x000000E4 144 145 extern EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo; 146 147 // 148 // Callback function prototypes 149 // 150 VOID 151 EFIAPI 152 PowerButtonCallback ( 153 IN EFI_HANDLE DispatchHandle, 154 IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT *DispatchContext 155 ); 156 157 VOID 158 S5SleepWakeOnLanCallBack ( 159 IN EFI_HANDLE DispatchHandle, 160 IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext 161 ); 162 163 VOID 164 EFIAPI 165 S5SleepAcLossCallBack ( 166 IN EFI_HANDLE DispatchHandle, 167 IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext 168 ); 169 170 171 VOID 172 EFIAPI 173 S4S5CallBack ( 174 IN EFI_HANDLE DispatchHandle, 175 IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext 176 ); 177 178 VOID 179 EFIAPI 180 EnableAcpiCallback ( 181 IN EFI_HANDLE DispatchHandle, 182 IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext 183 ); 184 185 VOID 186 EFIAPI 187 DisableAcpiCallback ( 188 IN EFI_HANDLE DispatchHandle, 189 IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext 190 ); 191 192 VOID 193 EFIAPI 194 SmmReadyToBootCallback ( 195 IN EFI_HANDLE DispatchHandle, 196 IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext 197 ); 198 199 VOID 200 DummyTco1Callback ( 201 IN EFI_HANDLE DispatchHandle, 202 IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext 203 ); 204 205 206 VOID 207 PerrSerrCallback ( 208 IN EFI_HANDLE DispatchHandle, 209 IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext 210 ); 211 212 VOID 213 RiCallback ( 214 IN EFI_HANDLE DispatchHandle, 215 IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext 216 ); 217 218 219 VOID 220 SetAfterG3On ( 221 BOOLEAN Enable 222 ); 223 224 VOID 225 TurnOffVregUsb ( 226 ); 227 228 VOID 229 PStateSupportCallback ( 230 IN EFI_HANDLE DispatchHandle, 231 IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext 232 ); 233 234 VOID 235 PStateTransitionCallback ( 236 IN EFI_HANDLE DispatchHandle, 237 IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext 238 ); 239 240 EFI_STATUS 241 EFIAPI 242 SxSleepEntryCallBack ( 243 IN EFI_HANDLE DispatchHandle, 244 IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext 245 ); 246 247 EFI_STATUS 248 SaveRuntimeScriptTable ( 249 VOID 250 ); 251 252 253 #endif 254 255