13cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** @file 23cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 4d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 5d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 6d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei This program and the accompanying materials are licensed and made available under 7d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 8d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei the terms and conditions of the BSD License that accompanies this distribution. 9d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 10d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei The full text of the license may be found at 11d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 12d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei http://opensource.org/licenses/bsd-license.php. 13d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 14d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 15d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 16d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 18d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 20d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 21d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 233cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiModule Name: 243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Platform.c 273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 283cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiAbstract: 293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Platform Initialization Driver. 313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei--*/ 343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include "PlatformDxe.h" 363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include "Platform.h" 373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include "PchCommonDefinitions.h" 383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/UsbPolicy.h> 393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/PchPlatformPolicy.h> 403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/TpmMp.h> 413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/CpuIo2.h> 423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Library/S3BootScriptLib.h> 433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Guid/PciLanInfo.h> 443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Guid/ItkData.h> 453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Library/PciLib.h> 463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <PlatformBootMode.h> 473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Guid/EventGroup.h> 483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Guid/Vlv2Variable.h> 493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/GlobalNvsArea.h> 503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Protocol/IgdOpRegion.h> 513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include <Library/PcdLib.h> 52620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He#include <Protocol/VariableLock.h> 53620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei// 563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei// VLV2 GPIO GROUP OFFSET 573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei// 583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#define GPIO_SCORE_OFFSET 0x0000 593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#define GPIO_NCORE_OFFSET 0x1000 603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#define GPIO_SSUS_OFFSET 0x2000 613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Weitypedef struct { 633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 offset; 643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 val; 653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} CFIO_PNP_INIT; 663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 673cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiGPIO_CONF_PAD_INIT mTB_BL_GpioInitData_SC_TRI_Exit_boot_Service[] = 683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei// Pad Name GPIO Number Used As GPO Default Function# INT Capable Interrupt Type PULL H/L MMIO Offset 703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GPIO_INIT_ITEM("LPC_CLKOUT0 GPIOC_47 " ,TRISTS ,NA ,F0 , , ,NONE ,0x47), 713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GPIO_INIT_ITEM("LPC_CLKOUT1 GPIOC_48 " ,TRISTS ,NA ,F0 , , ,NONE ,0x41), 723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei}; 733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 753cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_GUID mSystemHiiExportDatabase = EFI_HII_EXPORT_DATABASE_GUID; 763cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_GUID mPlatformDriverGuid = EFI_PLATFORM_DRIVER_GUID; 773cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSYSTEM_CONFIGURATION mSystemConfiguration; 783cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSYSTEM_PASSWORDS mSystemPassword; 793cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_HANDLE mImageHandle; 803cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiBOOLEAN mMfgMode = FALSE; 813cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID *mDxePlatformStringPack; 823cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT32 mPlatformBootMode = PLATFORM_NORMAL_MODE; 833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Weiextern CHAR16 gItkDataVarName[]; 843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 863cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_PLATFORM_INFO_HOB mPlatformInfo; 873cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo; 883cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_EVENT mReadyToBootEvent; 893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 903cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 mSmbusRsvdAddresses[] = PLATFORM_SMBUS_RSVD_ADDRESSES; 913cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 mNumberSmbusAddress = sizeof( mSmbusRsvdAddresses ) / sizeof( mSmbusRsvdAddresses[0] ); 923cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT32 mSubsystemVidDid; 933cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT32 mSubsystemAudioVidDid; 943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 953cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN mPciLanCount = 0; 963cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID *mPciLanInfo = NULL; 973cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN SpiBase; 983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Weistatic EFI_SPEAKER_IF_PROTOCOL mSpeakerInterface = { 1003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ProgramToneFrequency, 1013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GenerateBeepTone 1023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei}; 1033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1043cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_USB_POLICY_PROTOCOL mUsbPolicyData = {0}; 1053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1073cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiCFIO_PNP_INIT mTB_BL_GpioInitData_SC_TRI_S0ix_Exit_boot_Service[] = 1083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 1093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x410 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pconf0 1103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x470 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pconf0 1113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x560 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pconf0 1123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x450 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pconf0 1133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x480 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pconf0 1143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x420 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pconf0 1153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x430 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pconf0 1163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x440 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pconf0 1173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x460 ,0x20038e10}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pconf0 1183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x418 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout1_pad_val 1193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x478 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkout0_pad_val 1203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x568 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_ilb_serirq_pad_val 1213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x458 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_frameb_pad_val 1223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x488 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_clkrunb_pad_val 1233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x428 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad3_pad_val 1243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x438 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad2_pad_val 1253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x448 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad1_pad_val 1263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei {0x468 ,0x00000006}, //vlv.gpio.gpscore.cfio_regs_pad_lpc_ad0_pad_val 1273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei}; 1283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1293cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1303cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEfiOrMem ( 1313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *Destination, 1323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *Source, 1333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN Length 1343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0) 1373cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSTATIC 1383cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1393cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitFirmwareId(); 1403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 1413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1433cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1443cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitializeClockRouting( 1453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1473cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1483cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitializeSlotInfo ( 1493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0 1523cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1533cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitializeSensorInfoVariable ( 1543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 1563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1573cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1583cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitTcoReset ( 1593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1613cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1623cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitExI (); 1633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1643cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1653cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitItk(); 1663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1673cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1683cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPlatformBootMode(); 1693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1703cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1713cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitMfgAndConfigModeStateVar(); 1723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1733cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1743cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPchPlatformPolicy ( 1753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_PLATFORM_INFO_HOB *PlatformInfo 1763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1783cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1793cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitVlvPlatformPolicy ( 1803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1823cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1833cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitSioPlatformPolicy( 1843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1863cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1873cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiPchInitBeforeBoot( 1883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1903cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1913cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUpdateDVMTSetup( 1923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1943cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 1953cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPlatformUsbPolicy ( 1963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID 1973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 1983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1993cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 2003cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitRC6Policy( 2013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID 2023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 2033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 205620f289162b08d319fe1e73b3c7e2baff6b388e4Tim HeEFI_STATUS 206620f289162b08d319fe1e73b3c7e2baff6b388e4Tim HeEFIAPI 207620f289162b08d319fe1e73b3c7e2baff6b388e4Tim HeSaveSetupRecoveryVar( 208620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He VOID 209620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ) 210620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He{ 211620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He EFI_STATUS Status = EFI_SUCCESS; 212620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He UINTN SizeOfNvStore = 0; 213620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He UINTN SizeOfSetupVar = 0; 214620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SYSTEM_CONFIGURATION *SetupData = NULL; 215620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SYSTEM_CONFIGURATION *RecoveryNvData = NULL; 216620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock = NULL; 217620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 218620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 219620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He DEBUG ((EFI_D_INFO, "SaveSetupRecoveryVar() Entry \n")); 220620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SizeOfNvStore = sizeof(SYSTEM_CONFIGURATION); 221620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He RecoveryNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION)); 222620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (NULL == RecoveryNvData) { 223620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = EFI_OUT_OF_RESOURCES; 224620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He goto Exit; 225620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 226620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 227620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->GetVariable( 228620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He L"SetupRecovery", 229620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 230620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NULL, 231620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &SizeOfNvStore, 232620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He RecoveryNvData 233620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 234620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 235620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (EFI_ERROR (Status)) { 236620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He // Don't find the "SetupRecovery" variable. 237620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He // have to copy "Setup" variable to "SetupRecovery" variable. 238620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SetupData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION)); 239620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (NULL == SetupData) { 240620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = EFI_OUT_OF_RESOURCES; 241620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He goto Exit; 242620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 243620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SizeOfSetupVar = sizeof(SYSTEM_CONFIGURATION); 244620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->GetVariable( 245620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NORMAL_SETUP_NAME, 246620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 247620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NULL, 248620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &SizeOfSetupVar, 249620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SetupData 250620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 251620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ASSERT_EFI_ERROR (Status); 252620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 253620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->SetVariable ( 254620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He L"SetupRecovery", 255620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 256620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 257620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He sizeof(SYSTEM_CONFIGURATION), 258620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He SetupData 259620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 260620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ASSERT_EFI_ERROR (Status); 261620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 262620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock); 263620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (!EFI_ERROR (Status)) { 264620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = VariableLock->RequestToLock (VariableLock, L"SetupRecovery", &gEfiNormalSetupGuid); 265620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ASSERT_EFI_ERROR (Status); 266620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 267620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 268620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 269620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 270620f289162b08d319fe1e73b3c7e2baff6b388e4Tim HeExit: 271620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (RecoveryNvData) 272620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He FreePool (RecoveryNvData); 273620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (SetupData) 274620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He FreePool (SetupData); 275620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 276620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He return Status; 277620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 278620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He} 279620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 280620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 2813cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 2823cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiTristateLpcGpioConfig ( 2833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT32 Gpio_Mmio_Offset, 2843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT32 Gpio_Pin_Num, 2853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei GPIO_CONF_PAD_INIT* Gpio_Conf_Data 2863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 2873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 2893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 index; 2903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 mmio_conf0; 2913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 mmio_padval; 2923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PAD_CONF0 conf0_val; 2933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PAD_VAL pad_val; 2943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // GPIO WELL -- Memory base registers 2973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // A0 BIOS Spec doesn't mention it although X0 does. comment out now. 3013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // GPIO write 0x01001002 to IOBASE + Gpio_Mmio_Offset + 0x0900 3023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei for(index=0; index < Gpio_Pin_Num; index++) 3053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Calculate the MMIO Address for specific GPIO pin CONF0 register pointed by index. 3083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_conf0 = IO_BASE_ADDRESS + Gpio_Mmio_Offset + R_PCH_CFIO_PAD_CONF0 + Gpio_Conf_Data[index].offset * 16; 3103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_padval= IO_BASE_ADDRESS + Gpio_Mmio_Offset + R_PCH_CFIO_PAD_VAL + Gpio_Conf_Data[index].offset * 16; 3113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#ifdef EFI_DEBUG 3133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "%s, ", Gpio_Conf_Data[index].pad_name)); 3143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 3163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "Usage = %d, Func# = %d, IntType = %d, Pull Up/Down = %d, MMIO Base = 0x%08x, ", 3173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpio_Conf_Data[index].usage, 3183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpio_Conf_Data[index].func, 3193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpio_Conf_Data[index].int_type, 3203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpio_Conf_Data[index].pull, 3213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_conf0)); 3223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Step 1: PadVal Programming 3253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei pad_val.dw = MmioRead32(mmio_padval); 3273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Config PAD_VAL only for GPIO (Non-Native) Pin 3303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(Native != Gpio_Conf_Data[index].usage) 3323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei pad_val.dw &= ~0x6; // Clear bits 1:2 3343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei pad_val.dw |= (Gpio_Conf_Data[index].usage & 0x6); // Set bits 1:2 according to PadVal 3353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // set GPO default value 3383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(Gpio_Conf_Data[index].usage == GPO && Gpio_Conf_Data[index].gpod4 != NA) 3403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei pad_val.r.pad_val = Gpio_Conf_Data[index].gpod4; 3423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "Set PAD_VAL = 0x%08x, ", pad_val.dw)); 3473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioWrite32(mmio_padval, pad_val.dw); 3493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Step 2: CONF0 Programming 3523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Read GPIO default CONF0 value, which is assumed to be default value after reset. 3533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.dw = MmioRead32(mmio_conf0); 3553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Function # 3583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Func_Pin_Mux = Gpio_Conf_Data[index].func; 3603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(GPO == Gpio_Conf_Data[index].usage) 3623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // If used as GPO, then internal pull need to be disabled 3653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_assign = 0; // Non-pull 3673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei else 3693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set PullUp / PullDown 3723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(P_20K_H == Gpio_Conf_Data[index].pull) 3743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_assign = 0x1; // PullUp 3763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_strength = 0x2;// 20K 3773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei else if(P_20K_L == Gpio_Conf_Data[index].pull) 3793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_assign = 0x2; // PullDown 3813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_strength = 0x2;// 20K 3823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei else if(P_NONE == Gpio_Conf_Data[index].pull) 3843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.r.Pull_assign = 0; // Non-pull 3863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei else 3883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 3893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT(FALSE); // Invalid value 3903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set INT Trigger Type 3953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.dw &= ~0x0f000000; // Clear bits 27:24 3973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 3993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set INT Trigger Type 4003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(TRIG_ == Gpio_Conf_Data[index].int_type) 4023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 4033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Interrupt not capable, clear bits 27:24 4053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 4073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei else 4083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 4093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei conf0_val.dw |= (Gpio_Conf_Data[index].int_type & 0x0f)<<24; 4103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 4113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "Set CONF0 = 0x%08x\n", conf0_val.dw)); 4133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write back the targeted GPIO config value according to platform (board) GPIO setting 4163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioWrite32 (mmio_conf0, conf0_val.dw); 4183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 4193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // A0 BIOS Spec doesn't mention it although X0 does. comment out now. 4213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // GPIO SCORE write 0x01001002 to IOBASE + 0x0900 4223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 4243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4253cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 4263cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 4273cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSpiBiosProtectionFunction( 4283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_EVENT Event, 4293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID *Context 4303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 4313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 4323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN mPciD31F0RegBase; 434fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu UINTN BiosFlaLower0; 435fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu UINTN BiosFlaLimit0; 436fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu UINTN BiosFlaLower1; 437fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu UINTN BiosFlaLimit1; 438fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu 4393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 440fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLower0 = PcdGet32(PcdFlashMicroCodeAddress)-PcdGet32(PcdFlashAreaBaseAddress); 441fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLimit0 = PcdGet32(PcdFlashMicroCodeSize)-1; 442fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu #ifdef MINNOW2_FSP_BUILD 443fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLower1 = PcdGet32(PcdFlashFvFspBase)-PcdGet32(PcdFlashAreaBaseAddress); 444fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLimit1 = (PcdGet32(PcdFlashFvRecoveryBase)-PcdGet32(PcdFlashFvFspBase)+PcdGet32(PcdFlashFvRecoverySize))-1; 445fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu #else 446fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLower1 = PcdGet32(PcdFlashFvMainBase)-PcdGet32(PcdFlashAreaBaseAddress); 447fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu BiosFlaLimit1 = (PcdGet32(PcdFlashFvRecoveryBase)-PcdGet32(PcdFlashFvMainBase)+PcdGet32(PcdFlashFvRecoverySize))-1; 448fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu #endif 4493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 450fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu 4513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mPciD31F0RegBase = MmPciAddress (0, 4523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEFAULT_PCI_BUS_NUMBER_PCH, 4533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_DEVICE_NUMBER_PCH_LPC, 4543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_FUNCTION_NUMBER_PCH_LPC, 4553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 4563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 4573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SpiBase = MmioRead32(mPciD31F0RegBase + R_PCH_LPC_SPI_BASE) & B_PCH_LPC_SPI_BASE_BAR; 4583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Set SMM_BWP, WPD and LE bit 4613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioOr32 ((UINTN) (SpiBase + R_PCH_SPI_BCR), (UINT8) B_PCH_SPI_BCR_SMM_BWP); 4633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioAnd32 ((UINTN) (SpiBase + R_PCH_SPI_BCR), (UINT8)(~B_PCH_SPI_BCR_BIOSWE)); 4643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioOr32 ((UINTN) (SpiBase + R_PCH_SPI_BCR), (UINT8) B_PCH_SPI_BCR_BLE); 4653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //First check if FLOCKDN or PR0FLOCKDN is set. No action if either of them set already. 4683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if( (MmioRead16(SpiBase + R_PCH_SPI_HSFS) & B_PCH_SPI_HSFS_FLOCKDN) != 0 || 4703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (MmioRead32(SpiBase + R_PCH_SPI_IND_LOCK)& B_PCH_SPI_IND_LOCK_PR0) != 0) { 4713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Already locked. we could take no action here 4733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG((EFI_D_INFO, "PR0 already locked down. Stop configuring PR0.\n")); 4753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return; 4763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 4773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Set PR0 4803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 4813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioOr32((UINTN)(SpiBase + R_PCH_SPI_PR0), 4823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei B_PCH_SPI_PR0_RPE|B_PCH_SPI_PR0_WPE|\ 483fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu (B_PCH_SPI_PR0_PRB_MASK&(BiosFlaLower0>>12))|(B_PCH_SPI_PR0_PRL_MASK&(BiosFlaLimit0>>12)<<16)); 4843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 486fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu //Set PR1 487fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // 488fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu 489fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu MmioOr32((UINTN)(SpiBase + R_PCH_SPI_PR1), 490fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu B_PCH_SPI_PR1_RPE|B_PCH_SPI_PR1_WPE|\ 491fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu (B_PCH_SPI_PR1_PRB_MASK&(BiosFlaLower1>>12))|(B_PCH_SPI_PR1_PRL_MASK&(BiosFlaLimit1>>12)<<16)); 492fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu 493fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // 4946f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He //Lock down PRx 495fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // 496fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu MmioOr16 ((UINTN) (SpiBase + R_PCH_SPI_HSFS), (UINT16) (B_PCH_SPI_HSFS_FLOCKDN)); 497fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu 498fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // 499fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // Verify if it's really locked. 500fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // 501fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu if ((MmioRead16 (SpiBase + R_PCH_SPI_HSFS) & B_PCH_SPI_HSFS_FLOCKDN) == 0) { 5026f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He DEBUG((EFI_D_ERROR, "Failed to lock down PRx.\n")); 503fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu } 5043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return; 5053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 5073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5083cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 5093cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 5103cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPciDevPME ( 5113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_EVENT Event, 5123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID *Context 5133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 5143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 5153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN VarSize; 5163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 5173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(SYSTEM_CONFIGURATION); 5193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 5203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NORMAL_SETUP_NAME, 5213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 5223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 5233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 5243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mSystemConfiguration 5253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 5263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Program HDA PME_EN 5293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PchAzaliaPciCfg32Or (R_PCH_HDA_PCS, B_PCH_HDA_PCS_PMEE); 5313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Program SATA PME_EN 5343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PchSataPciCfg32Or (R_PCH_SATA_PMCS, B_PCH_SATA_PMCS_PMEE); 5363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "InitPciDevPME mSystemConfiguration.EhciPllCfgEnable = 0x%x \n",mSystemConfiguration.EhciPllCfgEnable)); 5383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (mSystemConfiguration.EhciPllCfgEnable != 1) { 5393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Program EHCI PME_EN 5413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 5423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PchMmPci32Or ( 5433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 5443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 5453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_DEVICE_NUMBER_PCH_USB, 5463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_FUNCTION_NUMBER_PCH_EHCI, 5473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei R_PCH_EHCI_PWR_CNTL_STS, 5483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei B_PCH_EHCI_PWR_CNTL_STS_PME_EN 5493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 5503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 5513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 5523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN EhciPciMmBase; 5533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 Buffer32 = 0; 5543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EhciPciMmBase = MmPciAddress (0, 5563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 5573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_DEVICE_NUMBER_PCH_USB, 5583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_FUNCTION_NUMBER_PCH_EHCI, 5593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 5603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 5613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "ConfigureAdditionalPm() EhciPciMmBase = 0x%x \n",EhciPciMmBase)); 5623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Buffer32 = MmioRead32(EhciPciMmBase + R_PCH_EHCI_PWR_CNTL_STS); 5633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "ConfigureAdditionalPm() R_PCH_EHCI_PWR_CNTL_STS = 0x%x \n",Buffer32)); 5643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 5653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 5663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5676f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim HeVOID 5686f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim HeEFIAPI 5696f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim HeInitThermalZone ( 5706f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He EFI_EVENT Event, 5716f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He VOID *Context 5726f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He ) 5736f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He{ 5746f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He UINTN VarSize; 5756f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He EFI_STATUS Status; 5766f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He EFI_GLOBAL_NVS_AREA_PROTOCOL *GlobalNvsArea; 5776f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He VarSize = sizeof(SYSTEM_CONFIGURATION); 5786f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He Status = gRT->GetVariable( 5796f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He NORMAL_SETUP_NAME, 5806f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He &gEfiNormalSetupGuid, 5816f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He NULL, 5826f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He &VarSize, 5836f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He &mSystemConfiguration 5846f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He ); 5856f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He Status = gBS->LocateProtocol ( 5866f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He &gEfiGlobalNvsAreaProtocolGuid, 5876f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He NULL, 5886f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He (void **)&GlobalNvsArea 5896f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He ); 5906f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He GlobalNvsArea->Area->CriticalThermalTripPoint = mSystemConfiguration.CriticalThermalTripPoint; 5916f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He GlobalNvsArea->Area->PassiveThermalTripPoint = mSystemConfiguration.PassiveThermalTripPoint; 5926f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He} 5933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY 5943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 5963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5983cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_STATUS 5993cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 6003cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiTristateLpcGpioS0i3Config ( 6013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 Gpio_Mmio_Offset, 6023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 Gpio_Pin_Num, 6033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CFIO_PNP_INIT* Gpio_Conf_Data 6043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 6053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 6063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 index; 6083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 mmio_reg; 6093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 mmio_val; 6103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((DEBUG_INFO, "TristateLpcGpioS0i3Config\n")); 6123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei for(index=0; index < Gpio_Pin_Num; index++) 6143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 6153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_reg = IO_BASE_ADDRESS + Gpio_Mmio_Offset + Gpio_Conf_Data[index].offset; 6163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MmioWrite32(mmio_reg, Gpio_Conf_Data[index].val); 6183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_val = 0; 6193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mmio_val = MmioRead32(mmio_reg); 6203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "Set MMIO=0x%08x PAD_VAL = 0x%08x,\n", mmio_reg, mmio_val)); 6223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 6233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return EFI_SUCCESS; 6253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 6263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6283cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_BOOT_SCRIPT_SAVE_PROTOCOL *mBootScriptSave; 6293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 6313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Event Notification during exit boot service to enabel ACPI mode 6323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Disable SW SMI Timer, SMI from USB & Intel Specific USB 2 6343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Clear all ACPI event status and disable all ACPI events 6363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Disable PM sources except power button 6373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Clear status bits 6383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm") 6403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Update EC to disable SMI and enable SCI 6423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Enable SCI 6443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Enable PME_B0_EN in GPE0a_EN 6463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Event - EFI Event Handle 6483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Context - Pointer to Notify Context 6493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval Nothing 6513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 6533cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 6543cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 6553cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEnableAcpiCallback ( 6563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_EVENT Event, 6573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *Context 6583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 6593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 6603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 RegData32; 6613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 Pm1Cnt; 6623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 AcpiBase; 6633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 Gpe0aEn; 6643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AcpiBase = MmioRead16 ( 6663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PchPciDeviceMmBase (DEFAULT_PCI_BUS_NUMBER_PCH, 6673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_DEVICE_NUMBER_PCH_LPC, 6683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PCI_FUNCTION_NUMBER_PCH_LPC) + R_PCH_LPC_ACPI_BASE 6693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) & B_PCH_LPC_ACPI_BASE_BAR; 6703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DEBUG ((EFI_D_INFO, "EnableAcpiCallback: AcpiBase = %x\n", AcpiBase)); 6723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Disable SW SMI Timer, SMI from USB & Intel Specific USB 2 6753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 = IoRead32(AcpiBase + R_PCH_SMI_EN); 6773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 &= ~(B_PCH_SMI_EN_SWSMI_TMR | B_PCH_SMI_EN_LEGACY_USB2 | B_PCH_SMI_EN_INTEL_USB2); 6783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite32(AcpiBase + R_PCH_SMI_EN, RegData32); 6793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 = IoRead32(AcpiBase + R_PCH_SMI_STS); 6813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 |= B_PCH_SMI_STS_SWSMI_TMR; 6823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite32(AcpiBase + R_PCH_SMI_STS, RegData32); 6833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Disable PM sources except power button 6863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // power button is enabled only for PCAT. Disabled it on Tablet platform 6873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite16(AcpiBase + R_PCH_ACPI_PM1_EN, B_PCH_ACPI_PM1_EN_PWRBTN); 6903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite16(AcpiBase + R_PCH_ACPI_PM1_STS, 0xffff); 6913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Guarantee day-of-month alarm is invalid (ACPI 5.0 Section 4.8.2.4 "Real Time Clock Alarm") 6943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear Status D reg VM bit, Date of month Alarm to make Data in CMOS RAM is no longer Valid 6953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, RTC_ADDRESS_REGISTER_D); 6973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (PCAT_RTC_DATA_REGISTER, 0x0); 6983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 = IoRead32(AcpiBase + R_PCH_ALT_GP_SMI_EN); 7003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RegData32 &= ~(BIT7); 7013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite32((AcpiBase + R_PCH_ALT_GP_SMI_EN), RegData32); 7023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Enable SCI 7053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Pm1Cnt = IoRead16(AcpiBase + R_PCH_ACPI_PM1_CNT); 7073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Pm1Cnt |= B_PCH_ACPI_PM1_CNT_SCI_EN; 7083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite16(AcpiBase + R_PCH_ACPI_PM1_CNT, Pm1Cnt); 7093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8(0x80, 0xA0); //SW_SMI_ACPI_ENABLE 7113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Enable PME_B0_EN in GPE0a_EN 7143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Caution: Enable PME_B0_EN must be placed after enabling SCI. 7153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Otherwise, USB PME could not be handled as SMI event since no handler is there. 7163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpe0aEn = IoRead32 (AcpiBase + R_PCH_ACPI_GPE0a_EN); 7183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gpe0aEn |= B_PCH_ACPI_GPE0a_EN_PME_B0; 7193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite32(AcpiBase + R_PCH_ACPI_GPE0a_EN, Gpe0aEn); 7203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 7223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 7243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Routine Description: 7263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is the standard EFI driver point for the Driver. This 7283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei driver is responsible for setting up any platform specific policy or 7293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei initialization information. 7303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param ImageHandle Handle for the image of this driver. 7323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SystemTable Pointer to the EFI System Table. 7333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval EFI_SUCCESS Policy decisions set. 7353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 7373cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFI_STATUS 7383cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 7393cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitializePlatform ( 7403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_HANDLE ImageHandle, 7413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_SYSTEM_TABLE *SystemTable 7423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 7433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 7443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 7453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN VarSize; 7463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_HANDLE Handle = NULL; 7473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_EVENT mEfiExitBootServicesEvent; 748d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei EFI_EVENT RtcEvent; 749d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei VOID *RtcCallbackReg = NULL; 750d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei 751d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei mImageHandle = ImageHandle; 7523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->InstallProtocolInterface ( 7543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Handle, 7553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiSpeakerInterfaceProtocolGuid, 7563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_NATIVE_INTERFACE, 7573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mSpeakerInterface 7583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 7593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->LocateProtocol ( 7613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiPciRootBridgeIoProtocolGuid, 7623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 7633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID **) &mPciRootBridgeIo 7643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 7653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT_EFI_ERROR (Status); 7663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(EFI_PLATFORM_INFO_HOB); 7683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 7693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"PlatformInfo", 7703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiVlv2VariableGuid, 7713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 7723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 7733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mPlatformInfo 7743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 7753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Initialize Product Board ID variable 7783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitMfgAndConfigModeStateVar(); 7803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitPlatformBootMode(); 7813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Install Observable protocol 7843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitializeObservableProtocol(); 7863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 787620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = SaveSetupRecoveryVar(); 788620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (EFI_ERROR (Status)) { 789620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He DEBUG ((EFI_D_ERROR, "InitializePlatform() Save SetupRecovery variable failed \n")); 790620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 7913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(SYSTEM_CONFIGURATION); 7933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 7943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NORMAL_SETUP_NAME, 7953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 7963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 7973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 7983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mSystemConfiguration 7993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 800620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { 801620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He //The setup variable is corrupted 802620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He VarSize = sizeof(SYSTEM_CONFIGURATION); 803620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->GetVariable( 804620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He L"SetupRecovery", 805620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 806620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NULL, 807620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &VarSize, 808620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &mSystemConfiguration 809620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 810620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ASSERT_EFI_ERROR (Status); 811620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->SetVariable ( 812620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NORMAL_SETUP_NAME, 813620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 814620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 815620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He sizeof(SYSTEM_CONFIGURATION), 816620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &mSystemConfiguration 817620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 818620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 819620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 8203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = EfiCreateEventReadyToBootEx ( 8213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TPL_CALLBACK, 8223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReadyToBootFunction, 8233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mReadyToBootEvent 8253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Create a ReadyToBoot Event to run the PME init process 8293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = EfiCreateEventReadyToBootEx ( 8313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TPL_CALLBACK, 8323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitPciDevPME, 8333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mReadyToBootEvent 8353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 837fb1a4e361e9b6ef15142000fc3a79f5f31777de7Shifei Lu // Create a ReadyToBoot Event to run enable PR0/PR1 and lock down,unlock variable region 8383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(mSystemConfiguration.SpiRwProtect==1) { 8403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = EfiCreateEventReadyToBootEx ( 8413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TPL_CALLBACK, 8423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SpiBiosProtectionFunction, 8433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mReadyToBootEvent 8453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 8476f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He // 8486f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He // Create a ReadyToBoot Event to run the thermalzone init process 8496f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He // 8506f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He Status = EfiCreateEventReadyToBootEx ( 8516f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He TPL_CALLBACK, 8526f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He InitThermalZone, 8536f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He NULL, 8546f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He &mReadyToBootEvent 8556f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He ); 8566f2ef18e8097c4fa11dd6ff5fdd0152c2c61ffc5Tim He 8573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReportStatusCodeEx ( 8583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PROGRESS_CODE, 8593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_COMPUTING_UNIT_CHIPSET | EFI_CU_PLATFORM_DXE_STEP1, 8603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 8613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiCallerIdGuid, 8623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 8653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined(SENSOR_INFO_VAR_SUPPORT) && SENSOR_INFO_VAR_SUPPORT != 0 8683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Initialize Sensor Info variable 8703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitializeSensorInfoVariable(); 8723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 8733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitPchPlatformPolicy(&mPlatformInfo); 8743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitVlvPlatformPolicy(); 8753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Add usb policy 8783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitPlatformUsbPolicy(); 8803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitSioPlatformPolicy(); 8813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitializeClockRouting(); 8823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitializeSlotInfo(); 8833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitTcoReset(); 8843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei //Init ExI 8873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 8883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitExI(); 8893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReportStatusCodeEx ( 8913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PROGRESS_CODE, 8923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_COMPUTING_UNIT_CHIPSET | EFI_CU_PLATFORM_DXE_STEP2, 8933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 8943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiCallerIdGuid, 8953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 8983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Install PCI Bus Driver Hook 9023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PciBusDriverHook(); 9043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitItk(); 9063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReportStatusCodeEx ( 9083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PROGRESS_CODE, 9093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_COMPUTING_UNIT_CHIPSET | EFI_CU_PLATFORM_DXE_STEP3, 9103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 9113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiCallerIdGuid, 9123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 9133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 9143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 9153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 9163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Initialize Password States and Callbacks 9203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei PchInitBeforeBoot(); 9223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY 9243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 9263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0) 9283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Re-write Firmware ID if it is changed 9303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 9313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InitFirmwareId(); 9323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 9333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReportStatusCodeEx ( 9353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PROGRESS_CODE, 9363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_COMPUTING_UNIT_CHIPSET | EFI_CU_PLATFORM_DXE_STEP4, 9373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 9383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiCallerIdGuid, 9393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 9403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 9413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0 9423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 9433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->CreateEventEx ( 9463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EVT_NOTIFY_SIGNAL, 9473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TPL_NOTIFY, 9483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EnableAcpiCallback, 9493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 9503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiEventExitBootServicesGuid, 9513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mEfiExitBootServicesEvent 9523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 9533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 954d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei // 955d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei // Adjust RTC deafult time to be BIOS-built time. 956d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei // 957d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei Status = gBS->CreateEvent ( 958d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei EVT_NOTIFY_SIGNAL, 959d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei TPL_CALLBACK, 960d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei AdjustDefaultRtcTimeCallback, 961d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei NULL, 962d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei &RtcEvent 963d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei ); 964d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei if (!EFI_ERROR (Status)) { 965d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei Status = gBS->RegisterProtocolNotify ( 966d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei &gExitPmAuthProtocolGuid, 967d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei RtcEvent, 968d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei &RtcCallbackReg 969d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei ); 9703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 971d71c25cf2c7783024a3e9c57327f43654305838fDavid Wei } 9723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return EFI_SUCCESS; 9743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 9753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 9773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Source Or Destination with Length bytes. 9783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param[in] Destination Target memory 9803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param[in] Source Source memory 9813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param[in] Length Number of bytes 9823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval None 9843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 9863cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 9873cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEfiOrMem ( 9883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *Destination, 9893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *Source, 9903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN Length 9913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 9923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 9933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CHAR8 *Destination8; 9943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CHAR8 *Source8; 9953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 9963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Source < Destination) { 9973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Destination8 = (CHAR8 *) Destination + Length - 1; 9983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Source8 = (CHAR8 *) Source + Length - 1; 9993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei while (Length--) { 10003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei *(Destination8--) |= *(Source8--); 10013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 10023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } else { 10033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Destination8 = (CHAR8 *) Destination; 10043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Source8 = (CHAR8 *) Source; 10053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei while (Length--) { 10063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei *(Destination8++) |= *(Source8++); 10073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 10083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 10093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 10103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10113cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 10123cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiPchInitBeforeBoot() 10133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 10143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 10153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Saved SPI Opcode menu to fix EFI variable unable to write after S3 resume. 10163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 10173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei S3BootScriptSaveMemWrite ( 10183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiBootScriptWidthUint32, 10193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU0)), 10203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 10213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID *)(UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU0))); 10223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei S3BootScriptSaveMemWrite ( 10243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiBootScriptWidthUint32, 10253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU1)), 10263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 10273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID *)(UINTN)(SPI_BASE_ADDRESS + (R_PCH_SPI_OPMENU1))); 10283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei S3BootScriptSaveMemWrite ( 10303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiBootScriptWidthUint16, 10313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_OPTYPE), 10323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 10333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID *)(UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_OPTYPE)); 10343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei S3BootScriptSaveMemWrite ( 10363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiBootScriptWidthUint16, 10373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_PREOP), 10383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 10393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID *)(UINTN)(SPI_BASE_ADDRESS + R_PCH_SPI_PREOP)); 10403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 10423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Saved MTPMC_1 for S3 resume. 10433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 10443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei S3BootScriptSaveMemWrite ( 10453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiBootScriptWidthUint32, 10463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (UINTN)(PMC_BASE_ADDRESS + R_PCH_PMC_MTPMC1), 10473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 10483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID *)(UINTN)(PMC_BASE_ADDRESS + R_PCH_PMC_MTPMC1)); 10493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return; 10503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 10513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10523cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 10533cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 10543cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiReadyToBootFunction ( 10553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_EVENT Event, 10563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID *Context 10573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 10583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 10593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 10603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_ISA_ACPI_PROTOCOL *IsaAcpi; 10613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_ISA_ACPI_DEVICE_ID IsaDevice; 10623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN Size; 10633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 State; 10643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_TPM_MP_DRIVER_PROTOCOL *TpmMpDriver; 10653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_CPU_IO_PROTOCOL *CpuIo; 10663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 Data; 10673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 ReceiveBuffer [64]; 10683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 ReceiveBufferSize; 10693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmForceClearCommand [] = {0x00, 0xC1, 10713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0A, 10723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x5D}; 10733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmPhysicalPresenceCommand [] = {0x00, 0xC1, 10743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0C, 10753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x40, 0x00, 0x00, 0x0A, 10763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00}; 10773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmPhysicalDisableCommand [] = {0x00, 0xC1, 10783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0A, 10793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x70}; 10803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmPhysicalEnableCommand [] = {0x00, 0xC1, 10813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0A, 10823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x6F}; 10833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmPhysicalSetDeactivatedCommand [] = {0x00, 0xC1, 10843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0B, 10853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x72, 10863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00}; 10873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 TpmSetOwnerInstallCommand [] = {0x00, 0xC1, 10883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x0B, 10893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00, 0x00, 0x00, 0x71, 10903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x00}; 10913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 10923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Size = sizeof(UINT16); 10933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable ( 10943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VAR_EQ_FLOPPY_MODE_DECIMAL_NAME, 10953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 10963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 10973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Size, 10983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &State 10993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Disable Floppy Controller if needed 11033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->LocateProtocol (&gEfiIsaAcpiProtocolGuid, NULL, (VOID **) &IsaAcpi); 11053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (!EFI_ERROR(Status) && (State == 0x00)) { 11063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IsaDevice.HID = EISA_PNP_ID(0x604); 11073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IsaDevice.UID = 0; 11083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = IsaAcpi->EnableDevice(IsaAcpi, &IsaDevice, FALSE); 11093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 11103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // save LAN info to a variable 11133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (NULL != mPciLanInfo) { 11153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->SetVariable ( 11163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei L"PciLanInfo", 11173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiPciLanInfoGuid, 11183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, 11193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mPciLanCount * sizeof(PCI_LAN_INFO), 11203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mPciLanInfo 11213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 11233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (NULL != mPciLanInfo) { 11253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gBS->FreePool (mPciLanInfo); 11263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mPciLanInfo = NULL; 11273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 11283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Handle ACPI OS TPM requests here 11323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->LocateProtocol ( 11343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiCpuIoProtocolGuid, 11353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 11363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID **)&CpuIo 11373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->LocateProtocol ( 11393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiTpmMpDriverProtocolGuid, 11403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 11413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (VOID **)&TpmMpDriver 11423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (!EFI_ERROR (Status)) 11443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 11453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Data = ReadCmosBank1Byte (CpuIo, ACPI_TPM_REQUEST); 11463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear pending ACPI TPM request indicator 11493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WriteCmosBank1Byte (CpuIo, ACPI_TPM_REQUEST, 0x00); 11513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data != 0) 11523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 11533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WriteCmosBank1Byte (CpuIo, ACPI_TPM_LAST_REQUEST, Data); 11543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 11553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Assert Physical Presence for these commands 11573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalPresenceCommand [11] = 0x20; 11593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 11603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 11613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, TpmPhysicalPresenceCommand, 11623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalPresenceCommand), 11633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, &ReceiveBufferSize 11643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // PF PhysicalPresence = TRUE 11673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalPresenceCommand [11] = 0x08; 11693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 11703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 11713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, TpmPhysicalPresenceCommand, 11723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalPresenceCommand), 11733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 11743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 11753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x01) 11773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 11783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalEnable 11803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 11823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 11833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, TpmPhysicalEnableCommand, 11843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalEnableCommand), 11853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, &ReceiveBufferSize 11863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 11873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 11883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x02) 11893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 11903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalDisable 11923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 11933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 11943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 11953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, TpmPhysicalDisableCommand, 11963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalDisableCommand), 11973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 11983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 11993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 12013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x03) 12023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 12033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=FALSE 12053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x00; 12083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 12113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 12123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, &ReceiveBufferSize 12133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); 12153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 12163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x04) 12173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 12183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=TRUE 12203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x01; 12233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 12263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 12273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 12283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 12293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 12313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 12323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 12333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 12343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 12353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 12373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x05) 12383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 12393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_ForceClear 12413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmForceClearCommand, 12463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmForceClearCommand), 12473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 12483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 12493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 12513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 12523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 12533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 12543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 12553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 12573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x06) 12583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 12593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalEnable 12613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalEnableCommand, 12663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalEnableCommand), 12673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 12683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 12693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=FALSE 12723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x00; 12753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 12783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 12793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 12803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 12813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 12833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 12843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 12853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 12863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 12873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 12883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 12893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x07) 12903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 12913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=TRUE 12933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 12943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 12953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x01; 12963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 12973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 12983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 12993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 13003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalDisable 13053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalDisableCommand, 13103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalDisableCommand), 13113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 13153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 13163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 13173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 13183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 13193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 13213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x08) 13223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 13233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_SetOwnerInstall=TRUE 13253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand [10] = 0x01; 13283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand, 13313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmSetOwnerInstallCommand), 13323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 13363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x09) 13373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 13383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_SetOwnerInstall=FALSE 13403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand [10] = 0x00; 13433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand, 13463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmSetOwnerInstallCommand), 13473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 13513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x0A) 13523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 13533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalEnable 13553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalEnableCommand, 13603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalEnableCommand), 13613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=FALSE 13663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x00; 13693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 13723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 13733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 13743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 13753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Do TPM_SetOwnerInstall=TRUE on next reboot 13783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 13803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WriteCmosBank1Byte (CpuIo, ACPI_TPM_REQUEST, 0xF0); 13813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 13823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 13833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 13843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 13853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 13863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 13873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 13883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 13893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x0B) 13903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 13913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_SetOwnerInstall=FALSE 13933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 13943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 13953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand [10] = 0x00; 13963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 13973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 13983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand, 13993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmSetOwnerInstallCommand), 14003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=TRUE 14053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x01; 14083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 14113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 14123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalDisable 14173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalDisableCommand, 14223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalDisableCommand), 14233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 14273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 14283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 14293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 14303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 14313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 14333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0x0E) 14343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 14353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_ForceClear 14373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmForceClearCommand, 14423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmForceClearCommand), 14433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalEnable 14483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalEnableCommand, 14533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalEnableCommand), 14543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // TPM_PhysicalSetDeactivated=FALSE 14593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand [10] = 0x00; 14623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalSetDeactivatedCommand, 14653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalSetDeactivatedCommand), 14663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->ResetSystem ( 14703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiResetWarm, 14713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_SUCCESS, 14723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 14733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL 14743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 14763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Data == 0xF0) 14773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei { 14783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Second part of ACPI TPM request 0x0A: OEM custom TPM_SetOwnerInstall=TRUE 14803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand [10] = 0x01; 14833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmSetOwnerInstallCommand, 14863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmSetOwnerInstallCommand), 14873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 14883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 14893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 14903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WriteCmosBank1Byte (CpuIo, ACPI_TPM_LAST_REQUEST, 0x0A); 14913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 14923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Deassert Physical Presence 14943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 14953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalPresenceCommand [11] = 0x10; 14963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBufferSize = sizeof(ReceiveBuffer); 14973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = TpmMpDriver->Transmit ( 14983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmMpDriver, 14993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei TpmPhysicalPresenceCommand, 15003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (TpmPhysicalPresenceCommand), 15013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReceiveBuffer, 15023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &ReceiveBufferSize 15033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 15043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 15053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 15063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return; 15083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 15093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 15113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Initializes manufacturing and config mode setting. 15133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 15153cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 15163cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitMfgAndConfigModeStateVar() 15173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 15183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PLATFORM_SETUP_ID *BootModeBuffer; 15193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID *HobList; 15203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HobList = GetFirstGuidHob(&gEfiPlatformBootModeGuid); 15233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (HobList != NULL) { 15243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BootModeBuffer = GET_GUID_HOB_DATA (HobList); 15253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Check if in Manufacturing mode 15283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ( !CompareMem ( 15303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &BootModeBuffer->SetupName, 15313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei MANUFACTURE_SETUP_NAME, 15323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei StrSize (MANUFACTURE_SETUP_NAME) 15333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) ) { 15343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mMfgMode = TRUE; 15353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 15363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1537620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 1538620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 15393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 15403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 15423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 15443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Initializes manufacturing and config mode setting. 15463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 15483cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 15493cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPlatformBootMode() 15503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 15513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_PLATFORM_SETUP_ID *BootModeBuffer; 15523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID *HobList; 15533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HobList = GetFirstGuidHob(&gEfiPlatformBootModeGuid); 15553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (HobList != NULL) { 15563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BootModeBuffer = GET_GUID_HOB_DATA (HobList); 15573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mPlatformBootMode = BootModeBuffer->PlatformBootMode; 15583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 15593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 15603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 15623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Initializes ITK. 15643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 15663cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 15673cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitItk( 15683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 15693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 15703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 15713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 ItkModBiosState; 15723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 Value; 15733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN DataSize; 15743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT32 Attributes; 15753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 15763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Setup local variable according to ITK variable 15783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Read ItkBiosModVar to determine if BIOS has been modified by ITK 15813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // If ItkBiosModVar = 0 or if variable hasn't been initialized then BIOS has not been modified by ITK modified 15823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set local variable VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME=0 if BIOS has not been modified by ITK 15833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei DataSize = sizeof (Value); 15853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable ( 15863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ITK_BIOS_MOD_VAR_NAME, 15873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gItkDataVarGuid, 15883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Attributes, 15893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &DataSize, 15903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Value 15913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 15923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Status == EFI_NOT_FOUND) { 15933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Variable not found, hasn't been initialized, intialize to 0 15953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value=0x00; 15973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 15983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write variable to flash. 15993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->SetVariable ( 16013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ITK_BIOS_MOD_VAR_NAME, 16023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gItkDataVarGuid, 16033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_RUNTIME_ACCESS | 16043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_NON_VOLATILE | 16053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_BOOTSERVICE_ACCESS, 16063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof (Value), 16073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Value 16083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 16093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 16113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ( (!EFI_ERROR (Status)) || (Status == EFI_NOT_FOUND) ) { 16123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Value == 0x00) { 16133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ItkModBiosState = 0x00; 16143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } else { 16153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ItkModBiosState = 0x01; 16163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 16173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei gRT->SetVariable ( 16183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VAR_EQ_ITK_BIOS_MOD_DECIMAL_NAME, 16193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 16203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_BOOTSERVICE_ACCESS, 16213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2, 16223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (void *)&ItkModBiosState 16233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 16243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 16253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 16263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#if defined(FIRMWARE_ID_BACKWARD_COMPATIBLE) && (FIRMWARE_ID_BACKWARD_COMPATIBLE != 0) 16283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 16303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Initializes the BIOS FIRMWARE ID from the FIRMWARE_ID build variable. 16323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 16343cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSTATIC 16353cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 16363cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitFirmwareId( 16373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 16383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 16393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 16403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CHAR16 FirmwareIdNameWithPassword[] = FIRMWARE_ID_NAME_WITH_PASSWORD; 16413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // First try writing the variable without a password in case we are 16443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // upgrading from a BIOS without password protection on the FirmwareId 16453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable( 16473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (CHAR16 *)&gFirmwareIdName, 16483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gFirmwareIdGuid, 16493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | 16503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_RUNTIME_ACCESS, 16513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof( FIRMWARE_ID ) - 1, 16523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei FIRMWARE_ID 16533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 16543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Status == EFI_INVALID_PARAMETER) { 16563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Since setting the firmware id without the password failed, 16593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // a password must be required. 16603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable( 16623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei (CHAR16 *)&FirmwareIdNameWithPassword, 16633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gFirmwareIdGuid, 16643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | 16653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_RUNTIME_ACCESS, 16663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof( FIRMWARE_ID ) - 1, 16673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei FIRMWARE_ID 16683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 16693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 16703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 16713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#endif 16723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16733cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 16743cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUpdateDVMTSetup( 16753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 16763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 16773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Workaround to support IIA bug. 16793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // IIA request to change option value to 4, 5 and 7 relatively 16803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // instead of 1, 2, and 3 which follow Lakeport Specs. 16813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Check option value, temporary hardcode GraphicsDriverMemorySize 16823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Option value to fulfill IIA requirment. So that user no need to 16833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // load default and update setupvariable after update BIOS. 16843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Option value hardcoded as: 1 to 4, 2 to 5, 3 to 7. 16853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // *This is for broadwater and above product only. 16863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 16873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SYSTEM_CONFIGURATION SystemConfiguration; 16893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN VarSize; 16903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 16913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 16923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VarSize = sizeof(SYSTEM_CONFIGURATION); 16933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->GetVariable( 16943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NORMAL_SETUP_NAME, 16953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 16963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 16973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &VarSize, 16983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &SystemConfiguration 16993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 17003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1701620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { 1702620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He //The setup variable is corrupted 1703620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He VarSize = sizeof(SYSTEM_CONFIGURATION); 1704620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He Status = gRT->GetVariable( 1705620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He L"SetupRecovery", 1706620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &gEfiNormalSetupGuid, 1707620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He NULL, 1708620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &VarSize, 1709620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He &SystemConfiguration 1710620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ); 1711620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He ASSERT_EFI_ERROR (Status); 1712620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He } 1713620f289162b08d319fe1e73b3c7e2baff6b388e4Tim He 17143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if((SystemConfiguration.GraphicsDriverMemorySize < 4) && !EFI_ERROR(Status) ) { 17153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei switch (SystemConfiguration.GraphicsDriverMemorySize){ 17163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei case 1: 17173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.GraphicsDriverMemorySize = 4; 17183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei break; 17193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei case 2: 17203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.GraphicsDriverMemorySize = 5; 17213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei break; 17223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei case 3: 17233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SystemConfiguration.GraphicsDriverMemorySize = 7; 17243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei break; 17253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei default: 17263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei break; 17273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 17283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gRT->SetVariable ( 17303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NORMAL_SETUP_NAME, 17313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gEfiNormalSetupGuid, 17323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 17333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei sizeof(SYSTEM_CONFIGURATION), 17343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &SystemConfiguration 17353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 17363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 17373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 17383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17393cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 17403cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInitPlatformUsbPolicy ( 17413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID 17423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 17433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 17453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_HANDLE Handle; 17463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_STATUS Status; 17473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Handle = NULL; 17493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.Version = (UINT8)USB_POLICY_PROTOCOL_REVISION_2; 17513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbMassStorageEmulationType = mSystemConfiguration.UsbBIOSINT13DeviceEmulation; 17523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if(mUsbPolicyData.UsbMassStorageEmulationType == 3) { 17533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbEmulationSize = mSystemConfiguration.UsbBIOSINT13DeviceEmulationSize; 17543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } else { 17553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbEmulationSize = 0; 17563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 17573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbZipEmulationType = mSystemConfiguration.UsbZipEmulation; 17583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbOperationMode = HIGH_SPEED; 17593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Some chipset need Period smi, 0 = LEGACY_PERIOD_UN_SUPP 17623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.USBPeriodSupport = LEGACY_PERIOD_UN_SUPP; 17643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Some platform need legacyfree, 0 = LEGACY_FREE_UN_SUPP 17673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.LegacyFreeSupport = LEGACY_FREE_UN_SUPP; 17693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Code base , TIANO_CODE_BASE =0x01, ICBD =0x00 17723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.CodeBase = (UINT8)ICBD_CODE_BASE; 17743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Some chispet 's LpcAcpibase are diffrent,set by platform or chipset, 17773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // default is Ich acpibase =0x040. acpitimerreg=0x08. 17783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.LpcAcpiBase = 0x40; 17793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.AcpiTimerReg = 0x08; 17803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set for reduce usb post time 17833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 17843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.UsbTimeTue = 0x00; 17853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.InternelHubExist = 0x00; //TigerPoint doesn't have RMH 17863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei mUsbPolicyData.EnumWaitPortStableStall = 100; 17873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status = gBS->InstallProtocolInterface ( 17903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Handle, 17913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &gUsbPolicyGuid, 17923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EFI_NATIVE_INTERFACE, 17933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &mUsbPolicyData 17943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 17953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT_EFI_ERROR(Status); 17963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 17983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 17993cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 18003cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiReadCmosBank1Byte ( 18013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_CPU_IO_PROTOCOL *CpuIo, 18023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 Index 18033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 18043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 18053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 Data; 18063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 18073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo->Io.Write (CpuIo, EfiCpuIoWidthUint8, 0x72, 1, &Index); 18083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo->Io.Read (CpuIo, EfiCpuIoWidthUint8, 0x73, 1, &Data); 18093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return Data; 18103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 18113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 18123cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 18133cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiWriteCmosBank1Byte ( 18143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN EFI_CPU_IO_PROTOCOL *CpuIo, 18153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 Index, 18163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 Data 18173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 18183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 18193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo->Io.Write ( 18203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo, 18213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiCpuIoWidthUint8, 18223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x72, 18233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 18243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Index 18253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 18263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo->Io.Write ( 18273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei CpuIo, 18283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei EfiCpuIoWidthUint8, 18293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0x73, 18303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1, 18313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei &Data 18323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 18333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 18343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1835