2 PS/2 Mouse driver header file.
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Protocol/SimplePointer.h>
15 #include <Protocol/SuperIo.h>
16 #include <Protocol/DevicePath.h>
18 #include <Library/DevicePathLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/UefiDriverEntryPoint.h>
21 #include <Library/UefiLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/ReportStatusCodeLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/IoLib.h>
32 extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver
;
33 extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName
;
34 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2
;
37 // PS/2 mouse sample rate
51 // PS/2 mouse resolution
70 // Driver Private Data
72 #define PS2_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('p', 's', '2', 'm')
78 EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol
;
79 EFI_SIMPLE_POINTER_STATE State
;
80 EFI_SIMPLE_POINTER_MODE Mode
;
84 // PS2 Mouse device specific information
89 UINT8 DataPackageSize
;
93 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
94 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
97 #define PS2_MOUSE_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)
100 // Function prototypes
103 Test to see if this driver supports ControllerHandle. Any ControllerHandle
104 than contains a IsaIo protocol can be supported.
106 @param This Protocol instance pointer.
107 @param ControllerHandle Handle of device to test
108 @param RemainingDevicePath Optional parameter use to pick a specific child
111 @retval EFI_SUCCESS This driver supports this device
112 @retval EFI_ALREADY_STARTED This driver is already running on this device
113 @retval other This driver does not support this device
118 PS2MouseDriverSupported (
119 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
120 IN EFI_HANDLE Controller
,
121 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
125 Start this driver on ControllerHandle by opening a IsaIo
126 protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
129 @param This Protocol instance pointer.
130 @param ControllerHandle Handle of device to bind driver to
131 @param RemainingDevicePath Optional parameter use to pick a specific child
134 @retval EFI_SUCCESS This driver is added to ControllerHandle
135 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
136 @retval other This driver does not support this device
141 PS2MouseDriverStart (
142 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
143 IN EFI_HANDLE Controller
,
144 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
148 Stop this driver on ControllerHandle. Support stopping any child handles
149 created by this driver.
151 @param This Protocol instance pointer.
152 @param ControllerHandle Handle of device to stop driver on
153 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
154 children is zero stop the entire bus driver.
155 @param ChildHandleBuffer List of Child Handles to Stop.
157 @retval EFI_SUCCESS This driver is removed ControllerHandle
158 @retval other This driver was not removed from this device
164 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
165 IN EFI_HANDLE Controller
,
166 IN UINTN NumberOfChildren
,
167 IN EFI_HANDLE
*ChildHandleBuffer
171 // EFI Component Name Functions
174 Retrieves a Unicode string that is the user readable name of the driver.
176 This function retrieves the user readable name of a driver in the form of a
177 Unicode string. If the driver specified by This has a user readable name in
178 the language specified by Language, then a pointer to the driver name is
179 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
180 by This does not support the language specified by Language,
181 then EFI_UNSUPPORTED is returned.
183 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
184 EFI_COMPONENT_NAME_PROTOCOL instance.
186 @param Language[in] A pointer to a Null-terminated ASCII string
187 array indicating the language. This is the
188 language of the driver name that the caller is
189 requesting, and it must match one of the
190 languages specified in SupportedLanguages. The
191 number of languages supported by a driver is up
192 to the driver writer. Language is specified
193 in RFC 4646 or ISO 639-2 language code format.
195 @param DriverName[out] A pointer to the Unicode string to return.
196 This Unicode string is the name of the
197 driver specified by This in the language
198 specified by Language.
200 @retval EFI_SUCCESS The Unicode string for the Driver specified by
201 This and the language specified by Language was
202 returned in DriverName.
204 @retval EFI_INVALID_PARAMETER Language is NULL.
206 @retval EFI_INVALID_PARAMETER DriverName is NULL.
208 @retval EFI_UNSUPPORTED The driver specified by This does not support
209 the language specified by Language.
214 Ps2MouseComponentNameGetDriverName (
215 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
217 OUT CHAR16
**DriverName
222 Retrieves a Unicode string that is the user readable name of the controller
223 that is being managed by a driver.
225 This function retrieves the user readable name of the controller specified by
226 ControllerHandle and ChildHandle in the form of a Unicode string. If the
227 driver specified by This has a user readable name in the language specified by
228 Language, then a pointer to the controller name is returned in ControllerName,
229 and EFI_SUCCESS is returned. If the driver specified by This is not currently
230 managing the controller specified by ControllerHandle and ChildHandle,
231 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
232 support the language specified by Language, then EFI_UNSUPPORTED is returned.
234 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
235 EFI_COMPONENT_NAME_PROTOCOL instance.
237 @param ControllerHandle[in] The handle of a controller that the driver
238 specified by This is managing. This handle
239 specifies the controller whose name is to be
242 @param ChildHandle[in] The handle of the child controller to retrieve
243 the name of. This is an optional parameter that
244 may be NULL. It will be NULL for device
245 drivers. It will also be NULL for a bus drivers
246 that wish to retrieve the name of the bus
247 controller. It will not be NULL for a bus
248 driver that wishes to retrieve the name of a
251 @param Language[in] A pointer to a Null-terminated ASCII string
252 array indicating the language. This is the
253 language of the driver name that the caller is
254 requesting, and it must match one of the
255 languages specified in SupportedLanguages. The
256 number of languages supported by a driver is up
257 to the driver writer. Language is specified in
258 RFC 4646 or ISO 639-2 language code format.
260 @param ControllerName[out] A pointer to the Unicode string to return.
261 This Unicode string is the name of the
262 controller specified by ControllerHandle and
263 ChildHandle in the language specified by
264 Language from the point of view of the driver
267 @retval EFI_SUCCESS The Unicode string for the user readable name in
268 the language specified by Language for the
269 driver specified by This was returned in
272 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
274 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
277 @retval EFI_INVALID_PARAMETER Language is NULL.
279 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
281 @retval EFI_UNSUPPORTED The driver specified by This is not currently
282 managing the controller specified by
283 ControllerHandle and ChildHandle.
285 @retval EFI_UNSUPPORTED The driver specified by This does not support
286 the language specified by Language.
291 Ps2MouseComponentNameGetControllerName (
292 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
293 IN EFI_HANDLE ControllerHandle
,
294 IN EFI_HANDLE ChildHandle OPTIONAL
,
296 OUT CHAR16
**ControllerName
300 Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and
301 there is a mouse device connected to system.
303 @param This - Pointer of simple pointer Protocol.
304 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
307 @retval EFI_SUCCESS - The command byte is written successfully.
308 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
314 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
315 IN BOOLEAN ExtendedVerification
319 Get and Clear mouse status.
321 @param This - Pointer of simple pointer Protocol.
322 @param State - Output buffer holding status.
324 @retval EFI_INVALID_PARAMETER Output buffer is invalid.
325 @retval EFI_NOT_READY Mouse is not changed status yet.
326 @retval EFI_SUCCESS Mouse status is changed and get successful.
331 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
332 IN OUT EFI_SIMPLE_POINTER_STATE
*State
337 Event notification function for SIMPLE_POINTER.WaitForInput event.
338 Signal the event if there is input from mouse.
340 @param Event event object
341 @param Context event context
352 Event notification function for TimerEvent event.
353 If mouse device is connected to system, try to get the mouse packet data.
355 @param Event - TimerEvent in PS2_MOUSE_DEV
356 @param Context - Pointer to PS2_MOUSE_DEV structure
367 I/O work flow of in 8042 data.
369 @param Data Data value
371 @retval EFI_SUCCESS Success to execute I/O work flow
372 @retval EFI_TIMEOUT Keyboard controller time out.
380 Check whether there is Ps/2 mouse device in system
382 @param MouseDev - Mouse Private Data Structure
384 @retval TRUE - Keyboard in System.
385 @retval FALSE - Keyboard not in System.
390 IN PS2_MOUSE_DEV
*MouseDev