summaryrefslogtreecommitdiff
path: root/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe
diff options
context:
space:
mode:
Diffstat (limited to 'ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe')
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.c631
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.cif14
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.dxs42
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.h158
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.inf113
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.mak88
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.sdl28
-rw-r--r--ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchOp.c178
8 files changed, 1252 insertions, 0 deletions
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.c b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.c
new file mode 100644
index 0000000..9c7efae
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.c
@@ -0,0 +1,631 @@
+/** @file
+
+@copyright
+ Copyright (c) 1999 - 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
+
+**/
+#include "TxtOneTouchDxe.h"
+
+TXT_ONE_TOUCH_OP_PROTOCOL mTxtOneTouchOpProtocol = {
+ TxtExecOperation,
+ TxtConfirmationDialog,
+ TxtResetState
+};
+
+EFI_TCG_PROTOCOL *mTcgProtocol;
+TXT_ONE_TOUCH_SETUP mTxtVariable;
+
+/**
+ @param[in] ImageHandle - A handle for this module
+ @param[in] SystemTable - A pointer to the EFI System Table
+
+ @retval EFI_SUCCESS - If TXT initialization succeed
+ @retval EFI_UNLOAD_IMAGE - If TXT criterias are not met
+**/
+EFI_STATUS
+EFIAPI
+DriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ ZeroMem (&mTxtVariable, sizeof (TXT_ONE_TOUCH_SETUP));
+
+ ///
+ /// Install the protocol
+ ///
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gTxtOneTouchOpProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mTxtOneTouchOpProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Locate TcgProtocol
+ ///
+ mTcgProtocol = NULL;
+ Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &mTcgProtocol);
+ ASSERT_EFI_ERROR (Status);
+
+ ///
+ /// Initiate the variable if it doesn't exist.
+ ///
+ if (ReadWriteVariable (&mTxtVariable, FALSE) != EFI_SUCCESS) {
+ ReadWriteVariable (&mTxtVariable, TRUE);
+ }
+
+ return Status;
+}
+
+/**
+ Read/Write variable for enable/disable TxT one
+ touch functions
+
+ @param[in] VariableData - Point to Setup variable buffer
+ @param[in] WriteData - TRUE, write changes to Setup Variable. FALSE, not to write variable.
+
+ @retval EFI_SUCCESS - Operation complete successful
+ @retval EFI_INVALID_PARAMETER - VariableData is NULL
+**/
+EFI_STATUS
+ReadWriteVariable (
+ IN OUT TXT_ONE_TOUCH_SETUP *VariableData,
+ IN BOOLEAN WriteData
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ UINT32 VarAttrib;
+
+ Status = EFI_SUCCESS;
+ Size = 0;
+ VarAttrib = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
+
+ if (VariableData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (WriteData == TRUE) {
+ ///
+ /// Write TxT variable
+ ///
+ Size = sizeof (TXT_ONE_TOUCH_SETUP);
+
+ Status = gRT->SetVariable (
+ TXT_ONE_TOUCH_VAR,
+ &gTxtOneTouchGuid,
+ VarAttrib,
+ Size,
+ VariableData
+ );
+ } else {
+ ///
+ /// Read TxT variable
+ ///
+ Size = sizeof (TXT_ONE_TOUCH_SETUP);
+
+ Status = gRT->GetVariable (
+ TXT_ONE_TOUCH_VAR,
+ &gTxtOneTouchGuid,
+ NULL,
+ &Size,
+ VariableData
+ );
+ }
+
+ return Status;
+}
+
+/**
+ Read TxT Maintenance flag
+
+ @retval TRUE - TxT Maintenance Flag is TRUE
+ @retval FALSE - TxT Maintenance Flag is FALSE
+**/
+BOOLEAN
+CheckTxtMaintenanceFlag (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+
+ ///
+ /// TBD. Need to read TPM NV index 0x50010000
+ ///
+ ///
+ /// Read TxT variable first
+ ///
+ Status = ReadWriteVariable (&mTxtVariable, FALSE);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ return mTxtVariable.NoTxtMaintenance;
+}
+
+/**
+ Extend PPI operation for TxT.
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+
+ @retval EFI_SUCCESS - Execute the Command successful
+ @retval EFI_UNSUPPORTED - Command is not supported
+**/
+EFI_STATUS
+EFIAPI
+TxtExecOperation (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+
+ ///
+ /// Read TxT variable first
+ ///
+ Status = ReadWriteVariable (&mTxtVariable, FALSE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ///
+ /// Read variable for TxT One Touch function
+ /// The variable can be Setup variable
+ ///
+ switch (Command) {
+ case DISABLE_DEACTIVATE:
+ ///
+ /// Disable & Deactive TPM
+ /// Disable TxT
+ ///
+ mTxtVariable.TxtEnable = FALSE;
+ break;
+
+ case ENABLE_VT:
+ ///
+ /// Enable VT
+ ///
+ mTxtVariable.VtEnable = TRUE;
+ break;
+
+ case DISABLE_VT_TXT:
+ ///
+ /// Disable VT and TxT
+ ///
+ mTxtVariable.VtEnable = FALSE;
+ mTxtVariable.TxtEnable = FALSE;
+ break;
+
+ case ENABLE_VTD:
+ ///
+ /// Enable VT-d
+ ///
+ mTxtVariable.VtdEnable = TRUE;
+ break;
+
+ case DISABLE_VTD_TXT:
+ ///
+ /// Disable VT-d and TxT
+ ///
+ mTxtVariable.VtdEnable = FALSE;
+ break;
+
+ case ENABLE_ACTTPM_VT_VTD_TXT_DISABLE_STM:
+ ///
+ /// Enable-Active TPM
+ /// Enable VT, VT-d and TxT
+ /// Disable STM
+ ///
+ TpmEnableActive (ENABLE_ACTIVATE);
+ ///
+ /// mTxtVariable.TpmEnable = TRUE;
+ /// mTxtVariable.TpmActive = TRUE;
+ ///
+ mTxtVariable.VtEnable = TRUE;
+ mTxtVariable.VtdEnable = TRUE;
+ mTxtVariable.TxtEnable = TRUE;
+ mTxtVariable.StmEnable = FALSE;
+ break;
+
+ case ENABLE_ACTTPM_VT_VTD_TXT_STM:
+ ///
+ /// Enable-Active TPM
+ /// Enable VT, VT-d, TxT and STM
+ ///
+ TpmEnableActive (ENABLE_ACTIVATE);
+ ///
+ /// mTxtVariable.TpmEnable = TRUE;
+ /// mTxtVariable.TpmActive = TRUE;
+ ///
+ mTxtVariable.VtEnable = TRUE;
+ mTxtVariable.VtdEnable = TRUE;
+ mTxtVariable.TxtEnable = TRUE;
+ mTxtVariable.StmEnable = TRUE;
+ break;
+
+ case DISABLE_STM:
+ ///
+ /// Disable STM
+ ///
+ mTxtVariable.StmEnable = FALSE;
+ break;
+
+ case DISABLE_TXT_STM:
+ ///
+ /// Disable TxT and STM
+ ///
+ mTxtVariable.TxtEnable = FALSE;
+ mTxtVariable.StmEnable = FALSE;
+ break;
+
+ case DISABLE_SENTER_VMX:
+ ///
+ /// Disable SENTER and VMX
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_VMX_SMX_ONLY:
+ ///
+ /// Enable VMX in SMX only
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_VMX_OUTSIDE_SMX:
+ ///
+ /// Enable VMX outside SMX Only
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_VMX:
+ ///
+ /// Enable VMX
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_SENTER_ONLY:
+ ///
+ /// Enable SENTER Only
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_SENTER_VMX_IN_SMX:
+ ///
+ /// Enable SENTER and VMX in SMX
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_SENTER_VMX_OUTSIDE_SMX:
+ ///
+ /// Enable SENTER and VMX outside SMX
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case ENABLE_SENTER_VMX:
+ ///
+ /// Enable SENTER and VMX
+ ///
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ case SET_NO_TXT_MAINTENANCE_FALSE:
+ ///
+ /// Set NoTxtMaintenance Flag FALSE
+ ///
+ mTxtVariable.NoTxtMaintenance = FALSE;
+ break;
+
+ case SET_NO_TXT_MAINTENANCE_TRUE:
+ ///
+ /// Set NoTxtMaintenance Flag TRUE
+ ///
+ mTxtVariable.NoTxtMaintenance = TRUE;
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ }
+ ///
+ /// Validate states
+ ///
+ Status = ValidateTxtStates (&mTxtVariable);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_UNSUPPORTED;
+ } else {
+ ///
+ /// if settings are correct, write it to variable
+ ///
+ Status = ReadWriteVariable (&mTxtVariable, TRUE);
+ }
+
+ return Status;
+}
+
+/**
+ Confirmation dialog for TxT PPI
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+ @param[in] Confirm - User confirm
+
+ @retval EFI_SUCCESS - Execute the Command successful
+ @retval EFI_UNSUPPORTED - Command is not supported
+**/
+EFI_STATUS
+EFIAPI
+TxtConfirmationDialog (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command,
+ IN OUT BOOLEAN *Confirm
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+
+ if (CheckTxtMaintenanceFlag ()) {
+ *Confirm = FALSE;
+ }
+
+ switch (Command) {
+ case DISABLE_DEACTIVATE:
+ ///
+ /// Disable & Deactive TPM
+ /// Disable TxT
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable TxT\n\n\r"
+ );
+
+ break;
+
+ case ENABLE_VT:
+ ///
+ /// Enable VT
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable VT\n\n\r"
+ );
+ break;
+
+ case DISABLE_VT_TXT:
+ ///
+ /// Disable VT and TxT
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable VT and TxT\n\n\r"
+ );
+ break;
+
+ case ENABLE_VTD:
+ ///
+ /// Enable VT-d
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable VT-d\n\n\r"
+ );
+ break;
+
+ case DISABLE_VTD_TXT:
+ ///
+ /// Disable VT-d and TxT
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable VT-d and TxT\n\n\r"
+ );
+ break;
+
+ case ENABLE_ACTTPM_VT_VTD_TXT_DISABLE_STM:
+ ///
+ /// Enable-Active TPM
+ /// Enable VT, VT-d and TxT
+ /// Disable STM
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable/Active TPM and Enable VT/VT-d/TxT, and Disable STM\n\n\r"
+ );
+ break;
+
+ case ENABLE_ACTTPM_VT_VTD_TXT_STM:
+ ///
+ /// Enable-Active TPM
+ /// Enable VT, VT-d, TxT and STM
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable/Active TPM and Enable VT/VT-d/TxT/STM\n\n\r"
+ );
+ break;
+
+ case DISABLE_STM:
+ ///
+ /// Disable STM
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable STM\n\n\r"
+ );
+ break;
+
+ case DISABLE_TXT_STM:
+ ///
+ /// Disable TxT and STM
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable TxT and STM\n\n\r"
+ );
+ break;
+
+ case DISABLE_SENTER_VMX:
+ ///
+ /// Disable SENTER and VMX
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Disable SENTER and VMX\n\n\r"
+ );
+ break;
+
+ case ENABLE_VMX_SMX_ONLY:
+ ///
+ /// Enable VMX in SMX only
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable VMX in SMX only\n\n\r"
+ );
+ break;
+
+ case ENABLE_VMX_OUTSIDE_SMX:
+ ///
+ /// Enable VMX outside SMX Only
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable VMX outside SMX Only\n\n\r"
+ );
+ break;
+
+ case ENABLE_VMX:
+ ///
+ /// Enable VMX
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable VMX\n\n\r"
+ );
+ break;
+
+ case ENABLE_SENTER_ONLY:
+ ///
+ /// Enable SENTER Only
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable SENTER only\n\n\r"
+ );
+ break;
+
+ case ENABLE_SENTER_VMX_IN_SMX:
+ ///
+ /// Enable SENTER and VMX in SMX
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable SENTER and VMX in SMX\n\n\r"
+ );
+ break;
+
+ case ENABLE_SENTER_VMX_OUTSIDE_SMX:
+ ///
+ /// Enable SENTER and VMX outside SMX
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable SENTER and VMX outside SMX\n\n\r"
+ );
+ break;
+
+ case ENABLE_SENTER_VMX:
+ ///
+ /// Enable SENTER and VMX
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Enable SENTER and VMX\n\n\r"
+ );
+ break;
+
+ case SET_NO_TXT_MAINTENANCE_FALSE:
+ ///
+ /// Set NoTxtMaintenance Flag FALSE
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Set TxT Maintenance Flag to FALSE\n\n\r"
+ );
+ break;
+
+ case SET_NO_TXT_MAINTENANCE_TRUE:
+ ///
+ /// Set NoTxtMaintenance Flag TRUE
+ ///
+ gST->ConOut->OutputString (
+ gST->ConOut,
+ L"\nA configuration change was requested to Set TxT Maintenance Flag to TRUE\n\n\r"
+ );
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ }
+
+ return Status;
+}
+
+/**
+ Reset system.
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+
+ @retval EFI_SUCCESS - Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TxtResetState (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command
+ )
+{
+ EFI_STATUS Status;
+ PCH_RESET_PROTOCOL *PchReset;
+
+ Status = gBS->LocateProtocol (&gPchResetProtocolGuid, NULL, (VOID **) &PchReset);
+ if (!EFI_ERROR (Status)) {
+ PchReset->Reset (PchReset, GlobalReset);
+ } else {
+ gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+ }
+
+ ASSERT (FALSE);
+ ///
+ /// Should not be here
+ ///
+ return EFI_SUCCESS;
+}
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.cif b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.cif
new file mode 100644
index 0000000..7e4a219
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "TxtOneTouch"
+ category = ModulePart
+ LocalRoot = "ReferenceCode\Haswell\SampleCode\TxtOneTouch\Dxe"
+ RefName = "TxtOneTouchDxe"
+[files]
+"TxtOneTouchDxe.sdl"
+"TxtOneTouchDxe.dxs"
+"TxtOneTouchDxe.mak"
+"TxtOneTouchDxe.inf"
+"TxtOneTouchDxe.c"
+"TxtOneTouchDxe.h"
+"TxtOneTouchOp.c"
+<endComponent>
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.dxs b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.dxs
new file mode 100644
index 0000000..2b37172
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.dxs
@@ -0,0 +1,42 @@
+/** @file
+ This is the Dependency expression for the TXT Dxe architectural protocol
+
+@copyright
+ Copyright (c) 1999 - 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
+
+**/
+
+
+//
+// Common for R8 and R9 codebase
+//
+#include "AutoGen.h"
+#include "DxeDepex.h"
+
+//
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are both "defined" in R8 codebase;
+// BUILD_WITH_EDKII_GLUE_LIB is defined in Edk-Dev-Snapshot-20070228 and later version
+// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are "not defined" in R9 codebase.
+//
+#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB)
+#include "EfiDepex.h"
+#include EFI_PROTOCOL_DEFINITION (CpuPlatformPolicy)
+#include EFI_PROTOCOL_CONSUMER (TcgService)
+#endif
+
+DEPENDENCY_START
+ EFI_TCG_PROTOCOL_GUID AND
+ DXE_CPU_PLATFORM_POLICY_PROTOCOL_GUID
+DEPENDENCY_END
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.h b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.h
new file mode 100644
index 0000000..5722d40
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.h
@@ -0,0 +1,158 @@
+/** @file
+
+@copyright
+ Copyright (c) 1999 - 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
+**/
+#ifndef _TXT_ONE_TOUCH_DXE_H_
+#define _TXT_ONE_TOUCH_DXE_H_
+
+///
+/// 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 EFI_GUID_DEFINITION (TxtOneTouch)
+#include EFI_PROTOCOL_DEFINITION (TxtOneTouchOp)
+#include EFI_PROTOCOL_DEFINITION (PchReset)
+#include EFI_PROTOCOL_CONSUMER (TcgService)
+#endif
+
+#define H2NL(x) (H2NS ((x) >> 16) | (H2NS ((x) & 0xffff) << 16))
+#define H2NS(x) ((((x) << 8) | ((x) >> 8)) & 0xffff)
+#define TPM_PP_USER_ABORT ((TPM_RESULT) (-0x10))
+#define TPM_PP_BIOS_FAILURE ((TPM_RESULT) (-0x0f))
+
+///
+/// TPM PPI Commands
+///
+#define ENABLE 1
+#define ACTIVATE 3
+#define ENABLE_ACTIVATE 6
+#define DISABLE_DEACTIVATE 7
+
+///
+/// Definitions
+///
+#define TXT_ONE_TOUCH_VAR L"TxtOneTouch"
+#pragma pack(push, 1)
+typedef struct {
+ BOOLEAN NoTxtMaintenance;
+ BOOLEAN TpmEnable;
+ BOOLEAN TpmActive;
+ BOOLEAN VtEnable;
+ BOOLEAN VtdEnable;
+ BOOLEAN TxtEnable;
+ BOOLEAN StmEnable;
+ BOOLEAN VmxEnable;
+ BOOLEAN VmxInSmxEnable;
+ BOOLEAN VmxOutsideSmxEnable;
+ BOOLEAN SenterEnable;
+} TXT_ONE_TOUCH_SETUP;
+#pragma pack(pop)
+
+/**
+ Extend PPI operation for TxT.
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+
+ @retval EFI_SUCCESS - Execute the Command successful
+ @retval EFI_UNSUPPORTED - Command is not supported
+**/
+EFI_STATUS
+EFIAPI
+TxtExecOperation (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command
+ );
+
+/**
+ Confirmation dialog for TxT PPI
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+ @param[in] Confirm - User confirm
+
+ @retval EFI_SUCCESS - Execute the Command successful
+ @retval EFI_UNSUPPORTED - Command is not supported
+**/
+EFI_STATUS
+EFIAPI
+TxtConfirmationDialog (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command,
+ IN OUT BOOLEAN *Confirm
+ );
+
+/**
+ Reset system.
+
+ @param[in] This - Point of TXT_ONE_TOUCH_OP_PROTOCOL
+ @param[in] Command - Operation value for TxT
+
+ @retval EFI_SUCCESS - Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TxtResetState (
+ IN TXT_ONE_TOUCH_OP_PROTOCOL *This,
+ IN UINT8 Command
+ );
+
+/**
+ Enable/Active TPM
+
+ @param[in] Command - The operation code for TxT One Touch function
+
+ @retval EFI_SUCCESS - TPM command lunch success
+ @retval EFI_UNSUPPORTED - The Command is not supported
+ @retval EFI_DEVICE_ERROR - Faile to lunch TPM command
+**/
+EFI_STATUS
+TpmEnableActive (
+ IN UINT8 Command
+ );
+
+/**
+ Read/Write variable for enable/disable TxT one
+ touch functions
+
+ @param[in] VariableData - Point to Setup variable buffer
+ @param[in] WriteData - TRUE, write changes to Setup Variable. FALSE, not to write variable.
+
+ @retval EFI_SUCCESS - Operation complete successful
+ @retval EFI_INVALID_PARAMETER - VariableData is NULL
+**/
+EFI_STATUS
+ReadWriteVariable (
+ IN OUT TXT_ONE_TOUCH_SETUP *VariableData,
+ IN BOOLEAN WriteData
+ );
+
+/**
+ Verify the status of Chipset capaibility and Setup settings
+
+ @param[in] Data - Point to TXT_ONE_TOUCH_SETUP
+
+ @exception EFI_UNSUPPORTED - The system is not able to lunch TxT
+ @retval EFI_SUCCESS - The system is able to lunch TxT
+**/
+EFI_STATUS
+ValidateTxtStates (
+ IN TXT_ONE_TOUCH_SETUP *Data
+ );
+
+#endif
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.inf b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.inf
new file mode 100644
index 0000000..5a7038b
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.inf
@@ -0,0 +1,113 @@
+## @file
+# Component description file for TXTDXE module
+#
+#@copyright
+# Copyright (c) 1999 - 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 = TxtOneTouchDxe
+FILE_GUID = 67791e00-0c05-4ae7-a921-fc4057221653
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ TxtOneTouchDxe.c
+ TxtOneTouchOp.c
+ TxtOneTouchDxe.h
+
+#
+# Edk II Glue Driver Entry Point
+#
+ EdkIIGlueDxeDriverEntryPoint.c
+
+[includes.common]
+ .
+ $(EFI_SOURCE)/$(PROJECT_CPU_ROOT)
+ $(EFI_SOURCE)/$(PROJECT_CPU_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include
+ $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation/Framework
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Framework/Include
+ $(EDK_SOURCE)/Foundation/Framework/Protocol
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Sample/Include
+ $(EDK_SOURCE)/Foundation/Cpu/Pentium/Include
+
+#
+# Edk II Glue Library, some hearder are included by R9 header so have to include
+#
+
+ $(EFI_SOURCE)
+ $(EFI_SOURCE)/Framework
+ $(EDK_SOURCE)/Foundation
+ $(EDK_SOURCE)/Foundation/Framework
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(EDK_SOURCE)/Foundation/Include/Pei
+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/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_CPU_ROOT)/SampleCode
+
+[libraries.common]
+ EfiGuidLib
+ EdkFrameworkProtocolLib
+ EdkProtocolLib
+ EfiScriptLib
+ CpuGuidLib
+ CpuProtocolLib
+ $(PROJECT_PCH_FAMILY)ProtocolLib
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueDxeReportStatusCodeLib
+ EdkIIGlueDxeServicesTableLib
+ EdkIIGlueDxeDebugLibReportStatusCode
+ EdkIIGlueUefiBootServicesTableLib
+ EdkIIGlueUefiRuntimeServicesTableLib
+ EdkIIGlueUefiLib
+ EdkIIGlueDxeHobLib
+#
+# 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.
+#
+ CpuSampleProtocolLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT = _ModuleEntryPoint
+ DPX_SOURCE = TxtOneTouchDxe.dxs
+#
+# Module Entry Point
+#
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=DriverEntry
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_BASE_LIB__ \
+ -D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ -D __EDKII_GLUE_DXE_SERVICES_TABLE_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__
+ C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_UEFI_LIB__ \
+ -D __EDKII_GLUE_DXE_HOB_LIB__
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.mak b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.mak
new file mode 100644
index 0000000..7481ab7
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.mak
@@ -0,0 +1,88 @@
+#/*++
+#Copyright (c) 2009 - 2011 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.
+#
+#Module Name:
+#
+# TxtPolicyInitDxeLib.mak
+#
+#Abstract:
+#
+# Make file for the TxtPolicyInitDxeLib component
+#
+#--*/
+all : TxtOneTouchDxe
+
+TxtOneTouchDxe : $(BUILD_DIR)\TxtOneTouchDxe.mak TxtOneTouchDxeBin
+
+$(BUILD_DIR)\TxtOneTouchDxe.mak : $(TxtOneTouchDxe_DIR)\$(@B).cif $(TxtOneTouchDxe_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TxtOneTouchDxe_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+TxtOneTouchDxeIncludes=\
+ $(MISCFRAMEWORK_INCLUDES)\
+ $(EdkIIGlueLib_INCLUDES)\
+ /I$(INTEL_PCH_DIR)\
+ $(PROJECT_CPU_INCLUDES)\
+ $(TXT_INCLUDES)\
+
+TxtOneTouchDxeDefines=\
+ $(MY_DEFINES)\
+ /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=DriverEntry"\
+ /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \
+ /D __EDKII_GLUE_BASE_LIB__ \
+ /D __EDKII_GLUE_BASE_MEMORY_LIB__ \
+ /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \
+ /D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \
+ /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \
+ /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \
+ /D __EDKII_GLUE_UEFI_LIB__ \
+ /D __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__ \
+ /D __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__ \
+ /D __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__ \
+ /D __EDKII_GLUE_DXE_HOB_LIB__ \
+
+TxtOneTouchDxeLibs=\
+ $(EFIGUIDLIB)\
+ $(EDKFRAMEWORKPROTOCOLLIB)\
+ $(EDKPROTOCOLLIB)\
+ $(EdkIIGlueBaseIoLibIntrinsic_LIB)\
+ $(EdkIIGlueBaseLib_LIB)\
+ $(EdkIIGlueBaseMemoryLib_LIB)\
+ $(EdkIIGlueDxeReportStatusCodeLib_LIB)\
+ $(EdkIIGlueDxeServicesTableLib_LIB)\
+ $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\
+ $(EdkIIGlueUefiBootServicesTableLib_LIB)\
+ $(EdkIIGlueUefiLib_LIB)\
+ $(EdkIIGlueBasePciLibPciExpress_LIB)\
+ $(EdkIIGlueDxeMemoryAllocationLib_LIB)\
+ $(EdkIIGlueBaseTimerLibLocalApic_LIB)\
+ $(EdkIIGlueDxeHobLib_LIB)\
+ $(EdkIIGlueHiiLib_LIB)\
+ $(EFIDRIVERLIB)\
+ $(UEFIEFIIFRSUPPORTLIB)\
+ $(EFISCRIPTLIB)\
+ $(CpuProtocolLib_LIB)\
+ $(CpuGuidLib_LIB)\
+ $(CPUIA32LIB)\
+ $(CpuSampleCodeProtocolLib_LIB)\
+ $(INTEL_PCH_PROTOCOL_LIB)
+
+TxtOneTouchDxeBin : $(TxtOneTouchDxeLibs)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ /f $(BUILD_DIR)\TxtOneTouchDxe.mak all\
+ "MY_INCLUDES=$(TxtOneTouchDxeIncludes)"\
+ "MY_DEFINES=$(TxtOneTouchDxeDefines)"\
+ "GUID=67791e00-0c05-4ae7-a921-fc4057221653"\
+ "AFLAGS=$(AFLAGS) $(TxtOneTouchDxeIncludes)"\
+ ENTRY_POINT=_ModuleEntryPoint \
+ TYPE=BS_DRIVER \
+ EDKIIModule=DXEDRIVER\
+ DEPEX1=$(TxtOneTouchDxe_DIR)\TxtOneTouchDxe.dxs\
+ DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX\
+ COMPRESS=1\
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.sdl b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.sdl
new file mode 100644
index 0000000..541ccf4
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchDxe.sdl
@@ -0,0 +1,28 @@
+TOKEN
+ Name = "TxtOneTouchSupport"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Help = "Main switch"
+End
+
+MODULE
+ Help = "Includes TxtOneTouchDxe.mak into project"
+ File = "TxtOneTouchDxe.mak"
+End
+
+PATH
+ Name = "TxtOneTouchDxe_DIR"
+ Help = "TxT DXE Policy Init directory"
+End
+
+
+ELINK
+ Name = "$(BUILD_DIR)\TxtOneTouchDxe.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
diff --git a/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchOp.c b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchOp.c
new file mode 100644
index 0000000..860e90d
--- /dev/null
+++ b/ReferenceCode/Haswell/SampleCode/TxtOneTouch/Dxe/TxtOneTouchOp.c
@@ -0,0 +1,178 @@
+/** @file
+
+@copyright
+ Copyright (c) 1999 - 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
+**/
+#include "TxtOneTouchDxe.h"
+#include "Tpm12.h"
+#include "CpuIa32.h"
+
+extern EFI_TCG_PROTOCOL *mTcgProtocol;
+
+/**
+ Execute TPM command
+
+ @param[in] TcgProtocol - Point to EFI_TCG_PROTOCOL
+ @param[in] Ordinal - TPM Command code
+ @param[in] AdditionalParameterSize - Size of additional parameters
+ @param[in] AdditionalParameters - Point to the buffer saves additional parameters
+
+ @retval EFI_SUCCESS - TPM command lunch success
+ @retval TPM_PP_BIOS_FAILURE - BIOS fail to execute TPM command
+**/
+TPM_RESULT
+TpmCommandNoReturnData (
+ IN EFI_TCG_PROTOCOL *TcgProtocol,
+ IN TPM_COMMAND_CODE Ordinal,
+ IN UINTN AdditionalParameterSize,
+ IN VOID *AdditionalParameters
+ )
+{
+ EFI_STATUS Status;
+ TPM_RQU_COMMAND_HDR *TpmRqu;
+ TPM_RSP_COMMAND_HDR TpmRsp;
+ UINT32 Size;
+
+ TpmRqu = (TPM_RQU_COMMAND_HDR *) AllocatePool (sizeof (*TpmRqu) + AdditionalParameterSize);
+ if (TpmRqu == NULL) {
+ return TPM_PP_BIOS_FAILURE;
+ }
+
+ TpmRqu->tag = H2NS (TPM_TAG_RQU_COMMAND);
+ Size = (UINT32) (sizeof (*TpmRqu) + AdditionalParameterSize);
+ TpmRqu->paramSize = H2NL (Size);
+ TpmRqu->ordinal = H2NL (Ordinal);
+ CopyMem (TpmRqu + 1, AdditionalParameters, AdditionalParameterSize);
+
+ Status = TcgProtocol->PassThroughToTpm (
+ TcgProtocol,
+ Size,
+ (UINT8 *) TpmRqu,
+ (UINT32) sizeof (TpmRsp),
+ (UINT8 *) &TpmRsp
+ );
+ FreePool (TpmRqu);
+ if (EFI_ERROR (Status) || (TpmRsp.tag != H2NS (TPM_TAG_RSP_COMMAND))) {
+ return TPM_PP_BIOS_FAILURE;
+ }
+
+ return H2NL (TpmRsp.returnCode);
+}
+
+/**
+ Enable/Active TPM
+
+ @param[in] Command - The operation code for TxT One Touch function
+
+ @retval EFI_SUCCESS - TPM command lunch success
+ @retval EFI_UNSUPPORTED - The Command is not supported
+ @retval EFI_DEVICE_ERROR - Faile to lunch TPM command
+**/
+EFI_STATUS
+TpmEnableActive (
+ IN UINT8 Command
+ )
+{
+ TPM_RESULT TpmResponse;
+ EFI_STATUS Status;
+ BOOLEAN BoolVal;
+
+ BoolVal = FALSE;
+ TpmResponse = 0;
+ Status = EFI_SUCCESS;
+
+ switch (Command) {
+ case ENABLE:
+ TpmResponse = TpmCommandNoReturnData (
+ mTcgProtocol,
+ TPM_ORD_PhysicalEnable,
+ 0,
+ NULL
+ );
+ break;
+
+ case ACTIVATE:
+ BoolVal = FALSE;
+ TpmResponse = TpmCommandNoReturnData (
+ mTcgProtocol,
+ TPM_ORD_PhysicalSetDeactivated,
+ sizeof (BoolVal),
+ &BoolVal
+ );
+ break;
+
+ case ENABLE_ACTIVATE:
+ Status = TpmEnableActive (ENABLE);
+ if (Status == EFI_SUCCESS) {
+ Status = TpmEnableActive (ACTIVATE);
+ }
+
+ return Status;
+
+ default:
+ Status = EFI_UNSUPPORTED;
+ break;
+ }
+
+ if (TpmResponse != 0) {
+ Status = EFI_DEVICE_ERROR;
+ }
+
+ return Status;
+}
+
+/**
+ Verify the status of Chipset capaibility and Setup settings
+
+ @param[in] Data - Point to TXT_ONE_TOUCH_SETUP
+
+ @exception EFI_UNSUPPORTED - The system is not able to lunch TxT
+ @retval EFI_SUCCESS - The system is able to lunch TxT
+**/
+EFI_STATUS
+ValidateTxtStates (
+ IN TXT_ONE_TOUCH_SETUP *Data
+ )
+{
+ EFI_CPUID_REGISTER CpuidRegs;
+
+ AsmCpuid (
+ 1,
+ &CpuidRegs.RegEax,
+ &CpuidRegs.RegEbx,
+ &CpuidRegs.RegEcx,
+ &CpuidRegs.RegEdx
+ );
+
+ if (Data->VtEnable) {
+ ///
+ /// Check if VMX supported
+ ///
+ if ((CpuidRegs.RegEcx & 0x020) == 0) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ if (Data->TxtEnable) {
+ ///
+ /// Check if TxT & VMX supported
+ ///
+ if ((CpuidRegs.RegEcx & 0x060) == 0) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ return EFI_SUCCESS;
+}