3 Routines that support SIMPLE_TEXT_IN protocol
5 Copyright (c) 2006 - 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "Ps2Keyboard.h"
20 // function declarations
25 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
26 IN BOOLEAN ExtendedVerification
31 KeyboardReadKeyStroke (
32 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
33 OUT EFI_INPUT_KEY
*Key
45 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
51 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
52 IN BOOLEAN ExtendedVerification
58 Implement SIMPLE_TEXT_IN.Reset()
59 Perform 8042 controller and keyboard initialization
66 // GC_TODO: This - add argument and description to function comment
67 // GC_TODO: ExtendedVerification - add argument and description to function comment
68 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
69 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
70 // GC_TODO: EFI_SUCCESS - add return value to function comment
73 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
76 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
77 if (ConsoleIn
->KeyboardErr
) {
78 return EFI_DEVICE_ERROR
;
81 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
83 EFI_PERIPHERAL_KEYBOARD
| EFI_P_PC_RESET
,
88 // Enter critical section
90 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
93 // Call InitKeyboard to initialize the keyboard
95 Status
= InitKeyboard (ConsoleIn
, ExtendedVerification
);
96 if (EFI_ERROR (Status
)) {
98 // Leave critical section and return
100 gBS
->RestoreTPL (OldTpl
);
101 return EFI_DEVICE_ERROR
;
104 // Clear the status of ConsoleIn.Key
106 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
107 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
110 // Leave critical section and return
112 gBS
->RestoreTPL (OldTpl
);
115 // Report the status If a stuck key was detected
117 if (KeyReadStatusRegister (ConsoleIn
) & 0x01) {
118 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
119 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
120 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_STUCK_KEY
,
121 ConsoleIn
->DevicePath
125 // Report the status If keyboard is locked
127 if (!(KeyReadStatusRegister (ConsoleIn
) & 0x10)) {
128 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
129 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
130 EFI_PERIPHERAL_KEYBOARD
| EFI_P_KEYBOARD_EC_LOCKED
,
131 ConsoleIn
->DevicePath
140 KeyboardReadKeyStroke (
141 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
142 OUT EFI_INPUT_KEY
*Key
148 Implement SIMPLE_TEXT_IN.ReadKeyStroke().
149 Retrieve key values for driver user.
156 // GC_TODO: This - add argument and description to function comment
157 // GC_TODO: Key - add argument and description to function comment
158 // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment
159 // GC_TODO: EFI_NOT_READY - add return value to function comment
160 // GC_TODO: EFI_SUCCESS - add return value to function comment
163 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
166 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
169 // Enter critical section
171 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
173 if (ConsoleIn
->KeyboardErr
) {
175 // Leave critical section and return
177 gBS
->RestoreTPL (OldTpl
);
179 return EFI_DEVICE_ERROR
;
182 // If there's no key, just return
184 Status
= KeyboardCheckForKey (This
);
185 if (EFI_ERROR (Status
)) {
187 // Leave critical section and return
189 gBS
->RestoreTPL (OldTpl
);
190 return EFI_NOT_READY
;
193 Key
->ScanCode
= ConsoleIn
->Key
.ScanCode
;
194 Key
->UnicodeChar
= ConsoleIn
->Key
.UnicodeChar
;
196 ConsoleIn
->Key
.ScanCode
= SCAN_NULL
;
197 ConsoleIn
->Key
.UnicodeChar
= 0x0000;
200 // Leave critical section and return
202 gBS
->RestoreTPL (OldTpl
);
217 Event notification function for SIMPLE_TEXT_IN.WaitForKey event
218 Signal the event if there is key available
225 // GC_TODO: Event - add argument and description to function comment
226 // GC_TODO: Context - add argument and description to function comment
229 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
231 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context
);
234 // Enter critical section
236 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
238 if (ConsoleIn
->KeyboardErr
) {
240 // Leave critical section and return
242 gBS
->RestoreTPL (OldTpl
);
246 // Someone is waiting on the keyboard event, if there's
247 // a key pending, signal the event
249 if (!EFI_ERROR (KeyboardCheckForKey (Context
))) {
250 gBS
->SignalEvent (Event
);
253 // Leave critical section and return
255 gBS
->RestoreTPL (OldTpl
);
261 KeyboardCheckForKey (
262 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
268 GC_TODO: Add function description
272 This - GC_TODO: add argument description
276 EFI_SUCCESS - GC_TODO: Add description for return value
280 KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
;
282 ConsoleIn
= KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This
);
285 // If ready to read next key, check it
287 if (ConsoleIn
->Key
.ScanCode
== SCAN_NULL
&& ConsoleIn
->Key
.UnicodeChar
== 0x00) {
288 return KeyGetchar (ConsoleIn
);