3 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
18 Platform Initialization Driver.
23 #include "PlatformDxe.h"
25 #include "PchCommonDefinitions.h"
26 #include <Protocol/UsbPolicy.h>
27 #include <Protocol/PchPlatformPolicy.h>
28 #include <Protocol/TpmMp.h>
29 #include <Protocol/CpuIo2.h>
30 #include <Library/S3BootScriptLib.h>
31 #include <Guid/PciLanInfo.h>
32 #include <Guid/ItkData.h>
33 #include <Library/PciLib.h>
34 #include <PlatformBootMode.h>
35 #include <Guid/EventGroup.h>
36 #include <Guid/Vlv2Variable.h>
37 #include <Protocol/GlobalNvsArea.h>
38 #include <Protocol/IgdOpRegion.h>
39 #include <Library/PcdLib.h>
40 #include <Protocol/VariableLock.h>
44 // VLV2 GPIO GROUP OFFSET
46 #define GPIO_SCORE_OFFSET 0x0000
47 #define GPIO_NCORE_OFFSET 0x1000
48 #define GPIO_SSUS_OFFSET 0x2000
55 GPIO_CONF_PAD_INIT mTB_BL_GpioInitData_SC_TRI_Exit_boot_Service
[] =
57 // Pad Name GPIO Number Used As GPO Default Function# INT Capable Interrupt Type PULL H/L MMIO Offset
58 GPIO_INIT_ITEM("LPC_CLKOUT0 GPIOC_47 " ,TRISTS
,NA
,F0
, , ,NONE
,0x47),
59 GPIO_INIT_ITEM("LPC_CLKOUT1 GPIOC_48 " ,TRISTS
,NA
,F0
, , ,NONE
,0x41),
63 EFI_GUID mSystemHiiExportDatabase
= EFI_HII_EXPORT_DATABASE_GUID
;
64 EFI_GUID mPlatformDriverGuid
= EFI_PLATFORM_DRIVER_GUID
;
65 SYSTEM_CONFIGURATION mSystemConfiguration
;
66 SYSTEM_PASSWORDS mSystemPassword
;
67 EFI_HANDLE mImageHandle
;
68 BOOLEAN mMfgMode
= FALSE
;
69 VOID
*mDxePlatformStringPack
;
70 UINT32 mPlatformBootMode
= PLATFORM_NORMAL_MODE
;
71 extern CHAR16 gItkDataVarName
[];
74 EFI_PLATFORM_INFO_HOB mPlatformInfo
;
75 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*mPciRootBridgeIo
;
76 EFI_EVENT mReadyToBootEvent
;
78 UINT8 mSmbusRsvdAddresses
[] = PLATFORM_SMBUS_RSVD_ADDRESSES
;
79 UINT8 mNumberSmbusAddress
= sizeof( mSmbusRsvdAddresses
) / sizeof( mSmbusRsvdAddresses
[0] );
80 UINT32 mSubsystemVidDid
;
81 UINT32 mSubsystemAudioVidDid
;
83 UINTN mPciLanCount
= 0;
84 VOID
*mPciLanInfo
= NULL
;
87 static EFI_SPEAKER_IF_PROTOCOL mSpeakerInterface
= {
92 EFI_USB_POLICY_PROTOCOL mUsbPolicyData
= {0};
95 CFIO_PNP_INIT mTB_BL_GpioInitData_SC_TRI_S0ix_Exit_boot_Service
[] =
97 {0x410 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pconf0
98 {0x470 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pconf0
99 {0x560 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pconf0
100 {0x450 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pconf0
101 {0x480 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pconf0
102 {0x420 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pconf0
103 {0x430 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pconf0
104 {0x440 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pconf0
105 {0x460 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pconf0
106 {0x418 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pad_val
107 {0x478 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pad_val
108 {0x568 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pad_val
109 {0x458 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pad_val
110 {0x488 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pad_val
111 {0x428 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pad_val
112 {0x438 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pad_val
113 {0x448 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pad_val
114 {0x468 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pad_val
119 IN VOID
*Destination
,
124 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
132 InitializeClockRouting(
139 #if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0
141 InitializeSensorInfoVariable (
156 InitPlatformBootMode();
159 InitMfgAndConfigModeStateVar();
162 InitPchPlatformPolicy (
163 IN EFI_PLATFORM_INFO_HOB
*PlatformInfo
167 InitVlvPlatformPolicy (
171 InitSioPlatformPolicy(
183 InitPlatformUsbPolicy (
195 SaveSetupRecoveryVar(
199 EFI_STATUS Status
= EFI_SUCCESS
;
200 UINTN SizeOfNvStore
= 0;
201 UINTN SizeOfSetupVar
= 0;
202 SYSTEM_CONFIGURATION
*SetupData
= NULL
;
203 SYSTEM_CONFIGURATION
*RecoveryNvData
= NULL
;
204 EDKII_VARIABLE_LOCK_PROTOCOL
*VariableLock
= NULL
;
207 DEBUG ((EFI_D_INFO
, "SaveSetupRecoveryVar() Entry \n"));
208 SizeOfNvStore
= sizeof(SYSTEM_CONFIGURATION
);
209 RecoveryNvData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
210 if (NULL
== RecoveryNvData
) {
211 Status
= EFI_OUT_OF_RESOURCES
;
215 Status
= gRT
->GetVariable(
217 &gEfiNormalSetupGuid
,
223 if (EFI_ERROR (Status
)) {
224 // Don't find the "SetupRecovery" variable.
225 // have to copy "Setup" variable to "SetupRecovery" variable.
226 SetupData
= AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION
));
227 if (NULL
== SetupData
) {
228 Status
= EFI_OUT_OF_RESOURCES
;
231 SizeOfSetupVar
= sizeof(SYSTEM_CONFIGURATION
);
232 Status
= gRT
->GetVariable(
234 &gEfiNormalSetupGuid
,
239 ASSERT_EFI_ERROR (Status
);
241 Status
= gRT
->SetVariable (
243 &gEfiNormalSetupGuid
,
244 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
245 sizeof(SYSTEM_CONFIGURATION
),
248 ASSERT_EFI_ERROR (Status
);
250 Status
= gBS
->LocateProtocol (&gEdkiiVariableLockProtocolGuid
, NULL
, (VOID
**) &VariableLock
);
251 if (!EFI_ERROR (Status
)) {
252 Status
= VariableLock
->RequestToLock (VariableLock
, L
"SetupRecovery", &gEfiNormalSetupGuid
);
253 ASSERT_EFI_ERROR (Status
);
260 FreePool (RecoveryNvData
);
262 FreePool (SetupData
);
270 TristateLpcGpioConfig (
271 IN UINT32 Gpio_Mmio_Offset
,
272 IN UINT32 Gpio_Pin_Num
,
273 GPIO_CONF_PAD_INIT
* Gpio_Conf_Data
284 // GPIO WELL -- Memory base registers
288 // A0 BIOS Spec doesn't mention it although X0 does. comment out now.
289 // GPIO write 0x01001002 to IOBASE + Gpio_Mmio_Offset + 0x0900
292 for(index
=0; index
< Gpio_Pin_Num
; index
++)
295 // Calculate the MMIO Address for specific GPIO pin CONF0 register pointed by index.
297 mmio_conf0
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ R_PCH_CFIO_PAD_CONF0
+ Gpio_Conf_Data
[index
].offset
* 16;
298 mmio_padval
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ R_PCH_CFIO_PAD_VAL
+ Gpio_Conf_Data
[index
].offset
* 16;
301 DEBUG ((EFI_D_INFO
, "%s, ", Gpio_Conf_Data
[index
].pad_name
));
304 DEBUG ((EFI_D_INFO
, "Usage = %d, Func# = %d, IntType = %d, Pull Up/Down = %d, MMIO Base = 0x%08x, ",
305 Gpio_Conf_Data
[index
].usage
,
306 Gpio_Conf_Data
[index
].func
,
307 Gpio_Conf_Data
[index
].int_type
,
308 Gpio_Conf_Data
[index
].pull
,
312 // Step 1: PadVal Programming
314 pad_val
.dw
= MmioRead32(mmio_padval
);
317 // Config PAD_VAL only for GPIO (Non-Native) Pin
319 if(Native
!= Gpio_Conf_Data
[index
].usage
)
321 pad_val
.dw
&= ~0x6; // Clear bits 1:2
322 pad_val
.dw
|= (Gpio_Conf_Data
[index
].usage
& 0x6); // Set bits 1:2 according to PadVal
325 // set GPO default value
327 if(Gpio_Conf_Data
[index
].usage
== GPO
&& Gpio_Conf_Data
[index
].gpod4
!= NA
)
329 pad_val
.r
.pad_val
= Gpio_Conf_Data
[index
].gpod4
;
334 DEBUG ((EFI_D_INFO
, "Set PAD_VAL = 0x%08x, ", pad_val
.dw
));
336 MmioWrite32(mmio_padval
, pad_val
.dw
);
339 // Step 2: CONF0 Programming
340 // Read GPIO default CONF0 value, which is assumed to be default value after reset.
342 conf0_val
.dw
= MmioRead32(mmio_conf0
);
347 conf0_val
.r
.Func_Pin_Mux
= Gpio_Conf_Data
[index
].func
;
349 if(GPO
== Gpio_Conf_Data
[index
].usage
)
352 // If used as GPO, then internal pull need to be disabled
354 conf0_val
.r
.Pull_assign
= 0; // Non-pull
359 // Set PullUp / PullDown
361 if(P_20K_H
== Gpio_Conf_Data
[index
].pull
)
363 conf0_val
.r
.Pull_assign
= 0x1; // PullUp
364 conf0_val
.r
.Pull_strength
= 0x2;// 20K
366 else if(P_20K_L
== Gpio_Conf_Data
[index
].pull
)
368 conf0_val
.r
.Pull_assign
= 0x2; // PullDown
369 conf0_val
.r
.Pull_strength
= 0x2;// 20K
371 else if(P_NONE
== Gpio_Conf_Data
[index
].pull
)
373 conf0_val
.r
.Pull_assign
= 0; // Non-pull
377 ASSERT(FALSE
); // Invalid value
382 // Set INT Trigger Type
384 conf0_val
.dw
&= ~0x0f000000; // Clear bits 27:24
387 // Set INT Trigger Type
389 if(TRIG_
== Gpio_Conf_Data
[index
].int_type
)
392 // Interrupt not capable, clear bits 27:24
397 conf0_val
.dw
|= (Gpio_Conf_Data
[index
].int_type
& 0x0f)<<24;
400 DEBUG ((EFI_D_INFO
, "Set CONF0 = 0x%08x\n", conf0_val
.dw
));
403 // Write back the targeted GPIO config value according to platform (board) GPIO setting
405 MmioWrite32 (mmio_conf0
, conf0_val
.dw
);
408 // A0 BIOS Spec doesn't mention it although X0 does. comment out now.
409 // GPIO SCORE write 0x01001002 to IOBASE + 0x0900
415 SpiBiosProtectionFunction(
421 UINTN mPciD31F0RegBase
;
428 BiosFlaLower0
= PcdGet32(PcdFlashMicroCodeAddress
)-PcdGet32(PcdFlashAreaBaseAddress
);
429 BiosFlaLimit0
= PcdGet32(PcdFlashMicroCodeSize
)-1;
430 #ifdef MINNOW2_FSP_BUILD
431 BiosFlaLower1
= PcdGet32(PcdFlashFvFspBase
)-PcdGet32(PcdFlashAreaBaseAddress
);
432 BiosFlaLimit1
= (PcdGet32(PcdFlashFvRecoveryBase
)-PcdGet32(PcdFlashFvFspBase
)+PcdGet32(PcdFlashFvRecoverySize
))-1;
434 BiosFlaLower1
= PcdGet32(PcdFlashFvMainBase
)-PcdGet32(PcdFlashAreaBaseAddress
);
435 BiosFlaLimit1
= (PcdGet32(PcdFlashFvRecoveryBase
)-PcdGet32(PcdFlashFvMainBase
)+PcdGet32(PcdFlashFvRecoverySize
))-1;
439 mPciD31F0RegBase
= MmPciAddress (0,
440 DEFAULT_PCI_BUS_NUMBER_PCH
,
441 PCI_DEVICE_NUMBER_PCH_LPC
,
442 PCI_FUNCTION_NUMBER_PCH_LPC
,
445 SpiBase
= MmioRead32(mPciD31F0RegBase
+ R_PCH_LPC_SPI_BASE
) & B_PCH_LPC_SPI_BASE_BAR
;
448 //Set SMM_BWP, WPD and LE bit
450 MmioOr32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
) B_PCH_SPI_BCR_SMM_BWP
);
451 MmioAnd32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
)(~B_PCH_SPI_BCR_BIOSWE
));
452 MmioOr32 ((UINTN
) (SpiBase
+ R_PCH_SPI_BCR
), (UINT8
) B_PCH_SPI_BCR_BLE
);
455 //First check if FLOCKDN or PR0FLOCKDN is set. No action if either of them set already.
457 if( (MmioRead16(SpiBase
+ R_PCH_SPI_HSFS
) & B_PCH_SPI_HSFS_FLOCKDN
) != 0 ||
458 (MmioRead32(SpiBase
+ R_PCH_SPI_IND_LOCK
)& B_PCH_SPI_IND_LOCK_PR0
) != 0) {
460 //Already locked. we could take no action here
462 DEBUG((EFI_D_INFO
, "PR0 already locked down. Stop configuring PR0.\n"));
469 MmioOr32((UINTN
)(SpiBase
+ R_PCH_SPI_PR0
),
470 B_PCH_SPI_PR0_RPE
|B_PCH_SPI_PR0_WPE
|\
471 (B_PCH_SPI_PR0_PRB_MASK
&(BiosFlaLower0
>>12))|(B_PCH_SPI_PR0_PRL_MASK
&(BiosFlaLimit0
>>12)<<16));
477 MmioOr32((UINTN
)(SpiBase
+ R_PCH_SPI_PR1
),
478 B_PCH_SPI_PR1_RPE
|B_PCH_SPI_PR1_WPE
|\
479 (B_PCH_SPI_PR1_PRB_MASK
&(BiosFlaLower1
>>12))|(B_PCH_SPI_PR1_PRL_MASK
&(BiosFlaLimit1
>>12)<<16));
484 MmioOr16 ((UINTN
) (SpiBase
+ R_PCH_SPI_HSFS
), (UINT16
) (B_PCH_SPI_HSFS_FLOCKDN
));
487 // Verify if it's really locked.
489 if ((MmioRead16 (SpiBase
+ R_PCH_SPI_HSFS
) & B_PCH_SPI_HSFS_FLOCKDN
) == 0) {
490 DEBUG((EFI_D_ERROR
, "Failed to lock down PRx.\n"));
505 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
508 &gEfiNormalSetupGuid
,
511 &mSystemConfiguration
517 PchAzaliaPciCfg32Or (R_PCH_HDA_PCS
, B_PCH_HDA_PCS_PMEE
);
520 //Program SATA PME_EN
522 PchSataPciCfg32Or (R_PCH_SATA_PMCS
, B_PCH_SATA_PMCS_PMEE
);
524 DEBUG ((EFI_D_INFO
, "InitPciDevPME mSystemConfiguration.EhciPllCfgEnable = 0x%x \n",mSystemConfiguration
.EhciPllCfgEnable
));
525 if (mSystemConfiguration
.EhciPllCfgEnable
!= 1) {
527 //Program EHCI PME_EN
532 PCI_DEVICE_NUMBER_PCH_USB
,
533 PCI_FUNCTION_NUMBER_PCH_EHCI
,
534 R_PCH_EHCI_PWR_CNTL_STS
,
535 B_PCH_EHCI_PWR_CNTL_STS_PME_EN
542 EhciPciMmBase
= MmPciAddress (0,
544 PCI_DEVICE_NUMBER_PCH_USB
,
545 PCI_FUNCTION_NUMBER_PCH_EHCI
,
548 DEBUG ((EFI_D_INFO
, "ConfigureAdditionalPm() EhciPciMmBase = 0x%x \n",EhciPciMmBase
));
549 Buffer32
= MmioRead32(EhciPciMmBase
+ R_PCH_EHCI_PWR_CNTL_STS
);
550 DEBUG ((EFI_D_INFO
, "ConfigureAdditionalPm() R_PCH_EHCI_PWR_CNTL_STS = 0x%x \n",Buffer32
));
562 EFI_GLOBAL_NVS_AREA_PROTOCOL
*GlobalNvsArea
;
563 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
566 &gEfiNormalSetupGuid
,
569 &mSystemConfiguration
571 gBS
->LocateProtocol (
572 &gEfiGlobalNvsAreaProtocolGuid
,
574 (void **)&GlobalNvsArea
576 GlobalNvsArea
->Area
->CriticalThermalTripPoint
= mSystemConfiguration
.CriticalThermalTripPoint
;
577 GlobalNvsArea
->Area
->PassiveThermalTripPoint
= mSystemConfiguration
.PassiveThermalTripPoint
;
579 #if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY
586 TristateLpcGpioS0i3Config (
587 UINT32 Gpio_Mmio_Offset
,
589 CFIO_PNP_INIT
* Gpio_Conf_Data
597 DEBUG ((DEBUG_INFO
, "TristateLpcGpioS0i3Config\n"));
599 for(index
=0; index
< Gpio_Pin_Num
; index
++)
601 mmio_reg
= IO_BASE_ADDRESS
+ Gpio_Mmio_Offset
+ Gpio_Conf_Data
[index
].offset
;
603 MmioWrite32(mmio_reg
, Gpio_Conf_Data
[index
].val
);
605 mmio_val
= MmioRead32(mmio_reg
);
607 DEBUG ((EFI_D_INFO
, "Set MMIO=0x%08x PAD_VAL = 0x%08x,\n", mmio_reg
, mmio_val
));
614 EFI_BOOT_SCRIPT_SAVE_PROTOCOL
*mBootScriptSave
;
617 Event Notification during exit boot service to enabel ACPI mode
619 Disable SW SMI Timer, SMI from USB & Intel Specific USB 2
621 Clear all ACPI event status and disable all ACPI events
622 Disable PM sources except power button
625 Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm")
627 Update EC to disable SMI and enable SCI
631 Enable PME_B0_EN in GPE0a_EN
633 @param Event - EFI Event Handle
634 @param Context - Pointer to Notify Context
651 AcpiBase
= MmioRead16 (
652 PchPciDeviceMmBase (DEFAULT_PCI_BUS_NUMBER_PCH
,
653 PCI_DEVICE_NUMBER_PCH_LPC
,
654 PCI_FUNCTION_NUMBER_PCH_LPC
) + R_PCH_LPC_ACPI_BASE
655 ) & B_PCH_LPC_ACPI_BASE_BAR
;
657 DEBUG ((EFI_D_INFO
, "EnableAcpiCallback: AcpiBase = %x\n", AcpiBase
));
660 // Disable SW SMI Timer, SMI from USB & Intel Specific USB 2
662 RegData32
= IoRead32(AcpiBase
+ R_PCH_SMI_EN
);
663 RegData32
&= ~(B_PCH_SMI_EN_SWSMI_TMR
| B_PCH_SMI_EN_LEGACY_USB2
| B_PCH_SMI_EN_INTEL_USB2
);
664 IoWrite32(AcpiBase
+ R_PCH_SMI_EN
, RegData32
);
666 RegData32
= IoRead32(AcpiBase
+ R_PCH_SMI_STS
);
667 RegData32
|= B_PCH_SMI_STS_SWSMI_TMR
;
668 IoWrite32(AcpiBase
+ R_PCH_SMI_STS
, RegData32
);
671 // Disable PM sources except power button
672 // power button is enabled only for PCAT. Disabled it on Tablet platform
675 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_EN
, B_PCH_ACPI_PM1_EN_PWRBTN
);
676 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_STS
, 0xffff);
679 // Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm")
680 // Clear Status D reg VM bit, Date of month Alarm to make Data in CMOS RAM is no longer Valid
682 IoWrite8 (PCAT_RTC_ADDRESS_REGISTER
, RTC_ADDRESS_REGISTER_D
);
683 IoWrite8 (PCAT_RTC_DATA_REGISTER
, 0x0);
685 RegData32
= IoRead32(AcpiBase
+ R_PCH_ALT_GP_SMI_EN
);
686 RegData32
&= ~(BIT7
);
687 IoWrite32((AcpiBase
+ R_PCH_ALT_GP_SMI_EN
), RegData32
);
692 Pm1Cnt
= IoRead16(AcpiBase
+ R_PCH_ACPI_PM1_CNT
);
693 Pm1Cnt
|= B_PCH_ACPI_PM1_CNT_SCI_EN
;
694 IoWrite16(AcpiBase
+ R_PCH_ACPI_PM1_CNT
, Pm1Cnt
);
696 IoWrite8(0x80, 0xA0); //SW_SMI_ACPI_ENABLE
699 // Enable PME_B0_EN in GPE0a_EN
700 // Caution: Enable PME_B0_EN must be placed after enabling SCI.
701 // Otherwise, USB PME could not be handled as SMI event since no handler is there.
703 Gpe0aEn
= IoRead32 (AcpiBase
+ R_PCH_ACPI_GPE0a_EN
);
704 Gpe0aEn
|= B_PCH_ACPI_GPE0a_EN_PME_B0
;
705 IoWrite32(AcpiBase
+ R_PCH_ACPI_GPE0a_EN
, Gpe0aEn
);
713 This is the standard EFI driver point for the Driver. This
714 driver is responsible for setting up any platform specific policy or
715 initialization information.
717 @param ImageHandle Handle for the image of this driver.
718 @param SystemTable Pointer to the EFI System Table.
720 @retval EFI_SUCCESS Policy decisions set.
726 IN EFI_HANDLE ImageHandle
,
727 IN EFI_SYSTEM_TABLE
*SystemTable
732 EFI_HANDLE Handle
= NULL
;
733 EFI_EVENT mEfiExitBootServicesEvent
;
735 VOID
*RtcCallbackReg
= NULL
;
737 mImageHandle
= ImageHandle
;
739 Status
= gBS
->InstallProtocolInterface (
741 &gEfiSpeakerInterfaceProtocolGuid
,
742 EFI_NATIVE_INTERFACE
,
746 Status
= gBS
->LocateProtocol (
747 &gEfiPciRootBridgeIoProtocolGuid
,
749 (VOID
**) &mPciRootBridgeIo
751 ASSERT_EFI_ERROR (Status
);
753 VarSize
= sizeof(EFI_PLATFORM_INFO_HOB
);
754 Status
= gRT
->GetVariable(
756 &gEfiVlv2VariableGuid
,
763 // Initialize Product Board ID variable
765 InitMfgAndConfigModeStateVar();
766 InitPlatformBootMode();
769 // Install Observable protocol
771 InitializeObservableProtocol();
773 Status
= SaveSetupRecoveryVar();
774 if (EFI_ERROR (Status
)) {
775 DEBUG ((EFI_D_ERROR
, "InitializePlatform() Save SetupRecovery variable failed \n"));
778 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
779 Status
= gRT
->GetVariable(
781 &gEfiNormalSetupGuid
,
784 &mSystemConfiguration
786 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
787 //The setup variable is corrupted
788 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
789 Status
= gRT
->GetVariable(
791 &gEfiNormalSetupGuid
,
794 &mSystemConfiguration
796 ASSERT_EFI_ERROR (Status
);
797 Status
= gRT
->SetVariable (
799 &gEfiNormalSetupGuid
,
800 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
801 sizeof(SYSTEM_CONFIGURATION
),
802 &mSystemConfiguration
806 Status
= EfiCreateEventReadyToBootEx (
814 // Create a ReadyToBoot Event to run the PME init process
816 Status
= EfiCreateEventReadyToBootEx (
823 // Create a ReadyToBoot Event to run enable PR0/PR1 and lock down,unlock variable region
825 if(mSystemConfiguration
.SpiRwProtect
==1) {
826 Status
= EfiCreateEventReadyToBootEx (
828 SpiBiosProtectionFunction
,
834 // Create a ReadyToBoot Event to run the thermalzone init process
836 Status
= EfiCreateEventReadyToBootEx (
845 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP1
,
853 #if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0
855 // Initialize Sensor Info variable
857 InitializeSensorInfoVariable();
859 InitPchPlatformPolicy(&mPlatformInfo
);
860 InitVlvPlatformPolicy();
865 InitPlatformUsbPolicy();
866 InitSioPlatformPolicy();
867 InitializeClockRouting();
868 InitializeSlotInfo();
878 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP2
,
887 // Install PCI Bus Driver Hook
895 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP3
,
905 // Initialize Password States and Callbacks
909 #if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY
913 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
915 // Re-write Firmware ID if it is changed
922 EFI_COMPUTING_UNIT_CHIPSET
| EFI_CU_PLATFORM_DXE_STEP4
,
931 Status
= gBS
->CreateEventEx (
936 &gEfiEventExitBootServicesGuid
,
937 &mEfiExitBootServicesEvent
941 // Adjust RTC deafult time to be BIOS-built time.
943 Status
= gBS
->CreateEvent (
946 AdjustDefaultRtcTimeCallback
,
950 if (!EFI_ERROR (Status
)) {
951 Status
= gBS
->RegisterProtocolNotify (
952 &gExitPmAuthProtocolGuid
,
963 Source Or Destination with Length bytes.
965 @param[in] Destination Target memory
966 @param[in] Source Source memory
967 @param[in] Length Number of bytes
974 IN VOID
*Destination
,
982 if (Source
< Destination
) {
983 Destination8
= (CHAR8
*) Destination
+ Length
- 1;
984 Source8
= (CHAR8
*) Source
+ Length
- 1;
986 *(Destination8
--) |= *(Source8
--);
989 Destination8
= (CHAR8
*) Destination
;
990 Source8
= (CHAR8
*) Source
;
992 *(Destination8
++) |= *(Source8
++);
1001 // Saved SPI Opcode menu to fix EFI variable unable to write after S3 resume.
1003 S3BootScriptSaveMemWrite (
1004 EfiBootScriptWidthUint32
,
1005 (UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU0
)),
1007 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU0
)));
1009 S3BootScriptSaveMemWrite (
1010 EfiBootScriptWidthUint32
,
1011 (UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU1
)),
1013 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ (R_PCH_SPI_OPMENU1
)));
1015 S3BootScriptSaveMemWrite (
1016 EfiBootScriptWidthUint16
,
1017 (UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_OPTYPE
),
1019 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_OPTYPE
));
1021 S3BootScriptSaveMemWrite (
1022 EfiBootScriptWidthUint16
,
1023 (UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_PREOP
),
1025 (VOID
*)(UINTN
)(SPI_BASE_ADDRESS
+ R_PCH_SPI_PREOP
));
1028 // Saved MTPMC_1 for S3 resume.
1030 S3BootScriptSaveMemWrite (
1031 EfiBootScriptWidthUint32
,
1032 (UINTN
)(PMC_BASE_ADDRESS
+ R_PCH_PMC_MTPMC1
),
1034 (VOID
*)(UINTN
)(PMC_BASE_ADDRESS
+ R_PCH_PMC_MTPMC1
));
1040 ReadyToBootFunction (
1046 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
1047 EFI_ISA_ACPI_DEVICE_ID IsaDevice
;
1050 EFI_TPM_MP_DRIVER_PROTOCOL
*TpmMpDriver
;
1051 EFI_CPU_IO_PROTOCOL
*CpuIo
;
1053 UINT8 ReceiveBuffer
[64];
1054 UINT32 ReceiveBufferSize
;
1056 UINT8 TpmForceClearCommand
[] = {0x00, 0xC1,
1057 0x00, 0x00, 0x00, 0x0A,
1058 0x00, 0x00, 0x00, 0x5D};
1059 UINT8 TpmPhysicalPresenceCommand
[] = {0x00, 0xC1,
1060 0x00, 0x00, 0x00, 0x0C,
1061 0x40, 0x00, 0x00, 0x0A,
1063 UINT8 TpmPhysicalDisableCommand
[] = {0x00, 0xC1,
1064 0x00, 0x00, 0x00, 0x0A,
1065 0x00, 0x00, 0x00, 0x70};
1066 UINT8 TpmPhysicalEnableCommand
[] = {0x00, 0xC1,
1067 0x00, 0x00, 0x00, 0x0A,
1068 0x00, 0x00, 0x00, 0x6F};
1069 UINT8 TpmPhysicalSetDeactivatedCommand
[] = {0x00, 0xC1,
1070 0x00, 0x00, 0x00, 0x0B,
1071 0x00, 0x00, 0x00, 0x72,
1073 UINT8 TpmSetOwnerInstallCommand
[] = {0x00, 0xC1,
1074 0x00, 0x00, 0x00, 0x0B,
1075 0x00, 0x00, 0x00, 0x71,
1078 Size
= sizeof(UINT16
);
1079 Status
= gRT
->GetVariable (
1080 VAR_EQ_FLOPPY_MODE_DECIMAL_NAME
,
1081 &gEfiNormalSetupGuid
,
1088 // Disable Floppy Controller if needed
1090 Status
= gBS
->LocateProtocol (&gEfiIsaAcpiProtocolGuid
, NULL
, (VOID
**) &IsaAcpi
);
1091 if (!EFI_ERROR(Status
) && (State
== 0x00)) {
1092 IsaDevice
.HID
= EISA_PNP_ID(0x604);
1094 Status
= IsaAcpi
->EnableDevice(IsaAcpi
, &IsaDevice
, FALSE
);
1098 // save LAN info to a variable
1100 if (NULL
!= mPciLanInfo
) {
1103 &gEfiPciLanInfoGuid
,
1104 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
1105 mPciLanCount
* sizeof(PCI_LAN_INFO
),
1110 if (NULL
!= mPciLanInfo
) {
1111 gBS
->FreePool (mPciLanInfo
);
1117 // Handle ACPI OS TPM requests here
1119 Status
= gBS
->LocateProtocol (
1120 &gEfiCpuIoProtocolGuid
,
1124 Status
= gBS
->LocateProtocol (
1125 &gEfiTpmMpDriverProtocolGuid
,
1127 (VOID
**)&TpmMpDriver
1129 if (!EFI_ERROR (Status
))
1131 Data
= ReadCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
);
1134 // Clear pending ACPI TPM request indicator
1136 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
, 0x00);
1139 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_LAST_REQUEST
, Data
);
1142 // Assert Physical Presence for these commands
1144 TpmPhysicalPresenceCommand
[11] = 0x20;
1145 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1146 Status
= TpmMpDriver
->Transmit (
1147 TpmMpDriver
, TpmPhysicalPresenceCommand
,
1148 sizeof (TpmPhysicalPresenceCommand
),
1149 ReceiveBuffer
, &ReceiveBufferSize
1152 // PF PhysicalPresence = TRUE
1154 TpmPhysicalPresenceCommand
[11] = 0x08;
1155 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1156 Status
= TpmMpDriver
->Transmit (
1157 TpmMpDriver
, TpmPhysicalPresenceCommand
,
1158 sizeof (TpmPhysicalPresenceCommand
),
1165 // TPM_PhysicalEnable
1167 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1168 Status
= TpmMpDriver
->Transmit (
1169 TpmMpDriver
, TpmPhysicalEnableCommand
,
1170 sizeof (TpmPhysicalEnableCommand
),
1171 ReceiveBuffer
, &ReceiveBufferSize
1177 // TPM_PhysicalDisable
1179 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1180 Status
= TpmMpDriver
->Transmit (
1181 TpmMpDriver
, TpmPhysicalDisableCommand
,
1182 sizeof (TpmPhysicalDisableCommand
),
1190 // TPM_PhysicalSetDeactivated=FALSE
1192 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1193 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1194 Status
= TpmMpDriver
->Transmit (
1196 TpmPhysicalSetDeactivatedCommand
,
1197 sizeof (TpmPhysicalSetDeactivatedCommand
),
1198 ReceiveBuffer
, &ReceiveBufferSize
1200 gRT
->ResetSystem (EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
1205 // TPM_PhysicalSetDeactivated=TRUE
1207 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1208 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1209 Status
= TpmMpDriver
->Transmit (
1211 TpmPhysicalSetDeactivatedCommand
,
1212 sizeof (TpmPhysicalSetDeactivatedCommand
),
1228 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1229 Status
= TpmMpDriver
->Transmit (
1231 TpmForceClearCommand
,
1232 sizeof (TpmForceClearCommand
),
1246 // TPM_PhysicalEnable
1248 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1249 Status
= TpmMpDriver
->Transmit (
1251 TpmPhysicalEnableCommand
,
1252 sizeof (TpmPhysicalEnableCommand
),
1257 // TPM_PhysicalSetDeactivated=FALSE
1259 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1260 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1261 Status
= TpmMpDriver
->Transmit (
1263 TpmPhysicalSetDeactivatedCommand
,
1264 sizeof (TpmPhysicalSetDeactivatedCommand
),
1278 // TPM_PhysicalSetDeactivated=TRUE
1280 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1281 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1282 Status
= TpmMpDriver
->Transmit (
1284 TpmPhysicalSetDeactivatedCommand
,
1285 sizeof (TpmPhysicalSetDeactivatedCommand
),
1290 // TPM_PhysicalDisable
1292 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1293 Status
= TpmMpDriver
->Transmit (
1295 TpmPhysicalDisableCommand
,
1296 sizeof (TpmPhysicalDisableCommand
),
1310 // TPM_SetOwnerInstall=TRUE
1312 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1313 TpmSetOwnerInstallCommand
[10] = 0x01;
1314 Status
= TpmMpDriver
->Transmit (
1316 TpmSetOwnerInstallCommand
,
1317 sizeof (TpmSetOwnerInstallCommand
),
1325 // TPM_SetOwnerInstall=FALSE
1327 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1328 TpmSetOwnerInstallCommand
[10] = 0x00;
1329 Status
= TpmMpDriver
->Transmit (
1331 TpmSetOwnerInstallCommand
,
1332 sizeof (TpmSetOwnerInstallCommand
),
1340 // TPM_PhysicalEnable
1342 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1343 Status
= TpmMpDriver
->Transmit (
1345 TpmPhysicalEnableCommand
,
1346 sizeof (TpmPhysicalEnableCommand
),
1351 // TPM_PhysicalSetDeactivated=FALSE
1353 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1354 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1355 Status
= TpmMpDriver
->Transmit (
1357 TpmPhysicalSetDeactivatedCommand
,
1358 sizeof (TpmPhysicalSetDeactivatedCommand
),
1363 // Do TPM_SetOwnerInstall=TRUE on next reboot
1366 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_REQUEST
, 0xF0);
1378 // TPM_SetOwnerInstall=FALSE
1380 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1381 TpmSetOwnerInstallCommand
[10] = 0x00;
1382 Status
= TpmMpDriver
->Transmit (
1384 TpmSetOwnerInstallCommand
,
1385 sizeof (TpmSetOwnerInstallCommand
),
1390 // TPM_PhysicalSetDeactivated=TRUE
1392 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1393 TpmPhysicalSetDeactivatedCommand
[10] = 0x01;
1394 Status
= TpmMpDriver
->Transmit (
1396 TpmPhysicalSetDeactivatedCommand
,
1397 sizeof (TpmPhysicalSetDeactivatedCommand
),
1402 // TPM_PhysicalDisable
1404 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1405 Status
= TpmMpDriver
->Transmit (
1407 TpmPhysicalDisableCommand
,
1408 sizeof (TpmPhysicalDisableCommand
),
1424 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1425 Status
= TpmMpDriver
->Transmit (
1427 TpmForceClearCommand
,
1428 sizeof (TpmForceClearCommand
),
1433 // TPM_PhysicalEnable
1435 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1436 Status
= TpmMpDriver
->Transmit (
1438 TpmPhysicalEnableCommand
,
1439 sizeof (TpmPhysicalEnableCommand
),
1444 // TPM_PhysicalSetDeactivated=FALSE
1446 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1447 TpmPhysicalSetDeactivatedCommand
[10] = 0x00;
1448 Status
= TpmMpDriver
->Transmit (
1450 TpmPhysicalSetDeactivatedCommand
,
1451 sizeof (TpmPhysicalSetDeactivatedCommand
),
1465 // Second part of ACPI TPM request 0x0A: OEM custom TPM_SetOwnerInstall=TRUE
1467 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1468 TpmSetOwnerInstallCommand
[10] = 0x01;
1469 Status
= TpmMpDriver
->Transmit (
1471 TpmSetOwnerInstallCommand
,
1472 sizeof (TpmSetOwnerInstallCommand
),
1476 WriteCmosBank1Byte (CpuIo
, ACPI_TPM_LAST_REQUEST
, 0x0A);
1479 // Deassert Physical Presence
1481 TpmPhysicalPresenceCommand
[11] = 0x10;
1482 ReceiveBufferSize
= sizeof(ReceiveBuffer
);
1483 Status
= TpmMpDriver
->Transmit (
1485 TpmPhysicalPresenceCommand
,
1486 sizeof (TpmPhysicalPresenceCommand
),
1498 Initializes manufacturing and config mode setting.
1502 InitMfgAndConfigModeStateVar()
1504 EFI_PLATFORM_SETUP_ID
*BootModeBuffer
;
1508 HobList
= GetFirstGuidHob(&gEfiPlatformBootModeGuid
);
1509 if (HobList
!= NULL
) {
1510 BootModeBuffer
= GET_GUID_HOB_DATA (HobList
);
1513 // Check if in Manufacturing mode
1516 &BootModeBuffer
->SetupName
,
1517 MANUFACTURE_SETUP_NAME
,
1518 StrSize (MANUFACTURE_SETUP_NAME
)
1531 Initializes manufacturing and config mode setting.
1535 InitPlatformBootMode()
1537 EFI_PLATFORM_SETUP_ID
*BootModeBuffer
;
1540 HobList
= GetFirstGuidHob(&gEfiPlatformBootModeGuid
);
1541 if (HobList
!= NULL
) {
1542 BootModeBuffer
= GET_GUID_HOB_DATA (HobList
);
1543 mPlatformBootMode
= BootModeBuffer
->PlatformBootMode
;
1557 UINT16 ItkModBiosState
;
1563 // Setup local variable according to ITK variable
1566 // Read ItkBiosModVar to determine if BIOS has been modified by ITK
1567 // If ItkBiosModVar = 0 or if variable hasn't been initialized then BIOS has not been modified by ITK modified
1568 // Set local variable VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME=0 if BIOS has not been modified by ITK
1570 DataSize
= sizeof (Value
);
1571 Status
= gRT
->GetVariable (
1572 ITK_BIOS_MOD_VAR_NAME
,
1578 if (Status
== EFI_NOT_FOUND
) {
1580 // Variable not found, hasn't been initialized, intialize to 0
1584 // Write variable to flash.
1587 ITK_BIOS_MOD_VAR_NAME
,
1589 EFI_VARIABLE_RUNTIME_ACCESS
|
1590 EFI_VARIABLE_NON_VOLATILE
|
1591 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1597 if ( (!EFI_ERROR (Status
)) || (Status
== EFI_NOT_FOUND
) ) {
1598 if (Value
== 0x00) {
1599 ItkModBiosState
= 0x00;
1601 ItkModBiosState
= 0x01;
1604 VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME
,
1605 &gEfiNormalSetupGuid
,
1606 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1608 (void *)&ItkModBiosState
1613 #if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0)
1617 Initializes the BIOS FIRMWARE ID from the FIRMWARE_ID build variable.
1626 CHAR16 FirmwareIdNameWithPassword
[] = FIRMWARE_ID_NAME_WITH_PASSWORD
;
1629 // First try writing the variable without a password in case we are
1630 // upgrading from a BIOS without password protection on the FirmwareId
1632 Status
= gRT
->SetVariable(
1633 (CHAR16
*)&gFirmwareIdName
,
1635 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
|
1636 EFI_VARIABLE_RUNTIME_ACCESS
,
1637 sizeof( FIRMWARE_ID
) - 1,
1641 if (Status
== EFI_INVALID_PARAMETER
) {
1644 // Since setting the firmware id without the password failed,
1645 // a password must be required.
1647 Status
= gRT
->SetVariable(
1648 (CHAR16
*)&FirmwareIdNameWithPassword
,
1650 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
|
1651 EFI_VARIABLE_RUNTIME_ACCESS
,
1652 sizeof( FIRMWARE_ID
) - 1,
1664 // Workaround to support IIA bug.
1665 // IIA request to change option value to 4, 5 and 7 relatively
1666 // instead of 1, 2, and 3 which follow Lakeport Specs.
1667 // Check option value, temporary hardcode GraphicsDriverMemorySize
1668 // Option value to fulfill IIA requirment. So that user no need to
1669 // load default and update setupvariable after update BIOS.
1670 // Option value hardcoded as: 1 to 4, 2 to 5, 3 to 7.
1671 // *This is for broadwater and above product only.
1674 SYSTEM_CONFIGURATION SystemConfiguration
;
1678 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1679 Status
= gRT
->GetVariable(
1681 &gEfiNormalSetupGuid
,
1684 &SystemConfiguration
1687 if (EFI_ERROR (Status
) || VarSize
!= sizeof(SYSTEM_CONFIGURATION
)) {
1688 //The setup variable is corrupted
1689 VarSize
= sizeof(SYSTEM_CONFIGURATION
);
1690 Status
= gRT
->GetVariable(
1692 &gEfiNormalSetupGuid
,
1695 &SystemConfiguration
1697 ASSERT_EFI_ERROR (Status
);
1700 if((SystemConfiguration
.GraphicsDriverMemorySize
< 4) && !EFI_ERROR(Status
) ) {
1701 switch (SystemConfiguration
.GraphicsDriverMemorySize
){
1703 SystemConfiguration
.GraphicsDriverMemorySize
= 4;
1706 SystemConfiguration
.GraphicsDriverMemorySize
= 5;
1709 SystemConfiguration
.GraphicsDriverMemorySize
= 7;
1715 Status
= gRT
->SetVariable (
1717 &gEfiNormalSetupGuid
,
1718 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1719 sizeof(SYSTEM_CONFIGURATION
),
1720 &SystemConfiguration
1726 InitPlatformUsbPolicy (
1736 mUsbPolicyData
.Version
= (UINT8
)USB_POLICY_PROTOCOL_REVISION_2
;
1737 mUsbPolicyData
.UsbMassStorageEmulationType
= mSystemConfiguration
.UsbBIOSINT13DeviceEmulation
;
1738 if(mUsbPolicyData
.UsbMassStorageEmulationType
== 3) {
1739 mUsbPolicyData
.UsbEmulationSize
= mSystemConfiguration
.UsbBIOSINT13DeviceEmulationSize
;
1741 mUsbPolicyData
.UsbEmulationSize
= 0;
1743 mUsbPolicyData
.UsbZipEmulationType
= mSystemConfiguration
.UsbZipEmulation
;
1744 mUsbPolicyData
.UsbOperationMode
= HIGH_SPEED
;
1747 // Some chipset need Period smi, 0 = LEGACY_PERIOD_UN_SUPP
1749 mUsbPolicyData
.USBPeriodSupport
= LEGACY_PERIOD_UN_SUPP
;
1752 // Some platform need legacyfree, 0 = LEGACY_FREE_UN_SUPP
1754 mUsbPolicyData
.LegacyFreeSupport
= LEGACY_FREE_UN_SUPP
;
1757 // Set Code base , TIANO_CODE_BASE =0x01, ICBD =0x00
1759 mUsbPolicyData
.CodeBase
= (UINT8
)ICBD_CODE_BASE
;
1762 // Some chispet 's LpcAcpibase are diffrent,set by platform or chipset,
1763 // default is Ich acpibase =0x040. acpitimerreg=0x08.
1764 mUsbPolicyData
.LpcAcpiBase
= 0x40;
1765 mUsbPolicyData
.AcpiTimerReg
= 0x08;
1768 // Set for reduce usb post time
1770 mUsbPolicyData
.UsbTimeTue
= 0x00;
1771 mUsbPolicyData
.InternelHubExist
= 0x00; //TigerPoint doesn't have RMH
1772 mUsbPolicyData
.EnumWaitPortStableStall
= 100;
1775 Status
= gBS
->InstallProtocolInterface (
1778 EFI_NATIVE_INTERFACE
,
1781 ASSERT_EFI_ERROR(Status
);
1787 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,
1793 CpuIo
->Io
.Write (CpuIo
, EfiCpuIoWidthUint8
, 0x72, 1, &Index
);
1794 CpuIo
->Io
.Read (CpuIo
, EfiCpuIoWidthUint8
, 0x73, 1, &Data
);
1799 WriteCmosBank1Byte (
1800 IN EFI_CPU_IO_PROTOCOL
*CpuIo
,