]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c
Update to BSD license header.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseDxe / Ps2Mouse.c
CommitLineData
05fbd06d 1/*++\r
2\r
92a428e1 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 Ps2Mouse.c\r
15\r
16Abstract:\r
17\r
18 PS/2 Mouse driver. Routines that interacts with callers,\r
19 conforming to EFI driver model\r
20\r
21--*/\r
22\r
23//\r
24// Include common header file for this module.\r
25//\r
26#include "CommonHeader.h"\r
27\r
28#include "Ps2Mouse.h"\r
29#include "CommPs2.h"\r
30\r
31//\r
32// DriverBinding Protocol Instance\r
33//\r
34EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver = {\r
35 PS2MouseDriverSupported,\r
36 PS2MouseDriverStart,\r
37 PS2MouseDriverStop,\r
38 0xa,\r
39 NULL,\r
40 NULL\r
41};\r
42\r
43EFI_STATUS\r
44EFIAPI\r
45PS2MouseDriverSupported (\r
46 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
47 IN EFI_HANDLE Controller,\r
48 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
49 )\r
50/*++\r
51\r
52Routine Description:\r
53\r
54 ControllerDriver Protocol Method\r
55\r
56Arguments:\r
57\r
58Returns:\r
59\r
60--*/\r
61// GC_TODO: This - add argument and description to function comment\r
62// GC_TODO: Controller - add argument and description to function comment\r
63// GC_TODO: RemainingDevicePath - add argument and description to function comment\r
64{\r
65 EFI_STATUS Status;\r
66 EFI_ISA_IO_PROTOCOL *IsaIo;\r
67\r
68 Status = EFI_SUCCESS;\r
69\r
70 //\r
71 // Open the IO Abstraction(s) needed to perform the supported test\r
72 //\r
73 Status = gBS->OpenProtocol (\r
74 Controller,\r
75 &gEfiIsaIoProtocolGuid,\r
76 (VOID **) &IsaIo,\r
77 This->DriverBindingHandle,\r
78 Controller,\r
79 EFI_OPEN_PROTOCOL_BY_DRIVER\r
80 );\r
81 if (EFI_ERROR (Status)) {\r
82 return Status;\r
83 }\r
84 //\r
85 // Use the ISA I/O Protocol to see if Controller is the Keyboard controller\r
86 //\r
87 switch (IsaIo->ResourceList->Device.HID) {\r
88 case EISA_PNP_ID (0xF03):\r
89 //\r
90 // Microsoft PS/2 style mouse\r
91 //\r
92 case EISA_PNP_ID (0xF13):\r
93 //\r
94 // PS/2 Port for PS/2-style Mice\r
95 //\r
96 break;\r
97\r
98 case EISA_PNP_ID (0x303):\r
99 //\r
100 // IBM Enhanced (101/102-key, PS/2 mouse support)\r
101 //\r
102 if (IsaIo->ResourceList->Device.UID == 1) {\r
103 break;\r
104 }\r
105\r
106 default:\r
107 Status = EFI_UNSUPPORTED;\r
108 break;\r
109 }\r
110 //\r
111 // Close the I/O Abstraction(s) used to perform the supported test\r
112 //\r
113 gBS->CloseProtocol (\r
114 Controller,\r
115 &gEfiIsaIoProtocolGuid,\r
116 This->DriverBindingHandle,\r
117 Controller\r
118 );\r
119\r
120 return Status;\r
121}\r
122\r
123EFI_STATUS\r
124EFIAPI\r
125PS2MouseDriverStart (\r
126 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
127 IN EFI_HANDLE Controller,\r
128 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
129 )\r
130/*++\r
131\r
132Routine Description:\r
133 Start protocol interfaces for the mouse device handles.\r
134\r
135Arguments:\r
136 This - Protocol instance pointer.\r
137 Controller - Handle of device to bind driver to.\r
138 RemainingDevicePath - Not used.\r
139\r
140Returns:\r
141 EFI_SUCCESS - This driver is added to DeviceHandle.\r
142 other - Errors occurred.\r
143\r
144--*/\r
145{\r
146 EFI_STATUS Status;\r
147 EFI_STATUS EmptyStatus;\r
148 EFI_ISA_IO_PROTOCOL *IsaIo;\r
149 PS2_MOUSE_DEV *MouseDev;\r
150 UINT8 Data;\r
151 EFI_TPL OldTpl;\r
152 EFI_STATUS_CODE_VALUE StatusCode;\r
153 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
154\r
155 StatusCode = 0;\r
156 MouseDev = NULL;\r
157 IsaIo = NULL;\r
158\r
159 //\r
160 // Open the device path protocol\r
161 //\r
162 Status = gBS->OpenProtocol (\r
163 Controller,\r
164 &gEfiDevicePathProtocolGuid,\r
165 (VOID **) &ParentDevicePath,\r
166 This->DriverBindingHandle,\r
167 Controller,\r
168 EFI_OPEN_PROTOCOL_BY_DRIVER\r
169 );\r
170 if (EFI_ERROR (Status)) {\r
171 return Status;\r
172 }\r
173 //\r
174 // Report that the keyboard is being enabled\r
175 //\r
176 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
177 EFI_PROGRESS_CODE,\r
178 EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,\r
179 ParentDevicePath\r
180 );\r
181\r
182 //\r
183 // Get the ISA I/O Protocol on Controller's handle\r
184 //\r
185 Status = gBS->OpenProtocol (\r
186 Controller,\r
187 &gEfiIsaIoProtocolGuid,\r
188 (VOID **) &IsaIo,\r
189 This->DriverBindingHandle,\r
190 Controller,\r
191 EFI_OPEN_PROTOCOL_BY_DRIVER\r
192 );\r
193 if (EFI_ERROR (Status)) {\r
194 gBS->CloseProtocol (\r
195 Controller,\r
196 &gEfiDevicePathProtocolGuid,\r
197 This->DriverBindingHandle,\r
198 Controller\r
199 );\r
200 return EFI_INVALID_PARAMETER;\r
201 }\r
202 //\r
203 // Raise TPL to avoid keyboard operation impact\r
204 //\r
205 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
206\r
207 //\r
208 // Allocate private data\r
209 //\r
210 MouseDev = AllocateZeroPool (sizeof (PS2_MOUSE_DEV));\r
211 if (MouseDev == NULL) {\r
212 Status = EFI_OUT_OF_RESOURCES;\r
213 goto ErrorExit;\r
214 }\r
215 //\r
216 // Setup the device instance\r
217 //\r
218 MouseDev->Signature = PS2_MOUSE_DEV_SIGNATURE;\r
219 MouseDev->Handle = Controller;\r
220 MouseDev->SampleRate = SSR_20;\r
221 MouseDev->Resolution = CMR4;\r
222 MouseDev->Scaling = SF1;\r
223 MouseDev->DataPackageSize = 3;\r
224 MouseDev->IsaIo = IsaIo;\r
225 MouseDev->DevicePath = ParentDevicePath;\r
226\r
227 //\r
228 // Resolution = 4 counts/mm\r
229 //\r
230 MouseDev->Mode.ResolutionX = 4;\r
231 MouseDev->Mode.ResolutionY = 4;\r
232 MouseDev->Mode.LeftButton = TRUE;\r
233 MouseDev->Mode.RightButton = TRUE;\r
234\r
235 MouseDev->SimplePointerProtocol.Reset = MouseReset;\r
236 MouseDev->SimplePointerProtocol.GetState = MouseGetState;\r
237 MouseDev->SimplePointerProtocol.Mode = &(MouseDev->Mode);\r
238\r
239 //\r
240 // Initialize keyboard controller if necessary\r
241 //\r
242 IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
243 if ((Data & KBC_SYSF) != KBC_SYSF) {\r
244 Status = KbcSelfTest (IsaIo);\r
245 if (EFI_ERROR (Status)) {\r
246 StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;\r
247 goto ErrorExit;\r
248 }\r
249 }\r
250\r
251 KbcEnableAux (IsaIo);\r
252\r
253 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
254 EFI_PROGRESS_CODE,\r
255 EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,\r
256 ParentDevicePath\r
257 );\r
258\r
259 //\r
260 // Reset the mouse\r
261 //\r
262 Status = MouseDev->SimplePointerProtocol.Reset (&MouseDev->SimplePointerProtocol, TRUE);\r
263 if (EFI_ERROR (Status)) {\r
264 //\r
265 // mouse not connected\r
266 //\r
267 Status = EFI_SUCCESS;\r
268 StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;\r
269 goto ErrorExit;\r
270 }\r
271 //\r
272 // Setup the WaitForKey event\r
273 //\r
274 Status = gBS->CreateEvent (\r
275 EVT_NOTIFY_WAIT,\r
276 TPL_NOTIFY,\r
277 MouseWaitForInput,\r
278 MouseDev,\r
279 &((MouseDev->SimplePointerProtocol).WaitForInput)\r
280 );\r
281 if (EFI_ERROR (Status)) {\r
282 Status = EFI_OUT_OF_RESOURCES;\r
283 goto ErrorExit;\r
284 }\r
285 //\r
286 // Setup a periodic timer, used to poll mouse state\r
287 //\r
288 Status = gBS->CreateEvent (\r
289 EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
290 TPL_NOTIFY,\r
291 PollMouse,\r
292 MouseDev,\r
293 &MouseDev->TimerEvent\r
294 );\r
295 if (EFI_ERROR (Status)) {\r
296 Status = EFI_OUT_OF_RESOURCES;\r
297 goto ErrorExit;\r
298 }\r
299 //\r
300 // Start timer to poll mouse (100 samples per second)\r
301 //\r
302 Status = gBS->SetTimer (MouseDev->TimerEvent, TimerPeriodic, 100000);\r
303 if (EFI_ERROR (Status)) {\r
304 Status = EFI_OUT_OF_RESOURCES;\r
305 goto ErrorExit;\r
306 }\r
307\r
308 MouseDev->ControllerNameTable = NULL;\r
309 AddUnicodeString (\r
310 "eng",\r
311 gPs2MouseComponentName.SupportedLanguages,\r
312 &MouseDev->ControllerNameTable,\r
313 L"PS/2 Mouse Device"\r
314 );\r
315\r
316 //\r
317 // Install protocol interfaces for the mouse device.\r
318 //\r
319 Status = gBS->InstallMultipleProtocolInterfaces (\r
320 &Controller,\r
321 &gEfiSimplePointerProtocolGuid,\r
322 &MouseDev->SimplePointerProtocol,\r
323 NULL\r
324 );\r
325 if (EFI_ERROR (Status)) {\r
326 goto ErrorExit;\r
327 }\r
328\r
329 gBS->RestoreTPL (OldTpl);\r
330\r
331 return Status;\r
332\r
333ErrorExit:\r
334\r
335 KbcDisableAux (IsaIo);\r
336\r
337 if (StatusCode != 0) {\r
338 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
339 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
340 StatusCode,\r
341 ParentDevicePath\r
342 );\r
343 }\r
344\r
345 if ((MouseDev != NULL) && (MouseDev->SimplePointerProtocol.WaitForInput != NULL)) {\r
346 gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);\r
347 }\r
348\r
349 if ((MouseDev != NULL) && (MouseDev->TimerEvent != NULL)) {\r
350 gBS->CloseEvent (MouseDev->TimerEvent);\r
351 }\r
352\r
353 if ((MouseDev != NULL) && (MouseDev->ControllerNameTable != NULL)) {\r
354 FreeUnicodeStringTable (MouseDev->ControllerNameTable);\r
355 }\r
356 //\r
357 // Since there will be no timer handler for mouse input any more,\r
358 // exhaust input data just in case there is still mouse data left\r
359 //\r
360 EmptyStatus = EFI_SUCCESS;\r
361 while (!EFI_ERROR (EmptyStatus)) {\r
362 EmptyStatus = In8042Data (IsaIo, &Data);\r
363 }\r
364\r
365 if (MouseDev != NULL) {\r
366 gBS->FreePool (MouseDev);\r
367 }\r
368\r
369 gBS->CloseProtocol (\r
370 Controller,\r
371 &gEfiDevicePathProtocolGuid,\r
372 This->DriverBindingHandle,\r
373 Controller\r
374 );\r
375\r
376 gBS->CloseProtocol (\r
377 Controller,\r
378 &gEfiIsaIoProtocolGuid,\r
379 This->DriverBindingHandle,\r
380 Controller\r
381 );\r
382\r
383 gBS->RestoreTPL (OldTpl);\r
384\r
385 return Status;\r
386}\r
387\r
388EFI_STATUS\r
389EFIAPI\r
390PS2MouseDriverStop (\r
391 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
392 IN EFI_HANDLE Controller,\r
393 IN UINTN NumberOfChildren,\r
394 IN EFI_HANDLE *ChildHandleBuffer\r
395 )\r
396/*++\r
397\r
398 Routine Description:\r
399\r
400 Arguments:\r
401\r
402 Returns:\r
403\r
404--*/\r
405// GC_TODO: This - add argument and description to function comment\r
406// GC_TODO: Controller - add argument and description to function comment\r
407// GC_TODO: NumberOfChildren - add argument and description to function comment\r
408// GC_TODO: ChildHandleBuffer - add argument and description to function comment\r
409// GC_TODO: EFI_SUCCESS - add return value to function comment\r
410// GC_TODO: EFI_SUCCESS - add return value to function comment\r
411{\r
412 EFI_STATUS Status;\r
413 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;\r
414 PS2_MOUSE_DEV *MouseDev;\r
415 UINT8 Data;\r
416\r
417 Status = gBS->OpenProtocol (\r
418 Controller,\r
419 &gEfiSimplePointerProtocolGuid,\r
420 (VOID **) &SimplePointerProtocol,\r
421 This->DriverBindingHandle,\r
422 Controller,\r
423 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
424 );\r
425 if (EFI_ERROR (Status)) {\r
426 return EFI_SUCCESS;\r
427 }\r
428\r
429 MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);\r
430\r
431 //\r
432 // Report that the keyboard is being disabled\r
433 //\r
434 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
435 EFI_PROGRESS_CODE,\r
436 EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,\r
437 MouseDev->DevicePath\r
438 );\r
439\r
440 Status = gBS->UninstallProtocolInterface (\r
441 Controller,\r
442 &gEfiSimplePointerProtocolGuid,\r
443 &MouseDev->SimplePointerProtocol\r
444 );\r
445 if (EFI_ERROR (Status)) {\r
446 return Status;\r
447 }\r
448 //\r
449 // Disable mouse on keyboard controller\r
450 //\r
451 KbcDisableAux (MouseDev->IsaIo);\r
452\r
453 //\r
454 // Cancel mouse data polling timer, close timer event\r
455 //\r
456 gBS->SetTimer (MouseDev->TimerEvent, TimerCancel, 0);\r
457 gBS->CloseEvent (MouseDev->TimerEvent);\r
458\r
459 //\r
460 // Since there will be no timer handler for mouse input any more,\r
461 // exhaust input data just in case there is still mouse data left\r
462 //\r
463 Status = EFI_SUCCESS;\r
464 while (!EFI_ERROR (Status)) {\r
465 Status = In8042Data (MouseDev->IsaIo, &Data);\r
466 }\r
467\r
468 gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);\r
469 FreeUnicodeStringTable (MouseDev->ControllerNameTable);\r
470 gBS->FreePool (MouseDev);\r
471\r
472 gBS->CloseProtocol (\r
473 Controller,\r
474 &gEfiDevicePathProtocolGuid,\r
475 This->DriverBindingHandle,\r
476 Controller\r
477 );\r
478\r
479 gBS->CloseProtocol (\r
480 Controller,\r
481 &gEfiIsaIoProtocolGuid,\r
482 This->DriverBindingHandle,\r
483 Controller\r
484 );\r
485\r
486 return EFI_SUCCESS;\r
487}\r
488\r
489EFI_STATUS\r
490EFIAPI\r
491MouseReset (\r
492 IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
493 IN BOOLEAN ExtendedVerification\r
494 )\r
495/*++\r
496\r
497Routine Description:\r
498\r
499 Reset the Mouse and do BAT test for it, if ExtendedVerification isTRUE and there is a mouse device connectted to system\r
500\r
501Arguments:\r
502\r
503 This - Pointer of simple pointer Protocol.\r
504 ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.\r
505\r
506Returns:\r
507\r
508 EFI_SUCCESS - The command byte is written successfully.\r
509 EFI_DEVICE_ERROR - Errors occurred during reseting keyboard.\r
510\r
511--*/\r
512{\r
513 EFI_STATUS Status;\r
514 PS2_MOUSE_DEV *MouseDev;\r
515 EFI_TPL OldTpl;\r
516 BOOLEAN KeyboardEnable;\r
517 UINT8 Data;\r
518\r
519 MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);\r
520\r
521 //\r
522 // Report reset progress code\r
523 //\r
524 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
525 EFI_PROGRESS_CODE,\r
526 EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,\r
527 MouseDev->DevicePath\r
528 );\r
529\r
530 KeyboardEnable = FALSE;\r
531\r
532 //\r
533 // Raise TPL to avoid keyboard operation impact\r
534 //\r
535 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
536\r
537 ZeroMem (&MouseDev->State, sizeof (EFI_SIMPLE_POINTER_STATE));\r
538 MouseDev->StateChanged = FALSE;\r
539\r
540 //\r
541 // Exhaust input data\r
542 //\r
543 Status = EFI_SUCCESS;\r
544 while (!EFI_ERROR (Status)) {\r
545 Status = In8042Data (MouseDev->IsaIo, &Data);\r
546 }\r
547\r
548 CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);\r
549\r
550 KbcDisableKb (MouseDev->IsaIo);\r
551\r
552 MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
553\r
554 //\r
555 // if there's data block on KBC data port, read it out\r
556 //\r
557 if ((Data & KBC_OUTB) == KBC_OUTB) {\r
558 MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);\r
559 }\r
560\r
561 Status = EFI_SUCCESS;\r
562 //\r
563 // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.\r
564 // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is\r
565 // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling\r
566 //\r
567 if (ExtendedVerification && CheckMouseConnect (MouseDev)) {\r
568 //\r
569 // Send mouse reset command and set mouse default configure\r
570 //\r
571 Status = PS2MouseReset (MouseDev->IsaIo);\r
572 if (EFI_ERROR (Status)) {\r
573 Status = EFI_DEVICE_ERROR;\r
574 goto Exit;\r
575 }\r
576\r
577 Status = PS2MouseSetSampleRate (MouseDev->IsaIo, MouseDev->SampleRate);\r
578 if (EFI_ERROR (Status)) {\r
579 Status = EFI_DEVICE_ERROR;\r
580 goto Exit;\r
581 }\r
582\r
583 Status = PS2MouseSetResolution (MouseDev->IsaIo, MouseDev->Resolution);\r
584 if (EFI_ERROR (Status)) {\r
585 Status = EFI_DEVICE_ERROR;\r
586 goto Exit;\r
587 }\r
588\r
589 Status = PS2MouseSetScaling (MouseDev->IsaIo, MouseDev->Scaling);\r
590 if (EFI_ERROR (Status)) {\r
591 Status = EFI_DEVICE_ERROR;\r
592 goto Exit;\r
593 }\r
594\r
595 Status = PS2MouseEnable (MouseDev->IsaIo);\r
596 if (EFI_ERROR (Status)) {\r
597 Status = EFI_DEVICE_ERROR;\r
598 goto Exit;\r
599 }\r
600 }\r
601Exit:\r
602 gBS->RestoreTPL (OldTpl);\r
603\r
604 if (KeyboardEnable) {\r
605 KbcEnableKb (MouseDev->IsaIo);\r
606 }\r
607\r
608 return Status;\r
609}\r
610\r
611BOOLEAN\r
612CheckMouseConnect (\r
613 IN PS2_MOUSE_DEV *MouseDev\r
614 )\r
615/*++\r
616\r
617Routine Description:\r
618\r
619 Check whether there is Ps/2 mouse device in system\r
620\r
621Arguments:\r
622\r
623 PS2_MOUSE_DEV - Mouse Private Data Structure\r
624\r
625Returns:\r
626\r
627 TRUE - Keyboard in System.\r
628 FALSE - Keyboard not in System.\r
629\r
630--*/\r
631{\r
632 EFI_STATUS Status;\r
633\r
634 Status = PS2MouseEnable (MouseDev->IsaIo);\r
635 if (!EFI_ERROR (Status)) {\r
636 return TRUE;\r
637 }\r
638\r
639 return FALSE;\r
640}\r
641\r
642EFI_STATUS\r
643EFIAPI\r
644MouseGetState (\r
645 IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r
646 IN OUT EFI_SIMPLE_POINTER_STATE *State\r
647 )\r
648/*++\r
649\r
650Routine Description:\r
651\r
652 GC_TODO: Add function description\r
653\r
654Arguments:\r
655\r
656 This - GC_TODO: add argument description\r
657 State - GC_TODO: add argument description\r
658\r
659Returns:\r
660\r
661 EFI_INVALID_PARAMETER - GC_TODO: Add description for return value\r
662 EFI_NOT_READY - GC_TODO: Add description for return value\r
663 EFI_SUCCESS - GC_TODO: Add description for return value\r
664\r
665--*/\r
666{\r
667 PS2_MOUSE_DEV *MouseDev;\r
668 EFI_TPL OldTpl;\r
669\r
670 MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);\r
671\r
672 if (State == NULL) {\r
673 return EFI_INVALID_PARAMETER;\r
674 }\r
675\r
676 if (!MouseDev->StateChanged) {\r
677 return EFI_NOT_READY;\r
678 }\r
679\r
680 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
681 CopyMem (State, &(MouseDev->State), sizeof (EFI_SIMPLE_POINTER_STATE));\r
682\r
683 //\r
684 // clear mouse state\r
685 //\r
686 MouseDev->State.RelativeMovementX = 0;\r
687 MouseDev->State.RelativeMovementY = 0;\r
688 MouseDev->State.RelativeMovementZ = 0;\r
689 MouseDev->StateChanged = FALSE;\r
690 gBS->RestoreTPL (OldTpl);\r
691\r
692 return EFI_SUCCESS;\r
693}\r
694\r
695VOID\r
696EFIAPI\r
697MouseWaitForInput (\r
698 IN EFI_EVENT Event,\r
699 IN VOID *Context\r
700 )\r
701/*++\r
702\r
703Routine Description:\r
704\r
705 Event notification function for SIMPLE_POINTER.WaitForInput event\r
706 Signal the event if there is input from mouse\r
707\r
708Arguments:\r
709\r
710Returns:\r
711\r
712--*/\r
713// GC_TODO: Event - add argument and description to function comment\r
714// GC_TODO: Context - add argument and description to function comment\r
715{\r
716 PS2_MOUSE_DEV *MouseDev;\r
717\r
718 MouseDev = (PS2_MOUSE_DEV *) Context;\r
719\r
720 //\r
721 // Someone is waiting on the mouse event, if there's\r
722 // input from mouse, signal the event\r
723 //\r
724 if (MouseDev->StateChanged) {\r
725 gBS->SignalEvent (Event);\r
726 }\r
727\r
728}\r
729\r
730VOID\r
731EFIAPI\r
732PollMouse (\r
733 IN EFI_EVENT Event,\r
734 IN VOID *Context\r
735 )\r
736/*++\r
737\r
738Routine Description:\r
739\r
740 Event notification function for TimerEvent event\r
741 If mouse device is connected to system, try to get the mouse packet data\r
742\r
743Arguments:\r
744\r
745 Event - TimerEvent in PS2_MOUSE_DEV\r
746 Context - Pointer to PS2_MOUSE_DEV structure\r
747\r
748Returns:\r
749\r
750 None\r
751\r
752--*/\r
753{\r
754 PS2_MOUSE_DEV *MouseDev;\r
755\r
756 MouseDev = (PS2_MOUSE_DEV *) Context;\r
757\r
758 //\r
759 // Polling mouse packet data\r
760 //\r
761 PS2MouseGetPacket (MouseDev);\r
762}\r