summaryrefslogtreecommitdiff
path: root/Board/CPU/TxtDxe/AmiTxtInfoHook.c
blob: a7fb7bcebe339a8da62b701b03083b133d3fd28e (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1987-2013, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/Projects/Intel/Haswell/LynxPoint_SharkBay-DT_Crb_1AQQW/Board/Cpu/TxtDxe/AmiTxtInfoHook.c 1     7/08/15 4:26a Chienhsieh $
//
// $Revision: 1 $
//
// $Date: 7/08/15 4:26a $
//**********************************************************************
// Revision History
// ----------------
// $Log:
//
//**********************************************************************

//<AMI_FHDR_START>
//---------------------------------------------------------------------------
//
// Name:	AmiTxtInfoHook.c
//
// Description:	AmiTxtInfo Rountines
//
//---------------------------------------------------------------------------
//<AMI_FHDR_END>

#include <Setup.h>
#include <AmiDxeLib.h>
#include <AmiHobs.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/AMIPostMgr.h>
#include "Include/Protocol/AmiTxtInfo.h"

extern EFI_BOOT_SERVICES      *gBS;
extern EFI_SYSTEM_TABLE       *gST;
extern EFI_RUNTIME_SERVICES   *gRT;

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	AmiTxtHook
//
// Description:	Initialize CPU strings.
//
// Input:
//      IN EFI_HII_HANDLE   HiiHandle
//      IN UINT16           Class
//
// Output:
//      VOID
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

BOOLEAN AmiTxtHook  (VOID)
{
    EFI_STATUS  Status;
	EFI_GUID AmiTseSetupguid = AMITSESETUP_GUID;
	EFI_GUID gAmiTxtInfoProtocolGuid    = AMI_TXT_INFO_PROTOCOL_GUID;
	EFI_GUID gAmiPostManagerProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID;
	AMI_POST_MANAGER_PROTOCOL *gAmiPostMgr = NULL;
	AMI_TXT_INFO_PROTOCOL *gAmiTxtInfoProt;
	AMI_TXT_INFO_DATA     *AmiTxtInfoData = NULL;    
	UINTN 		Index;
	EFI_INPUT_KEY 	Key;
	AMITSESETUP TSEVar;
    UINTN       Size;
	CHAR16		Str[30];

	Size = sizeof (AMITSESETUP);

    Status = gRT->GetVariable(L"AMITSESetup", \
                               &AmiTseSetupguid, \
                               NULL, \
                               &Size, \
                               &TSEVar );
	if (EFI_ERROR(Status)) return EFI_SUCCESS;

	Status = pBS->LocateProtocol( &gAmiPostManagerProtocolGuid, NULL, &gAmiPostMgr );
	if (EFI_ERROR(Status)) return EFI_SUCCESS;

	Status = pBS->LocateProtocol (&gAmiTxtInfoProtocolGuid, NULL, &gAmiTxtInfoProt);
	if (EFI_ERROR(Status)) return EFI_SUCCESS;

	//Get AmiTxt info data
	gAmiTxtInfoProt->GetTxtInfo(gAmiTxtInfoProt, &AmiTxtInfoData);

	//Only display txtinfor when error occur
	if (!AmiTxtInfoData->TxtErrCode) return EFI_SUCCESS;

	//If it's silent boot, change to post screen
	if(TSEVar.AMISilentBoot != 0) gAmiPostMgr->SwitchToPostScreen();

	gAmiPostMgr->DisplayPostMessage(L"Intel Txt Information:");

	if (AmiTxtInfoData->ChipsetIsProduction)
		gAmiPostMgr->DisplayPostMessage(L"Chipset Production Fused");
	else
		gAmiPostMgr->DisplayPostMessage(L"Chipset Debug Fused");

	if (AmiTxtInfoData->ChipsetIsTxtCapable)
		gAmiPostMgr->DisplayPostMessage(L"Chipset Txt Supported");
	else
		gAmiPostMgr->DisplayPostMessage(L"Chipset Txt Don't Support");
	
	if (AmiTxtInfoData->CpuIsTxtCapable)   //CPUID eax=1 ecx[6]
		gAmiPostMgr->DisplayPostMessage(L"Cpu Txt Supported");
	else
		gAmiPostMgr->DisplayPostMessage(L"Cpu Txt don't Support");
	
	if (AmiTxtInfoData->TxtErrCode) {
		UINT32 ClassCode = (AmiTxtInfoData->TxtErrCode >> 4) & 0x3f; //ErrorCode[9:4]
		UINT32 MajorCode = (AmiTxtInfoData->TxtErrCode >> 10) & 0x1f; //ErrorCode[14:10]
		UINT32 MinorCode = (AmiTxtInfoData->TxtErrCode >> 16) & 0x1ff; //ErrorCode[24:16]
		
		Swprintf(Str,L"Error Code %x", AmiTxtInfoData->TxtErrCode);
		gAmiPostMgr->DisplayPostMessage(Str);
		
		Swprintf(Str,L"  Class Code %x", ClassCode);
		gAmiPostMgr->DisplayPostMessage(Str);

		Swprintf(Str,L"  Major Code %x", MajorCode);
		gAmiPostMgr->DisplayPostMessage(Str);
		
		Swprintf(Str,L"  Minor Code %x", MinorCode);
		gAmiPostMgr->DisplayPostMessage(Str);
    } else {
		gAmiPostMgr->DisplayPostMessage(L"Error Code None");
		gAmiPostMgr->DisplayPostMessage(L"  Class Code None");
		gAmiPostMgr->DisplayPostMessage(L"  Major Code None");
		gAmiPostMgr->DisplayPostMessage(L"  Minor Code None");
	}

	gAmiPostMgr->DisplayPostMessage(L"Press anykey to continue");

	while(1){
		gBS->WaitForEvent(1, &(gST->ConIn->WaitForKey), &Index);
		gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);
		if((Key.UnicodeChar != 0) || (Key.ScanCode != 0)) break;
	}
					
	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                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************