]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseAbsolutePointerDxe / Ps2MouseAbsolutePointer.h
1 /** @file
2 A Ps2MouseAbsolutePointer driver header file
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __PS2MOUSEABSOLUTEPOINTER_H__
16 #define __PS2MOUSEABSOLUTEPOINTER_H__
17
18 #include <Uefi.h>
19
20 #include <Protocol/AbsolutePointer.h>
21 #include <Protocol/IsaIo.h>
22 #include <Protocol/DevicePath.h>
23
24 #include <Library/DebugLib.h>
25 #include <Library/UefiDriverEntryPoint.h>
26 #include <Library/UefiLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/ReportStatusCodeLib.h>
31 #include <Library/PcdLib.h>
32
33 //
34 // Global Variables
35 //
36 extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseAbsolutePointerDriver;
37 extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseAbsolutePointerComponentName;
38 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseAbsolutePointerComponentName2;
39
40 //
41 // PS/2 mouse sample rate
42 //
43 typedef enum {
44 SampleRate10,
45 SampleRate20,
46 SampleRate40,
47 SampleRate60,
48 SampleRate80,
49 SampleRate100,
50 SampleRate200,
51 MaxSampleRate
52 } MOUSE_SR;
53
54 //
55 // PS/2 mouse resolution
56 //
57 typedef enum {
58 MouseResolution1,
59 MouseResolution2,
60 MouseResolution4,
61 MouseResolution8,
62 MaxResolution
63 } MOUSE_RE;
64
65 //
66 // PS/2 mouse scaling
67 //
68 typedef enum {
69 Scaling1,
70 Scaling2
71 } MOUSE_SF;
72
73 //
74 // Driver Private Data
75 //
76 #define PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('p', '2', 's', 't')
77
78 typedef struct {
79 UINTN Signature;
80
81 EFI_HANDLE Handle;
82 EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol;
83 EFI_ABSOLUTE_POINTER_STATE State;
84 EFI_ABSOLUTE_POINTER_MODE Mode;
85 BOOLEAN StateChanged;
86
87 //
88 // PS2 Mouse device specific information
89 //
90 MOUSE_SR SampleRate;
91 MOUSE_RE Resolution;
92 MOUSE_SF Scaling;
93 UINT8 DataPackageSize;
94
95 EFI_ISA_IO_PROTOCOL *IsaIo;
96
97 EFI_EVENT TimerEvent;
98
99 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
100 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
101 } PS2_MOUSE_ABSOLUTE_POINTER_DEV;
102
103 #define PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_ABSOLUTE_POINTER_DEV, AbsolutePointerProtocol, PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE)
104
105 //
106 // Function prototypes
107 //
108 /**
109 Test to see if this driver supports ControllerHandle. Any ControllerHandle
110 than contains a IsaIo protocol can be supported.
111
112 @param This Protocol instance pointer.
113 @param ControllerHandle Handle of device to test
114 @param RemainingDevicePath Optional parameter use to pick a specific child
115 device to start.
116
117 @retval EFI_SUCCESS This driver supports this device
118 @retval EFI_ALREADY_STARTED This driver is already running on this device
119 @retval other This driver does not support this device
120
121 **/
122 EFI_STATUS
123 EFIAPI
124 PS2MouseAbsolutePointerDriverSupported (
125 IN EFI_DRIVER_BINDING_PROTOCOL *This,
126 IN EFI_HANDLE Controller,
127 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
128 );
129
130 /**
131 Start this driver on ControllerHandle by opening a IsaIo
132 protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
133 finnally.
134
135 @param This Protocol instance pointer.
136 @param ControllerHandle Handle of device to bind driver to
137 @param RemainingDevicePath Optional parameter use to pick a specific child
138 device to start.
139
140 @retval EFI_SUCCESS This driver is added to ControllerHandle
141 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
142 @retval other This driver does not support this device
143
144 **/
145 EFI_STATUS
146 EFIAPI
147 PS2MouseAbsolutePointerDriverStart (
148 IN EFI_DRIVER_BINDING_PROTOCOL *This,
149 IN EFI_HANDLE Controller,
150 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
151 );
152
153 /**
154 Stop this driver on ControllerHandle. Support stopping any child handles
155 created by this driver.
156
157 @param This Protocol instance pointer.
158 @param ControllerHandle Handle of device to stop driver on
159 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
160 children is zero stop the entire bus driver.
161 @param ChildHandleBuffer List of Child Handles to Stop.
162
163 @retval EFI_SUCCESS This driver is removed ControllerHandle
164 @retval other This driver was not removed from this device
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 PS2MouseAbsolutePointerDriverStop (
170 IN EFI_DRIVER_BINDING_PROTOCOL *This,
171 IN EFI_HANDLE Controller,
172 IN UINTN NumberOfChildren,
173 IN EFI_HANDLE *ChildHandleBuffer
174 );
175
176 //
177 // EFI Component Name Functions
178 //
179 /**
180 Retrieves a Unicode string that is the user readable name of the driver.
181
182 This function retrieves the user readable name of a driver in the form of a
183 Unicode string. If the driver specified by This has a user readable name in
184 the language specified by Language, then a pointer to the driver name is
185 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
186 by This does not support the language specified by Language,
187 then EFI_UNSUPPORTED is returned.
188
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
191
192 @param Language[in] A pointer to a Null-terminated ASCII string
193 array indicating the language. This is the
194 language of the driver name that the caller is
195 requesting, and it must match one of the
196 languages specified in SupportedLanguages. The
197 number of languages supported by a driver is up
198 to the driver writer. Language is specified
199 in RFC 4646 or ISO 639-2 language code format.
200
201 @param DriverName[out] A pointer to the Unicode string to return.
202 This Unicode string is the name of the
203 driver specified by This in the language
204 specified by Language.
205
206 @retval EFI_SUCCESS The Unicode string for the Driver specified by
207 This and the language specified by Language was
208 returned in DriverName.
209
210 @retval EFI_INVALID_PARAMETER Language is NULL.
211
212 @retval EFI_INVALID_PARAMETER DriverName is NULL.
213
214 @retval EFI_UNSUPPORTED The driver specified by This does not support
215 the language specified by Language.
216
217 **/
218 EFI_STATUS
219 EFIAPI
220 Ps2MouseAbsolutePointerComponentNameGetDriverName (
221 IN EFI_COMPONENT_NAME_PROTOCOL *This,
222 IN CHAR8 *Language,
223 OUT CHAR16 **DriverName
224 );
225
226
227 /**
228 Retrieves a Unicode string that is the user readable name of the controller
229 that is being managed by a driver.
230
231 This function retrieves the user readable name of the controller specified by
232 ControllerHandle and ChildHandle in the form of a Unicode string. If the
233 driver specified by This has a user readable name in the language specified by
234 Language, then a pointer to the controller name is returned in ControllerName,
235 and EFI_SUCCESS is returned. If the driver specified by This is not currently
236 managing the controller specified by ControllerHandle and ChildHandle,
237 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
238 support the language specified by Language, then EFI_UNSUPPORTED is returned.
239
240 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
241 EFI_COMPONENT_NAME_PROTOCOL instance.
242
243 @param ControllerHandle[in] The handle of a controller that the driver
244 specified by This is managing. This handle
245 specifies the controller whose name is to be
246 returned.
247
248 @param ChildHandle[in] The handle of the child controller to retrieve
249 the name of. This is an optional parameter that
250 may be NULL. It will be NULL for device
251 drivers. It will also be NULL for a bus drivers
252 that wish to retrieve the name of the bus
253 controller. It will not be NULL for a bus
254 driver that wishes to retrieve the name of a
255 child controller.
256
257 @param Language[in] A pointer to a Null-terminated ASCII string
258 array indicating the language. This is the
259 language of the driver name that the caller is
260 requesting, and it must match one of the
261 languages specified in SupportedLanguages. The
262 number of languages supported by a driver is up
263 to the driver writer. Language is specified in
264 RFC 4646 or ISO 639-2 language code format.
265
266 @param ControllerName[out] A pointer to the Unicode string to return.
267 This Unicode string is the name of the
268 controller specified by ControllerHandle and
269 ChildHandle in the language specified by
270 Language from the point of view of the driver
271 specified by This.
272
273 @retval EFI_SUCCESS The Unicode string for the user readable name in
274 the language specified by Language for the
275 driver specified by This was returned in
276 DriverName.
277
278 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
279
280 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
281 EFI_HANDLE.
282
283 @retval EFI_INVALID_PARAMETER Language is NULL.
284
285 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
286
287 @retval EFI_UNSUPPORTED The driver specified by This is not currently
288 managing the controller specified by
289 ControllerHandle and ChildHandle.
290
291 @retval EFI_UNSUPPORTED The driver specified by This does not support
292 the language specified by Language.
293
294 **/
295 EFI_STATUS
296 EFIAPI
297 Ps2MouseAbsolutePointerComponentNameGetControllerName (
298 IN EFI_COMPONENT_NAME_PROTOCOL *This,
299 IN EFI_HANDLE ControllerHandle,
300 IN EFI_HANDLE ChildHandle OPTIONAL,
301 IN CHAR8 *Language,
302 OUT CHAR16 **ControllerName
303 );
304
305 /**
306 Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system.
307
308 @param This - Pointer of simple pointer Protocol.
309 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
310
311
312 @retval EFI_SUCCESS - The command byte is written successfully.
313 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
314
315 **/
316 EFI_STATUS
317 EFIAPI
318 MouseAbsolutePointerReset (
319 IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
320 IN BOOLEAN ExtendedVerification
321 );
322
323 /**
324 Get and Clear mouse status.
325
326 @param This - Pointer of simple pointer Protocol.
327 @param State - Output buffer holding status.
328
329 @retval EFI_INVALID_PARAMETER Output buffer is invalid.
330 @retval EFI_NOT_READY Mouse is not changed status yet.
331 @retval EFI_SUCCESS Mouse status is changed and get successful.
332 **/
333 EFI_STATUS
334 EFIAPI
335 MouseAbsolutePointerGetState (
336 IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
337 IN OUT EFI_ABSOLUTE_POINTER_STATE *State
338 );
339
340 /**
341
342 Event notification function for SIMPLE_POINTER.WaitForInput event.
343 Signal the event if there is input from mouse.
344
345 @param Event event object
346 @param Context event context
347
348 **/
349 VOID
350 EFIAPI
351 MouseAbsolutePointerWaitForInput (
352 IN EFI_EVENT Event,
353 IN VOID *Context
354 );
355
356 /**
357 Event notification function for TimerEvent event.
358 If mouse device is connected to system, try to get the mouse packet data.
359
360 @param Event - TimerEvent in PS2_MOUSE_DEV
361 @param Context - Pointer to PS2_MOUSE_DEV structure
362
363 **/
364 VOID
365 EFIAPI
366 PollMouseAbsolutePointer (
367 IN EFI_EVENT Event,
368 IN VOID *Context
369 );
370
371 /**
372 I/O work flow of in 8042 data.
373
374 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
375 @param Data Data value
376
377 @retval EFI_SUCCESS Success to execute I/O work flow
378 @retval EFI_TIMEOUT Keyboard controller time out.
379 **/
380 EFI_STATUS
381 In8042Data (
382 IN EFI_ISA_IO_PROTOCOL *IsaIo,
383 IN OUT UINT8 *Data
384 );
385
386 /**
387 Check whether there is Ps/2 mouse device in system
388
389 @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure
390
391 @retval TRUE - Keyboard in System.
392 @retval FALSE - Keyboard not in System.
393
394 **/
395 BOOLEAN
396 CheckMouseAbsolutePointerConnect (
397 IN PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
398 );
399
400 #endif