3 Copyright (c) 2006, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
20 Routines that support SIMPLE_TEXT_IN protocol
27 // Include common header file for this module.
29 #include "CommonHeader.h"
31 #include "Ps2Keyboard.h"
34 // function declarations
39 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
40 IN BOOLEAN ExtendedVerification
45 KeyboardReadKeyStroke (
46 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
47 OUT EFI_INPUT_KEY
*Key
59 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
65 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
66 IN BOOLEAN ExtendedVerification
72 Implement SIMPLE_TEXT_IN.Reset()
73 Perform 8042 controller and keyboard initialization
80 // GC_TODO: This - add argument and description to function comment
81 // GC_TODO: ExtendedVerification - add argument and description to function comment
82 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
83 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
84 // GC_TODO: EFI_SUCCESS - add return value to function comment
87 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
90 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
91 if (ConsoleIn
->KeyboardErr
) {
92 return EFI_DEVICE_ERROR
;
95 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
97 EFI_PERIPHERAL_KEYBOARD
| EFI_P_PC_RESET
,
102 // Enter critical section
104 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
107 // Call InitKeyboard to initialize the keyboard
109 Status
= InitKeyboard (ConsoleIn
, ExtendedVerification
);
110 if (EFI_ERROR (Status
)) {
112 // Leave critical section and return
114 gBS
->RestoreTPL (OldTpl
);
115 return EFI_DEVICE_ERROR
;
118 // Clear the status of ConsoleIn.Key
120 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
121 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
124 // Leave critical section and return
126 gBS
->RestoreTPL (OldTpl
);
129 // Report the status If a stuck key was detected
131 if (KeyReadStatusRegister (ConsoleIn
) & 0x01) {
132 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
133 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
134 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_STUCK_KEY
,
135 ConsoleIn
->DevicePath
139 // Report the status If keyboard is locked
141 if (!(KeyReadStatusRegister (ConsoleIn
) & 0x10)) {
142 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
143 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
144 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_LOCKED
,
145 ConsoleIn
->DevicePath
154 KeyboardReadKeyStroke (
155 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
156 OUT EFI_INPUT_KEY
*Key
162 Implement SIMPLE_TEXT_IN.ReadKeyStroke().
163 Retrieve key values for driver user.
170 // GC_TODO: This - add argument and description to function comment
171 // GC_TODO: Key - add argument and description to function comment
172 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
173 // GC_TODO: EFI_NOT_READY - add return value to function comment
174 // GC_TODO: EFI_SUCCESS - add return value to function comment
177 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
180 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
183 // Enter critical section
185 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
187 if (ConsoleIn
->KeyboardErr
) {
189 // Leave critical section and return
191 gBS
->RestoreTPL (OldTpl
);
193 return EFI_DEVICE_ERROR
;
196 // If there's no key, just return
198 Status
= KeyboardCheckForKey (This
);
199 if (EFI_ERROR (Status
)) {
201 // Leave critical section and return
203 gBS
->RestoreTPL (OldTpl
);
204 return EFI_NOT_READY
;
207 Key
->ScanCode
= ConsoleIn
->Key
.ScanCode
;
208 Key
->UnicodeChar
= ConsoleIn
->Key
.UnicodeChar
;
210 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
211 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
214 // Leave critical section and return
216 gBS
->RestoreTPL (OldTpl
);
231 Event notification function for SIMPLE_TEXT_IN.WaitForKey event
232 Signal the event if there is key available
239 // GC_TODO: Event - add argument and description to function comment
240 // GC_TODO: Context - add argument and description to function comment
243 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
245 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context
);
248 // Enter critical section
250 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
252 if (ConsoleIn
->KeyboardErr
) {
254 // Leave critical section and return
256 gBS
->RestoreTPL (OldTpl
);
260 // Someone is waiting on the keyboard event, if there's
261 // a key pending, signal the event
263 if (!EFI_ERROR (KeyboardCheckForKey (Context
))) {
264 gBS
->SignalEvent (Event
);
267 // Leave critical section and return
269 gBS
->RestoreTPL (OldTpl
);
275 KeyboardCheckForKey (
276 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
282 GC_TODO: Add function description
286 This - GC_TODO: add argument description
290 EFI_SUCCESS - GC_TODO: Add description for return value
294 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
296 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
299 // If ready to read next key, check it
301 if (ConsoleIn
->Key
.ScanCode
== SCAN_NULL
&& ConsoleIn
->Key
.UnicodeChar
== 0x00) {
302 return KeyGetchar (ConsoleIn
);