summaryrefslogtreecommitdiff
path: root/Board/CPU/TxtDxe/TxtSetup.c
blob: 256571471fee32b7374e593fa068bdcc0f90b82b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1987-2013, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/Haswell/AMI Cpu PKG/AMI TXT DXE/TxtSetup.c 2     10/14/12 11:49p Davidhsieh $
//
// $Revision: 2 $
//
// $Date: 10/14/12 11:49p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/Haswell/AMI Cpu PKG/AMI TXT DXE/TxtSetup.c $
// 
// 2     10/14/12 11:49p Davidhsieh
// [TAG]  		None
// [Category]  	Improvement
// [Description]  	Use SBLib_ExtResetSystem when pRS->ResetSystem does not
// support GlobaRest type in the project
// 
// 1     8/14/12 5:05a Davidhsieh
// [TAG]  		EIP97190
// [Category]  	Improvement
// [Description]  	Changes in TXT Configuration require a Powercycle reset
// 
//
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:    TXTSetup.c
//
// Description:
//
//<AMI_FHDR_END>
//**********************************************************************
//----------------------------------------------------------------------------
// Includes
#include <AmiLib.h>
#include <AmiDxeLib.h>
#include <Setup.h>
#include <AmiCspLib.h>
#include <SetupStrTokens.h>

#pragma pack (1)
typedef struct {
	UINT8	SMXSupport;
} SETUP_TXT_FEATURES;
#pragma pack ()

//----------------------------------------------------------------------------
// Local Variables

//----------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   TxtExitSetupEvent
//
// Description: This routine for calling global reset if necessary.
//
// Input:       EFI_EVENT   - Efi event.
//              VOID*       - Image handle.
//
// Output:      None.
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
typedef enum {
  mColdReset,
  mWarmReset,
  mShutdownReset,
  mPowerCycleReset,
  mGlobalReset,
  mGlobalResetWithEc
} PCH_RESET_TYPE;

EFI_STATUS
TxtExitSetupEvent  (VOID)
{
    EFI_STATUS          Status;
    SETUP_DATA          SetupData;
    UINTN               VariableSize;
    EFI_GUID            SetupGuid = SETUP_GUID;
    // Get current Setup Data.
    VariableSize = sizeof(SETUP_DATA);
    Status = pRS->GetVariable ( L"Setup", \
                                &SetupGuid, \
                                NULL, \
                                &VariableSize, \
                                &SetupData );
    if (EFI_ERROR(Status)) return (Status);

    if ( SetupData.TxtSupport != 0 ) {
        // Generate Global Reset System if TXT is enabled w/o SMX enabled 
        if ((UINT16)(ReadMsr(0x3A) & 0xFF03) == 0xFF03) return EFI_SUCCESS; 
    } else { 
        // Generate Global Reset System if TXT is disabled with SMX enabled.
        if ((UINT16)(ReadMsr(0x3A) & 0xFF03) != 0xFF03) return EFI_SUCCESS; 
    }
    // PlatformResetSystem() of ReferenceCode\ME\..\PlatformReset.c
#if defined(RESET_RUNTIME_SERVICES_SUPPORT) && (RESET_RUNTIME_SERVICES_SUPPORT == 0)
    pRS->ResetSystem (mGlobalReset, EFI_SUCCESS, 0, NULL);
#else
    SBLib_ExtResetSystem (SbResetGlobal);
#endif
    EFI_DEADLOOP()
    return EFI_SUCCESS;
}

//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1987-2013, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************