]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Isa / Ps2MouseDxe / Ps2Mouse.h
1 /** @file
2 PS/2 Mouse driver header file.
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _PS2MOUSE_H_
10 #define _PS2MOUSE_H_
11
12 #include <Uefi.h>
13
14 #include <Protocol/SimplePointer.h>
15 #include <Protocol/SuperIo.h>
16 #include <Protocol/DevicePath.h>
17
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>
28
29 //
30 // Global Variables
31 //
32 extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver;
33 extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName;
34 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2;
35
36 //
37 // PS/2 mouse sample rate
38 //
39 typedef enum {
40 SampleRate10,
41 SampleRate20,
42 SampleRate40,
43 SampleRate60,
44 SampleRate80,
45 SampleRate100,
46 SampleRate200,
47 MaxSampleRate
48 } MOUSE_SR;
49
50 //
51 // PS/2 mouse resolution
52 //
53 typedef enum {
54 MouseResolution1,
55 MouseResolution2,
56 MouseResolution4,
57 MouseResolution8,
58 MaxResolution
59 } MOUSE_RE;
60
61 //
62 // PS/2 mouse scaling
63 //
64 typedef enum {
65 Scaling1,
66 Scaling2
67 } MOUSE_SF;
68
69 //
70 // Driver Private Data
71 //
72 #define PS2_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('p', 's', '2', 'm')
73
74 typedef struct {
75 UINTN Signature;
76
77 EFI_HANDLE Handle;
78 EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;
79 EFI_SIMPLE_POINTER_STATE State;
80 EFI_SIMPLE_POINTER_MODE Mode;
81 BOOLEAN StateChanged;
82
83 //
84 // PS2 Mouse device specific information
85 //
86 MOUSE_SR SampleRate;
87 MOUSE_RE Resolution;
88 MOUSE_SF Scaling;
89 UINT8 DataPackageSize;
90
91 EFI_EVENT TimerEvent;
92
93 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
94 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
95 } PS2_MOUSE_DEV;
96
97 #define PS2_MOUSE_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)
98
99 //
100 // Function prototypes
101 //
102
103 /**
104 Test to see if this driver supports ControllerHandle. Any ControllerHandle
105 than contains a IsaIo protocol can be supported.
106
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
110 device to start.
111
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
115
116 **/
117 EFI_STATUS
118 EFIAPI
119 PS2MouseDriverSupported (
120 IN EFI_DRIVER_BINDING_PROTOCOL *This,
121 IN EFI_HANDLE Controller,
122 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
123 );
124
125 /**
126 Start this driver on ControllerHandle by opening a IsaIo
127 protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
128 finally.
129
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
133 device to start.
134
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
138
139 **/
140 EFI_STATUS
141 EFIAPI
142 PS2MouseDriverStart (
143 IN EFI_DRIVER_BINDING_PROTOCOL *This,
144 IN EFI_HANDLE Controller,
145 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
146 );
147
148 /**
149 Stop this driver on ControllerHandle. Support stopping any child handles
150 created by this driver.
151
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.
157
158 @retval EFI_SUCCESS This driver is removed ControllerHandle
159 @retval other This driver was not removed from this device
160
161 **/
162 EFI_STATUS
163 EFIAPI
164 PS2MouseDriverStop (
165 IN EFI_DRIVER_BINDING_PROTOCOL *This,
166 IN EFI_HANDLE Controller,
167 IN UINTN NumberOfChildren,
168 IN EFI_HANDLE *ChildHandleBuffer
169 );
170
171 //
172 // EFI Component Name Functions
173 //
174
175 /**
176 Retrieves a Unicode string that is the user readable name of the driver.
177
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.
184
185 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
186 EFI_COMPONENT_NAME_PROTOCOL instance.
187
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.
196
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.
201
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.
205
206 @retval EFI_INVALID_PARAMETER Language is NULL.
207
208 @retval EFI_INVALID_PARAMETER DriverName is NULL.
209
210 @retval EFI_UNSUPPORTED The driver specified by This does not support
211 the language specified by Language.
212
213 **/
214 EFI_STATUS
215 EFIAPI
216 Ps2MouseComponentNameGetDriverName (
217 IN EFI_COMPONENT_NAME_PROTOCOL *This,
218 IN CHAR8 *Language,
219 OUT CHAR16 **DriverName
220 );
221
222 /**
223 Retrieves a Unicode string that is the user readable name of the controller
224 that is being managed by a driver.
225
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.
234
235 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
236 EFI_COMPONENT_NAME_PROTOCOL instance.
237
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
241 returned.
242
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
250 child controller.
251
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.
260
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
266 specified by This.
267
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
271 DriverName.
272
273 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
274
275 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
276 EFI_HANDLE.
277
278 @retval EFI_INVALID_PARAMETER Language is NULL.
279
280 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
281
282 @retval EFI_UNSUPPORTED The driver specified by This is not currently
283 managing the controller specified by
284 ControllerHandle and ChildHandle.
285
286 @retval EFI_UNSUPPORTED The driver specified by This does not support
287 the language specified by Language.
288
289 **/
290 EFI_STATUS
291 EFIAPI
292 Ps2MouseComponentNameGetControllerName (
293 IN EFI_COMPONENT_NAME_PROTOCOL *This,
294 IN EFI_HANDLE ControllerHandle,
295 IN EFI_HANDLE ChildHandle OPTIONAL,
296 IN CHAR8 *Language,
297 OUT CHAR16 **ControllerName
298 );
299
300 /**
301 Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and
302 there is a mouse device connected to system.
303
304 @param This - Pointer of simple pointer Protocol.
305 @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
306
307
308 @retval EFI_SUCCESS - The command byte is written successfully.
309 @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
310
311 **/
312 EFI_STATUS
313 EFIAPI
314 MouseReset (
315 IN EFI_SIMPLE_POINTER_PROTOCOL *This,
316 IN BOOLEAN ExtendedVerification
317 );
318
319 /**
320 Get and Clear mouse status.
321
322 @param This - Pointer of simple pointer Protocol.
323 @param State - Output buffer holding status.
324
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.
328 **/
329 EFI_STATUS
330 EFIAPI
331 MouseGetState (
332 IN EFI_SIMPLE_POINTER_PROTOCOL *This,
333 IN OUT EFI_SIMPLE_POINTER_STATE *State
334 );
335
336 /**
337
338 Event notification function for SIMPLE_POINTER.WaitForInput event.
339 Signal the event if there is input from mouse.
340
341 @param Event event object
342 @param Context event context
343
344 **/
345 VOID
346 EFIAPI
347 MouseWaitForInput (
348 IN EFI_EVENT Event,
349 IN VOID *Context
350 );
351
352 /**
353 Event notification function for TimerEvent event.
354 If mouse device is connected to system, try to get the mouse packet data.
355
356 @param Event - TimerEvent in PS2_MOUSE_DEV
357 @param Context - Pointer to PS2_MOUSE_DEV structure
358
359 **/
360 VOID
361 EFIAPI
362 PollMouse (
363 IN EFI_EVENT Event,
364 IN VOID *Context
365 );
366
367 /**
368 I/O work flow of in 8042 data.
369
370 @param Data Data value
371
372 @retval EFI_SUCCESS Success to execute I/O work flow
373 @retval EFI_TIMEOUT Keyboard controller time out.
374 **/
375 EFI_STATUS
376 In8042Data (
377 IN OUT UINT8 *Data
378 );
379
380 /**
381 Check whether there is Ps/2 mouse device in system
382
383 @param MouseDev - Mouse Private Data Structure
384
385 @retval TRUE - Keyboard in System.
386 @retval FALSE - Keyboard not in System.
387
388 **/
389 BOOLEAN
390 CheckMouseConnect (
391 IN PS2_MOUSE_DEV *MouseDev
392 );
393
394 #endif