2 A Ps2MouseAbsolutePointer driver header file
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __PS2MOUSEABSOLUTEPOINTER_H__
10 #define __PS2MOUSEABSOLUTEPOINTER_H__
14 #include <Protocol/AbsolutePointer.h>
15 #include <Protocol/IsaIo.h>
16 #include <Protocol/DevicePath.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiDriverEntryPoint.h>
20 #include <Library/UefiLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/MemoryAllocationLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/ReportStatusCodeLib.h>
25 #include <Library/PcdLib.h>
30 extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseAbsolutePointerDriver
;
31 extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseAbsolutePointerComponentName
;
32 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseAbsolutePointerComponentName2
;
35 // PS/2 mouse sample rate
49 // PS/2 mouse resolution
68 // Driver Private Data
70 #define PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('p', '2', 's', 't')
76 EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol
;
77 EFI_ABSOLUTE_POINTER_STATE State
;
78 EFI_ABSOLUTE_POINTER_MODE Mode
;
82 // PS2 Mouse device specific information
87 UINT8 DataPackageSize
;
89 EFI_ISA_IO_PROTOCOL
*IsaIo
;
93 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
94 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
95 } PS2_MOUSE_ABSOLUTE_POINTER_DEV
;
97 #define PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_ABSOLUTE_POINTER_DEV, AbsolutePointerProtocol, PS2_MOUSE_ABSOLUTE_POINTER_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 PS2MouseAbsolutePointerDriverSupported (
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 PS2MouseAbsolutePointerDriverStart (
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
163 PS2MouseAbsolutePointerDriverStop (
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 Ps2MouseAbsolutePointerComponentNameGetDriverName (
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 Ps2MouseAbsolutePointerComponentNameGetControllerName (
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 there is a mouse device connected to system.
302 @param This - Pointer of simple pointer Protocol.
303 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
306 @retval EFI_SUCCESS - The command byte is written successfully.
307 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
312 MouseAbsolutePointerReset (
313 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
314 IN BOOLEAN ExtendedVerification
318 Get and Clear mouse status.
320 @param This - Pointer of simple pointer Protocol.
321 @param State - Output buffer holding status.
323 @retval EFI_INVALID_PARAMETER Output buffer is invalid.
324 @retval EFI_NOT_READY Mouse is not changed status yet.
325 @retval EFI_SUCCESS Mouse status is changed and get successful.
329 MouseAbsolutePointerGetState (
330 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
331 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
336 Event notification function for SIMPLE_POINTER.WaitForInput event.
337 Signal the event if there is input from mouse.
339 @param Event event object
340 @param Context event context
345 MouseAbsolutePointerWaitForInput (
351 Event notification function for TimerEvent event.
352 If mouse device is connected to system, try to get the mouse packet data.
354 @param Event - TimerEvent in PS2_MOUSE_DEV
355 @param Context - Pointer to PS2_MOUSE_DEV structure
360 PollMouseAbsolutePointer (
366 I/O work flow of in 8042 data.
368 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
369 @param Data Data value
371 @retval EFI_SUCCESS Success to execute I/O work flow
372 @retval EFI_TIMEOUT Keyboard controller time out.
376 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
381 Check whether there is Ps/2 mouse device in system
383 @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure
385 @retval TRUE - Keyboard in System.
386 @retval FALSE - Keyboard not in System.
390 CheckMouseAbsolutePointerConnect (
391 IN PS2_MOUSE_ABSOLUTE_POINTER_DEV
*MouseAbsolutePointerDev