3 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php.
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 Platform Initialization Driver.
35 #include "PlatformDxe.h"
37 #include "PchCommonDefinitions.h"
38 #include <Protocol/UsbPolicy.h>
39 #include <Protocol/PchPlatformPolicy.h>
40 #include <Protocol/TpmMp.h>
41 #include <Protocol/CpuIo2.h>
42 #include <Library/S3BootScriptLib.h>
43 #include <Guid/PciLanInfo.h>
44 #include <Guid/ItkData.h>
45 #include <Library/PciLib.h>
46 #include <PlatformBootMode.h>
47 #include <Guid/EventGroup.h>
48 #include <Guid/Vlv2Variable.h>
49 #include <Protocol/GlobalNvsArea.h>
50 #include <Protocol/IgdOpRegion.h>
51 #include <Library/PcdLib.h>
54 // VLV2 GPIO GROUP OFFSET
56 #define GPIO_SCORE_OFFSET 0x0000
57 #define GPIO_NCORE_OFFSET 0x1000
58 #define GPIO_SSUS_OFFSET 0x2000
65 GPIO_CONF_PAD_INIT mTB_BL_GpioInitData_SC_TRI_Exit_boot_Service
[] =
67 // Pad Name GPIO Number Used As GPO Default Function# INT Capable Interrupt Type PULL H/L MMIO Offset
68 GPIO_INIT_ITEM("LPC_CLKOUT0 GPIOC_47 " ,TRISTS
,NA
,F0
, , ,NONE
,0x47),
69 GPIO_INIT_ITEM("LPC_CLKOUT1 GPIOC_48 " ,TRISTS
,NA
,F0
, , ,NONE
,0x41),
73 EFI_GUID mSystemHiiExportDatabase
= EFI_HII_EXPORT_DATABASE_GUID
;
74 EFI_GUID mPlatformDriverGuid
= EFI_PLATFORM_DRIVER_GUID
;
75 SYSTEM_CONFIGURATION mSystemConfiguration
;
76 SYSTEM_PASSWORDS mSystemPassword
;
77 EFI_HANDLE mImageHandle
;
78 BOOLEAN mMfgMode
= FALSE
;
79 VOID
*mDxePlatformStringPack
;
80 UINT32 mPlatformBootMode
= PLATFORM_NORMAL_MODE
;
81 extern CHAR16 gItkDataVarName
[];
84 EFI_PLATFORM_INFO_HOB mPlatformInfo
;
85 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*mPciRootBridgeIo
;
86 EFI_EVENT mReadyToBootEvent
;
88 UINT8 mSmbusRsvdAddresses
[] = PLATFORM_SMBUS_RSVD_ADDRESSES
;
89 UINT8 mNumberSmbusAddress
= sizeof( mSmbusRsvdAddresses
) / sizeof( mSmbusRsvdAddresses
[0] );
90 UINT32 mSubsystemVidDid
;
91 UINT32 mSubsystemAudioVidDid
;
93 UINTN mPciLanCount
= 0;
94 VOID
*mPciLanInfo
= NULL
;
97 static EFI_SPEAKER_IF_PROTOCOL mSpeakerInterface
= {
102 EFI_USB_POLICY_PROTOCOL mUsbPolicyData
= {0};
105 CFIO_PNP_INIT mTB_BL_GpioInitData_SC_TRI_S0ix_Exit_boot_Service
[] =
107 {0x410 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pconf0
108 {0x470 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pconf0
109 {0x560 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pconf0
110 {0x450 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pconf0
111 {0x480 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pconf0
112 {0x420 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pconf0
113 {0x430 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pconf0
114 {0x440 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pconf0
115 {0x460 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pconf0
116 {0x418 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pad_val
117 {0x478 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pad_val
118 {0x568 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pad_val
119 {0x458 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pad_val
120 {0x488 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pad_val
121 {0x428 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pad_val
122 {0x438 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pad_val
123 {0x448 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pad_val
124 {0x468 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pad_val
129 IN VOID
*Destination
,
134 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
142 InitializeClockRouting(
149 #if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0
151 InitializeSensorInfoVariable (
166 InitPlatformBootMode();
169 InitMfgAndConfigModeStateVar();
172 InitPchPlatformPolicy (
173 IN EFI_PLATFORM_INFO_HOB
*PlatformInfo
177 InitVlvPlatformPolicy (
181 InitSioPlatformPolicy(
193 InitPlatformUsbPolicy (
204 TristateLpcGpioConfig (
205 IN UINT32 Gpio_Mmio_Offset
,
206 IN UINT32 Gpio_Pin_Num
,
207 GPIO_CONF_PAD_INIT
* Gpio_Conf_Data
218 // GPIO WELL -- Memory base registers
222 // A0 BIOS Spec doesn't mention it although X0 does. comment out now.
223 // GPIO write 0x01001002 to IOBASE + Gpio_Mmio_Offset + 0x0900
226 for(index
=0; index
< Gpio_Pin_Num
; index
++)
229 // Calculate the MMIO Address for specific GPIO pin CONF0 register pointed by index.
231 mmio_conf0
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ R_PCH_CFIO_PAD_CONF0
+ Gpio_Conf_Data
[index
].offset
* 16;
232 mmio_padval
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ R_PCH_CFIO_PAD_VAL
+ Gpio_Conf_Data
[index
].offset
* 16;
235 DEBUG ((EFI_D_INFO
, "%s, ", Gpio_Conf_Data
[index
].pad_name
));
238 DEBUG ((EFI_D_INFO
, "Usage = %d, Func# = %d, IntType = %d, Pull Up/Down = %d, MMIO Base = 0x%08x, ",
239 Gpio_Conf_Data
[index
].usage
,
240 Gpio_Conf_Data
[index
].func
,
241 Gpio_Conf_Data
[index
].int_type
,
242 Gpio_Conf_Data
[index
].pull
,
246 // Step 1: PadVal Programming
248 pad_val
.dw
= MmioRead32(mmio_padval
);
251 // Config PAD_VAL only for GPIO (Non-Native) Pin
253 if(Native
!= Gpio_Conf_Data
[index
].usage
)
255 pad_val
.dw
&= ~0x6; // Clear bits 1:2
256 pad_val
.dw
|= (Gpio_Conf_Data
[index
].usage
& 0x6); // Set bits 1:2 according to PadVal
259 // set GPO default value
261 if(Gpio_Conf_Data
[index
].usage
== GPO
&& Gpio_Conf_Data
[index
].gpod4
!= NA
)
263 pad_val
.r
.pad_val
= Gpio_Conf_Data
[index
].gpod4
;
268 DEBUG ((EFI_D_INFO
, "Set PAD_VAL = 0x%08x, ", pad_val
.dw
));
270 MmioWrite32(mmio_padval
, pad_val
.dw
);
273 // Step 2: CONF0 Programming
274 // Read GPIO default CONF0 value, which is assumed to be default value after reset.
276 conf0_val
.dw
= MmioRead32(mmio_conf0
);
281 conf0_val
.r
.Func_Pin_Mux
= Gpio_Conf_Data
[index
].func
;
283 if(GPO
== Gpio_Conf_Data
[index
].usage
)
286 // If used as GPO, then internal pull need to be disabled
288 conf0_val
.r
.Pull_assign
= 0; // Non-pull
293 // Set PullUp / PullDown
295 if(P_20K_H
== Gpio_Conf_Data
[index
].pull
)
297 conf0_val
.r
.Pull_assign
= 0x1; // PullUp
298 conf0_val
.r
.Pull_strength
= 0x2;// 20K
300 else if(P_20K_L
== Gpio_Conf_Data
[index
].pull
)
302 conf0_val
.r
.Pull_assign
= 0x2; // PullDown
303 conf0_val
.r
.Pull_strength
= 0x2;// 20K
305 else if(P_NONE
== Gpio_Conf_Data
[index
].pull
)
307 conf0_val
.r
.Pull_assign
= 0; // Non-pull
311 ASSERT(FALSE
); // Invalid value
316 // Set INT Trigger Type
318 conf0_val
.dw
&= ~0x0f000000; // Clear bits 27:24
321 // Set INT Trigger Type
323 if(TRIG_
== Gpio_Conf_Data
[index
].int_type
)
326 // Interrupt not capable, clear bits 27:24
331 conf0_val
.dw
|= (Gpio_Conf_Data
[index
].int_type
& 0x0f)<<24;
334 DEBUG ((EFI_D_INFO
, "Set CONF0 = 0x%08x\n", conf0_val
.dw
));
337 // Write back the targeted GPIO config value according to platform (board) GPIO setting
339 MmioWrite32 (mmio_conf0
, conf0_val
.dw
);
342 // A0 BIOS Spec doesn't mention it although X0 does. comment out now.
343 // GPIO SCORE write 0x01001002 to IOBASE + 0x0900
349 SpiBiosProtectionFunction(
355 UINTN mPciD31F0RegBase
;
362 BiosFlaLower0
= PcdGet32(PcdFlashMicroCodeAddress
)-PcdGet32(PcdFlashAreaBaseAddress
);
363 BiosFlaLimit0
= PcdGet32(PcdFlashMicroCodeSize
)-1;
364 #ifdef MINNOW2_FSP_BUILD
365 BiosFlaLower1
= PcdGet32(PcdFlashFvFspBase
)-PcdGet32(PcdFlashAreaBaseAddress
);
366 BiosFlaLimit1
= (PcdGet32(PcdFlashFvRecoveryBase
)-PcdGet32(PcdFlashFvFspBase
)+PcdGet32(PcdFlashFvRecoverySize
))-1;
368 BiosFlaLower1
= PcdGet32(PcdFlashFvMainBase
)-PcdGet32(PcdFlashAreaBaseAddress
);
369 BiosFlaLimit1
= (PcdGet32(PcdFlashFvRecoveryBase
)-PcdGet32(PcdFlashFvMainBase
)+PcdGet32(PcdFlashFvRecoverySize
))-1;
373 mPciD31F0RegBase
= MmPciAddress (0,
374 DEFAULT_PCI_BUS_NUMBER_PCH
,
375 PCI_DEVICE_NUMBER_PCH_LPC
,
376 PCI_FUNCTION_NUMBER_PCH_LPC
,
379 SpiBase
= MmioRead32(mPciD31F0RegBase
+ R_PCH_LPC_SPI_BASE
) & B_PCH_LPC_SPI_BASE_BAR
;
382 //Set SMM_BWP, WPD and LE bit
384 MmioOr32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
) B_PCH_SPI_BCR_SMM_BWP
);
385 MmioAnd32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
)(~B_PCH_SPI_BCR_BIOSWE
));
386 MmioOr32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
) B_PCH_SPI_BCR_BLE
);
389 //First check if FLOCKDN or PR0FLOCKDN is set. No action if either of them set already.
391 if( (MmioRead16(SpiBase
+ R_PCH_SPI_HSFS
) & B_PCH_SPI_HSFS_FLOCKDN
) != 0 ||
392 (MmioRead32(SpiBase
+ R_PCH_SPI_IND_LOCK
)& B_PCH_SPI_IND_LOCK_PR0
) != 0) {
394 //Already locked. we could take no action here
396 DEBUG((EFI_D_INFO
, "PR0 already locked down. Stop configuring PR0.\n"));
403 MmioOr32((UINTN
)(SpiBase
+ R_PCH_SPI_PR0
),
404 B_PCH_SPI_PR0_RPE
|B_PCH_SPI_PR0_WPE
|\
405 (B_PCH_SPI_PR0_PRB_MASK
&(BiosFlaLower0
>>12))|(B_PCH_SPI_PR0_PRL_MASK
&(BiosFlaLimit0
>>12)<<16));
410 MmioOr16 ((UINTN
) (SpiBase
+ R_PCH_SPI_HSFS
), (UINT16
) (B_PCH_SPI_HSFS_FLOCKDN
));
413 // Verify if it's really locked.
415 if ((MmioRead16 (SpiBase
+ R_PCH_SPI_HSFS
) & B_PCH_SPI_HSFS_FLOCKDN
) == 0) {
416 DEBUG((EFI_D_ERROR
, "Failed to lock down PR0.\n"));
423 MmioOr32((UINTN
)(SpiBase
+ R_PCH_SPI_PR1
),
424 B_PCH_SPI_PR1_RPE
|B_PCH_SPI_PR1_WPE
|\
425 (B_PCH_SPI_PR1_PRB_MASK
&(BiosFlaLower1
>>12))|(B_PCH_SPI_PR1_PRL_MASK
&(BiosFlaLimit1
>>12)<<16));
430 MmioOr16 ((UINTN
) (SpiBase
+ R_PCH_SPI_HSFS
), (UINT16
) (B_PCH_SPI_HSFS_FLOCKDN
));
433 // Verify if it's really locked.
435 if ((MmioRead16 (SpiBase
+ R_PCH_SPI_HSFS
) & B_PCH_SPI_HSFS_FLOCKDN
) == 0) {
436 DEBUG((EFI_D_ERROR
, "Failed to lock down PR1.\n"));
452 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
453 Status
= gRT
->GetVariable(
455 &gEfiNormalSetupGuid
,
458 &mSystemConfiguration
464 PchAzaliaPciCfg32Or (R_PCH_HDA_PCS
, B_PCH_HDA_PCS_PMEE
);
467 //Program SATA PME_EN
469 PchSataPciCfg32Or (R_PCH_SATA_PMCS
, B_PCH_SATA_PMCS_PMEE
);
471 DEBUG ((EFI_D_INFO
, "InitPciDevPME mSystemConfiguration.EhciPllCfgEnable = 0x%x \n",mSystemConfiguration
.EhciPllCfgEnable
));
472 if (mSystemConfiguration
.EhciPllCfgEnable
!= 1) {
474 //Program EHCI PME_EN
479 PCI_DEVICE_NUMBER_PCH_USB
,
480 PCI_FUNCTION_NUMBER_PCH_EHCI
,
481 R_PCH_EHCI_PWR_CNTL_STS
,
482 B_PCH_EHCI_PWR_CNTL_STS_PME_EN
489 EhciPciMmBase
= MmPciAddress (0,
491 PCI_DEVICE_NUMBER_PCH_USB
,
492 PCI_FUNCTION_NUMBER_PCH_EHCI
,
495 DEBUG ((EFI_D_INFO
, "ConfigureAdditionalPm() EhciPciMmBase = 0x%x \n",EhciPciMmBase
));
496 Buffer32
= MmioRead32(EhciPciMmBase
+ R_PCH_EHCI_PWR_CNTL_STS
);
497 DEBUG ((EFI_D_INFO
, "ConfigureAdditionalPm() R_PCH_EHCI_PWR_CNTL_STS = 0x%x \n",Buffer32
));
501 #if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY
508 TristateLpcGpioS0i3Config (
509 UINT32 Gpio_Mmio_Offset
,
511 CFIO_PNP_INIT
* Gpio_Conf_Data
519 DEBUG ((DEBUG_INFO
, "TristateLpcGpioS0i3Config\n"));
521 for(index
=0; index
< Gpio_Pin_Num
; index
++)
523 mmio_reg
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ Gpio_Conf_Data
[index
].offset
;
525 MmioWrite32(mmio_reg
, Gpio_Conf_Data
[index
].val
);
527 mmio_val
= MmioRead32(mmio_reg
);
529 DEBUG ((EFI_D_INFO
, "Set MMIO=0x%08x PAD_VAL = 0x%08x,\n", mmio_reg
, mmio_val
));
536 EFI_BOOT_SCRIPT_SAVE_PROTOCOL
*mBootScriptSave
;
539 Event Notification during exit boot service to enabel ACPI mode
541 Disable SW SMI Timer, SMI from USB & Intel Specific USB 2
543 Clear all ACPI event status and disable all ACPI events
544 Disable PM sources except power button
547 Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm")
549 Update EC to disable SMI and enable SCI
553 Enable PME_B0_EN in GPE0a_EN
555 @param Event - EFI Event Handle
556 @param Context - Pointer to Notify Context
573 AcpiBase
= MmioRead16 (
574 PchPciDeviceMmBase (DEFAULT_PCI_BUS_NUMBER_PCH
,
575 PCI_DEVICE_NUMBER_PCH_LPC
,
576 PCI_FUNCTION_NUMBER_PCH_LPC
) + R_PCH_LPC_ACPI_BASE
577 ) & B_PCH_LPC_ACPI_BASE_BAR
;
579 DEBUG ((EFI_D_INFO
, "EnableAcpiCallback: AcpiBase = %x\n", AcpiBase
));
582 // Disable SW SMI Timer, SMI from USB & Intel Specific USB 2
584 RegData32
= IoRead32(AcpiBase
+ R_PCH_SMI_EN
);
585 RegData32
&= ~(B_PCH_SMI_EN_SWSMI_TMR
| B_PCH_SMI_EN_LEGACY_USB2
| B_PCH_SMI_EN_INTEL_USB2
);
586 IoWrite32(AcpiBase
+ R_PCH_SMI_EN
, RegData32
);
588 RegData32
= IoRead32(AcpiBase
+ R_PCH_SMI_STS
);
589 RegData32
|= B_PCH_SMI_STS_SWSMI_TMR
;
590 IoWrite32(AcpiBase
+ R_PCH_SMI_STS
, RegData32
);
593 // Disable PM sources except power button
594 // power button is enabled only for PCAT. Disabled it on Tablet platform
597 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_EN
, B_PCH_ACPI_PM1_EN_PWRBTN
);
598 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_STS
, 0xffff);
601 // Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm")
602 // Clear Status D reg VM bit, Date of month Alarm to make Data in CMOS RAM is no longer Valid
604 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, RTC_ADDRESS_REGISTER_D
);
605 IoWrite8 (PCAT_RTC_DATA_REGISTER
, 0x0);
607 RegData32
= IoRead32(AcpiBase
+ R_PCH_ALT_GP_SMI_EN
);
608 RegData32
&= ~(BIT7
);
609 IoWrite32((AcpiBase
+ R_PCH_ALT_GP_SMI_EN
), RegData32
);
614 Pm1Cnt
= IoRead16(AcpiBase
+ R_PCH_ACPI_PM1_CNT
);
615 Pm1Cnt
|= B_PCH_ACPI_PM1_CNT_SCI_EN
;
616 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_CNT
, Pm1Cnt
);
618 IoWrite8(0x80, 0xA0); //SW_SMI_ACPI_ENABLE
621 // Enable PME_B0_EN in GPE0a_EN
622 // Caution: Enable PME_B0_EN must be placed after enabling SCI.
623 // Otherwise, USB PME could not be handled as SMI event since no handler is there.
625 Gpe0aEn
= IoRead32 (AcpiBase
+ R_PCH_ACPI_GPE0a_EN
);
626 Gpe0aEn
|= B_PCH_ACPI_GPE0a_EN_PME_B0
;
627 IoWrite32(AcpiBase
+ R_PCH_ACPI_GPE0a_EN
, Gpe0aEn
);
635 This is the standard EFI driver point for the Driver. This
636 driver is responsible for setting up any platform specific policy or
637 initialization information.
639 @param ImageHandle Handle for the image of this driver.
640 @param SystemTable Pointer to the EFI System Table.
642 @retval EFI_SUCCESS Policy decisions set.
648 IN EFI_HANDLE ImageHandle
,
649 IN EFI_SYSTEM_TABLE
*SystemTable
654 EFI_HANDLE Handle
= NULL
;
655 EFI_EVENT mEfiExitBootServicesEvent
;
657 VOID
*RtcCallbackReg
= NULL
;
659 mImageHandle
= ImageHandle
;
661 Status
= gBS
->InstallProtocolInterface (
663 &gEfiSpeakerInterfaceProtocolGuid
,
664 EFI_NATIVE_INTERFACE
,
668 Status
= gBS
->LocateProtocol (
669 &gEfiPciRootBridgeIoProtocolGuid
,
671 (VOID
**) &mPciRootBridgeIo
673 ASSERT_EFI_ERROR (Status
);
675 VarSize
= sizeof(EFI_PLATFORM_INFO_HOB
);
676 Status
= gRT
->GetVariable(
678 &gEfiVlv2VariableGuid
,
685 // Initialize Product Board ID variable
687 InitMfgAndConfigModeStateVar();
688 InitPlatformBootMode();
691 // Install Observable protocol
693 InitializeObservableProtocol();
696 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
697 Status
= gRT
->GetVariable(
699 &gEfiNormalSetupGuid
,
702 &mSystemConfiguration
706 Status
= EfiCreateEventReadyToBootEx (
714 // Create a ReadyToBoot Event to run the PME init process
716 Status
= EfiCreateEventReadyToBootEx (
723 // Create a ReadyToBoot Event to run enable PR0/PR1 and lock down,unlock variable region
725 if(mSystemConfiguration
.SpiRwProtect
==1) {
726 Status
= EfiCreateEventReadyToBootEx (
728 SpiBiosProtectionFunction
,
736 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP1
,
744 #if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0
746 // Initialize Sensor Info variable
748 InitializeSensorInfoVariable();
750 InitPchPlatformPolicy(&mPlatformInfo
);
751 InitVlvPlatformPolicy();
756 InitPlatformUsbPolicy();
757 InitSioPlatformPolicy();
758 InitializeClockRouting();
759 InitializeSlotInfo();
769 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP2
,
778 // Install PCI Bus Driver Hook
786 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP3
,
796 // Initialize Password States and Callbacks
800 #if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY
804 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
806 // Re-write Firmware ID if it is changed
813 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP4
,
822 Status
= gBS
->CreateEventEx (
827 &gEfiEventExitBootServicesGuid
,
828 &mEfiExitBootServicesEvent
832 // Adjust RTC deafult time to be BIOS-built time.
834 Status
= gBS
->CreateEvent (
837 AdjustDefaultRtcTimeCallback
,
841 if (!EFI_ERROR (Status
)) {
842 Status
= gBS
->RegisterProtocolNotify (
843 &gExitPmAuthProtocolGuid
,
854 Source Or Destination with Length bytes.
856 @param[in] Destination Target memory
857 @param[in] Source Source memory
858 @param[in] Length Number of bytes
865 IN VOID
*Destination
,
873 if (Source
< Destination
) {
874 Destination8
= (CHAR8
*) Destination
+ Length
- 1;
875 Source8
= (CHAR8
*) Source
+ Length
- 1;
877 *(Destination8
--) |= *(Source8
--);
880 Destination8
= (CHAR8
*) Destination
;
881 Source8
= (CHAR8
*) Source
;
883 *(Destination8
++) |= *(Source8
++);
892 // Saved SPI Opcode menu to fix EFI variable unable to write after S3 resume.
894 S3BootScriptSaveMemWrite (
895 EfiBootScriptWidthUint32
,
896 (UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU0
)),
898 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU0
)));
900 S3BootScriptSaveMemWrite (
901 EfiBootScriptWidthUint32
,
902 (UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU1
)),
904 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU1
)));
906 S3BootScriptSaveMemWrite (
907 EfiBootScriptWidthUint16
,
908 (UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_OPTYPE
),
910 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_OPTYPE
));
912 S3BootScriptSaveMemWrite (
913 EfiBootScriptWidthUint16
,
914 (UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_PREOP
),
916 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_PREOP
));
919 // Saved MTPMC_1 for S3 resume.
921 S3BootScriptSaveMemWrite (
922 EfiBootScriptWidthUint32
,
923 (UINTN
)(PMC_BASE_ADDRESS
+ R_PCH_PMC_MTPMC1
),
925 (VOID
*)(UINTN
)(PMC_BASE_ADDRESS
+ R_PCH_PMC_MTPMC1
));
931 ReadyToBootFunction (
937 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
938 EFI_ISA_ACPI_DEVICE_ID IsaDevice
;
941 EFI_TPM_MP_DRIVER_PROTOCOL
*TpmMpDriver
;
942 EFI_CPU_IO_PROTOCOL
*CpuIo
;
944 UINT8 ReceiveBuffer
[64];
945 UINT32 ReceiveBufferSize
;
947 UINT8 TpmForceClearCommand
[] = {0x00, 0xC1,
948 0x00, 0x00, 0x00, 0x0A,
949 0x00, 0x00, 0x00, 0x5D};
950 UINT8 TpmPhysicalPresenceCommand
[] = {0x00, 0xC1,
951 0x00, 0x00, 0x00, 0x0C,
952 0x40, 0x00, 0x00, 0x0A,
954 UINT8 TpmPhysicalDisableCommand
[] = {0x00, 0xC1,
955 0x00, 0x00, 0x00, 0x0A,
956 0x00, 0x00, 0x00, 0x70};
957 UINT8 TpmPhysicalEnableCommand
[] = {0x00, 0xC1,
958 0x00, 0x00, 0x00, 0x0A,
959 0x00, 0x00, 0x00, 0x6F};
960 UINT8 TpmPhysicalSetDeactivatedCommand
[] = {0x00, 0xC1,
961 0x00, 0x00, 0x00, 0x0B,
962 0x00, 0x00, 0x00, 0x72,
964 UINT8 TpmSetOwnerInstallCommand
[] = {0x00, 0xC1,
965 0x00, 0x00, 0x00, 0x0B,
966 0x00, 0x00, 0x00, 0x71,
969 Size
= sizeof(UINT16
);
970 Status
= gRT
->GetVariable (
971 VAR_EQ_FLOPPY_MODE_DECIMAL_NAME
,
972 &gEfiNormalSetupGuid
,
979 // Disable Floppy Controller if needed
981 Status
= gBS
->LocateProtocol (&gEfiIsaAcpiProtocolGuid
, NULL
, (VOID
**) &IsaAcpi
);
982 if (!EFI_ERROR(Status
) && (State
== 0x00)) {
983 IsaDevice
.HID
= EISA_PNP_ID(0x604);
985 Status
= IsaAcpi
->EnableDevice(IsaAcpi
, &IsaDevice
, FALSE
);
989 // save LAN info to a variable
991 if (NULL
!= mPciLanInfo
) {
995 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
996 mPciLanCount
* sizeof(PCI_LAN_INFO
),
1001 if (NULL
!= mPciLanInfo
) {
1002 gBS
->FreePool (mPciLanInfo
);
1008 // Handle ACPI OS TPM requests here
1010 Status
= gBS
->LocateProtocol (
1011 &gEfiCpuIoProtocolGuid
,
1015 Status
= gBS
->LocateProtocol (
1016 &gEfiTpmMpDriverProtocolGuid
,
1018 (VOID
**)&TpmMpDriver
1020 if (!EFI_ERROR (Status
))
1022 Data
= ReadCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
);
1025 // Clear pending ACPI TPM request indicator
1027 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
, 0x00);
1030 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_LAST_REQUEST
, Data
);
1033 // Assert Physical Presence for these commands
1035 TpmPhysicalPresenceCommand
[11] = 0x20;
1036 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1037 Status
= TpmMpDriver
->Transmit (
1038 TpmMpDriver
, TpmPhysicalPresenceCommand
,
1039 sizeof (TpmPhysicalPresenceCommand
),
1040 ReceiveBuffer
, &ReceiveBufferSize
1043 // PF PhysicalPresence = TRUE
1045 TpmPhysicalPresenceCommand
[11] = 0x08;
1046 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1047 Status
= TpmMpDriver
->Transmit (
1048 TpmMpDriver
, TpmPhysicalPresenceCommand
,
1049 sizeof (TpmPhysicalPresenceCommand
),
1056 // TPM_PhysicalEnable
1058 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1059 Status
= TpmMpDriver
->Transmit (
1060 TpmMpDriver
, TpmPhysicalEnableCommand
,
1061 sizeof (TpmPhysicalEnableCommand
),
1062 ReceiveBuffer
, &ReceiveBufferSize
1068 // TPM_PhysicalDisable
1070 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1071 Status
= TpmMpDriver
->Transmit (
1072 TpmMpDriver
, TpmPhysicalDisableCommand
,
1073 sizeof (TpmPhysicalDisableCommand
),
1081 // TPM_PhysicalSetDeactivated=FALSE
1083 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1084 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1085 Status
= TpmMpDriver
->Transmit (
1087 TpmPhysicalSetDeactivatedCommand
,
1088 sizeof (TpmPhysicalSetDeactivatedCommand
),
1089 ReceiveBuffer
, &ReceiveBufferSize
1091 gRT
->ResetSystem (EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
1096 // TPM_PhysicalSetDeactivated=TRUE
1098 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1099 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1100 Status
= TpmMpDriver
->Transmit (
1102 TpmPhysicalSetDeactivatedCommand
,
1103 sizeof (TpmPhysicalSetDeactivatedCommand
),
1119 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1120 Status
= TpmMpDriver
->Transmit (
1122 TpmForceClearCommand
,
1123 sizeof (TpmForceClearCommand
),
1137 // TPM_PhysicalEnable
1139 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1140 Status
= TpmMpDriver
->Transmit (
1142 TpmPhysicalEnableCommand
,
1143 sizeof (TpmPhysicalEnableCommand
),
1148 // TPM_PhysicalSetDeactivated=FALSE
1150 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1151 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1152 Status
= TpmMpDriver
->Transmit (
1154 TpmPhysicalSetDeactivatedCommand
,
1155 sizeof (TpmPhysicalSetDeactivatedCommand
),
1169 // TPM_PhysicalSetDeactivated=TRUE
1171 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1172 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1173 Status
= TpmMpDriver
->Transmit (
1175 TpmPhysicalSetDeactivatedCommand
,
1176 sizeof (TpmPhysicalSetDeactivatedCommand
),
1181 // TPM_PhysicalDisable
1183 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1184 Status
= TpmMpDriver
->Transmit (
1186 TpmPhysicalDisableCommand
,
1187 sizeof (TpmPhysicalDisableCommand
),
1201 // TPM_SetOwnerInstall=TRUE
1203 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1204 TpmSetOwnerInstallCommand
[10] = 0x01;
1205 Status
= TpmMpDriver
->Transmit (
1207 TpmSetOwnerInstallCommand
,
1208 sizeof (TpmSetOwnerInstallCommand
),
1216 // TPM_SetOwnerInstall=FALSE
1218 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1219 TpmSetOwnerInstallCommand
[10] = 0x00;
1220 Status
= TpmMpDriver
->Transmit (
1222 TpmSetOwnerInstallCommand
,
1223 sizeof (TpmSetOwnerInstallCommand
),
1231 // TPM_PhysicalEnable
1233 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1234 Status
= TpmMpDriver
->Transmit (
1236 TpmPhysicalEnableCommand
,
1237 sizeof (TpmPhysicalEnableCommand
),
1242 // TPM_PhysicalSetDeactivated=FALSE
1244 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1245 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1246 Status
= TpmMpDriver
->Transmit (
1248 TpmPhysicalSetDeactivatedCommand
,
1249 sizeof (TpmPhysicalSetDeactivatedCommand
),
1254 // Do TPM_SetOwnerInstall=TRUE on next reboot
1257 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
, 0xF0);
1269 // TPM_SetOwnerInstall=FALSE
1271 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1272 TpmSetOwnerInstallCommand
[10] = 0x00;
1273 Status
= TpmMpDriver
->Transmit (
1275 TpmSetOwnerInstallCommand
,
1276 sizeof (TpmSetOwnerInstallCommand
),
1281 // TPM_PhysicalSetDeactivated=TRUE
1283 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1284 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1285 Status
= TpmMpDriver
->Transmit (
1287 TpmPhysicalSetDeactivatedCommand
,
1288 sizeof (TpmPhysicalSetDeactivatedCommand
),
1293 // TPM_PhysicalDisable
1295 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1296 Status
= TpmMpDriver
->Transmit (
1298 TpmPhysicalDisableCommand
,
1299 sizeof (TpmPhysicalDisableCommand
),
1315 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1316 Status
= TpmMpDriver
->Transmit (
1318 TpmForceClearCommand
,
1319 sizeof (TpmForceClearCommand
),
1324 // TPM_PhysicalEnable
1326 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1327 Status
= TpmMpDriver
->Transmit (
1329 TpmPhysicalEnableCommand
,
1330 sizeof (TpmPhysicalEnableCommand
),
1335 // TPM_PhysicalSetDeactivated=FALSE
1337 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1338 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1339 Status
= TpmMpDriver
->Transmit (
1341 TpmPhysicalSetDeactivatedCommand
,
1342 sizeof (TpmPhysicalSetDeactivatedCommand
),
1356 // Second part of ACPI TPM request 0x0A: OEM custom TPM_SetOwnerInstall=TRUE
1358 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1359 TpmSetOwnerInstallCommand
[10] = 0x01;
1360 Status
= TpmMpDriver
->Transmit (
1362 TpmSetOwnerInstallCommand
,
1363 sizeof (TpmSetOwnerInstallCommand
),
1367 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_LAST_REQUEST
, 0x0A);
1370 // Deassert Physical Presence
1372 TpmPhysicalPresenceCommand
[11] = 0x10;
1373 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1374 Status
= TpmMpDriver
->Transmit (
1376 TpmPhysicalPresenceCommand
,
1377 sizeof (TpmPhysicalPresenceCommand
),
1389 Initializes manufacturing and config mode setting.
1393 InitMfgAndConfigModeStateVar()
1395 EFI_PLATFORM_SETUP_ID
*BootModeBuffer
;
1400 // Variable initialization
1404 HobList
= GetFirstGuidHob(&gEfiPlatformBootModeGuid
);
1405 if (HobList
!= NULL
) {
1406 BootModeBuffer
= GET_GUID_HOB_DATA (HobList
);
1409 // Check if in Manufacturing mode
1412 &BootModeBuffer
->SetupName
,
1413 MANUFACTURE_SETUP_NAME
,
1414 StrSize (MANUFACTURE_SETUP_NAME
)
1420 // Check if in safe mode
1423 &BootModeBuffer
->SetupName
,
1425 StrSize (SAFE_SETUP_NAME
)
1435 Initializes manufacturing and config mode setting.
1439 InitPlatformBootMode()
1441 EFI_PLATFORM_SETUP_ID
*BootModeBuffer
;
1444 HobList
= GetFirstGuidHob(&gEfiPlatformBootModeGuid
);
1445 if (HobList
!= NULL
) {
1446 BootModeBuffer
= GET_GUID_HOB_DATA (HobList
);
1447 mPlatformBootMode
= BootModeBuffer
->PlatformBootMode
;
1461 UINT16 ItkModBiosState
;
1467 // Setup local variable according to ITK variable
1470 // Read ItkBiosModVar to determine if BIOS has been modified by ITK
1471 // If ItkBiosModVar = 0 or if variable hasn't been initialized then BIOS has not been modified by ITK modified
1472 // Set local variable VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME=0 if BIOS has not been modified by ITK
1474 DataSize
= sizeof (Value
);
1475 Status
= gRT
->GetVariable (
1476 ITK_BIOS_MOD_VAR_NAME
,
1482 if (Status
== EFI_NOT_FOUND
) {
1484 // Variable not found, hasn't been initialized, intialize to 0
1488 // Write variable to flash.
1491 ITK_BIOS_MOD_VAR_NAME
,
1493 EFI_VARIABLE_RUNTIME_ACCESS
|
1494 EFI_VARIABLE_NON_VOLATILE
|
1495 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1501 if ( (!EFI_ERROR (Status
)) || (Status
== EFI_NOT_FOUND
) ) {
1502 if (Value
== 0x00) {
1503 ItkModBiosState
= 0x00;
1505 ItkModBiosState
= 0x01;
1508 VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME
,
1509 &gEfiNormalSetupGuid
,
1510 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1512 (void *)&ItkModBiosState
1517 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
1521 Initializes the BIOS FIRMWARE ID from the FIRMWARE_ID build variable.
1530 CHAR16 FirmwareIdNameWithPassword
[] = FIRMWARE_ID_NAME_WITH_PASSWORD
;
1533 // First try writing the variable without a password in case we are
1534 // upgrading from a BIOS without password protection on the FirmwareId
1536 Status
= gRT
->SetVariable(
1537 (CHAR16
*)&gFirmwareIdName
,
1539 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
|
1540 EFI_VARIABLE_RUNTIME_ACCESS
,
1541 sizeof( FIRMWARE_ID
) - 1,
1545 if (Status
== EFI_INVALID_PARAMETER
) {
1548 // Since setting the firmware id without the password failed,
1549 // a password must be required.
1551 Status
= gRT
->SetVariable(
1552 (CHAR16
*)&FirmwareIdNameWithPassword
,
1554 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
|
1555 EFI_VARIABLE_RUNTIME_ACCESS
,
1556 sizeof( FIRMWARE_ID
) - 1,
1568 // Workaround to support IIA bug.
1569 // IIA request to change option value to 4, 5 and 7 relatively
1570 // instead of 1, 2, and 3 which follow Lakeport Specs.
1571 // Check option value, temporary hardcode GraphicsDriverMemorySize
1572 // Option value to fulfill IIA requirment. So that user no need to
1573 // load default and update setupvariable after update BIOS.
1574 // Option value hardcoded as: 1 to 4, 2 to 5, 3 to 7.
1575 // *This is for broadwater and above product only.
1578 SYSTEM_CONFIGURATION SystemConfiguration
;
1582 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1583 Status
= gRT
->GetVariable(
1585 &gEfiNormalSetupGuid
,
1588 &SystemConfiguration
1591 if((SystemConfiguration
.GraphicsDriverMemorySize
< 4) && !EFI_ERROR(Status
) ) {
1592 switch (SystemConfiguration
.GraphicsDriverMemorySize
){
1594 SystemConfiguration
.GraphicsDriverMemorySize
= 4;
1597 SystemConfiguration
.GraphicsDriverMemorySize
= 5;
1600 SystemConfiguration
.GraphicsDriverMemorySize
= 7;
1606 Status
= gRT
->SetVariable (
1608 &gEfiNormalSetupGuid
,
1609 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1610 sizeof(SYSTEM_CONFIGURATION
),
1611 &SystemConfiguration
1617 InitPlatformUsbPolicy (
1627 mUsbPolicyData
.Version
= (UINT8
)USB_POLICY_PROTOCOL_REVISION_2
;
1628 mUsbPolicyData
.UsbMassStorageEmulationType
= mSystemConfiguration
.UsbBIOSINT13DeviceEmulation
;
1629 if(mUsbPolicyData
.UsbMassStorageEmulationType
== 3) {
1630 mUsbPolicyData
.UsbEmulationSize
= mSystemConfiguration
.UsbBIOSINT13DeviceEmulationSize
;
1632 mUsbPolicyData
.UsbEmulationSize
= 0;
1634 mUsbPolicyData
.UsbZipEmulationType
= mSystemConfiguration
.UsbZipEmulation
;
1635 mUsbPolicyData
.UsbOperationMode
= HIGH_SPEED
;
1638 // Some chipset need Period smi, 0 = LEGACY_PERIOD_UN_SUPP
1640 mUsbPolicyData
.USBPeriodSupport
= LEGACY_PERIOD_UN_SUPP
;
1643 // Some platform need legacyfree, 0 = LEGACY_FREE_UN_SUPP
1645 mUsbPolicyData
.LegacyFreeSupport
= LEGACY_FREE_UN_SUPP
;
1648 // Set Code base , TIANO_CODE_BASE =0x01, ICBD =0x00
1650 mUsbPolicyData
.CodeBase
= (UINT8
)ICBD_CODE_BASE
;
1653 // Some chispet 's LpcAcpibase are diffrent,set by platform or chipset,
1654 // default is Ich acpibase =0x040. acpitimerreg=0x08.
1655 mUsbPolicyData
.LpcAcpiBase
= 0x40;
1656 mUsbPolicyData
.AcpiTimerReg
= 0x08;
1659 // Set for reduce usb post time
1661 mUsbPolicyData
.UsbTimeTue
= 0x00;
1662 mUsbPolicyData
.InternelHubExist
= 0x00; //TigerPoint doesn't have RMH
1663 mUsbPolicyData
.EnumWaitPortStableStall
= 100;
1666 Status
= gBS
->InstallProtocolInterface (
1669 EFI_NATIVE_INTERFACE
,
1672 ASSERT_EFI_ERROR(Status
);
1678 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,
1684 CpuIo
->Io
.Write (CpuIo
, EfiCpuIoWidthUint8
, 0x72, 1, &Index
);
1685 CpuIo
->Io
.Read (CpuIo
, EfiCpuIoWidthUint8
, 0x73, 1, &Data
);
1690 WriteCmosBank1Byte (
1691 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,