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