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