summaryrefslogtreecommitdiff
path: root/Core/EM/AMITSE/Keymon.c
blob: 94904a066f9c3359c5fbab0453c7463d1a64d8a0 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
//**                                                             **//
//**         (C)Copyright 2010, American Megatrends, Inc.        **//
//**                                                             **//
//**                     All Rights Reserved.                    **//
//**                                                             **//
//**   5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093  **//
//**                                                             **//
//**                     Phone (770)-246-8600                    **//
//**                                                             **//
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
// $Archive: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/Keymon.c $
//
// $Author: Premkumara $
//
// $Revision: 7 $
//
// $Date: 8/28/14 4:29a $
//
//*****************************************************************//
//*****************************************************************//
// Revision History
// ----------------
// $Log: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/Keymon.c $
// 
// 7     8/28/14 4:29a Premkumara
// EIP-135253 Updating file name proper in #include
// 
// 6     10/18/12 5:31a Arunsb
// Updated for 2.16.1235 QA submission
// 
// 6     10/10/12 12:23p Arunsb
// Synched the source for v2.16.1232 backup with Aptio
// 
// 5     11/04/11 4:37a Arunsb
// [TAG]  		EIP67615
// [Category]  	Bug Fix
// [Severity]  	Normal
// [Symptom]  	Keyattribute support doesn't work in AMITSE Keymon support
// [RootCause]  	{SETUP_ENTRY_LEGACY_CODE,0} - This initilization code
// initilize only ScanCode and ShiftKey.
// It doesn't initilize the AltKey, CtrlKey etc ( Other fields in the
// KEY_ATTRIBUTE structure).
// [Solution]  	Modified the initilization like
// {SETUP_ENTRY_LEGACY_CODE,{0,0,0,0}}
// [Files]  		keymon.c
// 
// 4     2/19/10 12:58p Madhans
// Updated for TSE 2.01. Refer Changelog.log for File change history.
// 
// 4     2/19/10 7:59a Mallikarjunanv
// updated the year in copyright message
// 
// 3     7/14/09 6:32p Blaines
// For GTSE first Release.,
// 
// 2     6/24/09 6:33p Madhans
// Coding Standards
// 
// 1     6/04/09 7:49p Madhans
// AMI TSE Advanced.
// 
// 1     4/28/09 10:49p Madhans
// Tse 2.0 Code complete Checkin.
// 
// 1     4/28/09 10:24p Madhans
// Tse 2.0 Code complete Checkin.
// 
// 3     10/03/08 12:40p Madhans
// Update the changes provided by the core team
// 
// 2     7/18/07 7:58a Arunkumars
// clean up
// 
// 1     7/09/07 1:18p Arunkumars
// - Added elink hooks for Logo, Password management and Control Keys
// customizations
//
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
//<AMI_FHDR_START>
//
// Name:		Keymon.c
//
// Description:	Contains key monitoring functions.
//
//<AMI_FHDR_END>
//**********************************************************************

#ifdef TSE_FOR_APTIO_4_50

#include "Token.h"
#include <Efi.h>

#else //#ifdef TSE_FOR_APTIO_4_50

#include "minisetup.h"

#endif //#ifdef TSE_FOR_APTIO_4_50

#if SETUP_SUPPORT_KEY_MONITORING

#include <Protocol\KeyMonPlatform.h>
#include <Protocol\MonitorKeyFilter.h>

#include "KeyMon.h"


EFI_STATUS
GetPlatformMonitorKeyOptions(
  IN   EFI_KEYMON_PLATFORM_PROTOCOL *This,
  OUT  KEY_ELEMENT                    **KeyList,
  OUT  UINTN                          *KeyListSize
  );

static EFI_GUID EfiKeyMonPlatformProtocolGuid = EFI_KEYMON_PLATFORM_PROTOCOL_GUID;

static EFI_KEYMON_PLATFORM_PROTOCOL gKeyMonPlatformProtocol =
{
    GetPlatformMonitorKeyOptions
};

enum SETUP_KEYS
{
    SK_EntryKey
#if SETUP_ALT_ENTRY_ENABLE
    ,SK_AltEntryKey
#endif
#if SETUP_BBS_POPUP_ENABLE
    ,SK_PopupBootEntryKey
#endif
#if SETUP_OEM_KEY1_ENABLE
    ,SK_OemKey1
#endif
#if SETUP_OEM_KEY2_ENABLE
    ,SK_OemKey2
#endif
#if SETUP_OEM_KEY3_ENABLE
    ,SK_OemKey3
#endif
#if SETUP_OEM_KEY4_ENABLE
    ,SK_OemKey4
#endif
};

KEY_ELEMENT gLegacyKeyTable[]=
{
    {SETUP_ENTRY_LEGACY_CODE,{0,0,0,0}}
#if SETUP_ALT_ENTRY_ENABLE
    ,{SETUP_ALT_ENTRY_LEGACY_CODE,{0,0,0,0}}
#endif
#if SETUP_BBS_POPUP_ENABLE
    ,{POPUP_MENU_ENTRY_LEGACY_CODE,{0,0,0,0}}
#endif
#if SETUP_OEM_KEY1_ENABLE
    ,{SETUP_OEM_KEY1_LEGACY_CODE,{0,0,0,0}}
#endif
#if SETUP_OEM_KEY2_ENABLE
    ,{SETUP_OEM_KEY2_LEGACY_CODE,{0,0,0,0}}
#endif
#if SETUP_OEM_KEY3_ENABLE
    ,{SETUP_OEM_KEY3_LEGACY_CODE,{0,0,0,0}}
#endif
#if SETUP_OEM_KEY4_ENABLE
    ,{SETUP_OEM_KEY4_LEGACY_CODE,{0,0,0,0}}
#endif
};

UINT32 gLegacyKeys;
EFI_HANDLE KeyMonProtocolHandle;

extern EFI_BOOT_SERVICES *gBS;

VOID InstallKeyMonProtocol(VOID)
{
    gBS->InstallProtocolInterface(
                        &KeyMonProtocolHandle,
                        &EfiKeyMonPlatformProtocolGuid,
                        EFI_NATIVE_INTERFACE,
                        &gKeyMonPlatformProtocol
                        );
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	GetPlatformMonitorKeyOptions
//
// Description:	This function registers keys with key monitor driver
//              for monitoring in the legacy mode.
//
// Input:		EFI_USB_LEGACY_PLATFORM_PROTOCOL *This
//              KEY_ELEMENT **KeyList: List of keys to be monitored.
//              UINTN *KeyListSize: Size of data returned in KeyList.
//
// Output:		Return Status based on errors that occurred in library
//              functions.
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS
GetPlatformMonitorKeyOptions(
  IN   EFI_KEYMON_PLATFORM_PROTOCOL   *This,
  OUT  KEY_ELEMENT                    **KeyList,
  OUT  UINTN                          *KeyListSize
  )
{
    *KeyList = gLegacyKeyTable;
    *KeyListSize = sizeof(gLegacyKeyTable);

    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	GetKeysFromKeyMonFilter
//
// Description:	This function receives keys from key monitor filter
//
// Input:		VOID
//
// Output:		VOID
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID GetKeysFromKeyMonFilter(VOID)
{
    UINT32  KeyDetected;
	EFI_MONITOR_KEY_FILTER_PROTOCOL *MonKey;
    EFI_STATUS  Status;
    EFI_GUID EfiMonitorKeyFilterProtocolGuid = EFI_MONITOR_KEY_FILTER_PROTOCOL_GUID;

    // Locate protocols
	Status = gBS->LocateProtocol (
					&EfiMonitorKeyFilterProtocolGuid,
					NULL, &MonKey);
    if ( !(EFI_ERROR(Status)) )
    {
        MonKey->GetMonitoredKeys(MonKey, &KeyDetected);

        if(KeyDetected & (1 << SK_EntryKey))
        {
            gLegacyKeys|=SETUP_ENTRY_KEY_BIT;
        }
#if SETUP_ALT_ENTRY_ENABLE
        if(KeyDetected & (1 << SK_AltEntryKey))
        {
            gLegacyKeys|=SETUP_ENTRY_KEY_BIT;
        }
#endif
#if SETUP_BBS_POPUP_ENABLE
        if(KeyDetected & (1 << SK_PopupBootEntryKey))
        {
            gLegacyKeys|=POPUP_ENTRY_KEY_BIT;
        }
#endif
#if SETUP_OEM_KEY1_ENABLE
        if(KeyDetected & (1 << SK_OemKey1))
        {
            gLegacyKeys|=OEM_KEY1_BIT;
        }
#endif
#if SETUP_OEM_KEY2_ENABLE
        if(KeyDetected & (1 << SK_OemKey2))
        {
            gLegacyKeys|=OEM_KEY2_BIT;
        }
#endif
#if SETUP_OEM_KEY3_ENABLE
        if(KeyDetected & (1 << SK_OemKey3))
        {
            gLegacyKeys|=OEM_KEY3_BIT;
        }
#endif
#if SETUP_OEM_KEY4_ENABLE
        if(KeyDetected & (1 << SK_OemKey4))
        {
            gLegacyKeys|=OEM_KEY4_BIT;
        }
#endif

    }
}

#endif
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**     5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************