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