From b7c51c9cf4864df6aabb99a1ae843becd577237c Mon Sep 17 00:00:00 2001 From: raywu Date: Fri, 15 Jun 2018 00:00:50 +0800 Subject: init. 1AQQW051 --- ReferenceCode/ME/Library/AMT/AmtLibrary.cif | 11 + ReferenceCode/ME/Library/AMT/AmtLibrary.sdl | 20 + ReferenceCode/ME/Library/AMT/Dxe/AmtLib.c | 526 ++++++++++++++++++++ ReferenceCode/ME/Library/AMT/Dxe/AmtLib.h | 257 ++++++++++ ReferenceCode/ME/Library/AMT/Dxe/AmtLib.inf | 75 +++ ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.cif | 16 + ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.mak | 54 ++ ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.sdl | 36 ++ .../ME/Library/AMT/Dxe/AmtPolicyDebugDumpDxe.c | 115 +++++ ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.c | 547 +++++++++++++++++++++ ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.h | 298 +++++++++++ .../ME/Library/AMT/Dxe/MebxSetupDebugDumpDxe.c | 75 +++ ReferenceCode/ME/Library/AMT/Include/Amt.h | 59 +++ ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.cif | 13 + ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.h | 26 + ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.inf | 51 ++ ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.mak | 50 ++ ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.sdl | 36 ++ ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.c | 241 +++++++++ ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.h | 126 +++++ 20 files changed, 2632 insertions(+) create mode 100644 ReferenceCode/ME/Library/AMT/AmtLibrary.cif create mode 100644 ReferenceCode/ME/Library/AMT/AmtLibrary.sdl create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLib.c create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLib.h create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLib.inf create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.cif create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.mak create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.sdl create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyDebugDumpDxe.c create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.c create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.h create mode 100644 ReferenceCode/ME/Library/AMT/Dxe/MebxSetupDebugDumpDxe.c create mode 100644 ReferenceCode/ME/Library/AMT/Include/Amt.h create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.cif create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.h create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.inf create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.mak create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.sdl create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.c create mode 100644 ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.h (limited to 'ReferenceCode/ME/Library/AMT') diff --git a/ReferenceCode/ME/Library/AMT/AmtLibrary.cif b/ReferenceCode/ME/Library/AMT/AmtLibrary.cif new file mode 100644 index 0000000..c5be1a2 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/AmtLibrary.cif @@ -0,0 +1,11 @@ + + name = "AmtLibrary" + category = ModulePart + LocalRoot = "ReferenceCode\ME\Library\AMT\" + RefName = "AmtLibrary" +[files] +"AmtLibrary.sdl" +[parts] +"AmtLibDxe" +"AmtLibPei" + diff --git a/ReferenceCode/ME/Library/AMT/AmtLibrary.sdl b/ReferenceCode/ME/Library/AMT/AmtLibrary.sdl new file mode 100644 index 0000000..0e43375 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/AmtLibrary.sdl @@ -0,0 +1,20 @@ +TOKEN + Name = "AmtLibrary_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Help = "Main switch to enable AmtLibDxe support in Project" +End + +PATH + Name = "AmtLibrary_DIR" + Help = "iAMT Library file source directory" +End + +ELINK + Name = "/I$(AmtLibrary_DIR)\Include" + Parent = "ME_INCLUDES" + InvokeOrder = AfterParent +End diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.c b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.c new file mode 100644 index 0000000..6b69b16 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.c @@ -0,0 +1,526 @@ +/** @file + Implementation file for AMT functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement + +**/ + +// +// External include files do NOT need to be explicitly specified in real EDKII +// environment +// +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) + +#include "EdkIIGlueDxe.h" +#include "AmtLib.h" +#include "MeLib.h" + +#include EFI_PROTOCOL_CONSUMER (Heci) +#include EFI_PROTOCOL_CONSUMER (ActiveManagement) +#include EFI_PROTOCOL_CONSUMER (AmtPlatformPolicy) +#include EFI_GUID_DEFINITION (MeBiosExtensionSetup) +#endif + +EFI_ACTIVE_MANAGEMENT_PROTOCOL *mActiveManagement = NULL; +// +// AMT GUID and Variable Name +// +EFI_GUID mEfiMeBiosExtensionSetupGuid = EFI_ME_BIOS_EXTENSION_SETUP_GUID; +CHAR16 mEfiMeBiosExtensionSetupName[] = EFI_ME_BIOS_EXTENSION_SETUP_VARIABLE_NAME; + +/** + Check if Asf is enabled in setup options. + + @param[in] None. + @retval EFI_SUCCESS mActiveManagement is not NULL + @retval Error Status code returned by + LocateProtocol. +**/ +EFI_STATUS +AmtLibInit ( + VOID + ) +{ + EFI_STATUS Status; + + if (mActiveManagement == NULL) { + Status = gBS->LocateProtocol ( + &gEfiActiveManagementProtocolGuid, + NULL, + (VOID **) &mActiveManagement + ); + } else { + Status = EFI_SUCCESS; + } + + return Status; +} + +/** + This will return IDE Redirection Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True IDE-R is enabled. + @retval False IDE-R is disabled. +**/ +BOOLEAN +ActiveManagementEnableIdeR ( + VOID + ) +{ + BOOLEAN CurrentState; + UINTN VariableSize; + EFI_STATUS Status; + ME_BIOS_EXTENSION_SETUP MeBiosExtensionSetupData; + + CurrentState = FALSE; + VariableSize = 0; + + if (mActiveManagement != NULL) { + mActiveManagement->GetIderState (mActiveManagement, &CurrentState); + } + + VariableSize = sizeof (MeBiosExtensionSetupData); + Status = gRT->GetVariable ( + mEfiMeBiosExtensionSetupName, + &mEfiMeBiosExtensionSetupGuid, + NULL, + &VariableSize, + &MeBiosExtensionSetupData + ); + if (!EFI_ERROR (Status)) { + if ((MeBiosExtensionSetupData.AmtSolIder & IDER_ENABLE) == 0) { + CurrentState = FALSE; + } + } + + return CurrentState; +} + +/** + This will return Enforce Secure Boot over IDER Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Enforce Secure Boot is enabled. + @retval False Enforce Secure Boot is disabled. +**/ +BOOLEAN +ActiveManagementEnforceSecureBoot ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetEnforceSecureBootState (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + This will return BIOS Pause Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True BIOS Pause is enabled. + @retval False BIOS Pause is disabled. +**/ +BOOLEAN +ActiveManagementPauseBoot ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetBiosPauseState (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + This will return BIOS Setup Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True BIOS Setup is enabled. + @retval False BIOS Setup is disabled. +**/ +BOOLEAN +ActiveManagementEnterSetup ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetBiosSetupState (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + This will return Serial-over-Lan Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Console Lock is enabled. + @retval False Console Lock is disabled. +**/ +BOOLEAN +ActiveManagementConsoleLocked ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetConsoleLockState (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + This will return KVM Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True KVM is enabled. + @retval False KVM is disabled. +**/ +BOOLEAN +ActiveManagementEnableKvm ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetKvmState (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + This will return Serial-over-Lan Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Serial-over-Lan is enabled. + @retval False Serial-over-Lan is disabled. +**/ +BOOLEAN +ActiveManagementEnableSol ( + VOID + ) +{ + BOOLEAN CurrentState; + UINTN VariableSize; + EFI_STATUS Status; + ME_BIOS_EXTENSION_SETUP MeBiosExtensionSetupData; + + CurrentState = FALSE; + VariableSize = 0; + + if (mActiveManagement != NULL) { + mActiveManagement->GetSolState (mActiveManagement, &CurrentState); + } + + VariableSize = sizeof (MeBiosExtensionSetupData); + Status = gRT->GetVariable ( + mEfiMeBiosExtensionSetupName, + &mEfiMeBiosExtensionSetupGuid, + NULL, + &VariableSize, + &MeBiosExtensionSetupData + ); + if (!EFI_ERROR (Status)) { + if ((MeBiosExtensionSetupData.AmtSolIder & SOL_ENABLE) == 0) { + CurrentState = FALSE; + } + } + + return CurrentState; +} + +/** + This will return IDE Redirection boot device index to boot + + @param[in] None. + + @retval IdeBootDevice Return the boot device number to boot + Bits 0-1: If IDER boot is selected in Perimeter 1 then Bits 1,2 define the drive on the IDER controller to be used as the boot driver. + Bit 1 Bit0 + 0 0 Primary Master Drive + 0 1 Primary Slave Drive + 1 0 Secondary Master Drive + 1 1 Secondary Slave Drive + Bits 2-7: Reserved set to 0 +**/ +UINT8 +ActiveManagementIderBootDeviceGet ( + VOID + ) +{ + UINT8 IderBootDevice; + IderBootDevice = 0; + + if (mActiveManagement != NULL) { + mActiveManagement->GetIderBootDeviceSelectd (mActiveManagement, &IderBootDevice); + } + + return IderBootDevice; +} + +/** + Stop ASF Watch Dog Timer + + @param[in] None. + + @retval None +**/ +VOID +AsfStopWatchDog ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 HeciLength; + ASF_STOP_WDT AsfStopWdt; + UINT32 MeStatus; + UINT32 MeMode; + EFI_HECI_PROTOCOL *Heci; + + Status = gBS->LocateProtocol ( + &gEfiHeciProtocolGuid, + NULL, + (VOID **) &Heci + ); + + if (!EFI_ERROR (Status)) { + Status = Heci->GetMeMode (&MeMode); + if (EFI_ERROR (Status) || (MeMode != ME_MODE_NORMAL)) { + DEBUG ((EFI_D_ERROR, "MeMode is %x, Unable to Stop ME BIOS Watch Dog Timer", MeMode)); + + return ; + } + /// + /// Check ME Status + /// + Status = Heci->GetMeStatus (&MeStatus); + ASSERT_EFI_ERROR (Status); + /// + /// Send EOP/WDT message when ME is ready. Do not care about if ME FW INIT is completed. + /// + if (ME_STATUS_ME_STATE_ONLY (MeStatus) == ME_READY) { + /// + /// Check if watch dog is enabled in BIOS Setup + /// + if (AmtWatchDog ()) { + ZeroMem ((VOID *) &AsfStopWdt, sizeof (ASF_STOP_WDT)); + AsfStopWdt.Command = EFI_ASF_MESSAGE_COMMAND_MANAGEMENT_CONTROL; + AsfStopWdt.ByteCount = EFI_ASF_STOP_WDT_BYTE_COUNT; + AsfStopWdt.SubCommand = ASF_SUB_COMMAND_STOP_WDT; + AsfStopWdt.VersionNumber = EFI_ASF_STOP_WDT_VERSION; + + HeciLength = ASF_STOP_WDT_LENGTH; + Status = Heci->SendMsg ( + (UINT32 *) &AsfStopWdt, + HeciLength, + BIOS_FIXED_HOST_ADDR, + HECI_ASF_MESSAGE_ADDR + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "Unable to Stop ME BIOS Watch Dog Timer")); + } + } + } + } + + return ; +} + +/** + Start ASF Watch Dog Timer + + @param[in] WatchDogType Which kind of WatchDog, ASF OS WatchDog Timer setting or ASF BIOS WatchDog Timer setting + + @retval None +**/ +VOID +AsfStartWatchDog ( + IN UINT8 WatchDogType + ) +{ + EFI_STATUS Status; + UINT32 HeciLength; + ASF_START_WDT AsfStartWdt; + EFI_HECI_PROTOCOL *Heci; + UINT32 MeStatus; + UINT32 MeMode; + UINT16 WaitTimer; + + Status = gBS->LocateProtocol ( + &gEfiHeciProtocolGuid, + NULL, + (VOID **) &Heci + ); + + if (!EFI_ERROR (Status)) { + Status = Heci->GetMeMode (&MeMode); + if (EFI_ERROR (Status) || (MeMode != ME_MODE_NORMAL)) { + DEBUG ((EFI_D_ERROR, "MeMode is %x, Unable to Start ME Watch Dog Timer", MeMode)); + + return ; + } + /// + /// Check ME Status + /// + Status = Heci->GetMeStatus (&MeStatus); + ASSERT_EFI_ERROR (Status); + /// + /// Send EOP/WDT message when ME is ready. Do not care about if ME FW INIT is completed. + /// + if (ME_STATUS_ME_STATE_ONLY (MeStatus) == ME_READY) { + /// + /// Check if watch dog is enabled in BIOS Setup + /// + if (AmtWatchDog ()) { + ZeroMem ((VOID *) &AsfStartWdt, sizeof (ASF_START_WDT)); + AsfStartWdt.Command = EFI_ASF_MESSAGE_COMMAND_MANAGEMENT_CONTROL; + AsfStartWdt.ByteCount = EFI_ASF_START_WDT_BYTE_COUNT; + AsfStartWdt.SubCommand = ASF_SUB_COMMAND_START_WDT; + AsfStartWdt.VersionNumber = EFI_ASF_START_WDT_VERSION_NUMBER; + AsfStartWdt.EventSensorType = EFI_ASF_START_WDT_EVENT_SENSOR_TYPE; + AsfStartWdt.EventType = EFI_ASF_START_WDT_EVENT_TYPE; + AsfStartWdt.EventOffset = EFI_ASF_START_WDT_EVENT_OFFSET; + AsfStartWdt.EventSeverity = EFI_ASF_START_WDT_EVENT_SEVERITY; + AsfStartWdt.SensorDevice = EFI_ASF_START_WDT_SENSOR_DEVICE; + AsfStartWdt.SensorNumber = EFI_ASF_START_WDT_SENSOR_NUMBER; + AsfStartWdt.Entity = EFI_ASF_START_WDT_ENTITY; + AsfStartWdt.EntityInstance = EFI_ASF_START_WDT_ENTITY_INSTANCE; + AsfStartWdt.EventData[0] = EFI_ASF_START_WDT_EVENT_DATA_BYTE_0; + if (WatchDogType == ASF_START_BIOS_WDT) { + AsfStartWdt.EventSourceType = EFI_ASF_START_WDT_EVENT_SOURCE_TYPE_BIOS; + AsfStartWdt.EventData[1] = EFI_ASF_START_WDT_EVENT_DATA_BYTE_1_BIOS_TIMEOUT; + WaitTimer = AmtWatchDogTimerBiosGet (); + } else { + AsfStartWdt.EventSourceType = EFI_ASF_START_WDT_EVENT_SOURCE_TYPE_OS; + AsfStartWdt.EventData[1] = EFI_ASF_START_WDT_EVENT_DATA_BYTE_1_OS_TIMEOUT; + WaitTimer = AmtWatchDogTimerOsGet (); + } + + AsfStartWdt.TimeoutLow = (UINT8) WaitTimer; + AsfStartWdt.TimeoutHigh = (UINT8) (WaitTimer >> 8); + + HeciLength = ASF_START_WDT_LENGTH; + + Status = Heci->SendMsg ( + (UINT32 *) &AsfStartWdt, + HeciLength, + BIOS_FIXED_HOST_ADDR, + HECI_ASF_MESSAGE_ADDR + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "Unable to Start ME Watch Dog Timer")); + } + } + } + } + + return ; +} + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] None. + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +ActiveManagementFwProgress ( + VOID + ) +{ + BOOLEAN CurrentState; + + CurrentState = FALSE; + + if (mActiveManagement != NULL) { + mActiveManagement->GetProgressMsgRequest (mActiveManagement, &CurrentState); + } + + return CurrentState; +} + +/** + Sent initialize KVM message + + @param[in] None. + + @retval True KVM Initialization is successful + @retval False KVM is not enabled +**/ +BOOLEAN +BdsKvmInitialization ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 ResponseCode; + + MeReportError (MSG_KVM_WAIT); + Status = HeciQueryKvmRequest (QUERY_REQUEST, &ResponseCode); + if (EFI_ERROR (Status)) { + MeReportError (MSG_KVM_TIMES_UP); + Status = HeciQueryKvmRequest (CANCEL_REQUEST, &ResponseCode); + } else if (ResponseCode == KVM_SESSION_CANCELLED) { + MeReportError (MSG_KVM_REJECTED); + } else { + return TRUE; + } + + return FALSE; +} diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.h b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.h new file mode 100644 index 0000000..b89ae0a --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.h @@ -0,0 +1,257 @@ +/** @file + Header file for AMT functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#ifndef _AMT_LIB_H_ +#define _AMT_LIB_H_ + +#include "AmtPolicyLib.h" + +// +// ASF Message +// +#define EFI_ASF_START_WDT_VERSION 0x10 +#define EFI_ASF_STOP_WDT_VERSION 0x10 + +#define EFI_ASF_MESSAGE_COMMAND_SENSE_DEVICE_SYSTEM_STATE 0x01 +#define EFI_ASF_MESSAGE_COMMAND_MANAGEMENT_CONTROL 0x02 +#define EFI_ASF_MESSAGE_COMMAND_ASF_CONFIGURATION 0x03 +#define EFI_ASF_MESSAGE_COMMAND_MESSAGE 0x04 +#define EFI_ASF_MESSAGE_COMMAND_GETUUID 0xC7 + +// +// HECI ASF Command +// +#define EFI_ASF_START_WDT_BYTE_COUNT 0x0F +#define EFI_ASF_START_WDT_VERSION_NUMBER 0x10 +#define EFI_ASF_START_WDT_EVENT_SENSOR_TYPE 0x23 +#define EFI_ASF_START_WDT_EVENT_TYPE 0x6F +#define EFI_ASF_START_WDT_EVENT_OFFSET 0x00 +#define EFI_ASF_START_WDT_EVENT_SOURCE_TYPE_OS 0x48 +#define EFI_ASF_START_WDT_EVENT_SOURCE_TYPE_BIOS 0x00 +#define EFI_ASF_START_WDT_EVENT_SOURCE_TYPE 0x00 ///< 0x00 - BIOs, 0x48 - OS +#define EFI_ASF_START_WDT_EVENT_SEVERITY 0x10 ///< critical +#define EFI_ASF_START_WDT_SENSOR_DEVICE 0xFF ///< unspecified +#define EFI_ASF_START_WDT_SENSOR_NUMBER 0xFF ///< unspecified +#define EFI_ASF_START_WDT_ENTITY 0x00 ///< unspecified +#define EFI_ASF_START_WDT_ENTITY_INSTANCE 0x00 ///< unspecified +#define EFI_ASF_START_WDT_EVENT_DATA_BYTE_0 0x40 +#define EFI_ASF_START_WDT_EVENT_DATA_BYTE_1 0x02 ///< 0x02 BIOS POST WDT Timeout, 0x04 OS WDT timeout +#define EFI_ASF_START_WDT_EVENT_DATA_BYTE_1_BIOS_TIMEOUT 0x02 +#define EFI_ASF_START_WDT_EVENT_DATA_BYTE_1_OS_TIMEOUT 0x04 + +#define EFI_ASF_STOP_WDT_BYTE_COUNT 0x02 + +#define ASF_START_BIOS_WDT 0 +#define ASF_START_OS_WDT 1 + +/** + Check if Asf is enabled in setup options. + + @param[in] None. + @retval EFI_SUCCESS mActiveManagement is not NULL + @retval Error Status code returned by + LocateProtocol. +**/ +EFI_STATUS +AmtLibInit ( + VOID + ) +; + +/** + This will return IDE Redirection Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True IDE-R is enabled. + @retval False IDE-R is disabled. +**/ +BOOLEAN +ActiveManagementEnableIdeR ( + VOID + ) +; + +/** + This will return Enforce Secure Boot over IDER Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Enforce Secure Boot is enabled. + @retval False Enforce Secure Boot is disabled. +**/ +BOOLEAN +ActiveManagementEnforceSecureBoot ( + VOID + ) +; + +/** + This will return BIOS Pause Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True BIOS Pause is enabled. + @retval False BIOS Pause is disabled. +**/ +BOOLEAN +ActiveManagementPauseBoot ( + VOID + ) +; + +/** + This will return BIOS Setup Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True BIOS Setup is enabled. + @retval False BIOS Setup is disabled. +**/ +BOOLEAN +ActiveManagementEnterSetup ( + VOID + ) +; + +/** + This will return Serial-over-Lan Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Console Lock is enabled. + @retval False Console Lock is disabled. +**/ +BOOLEAN +ActiveManagementConsoleLocked ( + VOID + ) +; + +/** + This will return KVM Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True KVM is enabled. + @retval False KVM is disabled. +**/ +BOOLEAN +ActiveManagementEnableKvm ( + VOID + ) +; + +/** + This will return Serial-over-Lan Boot Option. + True if the option is enabled. + + @param[in] None. + + @retval True Serial-over-Lan is enabled. + @retval False Serial-over-Lan is disabled. +**/ +BOOLEAN +ActiveManagementEnableSol ( + VOID + ) +; + +/** + This will return IDE Redirection boot device index to boot + + @param[in] None. + + @retval IdeBootDevice Return the boot device number to boot + Bits 0-1: If IDER boot is selected in Perimeter 1 then Bits 1,2 define the drive on the IDER controller to be used as the boot driver. + Bit 1 Bit0 + 0 0 Primary Master Drive + 0 1 Primary Slave Drive + 1 0 Secondary Master Drive + 1 1 Secondary Slave Drive + Bits 2-7: Reserved set to 0 +**/ +UINT8 +ActiveManagementIderBootDeviceGet ( + VOID + ) +; + +/** + Stop ASF Watch Dog Timer + + @param[in] None. + + @retval None +**/ +VOID +AsfStopWatchDog ( + VOID + ) +; + +/** + Start ASF Watch Dog Timer + + @param[in] WatchDogType Which kind of WatchDog, ASF OS WatchDog Timer setting or ASF BIOS WatchDog Timer setting + + @retval None +**/ +VOID +AsfStartWatchDog ( + IN UINT8 WatchDogType + ) +; + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] None. + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +ActiveManagementFwProgress ( + VOID + ) +; + +/** + Sent initialize KVM message + + @param[in] None. + + @retval True KVM Initialization is successful + @retval False KVM is not enabled +**/ +BOOLEAN +BdsKvmInitialization ( + VOID + ) +; +#endif diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.inf b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.inf new file mode 100644 index 0000000..4089248 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLib.inf @@ -0,0 +1,75 @@ +## @file +# Component description file for AMT functionality +# +#@copyright +# Copyright (c) 2010 - 2012 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# This file contains a 'Sample Driver' and is licensed as such +# under the terms of your license agreement with Intel or your +# vendor. This file may be modified by the user, subject to +# the additional terms of the license agreement +# + +[defines] +BASE_NAME = AmtLib +COMPONENT_TYPE = LIBRARY + +[sources.common] + AmtLib.c + AmtLib.h + AmtPolicyLib.c + AmtPolicyLib.h + AmtPolicyDebugDumpDxe.c + MebxSetupDebugDumpDxe.c + +[includes.common] + $(EFI_SOURCE)/$(PROJECT_ME_ROOT) + $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Include + $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Library/MeKernel/Dxe + $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/Heci/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include + +# +# Typically the sample code referenced will be available in the code base already +# So keep this include at the end to defer to the source base definition +# and only use the sample code definition if source base does not include these files. +# + $(EFI_SOURCE)/$(PROJECT_ME_ROOT)/SampleCode + +# +# EDK II Glue Library utilizes some standard headers from EDK +# + $(EDK_SOURCE)/Foundation + $(EDK_SOURCE)/Foundation/Core/Dxe + $(EDK_SOURCE)/Foundation/Efi + $(EDK_SOURCE)/Foundation/Efi/Include + $(EDK_SOURCE)/Foundation/Framework + $(EDK_SOURCE)/Foundation/Framework/Include + $(EDK_SOURCE)/Foundation/Include + $(EDK_SOURCE)/Foundation/Include/IndustryStandard + $(EDK_SOURCE)/Foundation/Library/Dxe/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include + +[libraries.common] + MeLib + MeProtocolLib + EdkIIGlueBaseMemoryLib + EdkIIGlueUefiRuntimeServicesTableLib + EdkIIGlueUefiBootServicesTableLib + EdkIIGlueBasePciLibPciExpress + EdkIIGlueDxeDebugLibReportStatusCode + EdkIIGlueDxeReportStatusCodeLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_MEMORY_LIB__ \ + -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \ + -D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \ + -D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \ + -D __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.cif b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.cif new file mode 100644 index 0000000..9aae0a8 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.cif @@ -0,0 +1,16 @@ + + name = "AmtLibDxe" + category = ModulePart + LocalRoot = "ReferenceCode\ME\Library\AMT\Dxe\" + RefName = "AmtLibDxe" +[files] +"AmtLib.c" +"AmtLib.h" +"AmtLib.inf" +"AmtLibDxe.mak" +"AmtLibDxe.sdl" +"AmtPolicyLib.c" +"AmtPolicyLib.h" +"AmtPolicyDebugDumpDxe.c" +"MebxSetupDebugDumpDxe.c" + diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.mak b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.mak new file mode 100644 index 0000000..1d0a64b --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.mak @@ -0,0 +1,54 @@ +# /*++ +# Copyright (c) 2009 Intel Corporation. All rights reserved. +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# --*/ +# MAK file for the ModulePart:AmtLibDxe +all : AmtLibDxe + +$(BUILD_DIR)\AmtLibDxe.lib : AmtLibDxe + +AmtLibDxe : $(BUILD_DIR)\AmtLibDxe.mak AmtLibDxeBin + +$(BUILD_DIR)\AmtLibDxe.mak : $(AmtLibDxe_DIR)\$(@B).cif $(AmtLibDxe_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(AmtLibDxe_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +AmtLibDxe_INCLUDES=\ + $(EDK_INCLUDES) \ + $(EdkIIGlueLib_INCLUDES) \ + $(ME_INCLUDES)\ + $(INTEL_PCH_INCLUDES)\ + +AmtLibDxe_DEFINES=\ + $(MY_DEFINES)/D __EDKII_GLUE_BASE_MEMORY_LIB__\ + /D __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__\ + /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\ + +AmtLibDxe_LIBS=\ + $(MeProtocolLib_LIB)\ + $(MeLibDxe_LIB) + +AmtLibDxeBin : $(AmtLibDxe_LIBS) + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS) \ + /f $(BUILD_DIR)\AmtLibDxe.mak all \ + "MY_INCLUDES=$(AmtLibDxe_INCLUDES)" \ + "MY_DEFINES=$(AmtLibDxe_DEFINES)"\ + TYPE=LIBRARY \ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2006, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 6145-F Northbelt Pkwy, Norcross, GA 30071 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.sdl b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.sdl new file mode 100644 index 0000000..054446f --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtLibDxe.sdl @@ -0,0 +1,36 @@ +TOKEN + Name = "AmtLibDxe_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Help = "Main switch to enable AmtLibDxe support in Project" +End + +MODULE + Help = "Includes AmtLibDxe.mak to Project" + File = "AmtLibDxe.mak" +End + +PATH + Name = "AmtLibDxe_DIR" + Help = "iAMT Library file source directory" +End + +ELINK + Name = "AmtLibDxe_LIB" + InvokeOrder = ReplaceParent +End + +ELINK + Name = "$(BUILD_DIR)\AmtLibDxe.lib" + Parent = "AmtLibDxe_LIB" + InvokeOrder = AfterParent +End + +ELINK + Name = "/I$(AmtLibDxe_DIR)" + Parent = "ME_INCLUDES" + InvokeOrder = AfterParent +End diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyDebugDumpDxe.c b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyDebugDumpDxe.c new file mode 100644 index 0000000..608f886 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyDebugDumpDxe.c @@ -0,0 +1,115 @@ +/** @file + Dump whole DXE_AMT_POLICY_PROTOCOL and serial out. + +@copyright + Copyright (c) 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" +#include "AmtPolicyLib.h" +#endif + +extern DXE_AMT_POLICY_PROTOCOL *mDxePlatformAmtPolicy; + +/** + Dump DXE Amt Platform Policy + + @param[in] None. + + @retval None +**/ +VOID +DxeAmtPolicyDebugDump ( + VOID + ) +{ + EFI_STATUS Status; + + Status = AmtPolicyLibInit (); + if (EFI_ERROR(Status)) { + return; + } + + DEBUG ((EFI_D_INFO, "\n------------------------ AmtPlatformPolicy Dump Begin -----------------\n")); + DEBUG ((EFI_D_INFO, " Revision : 0x%x\n", mDxePlatformAmtPolicy->Revision)); + DEBUG ((EFI_D_INFO, "AmtConfig ---\n")); + // + // Byte 0, bit definition for functionality enable/disable + // + DEBUG ((EFI_D_INFO, " AsfEnabled : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.AsfEnabled)); + DEBUG ((EFI_D_INFO, " iAmtEnabled : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.iAmtEnabled)); + DEBUG ((EFI_D_INFO, " iAmtbxPasswordWrite : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.iAmtbxPasswordWrite)); + DEBUG ((EFI_D_INFO, " WatchDog : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.WatchDog)); + DEBUG ((EFI_D_INFO, " CiraRequest : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.CiraRequest)); + DEBUG ((EFI_D_INFO, " ManageabilityMode : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.ManageabilityMode)); + DEBUG ((EFI_D_INFO, " UnConfigureMe : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.UnConfigureMe)); + DEBUG ((EFI_D_INFO, " MebxDebugMsg : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.MebxDebugMsg)); + + // + // Byte 1, bit definition for functionality enable/disable + // + DEBUG ((EFI_D_INFO, " ForcMebxSyncUp : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.ForcMebxSyncUp)); + DEBUG ((EFI_D_INFO, " UsbrEnabled : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.UsbrEnabled)); + DEBUG ((EFI_D_INFO, " UsbLockingEnabled : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.UsbLockingEnabled)); + DEBUG ((EFI_D_INFO, " HideUnConfigureMeConfirm : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.HideUnConfigureMeConfirm)); + DEBUG ((EFI_D_INFO, " USBProvision : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.USBProvision)); + DEBUG ((EFI_D_INFO, " FWProgress : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.FWProgress)); + DEBUG ((EFI_D_INFO, " iAmtbxHotKeyPressed : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.iAmtbxHotkeyPressed)); + DEBUG ((EFI_D_INFO, " iAmtbxSelectionScreen : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.iAmtbxSelectionScreen)); + + // + // Byte 2, bit definition for functionality enable/disable + // + DEBUG ((EFI_D_INFO, " AtEnabled : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.AtEnabled)); + + // + // Byte 3-4 OS WatchDog Timer + // + DEBUG ((EFI_D_INFO, " WatchDogTimerOs : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.WatchDogTimerOs)); + + // + // Byte 5-6 BIOS WatchDog Timer + // + DEBUG ((EFI_D_INFO, " WatchDogTimerBios : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.WatchDogTimerBios)); + + // + // Byte 7 CIRA Timeout, Client Initiated Remote Access Timeout + // OEM defined timeout for MPS connection to be established. + // + DEBUG ((EFI_D_INFO, " CiraTimeout : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.CiraTimeout)); + + // + // Byte 8 CPU Replacement Timeout + // + DEBUG ((EFI_D_INFO, " CPU Replacement Timeout : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.CpuReplacementTimeout)); + + // + // Byte 9-10 OemResolutionSettings + // + DEBUG ((EFI_D_INFO, " MebxNonUiTextMode : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.MebxNonUiTextMode)); + DEBUG ((EFI_D_INFO, " MebxUiTextMode : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.MebxUiTextMode)); + DEBUG ((EFI_D_INFO, " MebxGraphicsMode : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.MebxGraphicsMode)); + + // + // Byte 11-14 Pointer to a list which contain on-board devices bus/device/fun number + // + DEBUG ((EFI_D_INFO, " PciDeviceFilterOutTable Pointer : 0x%x\n", mDxePlatformAmtPolicy->AmtConfig.PciDeviceFilterOutTable)); + + DEBUG ((EFI_D_INFO, "\n------------------------ AmtPlatformPolicy Dump End -------------------\n")); +} + diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.c b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.c new file mode 100644 index 0000000..4448504 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.c @@ -0,0 +1,547 @@ +/** @file + Implementation file for AMT Policy functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement + +**/ + +// +// External include files do NOT need to be explicitly specified in real EDKII +// environment +// +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) + +#include "EdkIIGlueDxe.h" +#include "AmtPolicyLib.h" +#include "MeLib.h" + +#include EFI_PROTOCOL_CONSUMER (ActiveManagement) +#include EFI_PROTOCOL_CONSUMER (AmtPlatformPolicy) +#endif +// +// Global variables +// +DXE_AMT_POLICY_PROTOCOL *mDxePlatformAmtPolicy = NULL; + +/** + Check if AMT is enabled in setup options. + + @param[in] None. + + @retval EFI_SUCCESS AMT platform policy pointer is initialized. + @retval All other error conditions encountered when no AMT platform policy available. +**/ +EFI_STATUS +AmtPolicyLibInit ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy != NULL) { + return EFI_SUCCESS; + } + // + // Get the desired platform setup policy. + // + Status = gBS->LocateProtocol (&gDxePlatformAmtPolicyGuid, NULL, (VOID **) &mDxePlatformAmtPolicy); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "No AMT Platform Policy Protocol available")); + ASSERT_EFI_ERROR(Status); + } else if (mDxePlatformAmtPolicy == NULL) { + DEBUG ((EFI_D_ERROR, "No AMT Platform Policy Protocol available")); + Status = EFI_UNSUPPORTED; + } + + return Status; +} + +/** + Check if Asf is enabled in setup options. + + @param[in] None. + + @retval FALSE Asf is disabled. + @retval TRUE Asf is enabled. +**/ +BOOLEAN +AsfSupported ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + // + // First check if ASF support is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.AsfEnabled != 1) { + return FALSE; + } + + return TRUE; +} + +/** + Check if Amt is enabled in setup options. + + @param[in] None. + + @retval FALSE Amt is disabled. + @retval TRUE Amt is enabled. +**/ +BOOLEAN +AmtSupported ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + // + // First check if AMT support is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.iAmtEnabled != 1) { + return FALSE; + } + + return TRUE; +} + +/** + Check if AMT BIOS Extension hotkey was pressed during BIOS boot. + + @param[in] None. + + @retval FALSE MEBx hotkey was not pressed. + @retval TRUE MEBx hotkey was pressed. +**/ +BOOLEAN +AmtHotkeyPressed ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + // + // First check if AMT Setup Prompt is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.iAmtbxHotkeyPressed == 1) { + Supported = TRUE; + } else { + Supported = FALSE; + } + + return Supported; +} + +/** + Check if AMT BIOS Extension Selection Screen is enabled in setup options. + + @param[in] None. + + @retval FALSE AMT Selection Screen is disabled. + @retval TRUE AMT Selection Screen is enabled. +**/ +BOOLEAN +AmtSelectionScreen ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + // + // First check if AMT Selection Screen is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.iAmtbxSelectionScreen == 1) { + Supported = TRUE; + } else { + Supported = FALSE; + } + + return Supported; +} + +/** + Check if AMT WatchDog is enabled in setup options. + + @param[in] None. + + @retval FALSE AMT WatchDog is disabled. + @retval TRUE AMT WatchDog is enabled. +**/ +BOOLEAN +AmtWatchDog ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + Supported = FALSE; + if (ManageabilityModeSetting () != 0) { + // + // First check if AMT WatchDog is enabled in Setup. + // + if (AsfSupported ()) { + if (mDxePlatformAmtPolicy->AmtConfig.WatchDog == 1) { + Supported = TRUE; + } + } + } + + return Supported; +} + +/** + Return BIOS watchdog timer + + @param[in] None. + + @retval UINT16 BIOS ASF Watchdog Timer +**/ +UINT16 +AmtWatchDogTimerBiosGet ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return 0; + } + } + return mDxePlatformAmtPolicy->AmtConfig.WatchDogTimerBios; +} + +/** + Return OS watchdog timer + + @param[in] None. + + @retval UINT16 OS ASF Watchdog Timer +**/ +UINT16 +AmtWatchDogTimerOsGet ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return 0; + } + } + return mDxePlatformAmtPolicy->AmtConfig.WatchDogTimerOs; +} + +/** + Provide CIRA request information from OEM code. + + @param[in] None. + + @retval Check if any CIRA requirement during POST +**/ +BOOLEAN +AmtCiraRequestTrigger ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + return mDxePlatformAmtPolicy->AmtConfig.CiraRequest == 1; +} + +/** + Provide CIRA request Timeout from OEM code. + + @param[in] None. + + @retval CIRA require Timeout for MPS connection to be estabilished +**/ +UINT8 +AmtCiraRequestTimeout ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + return mDxePlatformAmtPolicy->AmtConfig.CiraTimeout; +} + +/** + Provide Manageability Mode setting from MEBx BIOS Sync Data + + @param[in] None + + @retval UINT8 Manageability Mode = MNT_AMT or MNT_ASF +**/ +UINT8 +ManageabilityModeSetting ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return 0; + } + } + return (UINT8) (mDxePlatformAmtPolicy->AmtConfig.ManageabilityMode); +} + +/** + Provide UnConfigure ME without password request from OEM code. + + @param[in] None. + + @retval Check if unConfigure ME without password request +**/ +BOOLEAN +AmtUnConfigureMe ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + return mDxePlatformAmtPolicy->AmtConfig.UnConfigureMe == 1; +} + +/** + Provide 'Hiding the Unconfigure ME without password confirmation prompt' request from OEM code. + + @param[in] None. + + @retval Check if 'Hide unConfigure ME without password Confirmation prompt' request +**/ +BOOLEAN +AmtHideUnConfigureMeConfPrompt ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + return mDxePlatformAmtPolicy->AmtConfig.HideUnConfigureMeConfirm == 1; +} + +/** + Provide show MEBx debug message request from OEM code. + + @param[in] None. + + @retval Check show MEBx debug message request + **/ +BOOLEAN +AmtMebxDebugMsg ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + return mDxePlatformAmtPolicy->AmtConfig.MebxDebugMsg == 1; +} + +/** + Provide on-board device list table and do not need to report them to AMT. AMT only need to know removable PCI device + information. + + @param[in] None. + + @retval on-board device list table pointer other than system device. +**/ +UINT32 +AmtPciDeviceFilterOutTable ( + VOID + ) +{ + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return 0; + } + } + return mDxePlatformAmtPolicy->AmtConfig.PciDeviceFilterOutTable; +} + +/** + Check if USB provisioning enabled/disabled in platform policy. + + @param[in] None. + + @retval FALSE USB provisioning is disabled. + @retval TRUE USB provisioning is enabled. +**/ +BOOLEAN +USBProvisionSupport ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + Supported = FALSE; + + // + // First check if USB Provision is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.USBProvision == 1) { + Supported = TRUE; + } + + return Supported; +} + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] None. + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +FwProgressSupport ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + Supported = FALSE; + + // + // First check if FW Progress is enabled in Setup. + // + if (mDxePlatformAmtPolicy->AmtConfig.FWProgress == 1) { + Supported = TRUE; + } + + return Supported; +} + +/** + Check if ForcMebxSyncUp is enabled in setup options. + + @param[in] None. + + @retval FALSE ForcMebxSyncUp is disabled. + @retval TRUE ForcMebxSyncUp is enabled. +**/ +BOOLEAN +AmtForcMebxSyncUp ( + VOID + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + + if (mDxePlatformAmtPolicy == NULL) { + Status = AmtPolicyLibInit(); + if (EFI_ERROR(Status)) { + return FALSE; + } + } + if (mDxePlatformAmtPolicy->AmtConfig.ForcMebxSyncUp == 1) { + Supported = TRUE; + } else { + Supported = FALSE; + } + + return Supported; +} diff --git a/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.h b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.h new file mode 100644 index 0000000..866c5c0 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/AmtPolicyLib.h @@ -0,0 +1,298 @@ +/** @file + Header file for AMT Policy functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#ifndef _AMT_POLICY_LIB_H_ +#define _AMT_POLICY_LIB_H_ + +#include EFI_PROTOCOL_DEFINITION (AmtPlatformPolicy) +#include EFI_GUID_DEFINITION (MeBiosExtensionSetup) + +/** + Check if AMT is enabled in setup options. + + @param[in] None. + + @retval EFI_SUCCESS AMT platform policy is initialized. + @retval All other error conditions encountered when no AMT platform policy available. +**/ +EFI_STATUS +AmtPolicyLibInit ( + VOID + ) +; + +/** + Check if Asf is enabled in setup options. + + @param[in] None. + + @retval FALSE Asf is disabled. + @retval TRUE Asf is enabled. +**/ +BOOLEAN +AsfSupported ( + VOID + ) +; + +/** + Check if Amt is enabled in setup options. + + @param[in] None. + + @retval FALSE Amt is disabled. + @retval TRUE Amt is enabled. +**/ +BOOLEAN +AmtSupported ( + VOID + ) +; + +/** + Check if AMT BIOS Extension hotkey was pressed during BIOS boot. + + @param[in] None. + + @retval FALSE MEBx hotkey was not pressed. + @retval TRUE MEBx hotkey was pressed. +**/ +BOOLEAN +AmtHotkeyPressed ( + VOID + ) +; + +/** + Check if AMT BIOS Extension Selection Screen is enabled in setup options. + + @param[in] None. + + @retval FALSE AMT Selection Screen is disabled. + @retval TRUE AMT Selection Screen is enabled. +**/ +BOOLEAN +AmtSelectionScreen ( + VOID + ) +; + +/** + Check if AMT WatchDog is enabled in setup options. + + @param[in] None. + + @retval FALSE AMT WatchDog is disabled. + @retval TRUE AMT WatchDog is enabled. +**/ +BOOLEAN +AmtWatchDog ( + VOID + ) +; + +/** + Return BIOS watchdog timer + + @param[in] None. + + @retval UINT16 BIOS ASF Watchdog Timer +**/ +UINT16 +AmtWatchDogTimerBiosGet ( + VOID + ) +; + +/** + Return OS watchdog timer + + @param[in] None. + + @retval UINT16 OS ASF Watchdog Timer +**/ +UINT16 +AmtWatchDogTimerOsGet ( + VOID + ) +; + +/** + Provide CIRA request information from OEM code. + + @param[in] None. + + @retval Check if any CIRA requirement during POST +**/ +BOOLEAN +AmtCiraRequestTrigger ( + VOID + ) +; + +/** + Provide CIRA request Timeout from OEM code. + + @param[in] None. + + @retval CIRA require Timeout for MPS connection to be estabilished +**/ +UINT8 +AmtCiraRequestTimeout ( + VOID + ) + +; + +/** + Provide Manageability Mode setting from MEBx BIOS Sync Data + + @param[in] None + + @retval UINT8 Manageability Mode = MNT_AMT or MNT_ASF +**/ +UINT8 +ManageabilityModeSetting ( + VOID + ) +; + +/** + Provide UnConfigure ME without password request from OEM code. + + @param[in] None. + + @retval Check if unConfigure ME without password request +**/ +BOOLEAN +AmtUnConfigureMe ( + VOID + ) +; + +/** + Provide 'Hiding the Unconfigure ME without password confirmation prompt' request from OEM code. + + @param[in] None. + + @retval Check if 'Hide unConfigure ME without password Confirmation prompt' request +**/ +BOOLEAN +AmtHideUnConfigureMeConfPrompt ( + VOID + ) +; + +/** + Provide show MEBx debug message request from OEM code. + + @param[in] None. + + @retval Check show MEBx debug message request + **/ +BOOLEAN +AmtMebxDebugMsg ( + VOID + ) +; + +/** + Provide on-board device list table and do not need to report them to AMT. AMT only need to know removable PCI device + information. + + @param[in] None. + + @retval on-board device list table pointer other than system device. +**/ +UINT32 +AmtPciDeviceFilterOutTable ( + VOID + ) +; + +/** + Check if USB provisioning enabled/disabled in platform policy. + + @param[in] None. + + @retval FALSE USB provisioning is disabled. + @retval TRUE USB provisioning is enabled. +**/ +BOOLEAN +USBProvisionSupport ( + VOID + ) +; + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] None. + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +FwProgressSupport ( + VOID + ) +; + +/** + Check if ForcMebxSyncUp is enabled in setup options. + + @param[in] None. + + @retval FALSE ForcMebxSyncUp is disabled. + @retval TRUE ForcMebxSyncUp is enabled. +**/ +BOOLEAN +AmtForcMebxSyncUp ( + VOID + ) +; + +/** + Dump DXE Amt Platform Policy + + @param[in] None. + + @retval None +**/ +VOID +DxeAmtPolicyDebugDump ( + VOID + ) +; + +/** + Dump ME_BIOS_EXTENSION_SETUP variable + + @param[in] MeBiosExtensionSetup Pointer to ME_BIOS_EXTENSION_SETUP variable + + @retval None +**/ +VOID +DxeMebxSetupVariableDebugDump ( + IN ME_BIOS_EXTENSION_SETUP *MeBiosExtensionSetup OPTIONAL + ) +; +#endif diff --git a/ReferenceCode/ME/Library/AMT/Dxe/MebxSetupDebugDumpDxe.c b/ReferenceCode/ME/Library/AMT/Dxe/MebxSetupDebugDumpDxe.c new file mode 100644 index 0000000..7fd5048 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Dxe/MebxSetupDebugDumpDxe.c @@ -0,0 +1,75 @@ +/** @file + Dump whole ME_BIOS_EXTENSION_SETUP and serial out. + +@copyright + Copyright (c) 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ + +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" +#include "AmtPolicyLib.h" +#endif + +/** + Dump ME_BIOS_EXTENSION_SETUP variable + + @param[in] MeBiosExtensionSetup Pointer to ME_BIOS_EXTENSION_SETUP variable + + @retval None +**/ +VOID +DxeMebxSetupVariableDebugDump ( + IN ME_BIOS_EXTENSION_SETUP *MeBiosExtensionSetup OPTIONAL + ) +{ + EFI_STATUS Status; + UINTN VariableSize; + ME_BIOS_EXTENSION_SETUP MeBxSetup; + ME_BIOS_EXTENSION_SETUP *MeBxSetupPtr; + + if (MeBiosExtensionSetup == NULL) { + Status = gRT->GetVariable ( + gEfiMeBiosExtensionSetupName, + &gEfiMeBiosExtensionSetupGuid, + NULL, + &VariableSize, + &MeBxSetup + ); + if (EFI_ERROR(Status)) { + return; + } + MeBxSetupPtr = &MeBxSetup; + } else { + MeBxSetupPtr = MeBiosExtensionSetup; + } + + DEBUG ((EFI_D_INFO, "\n------------------------ MeBiosExtensionSetup Dump Begin -----------------\n")); + DEBUG ((EFI_D_INFO, " InterfaceVersion : 0x%x\n", MeBxSetupPtr->InterfaceVersion)); + DEBUG ((EFI_D_INFO, " Flags : 0x%x\n", MeBxSetupPtr->Flags)); + DEBUG ((EFI_D_INFO, " PlatformMngSel : 0x%x\n", MeBxSetupPtr->PlatformMngSel)); + DEBUG ((EFI_D_INFO, " AmtSolIder : 0x%x\n", MeBxSetupPtr->AmtSolIder)); + DEBUG ( + (EFI_D_INFO, + " RemoteAssistanceTriggerAvailablilty : 0x%x\n", + MeBxSetupPtr->RemoteAssistanceTriggerAvailablilty) + ); + DEBUG ((EFI_D_INFO, " KvmEnable : 0x%x\n", MeBxSetupPtr->KvmEnable)); + DEBUG ((EFI_D_INFO, " MebxDefaultSolIder : 0x%x\n", MeBxSetupPtr->MebxDefaultSolIder)); + + DEBUG ((EFI_D_INFO, "\n------------------------ MeBiosExtensionSetup Dump End -------------------\n")); + +} diff --git a/ReferenceCode/ME/Library/AMT/Include/Amt.h b/ReferenceCode/ME/Library/AMT/Include/Amt.h new file mode 100644 index 0000000..9698218 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Include/Amt.h @@ -0,0 +1,59 @@ +/** @file + Header file for common Active Management Technology defines. + +@copyright + Copyright (c) 2010 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#ifndef _AMT_H_ +#define _AMT_H_ + +/// +/// Intel Internet Assigned Numbers Authority Manufacturer ID +/// (The firmware sends 0x57010000 for decimal value 343) +/// +#define INTEL_IANA_SWAP32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | \ + (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) +#define ASF_INTEL_IANA 0x00000157 +#define ASF_INTEL_CONVERTED_IANA INTEL_IANA_SWAP32 (ASF_INTEL_IANA) ///< 0X57010000, received from ME +/// +/// Intel OEM Special Command +/// +#define ASF_INTEL_OEM_CMD 0xC1 + +/// +/// Intel OEM Parameters 16 bit OEM Parameter values +/// +#define USE_SOL 0x0001 ///< 0000 0000 0000 0001 - bit 0, use SOL on the next boot +// +// Intel OEM Command 16 bit special command parameter values +// +#define USE_IDER 0x0001 ///< 0000 0000 0000 0001 - bit 0 Paramater 2 will be used to indicate the channel +#define ENFORCE_SECURE_BOOT 0x0002 ///< 0000 0000 0000 0010 - bit 1 Enforce secure boot over IDER +#define REFLASH_BIOS 0x0004 ///< 0000 0000 0000 0100 - bit 2 +#define BIOS_SETUP 0x0008 ///< 0000 0000 0000 1000 - bit 3 +#define BIOS_PAUSE 0x0010 ///< 0000 0000 0001 0000 - bit 4 +#define USE_KVM 0x0020 ///< 0000 0000 0010 0000 - bit 5 +#define IDER_CD 0x0100 ///< 0000 0001 0000 0000 - bit 8 Primary Slave Drive +#define IDER_PRIMARY_MASTER 0x0000 +#define IDER_PRIMARY_SLAVE 0x0100 +#define IDER_SECONDARY_MASTER 0x0200 +#define IDER_SECONDARY_SLAVE 0x0300 + +#define IDER_BOOT_DEVICE_MASK 0x0300 +#define IDER_BOOT_DEVICE_SHIFT 8 + +#endif diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.cif b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.cif new file mode 100644 index 0000000..1c34f45 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.cif @@ -0,0 +1,13 @@ + + name = "AmtLibPei" + category = ModulePart + LocalRoot = "ReferenceCode\ME\Library\AMT\Pei\" + RefName = "AmtLibPei" +[files] +"AmtLibPei.sdl" +"AmtLibPei.mak" +"AmtPolicyLibPei.c" +"AmtPolicyLibPei.h" +"AmtLibPei.h" +"AmtLibPei.inf" + diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.h b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.h new file mode 100644 index 0000000..4b29fc9 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.h @@ -0,0 +1,26 @@ +/** @file + Header file for PEI AMT functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#ifndef _PEI_AMT_LIB_H_ +#define _PEI_AMT_LIB_H_ + +#include "AmtPolicyLibPei.h" + +#endif diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.inf b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.inf new file mode 100644 index 0000000..44d88ad --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.inf @@ -0,0 +1,51 @@ +## @file +# Component description file for AMT Library functions for PEIMs +# +#@copyright +# Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# This file contains a 'Sample Driver' and is licensed as such +# under the terms of your license agreement with Intel or your +# vendor. This file may be modified by the user, subject to +# the additional terms of the license agreement +# + +[defines] +BASE_NAME = AmtLibPei +COMPONENT_TYPE = LIBRARY + +[sources.common] + AmtPolicyLibPei.c + AmtPolicyLibPei.h + AmtLibPei.h + +[includes.common] + $(EFI_SOURCE)/$(PROJECT_ME_ROOT) + +# +# EDK II Glue Library utilizes some standard headers from EDK +# + $(EDK_SOURCE)/Foundation + $(EDK_SOURCE)/Foundation/Core/Dxe + $(EDK_SOURCE)/Foundation/Efi + $(EDK_SOURCE)/Foundation/Efi/Include + $(EDK_SOURCE)/Foundation/Framework + $(EDK_SOURCE)/Foundation/Framework/Include + $(EDK_SOURCE)/Foundation/Include + $(EDK_SOURCE)/Foundation/Include/IndustryStandard + $(EDK_SOURCE)/Foundation/Include/Pei + $(EDK_SOURCE)/Foundation/Library/Dxe/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include + +[libraries.common] + EdkIIGluePeiServicesLib + +[nmake.common] + C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_PEI_SERVICES_LIB__ diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.mak b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.mak new file mode 100644 index 0000000..e31ecc5 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.mak @@ -0,0 +1,50 @@ +# /*++ +# Copyright (c) 2009 Intel Corporation. All rights reserved. +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# --*/ +# MAK file for the ModulePart:AmtLibPei +all : AmtLibPei + +$(BUILD_DIR)\AmtLibPei.lib : AmtLibPei + +AmtLibPei : $(BUILD_DIR)\AmtLibPei.mak AmtLibPeiBin + +$(BUILD_DIR)\AmtLibPei.mak : $(AmtLibPei_DIR)\$(@B).cif $(AmtLibPei_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(AmtLibPei_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +AmtLibPei_INCLUDES=\ + $(EDK_INCLUDES) \ + $(EdkIIGlueLib_INCLUDES)\ + $(ME_INCLUDES) \ + +AmtLibPei_DEFINES=\ + /D __EDKII_GLUE_PEI_SERVICES_LIB__ + +AmtLibPei_LIBS=\ + $(EdkIIGluePeiServicesLib_LIB)\ + +AmtLibPeiBin : $(AmtLibPei_LIBS) $(MeLibPei_LIBS) + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS) \ + /f $(BUILD_DIR)\AmtLibPei.mak all \ + "MY_INCLUDES=$(AmtLibPei_INCLUDES)" \ + "CFLAGS=$(CFLAGS) $(AmtLibPei_DEFINES)"\ + TYPE=PEI_LIBRARY \ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2006, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 6145-F Northbelt Pkwy, Norcross, GA 30071 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.sdl b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.sdl new file mode 100644 index 0000000..b3a63bd --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtLibPei.sdl @@ -0,0 +1,36 @@ +TOKEN + Name = "AmtLibPei_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Help = "Main switch to enable AmtLibPei support in Project" +End + +MODULE + Help = "Includes AmtLibPei.mak to Project" + File = "AmtLibPei.mak" +End + +PATH + Name = "AmtLibPei_DIR" + Help = "iAMT Library file source directory" +End + +ELINK + Name = "AmtLibPei_LIB" + InvokeOrder = ReplaceParent +End + +ELINK + Name = "$(BUILD_DIR)\AmtLibPei.lib" + Parent = "AmtLibPei_LIB" + InvokeOrder = AfterParent +End + +ELINK + Name = "/I$(AmtLibPei_DIR)" + Parent = "ME_INCLUDES" + InvokeOrder = AfterParent +End diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.c b/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.c new file mode 100644 index 0000000..472ebbc --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.c @@ -0,0 +1,241 @@ +/** @file + Implementation file for AMT Policy functionality for PEIM + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ + +// +// External include files do NOT need to be explicitly specified in real EDKII +// environment +// +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGluePeim.h" +#include "AmtPolicyLibPei.h" +#endif + +EFI_GUID mPeiAmtStatusCodePpiGuid = PEI_AMT_STATUS_CODE_PPI_GUID; + +/** + Check if Amt is enabled in setup options. + + @param[in] PeiServices General purpose services available to every PEIM. + @param[in] PeiAmtPlatformPolicy The AMT Platform Policy protocol instance + + @retval EFI_SUCCESS AMT platform policy Ppi located + @retval All other error conditions encountered result in an ASSERT. +**/ +EFI_STATUS +PeiAmtPolicyLibInit ( + EFI_PEI_SERVICES **PeiServices, + PEI_AMT_PLATFORM_POLICY_PPI **PeiAmtPlatformPolicy + ) +{ + EFI_STATUS Status; + + /// + /// Locate system configuration variable + /// + Status = PeiServicesLocatePpi ( + &gPeiAmtPlatformPolicyPpiGuid, // GUID + 0, // INSTANCE + NULL, // EFI_PEI_PPI_DESCRIPTOR + (VOID **) PeiAmtPlatformPolicy // PPI + ); + ASSERT_EFI_ERROR (Status); + return Status; +} + +/** + Check if AMT WatchDog is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE AMT WatchDog is disabled. + @retval TRUE AMT WatchDog is enabled. +**/ +BOOLEAN +PeiAmtWatchDog ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + BOOLEAN Supported; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Supported = FALSE; + if (ManageabilityModeSetting (PeiServices) != 0) { + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + // + // First check if AMT WatchDog is enabled in Setup. + // + if (PeiAmtPlatformPolicy->WatchDog == 1) { + Supported = TRUE; + } + } + + return Supported; +} + +/** + Get WatchDog BIOS Timmer. + + @param[in] PeiServices Point to Pei Services structure + + @retval UINT16 WatchDog BIOS Timer +**/ +UINT16 +PeiAmtWatchTimerBiosGet ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + + return PeiAmtPlatformPolicy->WatchDogTimerBios; +} + +/** + Check if AMT is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE ActiveManagement is disabled. + @retval TRUE ActiveManagement is enabled. +**/ +BOOLEAN +PeiAmtSupported ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + BOOLEAN Supported; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + + // + // First check if AMT support is enabled in Setup. + // + if (PeiAmtPlatformPolicy->iAmtEnabled == 1) { + Supported = TRUE; + } else { + Supported = FALSE; + } + + return Supported; +} + +/** + Check if ASF is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE ASF is disabled. + @retval TRUE ASF is enabled. +**/ +BOOLEAN +PeiAsfSupported ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + BOOLEAN Supported; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + + if (PeiAmtPlatformPolicy->Revision < PEI_AMT_PLATFORM_POLICY_PPI_REVISION_2) { + return FALSE; + } + // + // First check if ASF support is enabled in Setup. + // + if (PeiAmtPlatformPolicy->AsfEnabled == 1) { + Supported = TRUE; + } else { + Supported = FALSE; + } + + return Supported; +} + +/** + Provide Manageability Mode setting from MEBx BIOS Sync Data + + @param[in] PeiServices Point to Pei Services structure + + @retval UINT8 Manageability Mode = MNT_AMT or MNT_ASF +**/ +UINT8 +ManageabilityModeSetting ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + + if (PeiAmtPlatformPolicy->Revision < PEI_AMT_PLATFORM_POLICY_PPI_REVISION_2) { + return 0; + } + + return (UINT8) (PeiAmtPlatformPolicy->ManageabilityMode); +} + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] PeiServices Point to Pei Services structure + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +PeiFwProgressSupport ( + IN EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + BOOLEAN Supported; + PEI_AMT_PLATFORM_POLICY_PPI *PeiAmtPlatformPolicy; + + Status = PeiAmtPolicyLibInit (PeiServices, &PeiAmtPlatformPolicy); + ASSERT_EFI_ERROR (Status); + + Supported = FALSE; + + if (PeiAmtPlatformPolicy->Revision >= PEI_AMT_PLATFORM_POLICY_PPI_REVISION_3) { + // + // Check if progress event is enabled in Setup. + // + if (PeiAmtPlatformPolicy->FWProgress == 1) { + Supported = TRUE; + } + } + + return Supported; +} diff --git a/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.h b/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.h new file mode 100644 index 0000000..b7361f4 --- /dev/null +++ b/ReferenceCode/ME/Library/AMT/Pei/AmtPolicyLibPei.h @@ -0,0 +1,126 @@ +/** @file + Header file for PEI AMT Policy functionality + +@copyright + Copyright (c) 2006 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#ifndef _PEI_AMT_POLICY_LIB_H_ +#define _PEI_AMT_POLICY_LIB_H_ + +#include EFI_PPI_DEFINITION (AmtPlatformPolicyPei) +#include EFI_PPI_DEFINITION (AmtStatusCode) + +/** + Check if Amt is enabled in setup options. + + @param[in] PeiServices General purpose services available to every PEIM. + @param[in] PeiAmtPlatformPolicy The AMT Platform Policy protocol instance + + @retval EFI_SUCCESS AMT platform policy Ppi located + @retval All other error conditions encountered result in an ASSERT. +**/ +EFI_STATUS +PeiAmtPolicyLibInit ( + EFI_PEI_SERVICES **PeiServices, + PEI_AMT_PLATFORM_POLICY_PPI **PeiAmtPlatformPolicy + ) +; + +/** + Check if AMT WatchDog is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE AMT WatchDog is disabled. + @retval TRUE AMT WatchDog is enabled. +**/ +BOOLEAN +PeiAmtWatchDog ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +/** + Get WatchDog BIOS Timmer. + + @param[in] PeiServices Point to Pei Services structure + + @retval UINT16 WatchDog BIOS Timer +**/ +UINT16 +PeiAmtWatchTimerBiosGet ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +/** + Check if AMT is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE ActiveManagement is disabled. + @retval TRUE ActiveManagement is enabled. +**/ +BOOLEAN +PeiAmtSupported ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +/** + Check if ASF is enabled in setup options. + + @param[in] PeiServices Point to Pei Services structure + + @retval FALSE ASF is disabled. + @retval TRUE ASF is enabled. +**/ +BOOLEAN +PeiAsfSupported ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +/** + Provide Manageability Mode setting from MEBx BIOS Sync Data + + @param[in] PeiServices Point to Pei Services structure + + @retval UINT8 Manageability Mode = MNT_AMT or MNT_ASF +**/ +UINT8 +ManageabilityModeSetting ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +/** + This will return progress event Option. + True if the option is enabled. + + @param[in] PeiServices Point to Pei Services structure + + @retval True progress event is enabled. + @retval False progress event is disabled. +**/ +BOOLEAN +PeiFwProgressSupport ( + IN EFI_PEI_SERVICES **PeiServices + ) +; + +#endif -- cgit v1.2.3