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
104 Test to see if this driver supports ControllerHandle. Any ControllerHandle
105 than contains a IsaIo protocol can be supported.
107 @param This Protocol instance pointer.
108 @param ControllerHandle Handle of device to test
109 @param RemainingDevicePath Optional parameter use to pick a specific child
112 @retval EFI_SUCCESS This driver supports this device
113 @retval EFI_ALREADY_STARTED This driver is already running on this device
114 @retval other This driver does not support this device
119 PS2MouseDriverSupported (
120 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
121 IN EFI_HANDLE Controller
,
122 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
126 Start this driver on ControllerHandle by opening a IsaIo
127 protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
130 @param This Protocol instance pointer.
131 @param ControllerHandle Handle of device to bind driver to
132 @param RemainingDevicePath Optional parameter use to pick a specific child
135 @retval EFI_SUCCESS This driver is added to ControllerHandle
136 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
137 @retval other This driver does not support this device
142 PS2MouseDriverStart (
143 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
144 IN EFI_HANDLE Controller
,
145 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
149 Stop this driver on ControllerHandle. Support stopping any child handles
150 created by this driver.
152 @param This Protocol instance pointer.
153 @param ControllerHandle Handle of device to stop driver on
154 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
155 children is zero stop the entire bus driver.
156 @param ChildHandleBuffer List of Child Handles to Stop.
158 @retval EFI_SUCCESS This driver is removed ControllerHandle
159 @retval other This driver was not removed from this device
165 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
166 IN EFI_HANDLE Controller
,
167 IN UINTN NumberOfChildren
,
168 IN EFI_HANDLE
*ChildHandleBuffer
172 // EFI Component Name Functions
176 Retrieves a Unicode string that is the user readable name of the driver.
178 This function retrieves the user readable name of a driver in the form of a
179 Unicode string. If the driver specified by This has a user readable name in
180 the language specified by Language, then a pointer to the driver name is
181 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
182 by This does not support the language specified by Language,
183 then EFI_UNSUPPORTED is returned.
185 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
186 EFI_COMPONENT_NAME_PROTOCOL instance.
188 @param Language[in] A pointer to a Null-terminated ASCII string
189 array indicating the language. This is the
190 language of the driver name that the caller is
191 requesting, and it must match one of the
192 languages specified in SupportedLanguages. The
193 number of languages supported by a driver is up
194 to the driver writer. Language is specified
195 in RFC 4646 or ISO 639-2 language code format.
197 @param DriverName[out] A pointer to the Unicode string to return.
198 This Unicode string is the name of the
199 driver specified by This in the language
200 specified by Language.
202 @retval EFI_SUCCESS The Unicode string for the Driver specified by
203 This and the language specified by Language was
204 returned in DriverName.
206 @retval EFI_INVALID_PARAMETER Language is NULL.
208 @retval EFI_INVALID_PARAMETER DriverName is NULL.
210 @retval EFI_UNSUPPORTED The driver specified by This does not support
211 the language specified by Language.
216 Ps2MouseComponentNameGetDriverName (
217 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
219 OUT CHAR16
**DriverName
223 Retrieves a Unicode string that is the user readable name of the controller
224 that is being managed by a driver.
226 This function retrieves the user readable name of the controller specified by
227 ControllerHandle and ChildHandle in the form of a Unicode string. If the
228 driver specified by This has a user readable name in the language specified by
229 Language, then a pointer to the controller name is returned in ControllerName,
230 and EFI_SUCCESS is returned. If the driver specified by This is not currently
231 managing the controller specified by ControllerHandle and ChildHandle,
232 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
233 support the language specified by Language, then EFI_UNSUPPORTED is returned.
235 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
236 EFI_COMPONENT_NAME_PROTOCOL instance.
238 @param ControllerHandle[in] The handle of a controller that the driver
239 specified by This is managing. This handle
240 specifies the controller whose name is to be
243 @param ChildHandle[in] The handle of the child controller to retrieve
244 the name of. This is an optional parameter that
245 may be NULL. It will be NULL for device
246 drivers. It will also be NULL for a bus drivers
247 that wish to retrieve the name of the bus
248 controller. It will not be NULL for a bus
249 driver that wishes to retrieve the name of a
252 @param Language[in] A pointer to a Null-terminated ASCII string
253 array indicating the language. This is the
254 language of the driver name that the caller is
255 requesting, and it must match one of the
256 languages specified in SupportedLanguages. The
257 number of languages supported by a driver is up
258 to the driver writer. Language is specified in
259 RFC 4646 or ISO 639-2 language code format.
261 @param ControllerName[out] A pointer to the Unicode string to return.
262 This Unicode string is the name of the
263 controller specified by ControllerHandle and
264 ChildHandle in the language specified by
265 Language from the point of view of the driver
268 @retval EFI_SUCCESS The Unicode string for the user readable name in
269 the language specified by Language for the
270 driver specified by This was returned in
273 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
275 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
278 @retval EFI_INVALID_PARAMETER Language is NULL.
280 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
282 @retval EFI_UNSUPPORTED The driver specified by This is not currently
283 managing the controller specified by
284 ControllerHandle and ChildHandle.
286 @retval EFI_UNSUPPORTED The driver specified by This does not support
287 the language specified by Language.
292 Ps2MouseComponentNameGetControllerName (
293 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
294 IN EFI_HANDLE ControllerHandle
,
295 IN EFI_HANDLE ChildHandle OPTIONAL
,
297 OUT CHAR16
**ControllerName
301 Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and
302 there is a mouse device connected to system.
304 @param This - Pointer of simple pointer Protocol.
305 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
308 @retval EFI_SUCCESS - The command byte is written successfully.
309 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
315 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
316 IN BOOLEAN ExtendedVerification
320 Get and Clear mouse status.
322 @param This - Pointer of simple pointer Protocol.
323 @param State - Output buffer holding status.
325 @retval EFI_INVALID_PARAMETER Output buffer is invalid.
326 @retval EFI_NOT_READY Mouse is not changed status yet.
327 @retval EFI_SUCCESS Mouse status is changed and get successful.
332 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
333 IN OUT EFI_SIMPLE_POINTER_STATE
*State
338 Event notification function for SIMPLE_POINTER.WaitForInput event.
339 Signal the event if there is input from mouse.
341 @param Event event object
342 @param Context event context
353 Event notification function for TimerEvent event.
354 If mouse device is connected to system, try to get the mouse packet data.
356 @param Event - TimerEvent in PS2_MOUSE_DEV
357 @param Context - Pointer to PS2_MOUSE_DEV structure
368 I/O work flow of in 8042 data.
370 @param Data Data value
372 @retval EFI_SUCCESS Success to execute I/O work flow
373 @retval EFI_TIMEOUT Keyboard controller time out.
381 Check whether there is Ps/2 mouse device in system
383 @param MouseDev - Mouse Private Data Structure
385 @retval TRUE - Keyboard in System.
386 @retval FALSE - Keyboard not in System.
391 IN PS2_MOUSE_DEV
*MouseDev