]>
Commit | Line | Data |
---|---|---|
05fbd06d | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation. All rights reserved. <BR>\r | |
4 | This software and associated documentation (if any) is furnished\r | |
5 | under a license and may only be used or copied in accordance\r | |
6 | with the terms of the license. Except as permitted by such\r | |
7 | license, no part of this software or documentation may be\r | |
8 | reproduced, stored in a retrieval system, or transmitted in any\r | |
9 | form or by any means without the express written consent of\r | |
10 | Intel Corporation.\r | |
11 | \r | |
12 | \r | |
13 | Module Name:\r | |
14 | \r | |
15 | Ps2KbdTextIn.c\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
19 | PS/2 Keyboard driver\r | |
20 | Routines that support SIMPLE_TEXT_IN protocol\r | |
21 | \r | |
22 | Revision History\r | |
23 | \r | |
24 | --*/\r | |
25 | \r | |
26 | //\r | |
27 | // Include common header file for this module.\r | |
28 | //\r | |
29 | #include "CommonHeader.h"\r | |
30 | \r | |
31 | #include "Ps2Keyboard.h"\r | |
32 | \r | |
33 | //\r | |
34 | // function declarations\r | |
35 | //\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | KeyboardEfiReset (\r | |
39 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
40 | IN BOOLEAN ExtendedVerification\r | |
41 | );\r | |
42 | \r | |
43 | EFI_STATUS\r | |
44 | EFIAPI\r | |
45 | KeyboardReadKeyStroke (\r | |
46 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
47 | OUT EFI_INPUT_KEY *Key\r | |
48 | );\r | |
49 | \r | |
50 | VOID\r | |
51 | EFIAPI\r | |
52 | KeyboardWaitForKey (\r | |
53 | IN EFI_EVENT Event,\r | |
54 | IN VOID *Context\r | |
55 | );\r | |
56 | \r | |
57 | EFI_STATUS\r | |
58 | KeyboardCheckForKey (\r | |
59 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r | |
60 | );\r | |
61 | \r | |
62 | EFI_STATUS\r | |
63 | EFIAPI\r | |
64 | KeyboardEfiReset (\r | |
65 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
66 | IN BOOLEAN ExtendedVerification\r | |
67 | )\r | |
68 | /*++\r | |
69 | \r | |
70 | Routine Description:\r | |
71 | \r | |
72 | Implement SIMPLE_TEXT_IN.Reset()\r | |
73 | Perform 8042 controller and keyboard initialization\r | |
74 | \r | |
75 | Arguments:\r | |
76 | \r | |
77 | Returns:\r | |
78 | \r | |
79 | --*/\r | |
80 | // GC_TODO: This - add argument and description to function comment\r | |
81 | // GC_TODO: ExtendedVerification - add argument and description to function comment\r | |
82 | // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
83 | // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
84 | // GC_TODO: EFI_SUCCESS - add return value to function comment\r | |
85 | {\r | |
86 | EFI_STATUS Status;\r | |
87 | KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r | |
88 | EFI_TPL OldTpl;\r | |
89 | \r | |
90 | ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r | |
91 | if (ConsoleIn->KeyboardErr) {\r | |
92 | return EFI_DEVICE_ERROR;\r | |
93 | }\r | |
94 | \r | |
95 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
96 | EFI_PROGRESS_CODE,\r | |
97 | EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET,\r | |
98 | ConsoleIn->DevicePath\r | |
99 | );\r | |
100 | \r | |
101 | //\r | |
102 | // Enter critical section\r | |
103 | //\r | |
104 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
105 | \r | |
106 | //\r | |
107 | // Call InitKeyboard to initialize the keyboard\r | |
108 | //\r | |
109 | Status = InitKeyboard (ConsoleIn, ExtendedVerification);\r | |
110 | if (EFI_ERROR (Status)) {\r | |
111 | //\r | |
112 | // Leave critical section and return\r | |
113 | //\r | |
114 | gBS->RestoreTPL (OldTpl);\r | |
115 | return EFI_DEVICE_ERROR;\r | |
116 | }\r | |
117 | //\r | |
118 | // Clear the status of ConsoleIn.Key\r | |
119 | //\r | |
120 | ConsoleIn->Key.ScanCode = SCAN_NULL;\r | |
121 | ConsoleIn->Key.UnicodeChar = 0x0000;\r | |
122 | \r | |
123 | //\r | |
124 | // Leave critical section and return\r | |
125 | //\r | |
126 | gBS->RestoreTPL (OldTpl);\r | |
127 | \r | |
128 | //\r | |
129 | // Report the status If a stuck key was detected\r | |
130 | //\r | |
131 | if (KeyReadStatusRegister (ConsoleIn) & 0x01) {\r | |
132 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
133 | EFI_ERROR_CODE | EFI_ERROR_MINOR,\r | |
134 | EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_STUCK_KEY,\r | |
135 | ConsoleIn->DevicePath\r | |
136 | );\r | |
137 | }\r | |
138 | //\r | |
139 | // Report the status If keyboard is locked\r | |
140 | //\r | |
141 | if (!(KeyReadStatusRegister (ConsoleIn) & 0x10)) {\r | |
142 | REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r | |
143 | EFI_ERROR_CODE | EFI_ERROR_MINOR,\r | |
144 | EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_LOCKED,\r | |
145 | ConsoleIn->DevicePath\r | |
146 | );\r | |
147 | }\r | |
148 | \r | |
149 | return EFI_SUCCESS;\r | |
150 | }\r | |
151 | \r | |
152 | EFI_STATUS\r | |
153 | EFIAPI\r | |
154 | KeyboardReadKeyStroke (\r | |
155 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
156 | OUT EFI_INPUT_KEY *Key\r | |
157 | )\r | |
158 | /*++\r | |
159 | \r | |
160 | Routine Description:\r | |
161 | \r | |
162 | Implement SIMPLE_TEXT_IN.ReadKeyStroke().\r | |
163 | Retrieve key values for driver user.\r | |
164 | \r | |
165 | Arguments:\r | |
166 | \r | |
167 | Returns:\r | |
168 | \r | |
169 | --*/\r | |
170 | // GC_TODO: This - add argument and description to function comment\r | |
171 | // GC_TODO: Key - add argument and description to function comment\r | |
172 | // GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
173 | // GC_TODO: EFI_NOT_READY - add return value to function comment\r | |
174 | // GC_TODO: EFI_SUCCESS - add return value to function comment\r | |
175 | {\r | |
176 | EFI_STATUS Status;\r | |
177 | KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r | |
178 | EFI_TPL OldTpl;\r | |
179 | \r | |
180 | ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r | |
181 | \r | |
182 | //\r | |
183 | // Enter critical section\r | |
184 | //\r | |
185 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
186 | \r | |
187 | if (ConsoleIn->KeyboardErr) {\r | |
188 | //\r | |
189 | // Leave critical section and return\r | |
190 | //\r | |
191 | gBS->RestoreTPL (OldTpl);\r | |
192 | \r | |
193 | return EFI_DEVICE_ERROR;\r | |
194 | }\r | |
195 | //\r | |
196 | // If there's no key, just return\r | |
197 | //\r | |
198 | Status = KeyboardCheckForKey (This);\r | |
199 | if (EFI_ERROR (Status)) {\r | |
200 | //\r | |
201 | // Leave critical section and return\r | |
202 | //\r | |
203 | gBS->RestoreTPL (OldTpl);\r | |
204 | return EFI_NOT_READY;\r | |
205 | }\r | |
206 | \r | |
207 | Key->ScanCode = ConsoleIn->Key.ScanCode;\r | |
208 | Key->UnicodeChar = ConsoleIn->Key.UnicodeChar;\r | |
209 | \r | |
210 | ConsoleIn->Key.ScanCode = SCAN_NULL;\r | |
211 | ConsoleIn->Key.UnicodeChar = 0x0000;\r | |
212 | \r | |
213 | //\r | |
214 | // Leave critical section and return\r | |
215 | //\r | |
216 | gBS->RestoreTPL (OldTpl);\r | |
217 | \r | |
218 | return EFI_SUCCESS;\r | |
219 | }\r | |
220 | \r | |
221 | VOID\r | |
222 | EFIAPI\r | |
223 | KeyboardWaitForKey (\r | |
224 | IN EFI_EVENT Event,\r | |
225 | IN VOID *Context\r | |
226 | )\r | |
227 | /*++\r | |
228 | \r | |
229 | Routine Description:\r | |
230 | \r | |
231 | Event notification function for SIMPLE_TEXT_IN.WaitForKey event\r | |
232 | Signal the event if there is key available\r | |
233 | \r | |
234 | Arguments:\r | |
235 | \r | |
236 | Returns:\r | |
237 | \r | |
238 | --*/\r | |
239 | // GC_TODO: Event - add argument and description to function comment\r | |
240 | // GC_TODO: Context - add argument and description to function comment\r | |
241 | {\r | |
242 | EFI_TPL OldTpl;\r | |
243 | KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r | |
244 | \r | |
245 | ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context);\r | |
246 | \r | |
247 | //\r | |
248 | // Enter critical section\r | |
249 | //\r | |
250 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
251 | \r | |
252 | if (ConsoleIn->KeyboardErr) {\r | |
253 | //\r | |
254 | // Leave critical section and return\r | |
255 | //\r | |
256 | gBS->RestoreTPL (OldTpl);\r | |
257 | return ;\r | |
258 | }\r | |
259 | //\r | |
260 | // Someone is waiting on the keyboard event, if there's\r | |
261 | // a key pending, signal the event\r | |
262 | //\r | |
263 | if (!EFI_ERROR (KeyboardCheckForKey (Context))) {\r | |
264 | gBS->SignalEvent (Event);\r | |
265 | }\r | |
266 | //\r | |
267 | // Leave critical section and return\r | |
268 | //\r | |
269 | gBS->RestoreTPL (OldTpl);\r | |
270 | \r | |
271 | return ;\r | |
272 | }\r | |
273 | \r | |
274 | EFI_STATUS\r | |
275 | KeyboardCheckForKey (\r | |
276 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r | |
277 | )\r | |
278 | /*++\r | |
279 | \r | |
280 | Routine Description:\r | |
281 | \r | |
282 | GC_TODO: Add function description\r | |
283 | \r | |
284 | Arguments:\r | |
285 | \r | |
286 | This - GC_TODO: add argument description\r | |
287 | \r | |
288 | Returns:\r | |
289 | \r | |
290 | EFI_SUCCESS - GC_TODO: Add description for return value\r | |
291 | \r | |
292 | --*/\r | |
293 | {\r | |
294 | KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r | |
295 | \r | |
296 | ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r | |
297 | \r | |
298 | //\r | |
299 | // If ready to read next key, check it\r | |
300 | //\r | |
301 | if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {\r | |
302 | return KeyGetchar (ConsoleIn);\r | |
303 | }\r | |
304 | \r | |
305 | return EFI_SUCCESS;\r | |
306 | }\r |