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