3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Routines that support SIMPLE_TEXT_IN protocol
25 #include "Ps2Keyboard.h"
28 // function declarations
33 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
34 IN BOOLEAN ExtendedVerification
39 KeyboardReadKeyStroke (
40 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
41 OUT EFI_INPUT_KEY
*Key
53 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
59 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
60 IN BOOLEAN ExtendedVerification
66 Implement SIMPLE_TEXT_IN.Reset()
67 Perform 8042 controller and keyboard initialization
74 // GC_TODO: This - add argument and description to function comment
75 // GC_TODO: ExtendedVerification - add argument and description to function comment
76 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
77 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
78 // GC_TODO: EFI_SUCCESS - add return value to function comment
81 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
84 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
85 if (ConsoleIn
->KeyboardErr
) {
86 return EFI_DEVICE_ERROR
;
89 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
91 EFI_PERIPHERAL_KEYBOARD
| EFI_P_PC_RESET
,
96 // Enter critical section
98 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
101 // Call InitKeyboard to initialize the keyboard
103 Status
= InitKeyboard (ConsoleIn
, ExtendedVerification
);
104 if (EFI_ERROR (Status
)) {
106 // Leave critical section and return
108 gBS
->RestoreTPL (OldTpl
);
109 return EFI_DEVICE_ERROR
;
112 // Clear the status of ConsoleIn.Key
114 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
115 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
118 // Leave critical section and return
120 gBS
->RestoreTPL (OldTpl
);
123 // Report the status If a stuck key was detected
125 if (KeyReadStatusRegister (ConsoleIn
) & 0x01) {
126 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
127 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
128 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_STUCK_KEY
,
129 ConsoleIn
->DevicePath
133 // Report the status If keyboard is locked
135 if (!(KeyReadStatusRegister (ConsoleIn
) & 0x10)) {
136 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
137 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
138 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_LOCKED
,
139 ConsoleIn
->DevicePath
148 KeyboardReadKeyStroke (
149 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
150 OUT EFI_INPUT_KEY
*Key
156 Implement SIMPLE_TEXT_IN.ReadKeyStroke().
157 Retrieve key values for driver user.
164 // GC_TODO: This - add argument and description to function comment
165 // GC_TODO: Key - add argument and description to function comment
166 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
167 // GC_TODO: EFI_NOT_READY - add return value to function comment
168 // GC_TODO: EFI_SUCCESS - add return value to function comment
171 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
174 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
177 // Enter critical section
179 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
181 if (ConsoleIn
->KeyboardErr
) {
183 // Leave critical section and return
185 gBS
->RestoreTPL (OldTpl
);
187 return EFI_DEVICE_ERROR
;
190 // If there's no key, just return
192 Status
= KeyboardCheckForKey (This
);
193 if (EFI_ERROR (Status
)) {
195 // Leave critical section and return
197 gBS
->RestoreTPL (OldTpl
);
198 return EFI_NOT_READY
;
201 Key
->ScanCode
= ConsoleIn
->Key
.ScanCode
;
202 Key
->UnicodeChar
= ConsoleIn
->Key
.UnicodeChar
;
204 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
205 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
208 // Leave critical section and return
210 gBS
->RestoreTPL (OldTpl
);
225 Event notification function for SIMPLE_TEXT_IN.WaitForKey event
226 Signal the event if there is key available
233 // GC_TODO: Event - add argument and description to function comment
234 // GC_TODO: Context - add argument and description to function comment
237 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
239 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context
);
242 // Enter critical section
244 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
246 if (ConsoleIn
->KeyboardErr
) {
248 // Leave critical section and return
250 gBS
->RestoreTPL (OldTpl
);
254 // Someone is waiting on the keyboard event, if there's
255 // a key pending, signal the event
257 if (!EFI_ERROR (KeyboardCheckForKey (Context
))) {
258 gBS
->SignalEvent (Event
);
261 // Leave critical section and return
263 gBS
->RestoreTPL (OldTpl
);
269 KeyboardCheckForKey (
270 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
276 GC_TODO: Add function description
280 This - GC_TODO: add argument description
284 EFI_SUCCESS - GC_TODO: Add description for return value
288 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
290 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
293 // If ready to read next key, check it
295 if (ConsoleIn
->Key
.ScanCode
== SCAN_NULL
&& ConsoleIn
->Key
.UnicodeChar
== 0x00) {
296 return KeyGetchar (ConsoleIn
);