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