2121#include "psmouse.h"
2222#include "vmmouse.h"
2323
24- #define VMMOUSE_PROTO_MAGIC 0x564D5868U
25-
2624/*
2725 * Main commands supported by the vmmouse hypervisor port.
2826 */
29- #define VMMOUSE_PROTO_CMD_GETVERSION 10
30- #define VMMOUSE_PROTO_CMD_ABSPOINTER_DATA 39
31- #define VMMOUSE_PROTO_CMD_ABSPOINTER_STATUS 40
32- #define VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND 41
33- #define VMMOUSE_PROTO_CMD_ABSPOINTER_RESTRICT 86
27+ #define VMWARE_CMD_ABSPOINTER_DATA 39
28+ #define VMWARE_CMD_ABSPOINTER_STATUS 40
29+ #define VMWARE_CMD_ABSPOINTER_COMMAND 41
30+ #define VMWARE_CMD_ABSPOINTER_RESTRICT 86
3431
3532/*
36- * Subcommands for VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND
33+ * Subcommands for VMWARE_CMD_ABSPOINTER_COMMAND
3734 */
3835#define VMMOUSE_CMD_ENABLE 0x45414552U
3936#define VMMOUSE_CMD_DISABLE 0x000000f5U
@@ -76,28 +73,6 @@ struct vmmouse_data {
7673 char dev_name [128 ];
7774};
7875
79- /*
80- * Hypervisor-specific bi-directional communication channel
81- * implementing the vmmouse protocol. Should never execute on
82- * bare metal hardware.
83- */
84- #define VMMOUSE_CMD (cmd , in1 , out1 , out2 , out3 , out4 ) \
85- ({ \
86- unsigned long __dummy1, __dummy2; \
87- __asm__ __volatile__ (VMWARE_HYPERCALL : \
88- "=a"(out1), \
89- "=b"(out2), \
90- "=c"(out3), \
91- "=d"(out4), \
92- "=S"(__dummy1), \
93- "=D"(__dummy2) : \
94- "a"(VMMOUSE_PROTO_MAGIC), \
95- "b"(in1), \
96- "c"(VMMOUSE_PROTO_CMD_##cmd), \
97- "d"(0) : \
98- "memory"); \
99- })
100-
10176/**
10277 * vmmouse_report_button - report button state on the correct input device
10378 *
@@ -145,14 +120,12 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse)
145120 struct input_dev * abs_dev = priv -> abs_dev ;
146121 struct input_dev * pref_dev ;
147122 u32 status , x , y , z ;
148- u32 dummy1 , dummy2 , dummy3 ;
149123 unsigned int queue_length ;
150124 unsigned int count = 255 ;
151125
152126 while (count -- ) {
153127 /* See if we have motion data. */
154- VMMOUSE_CMD (ABSPOINTER_STATUS , 0 ,
155- status , dummy1 , dummy2 , dummy3 );
128+ status = vmware_hypercall1 (VMWARE_CMD_ABSPOINTER_STATUS , 0 );
156129 if ((status & VMMOUSE_ERROR ) == VMMOUSE_ERROR ) {
157130 psmouse_err (psmouse , "failed to fetch status data\n" );
158131 /*
@@ -172,7 +145,8 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse)
172145 }
173146
174147 /* Now get it */
175- VMMOUSE_CMD (ABSPOINTER_DATA , 4 , status , x , y , z );
148+ status = vmware_hypercall4 (VMWARE_CMD_ABSPOINTER_DATA , 4 ,
149+ & x , & y , & z );
176150
177151 /*
178152 * And report what we've got. Prefer to report button
@@ -247,14 +221,10 @@ static psmouse_ret_t vmmouse_process_byte(struct psmouse *psmouse)
247221static void vmmouse_disable (struct psmouse * psmouse )
248222{
249223 u32 status ;
250- u32 dummy1 , dummy2 , dummy3 , dummy4 ;
251-
252- VMMOUSE_CMD (ABSPOINTER_COMMAND , VMMOUSE_CMD_DISABLE ,
253- dummy1 , dummy2 , dummy3 , dummy4 );
254224
255- VMMOUSE_CMD (ABSPOINTER_STATUS , 0 ,
256- status , dummy1 , dummy2 , dummy3 );
225+ vmware_hypercall1 (VMWARE_CMD_ABSPOINTER_COMMAND , VMMOUSE_CMD_DISABLE );
257226
227+ status = vmware_hypercall1 (VMWARE_CMD_ABSPOINTER_STATUS , 0 );
258228 if ((status & VMMOUSE_ERROR ) != VMMOUSE_ERROR )
259229 psmouse_warn (psmouse , "failed to disable vmmouse device\n" );
260230}
@@ -271,26 +241,24 @@ static void vmmouse_disable(struct psmouse *psmouse)
271241static int vmmouse_enable (struct psmouse * psmouse )
272242{
273243 u32 status , version ;
274- u32 dummy1 , dummy2 , dummy3 , dummy4 ;
275244
276245 /*
277246 * Try enabling the device. If successful, we should be able to
278247 * read valid version ID back from it.
279248 */
280- VMMOUSE_CMD (ABSPOINTER_COMMAND , VMMOUSE_CMD_ENABLE ,
281- dummy1 , dummy2 , dummy3 , dummy4 );
249+ vmware_hypercall1 (VMWARE_CMD_ABSPOINTER_COMMAND , VMMOUSE_CMD_ENABLE );
282250
283251 /*
284252 * See if version ID can be retrieved.
285253 */
286- VMMOUSE_CMD ( ABSPOINTER_STATUS , 0 , status , dummy1 , dummy2 , dummy3 );
254+ status = vmware_hypercall1 ( VMWARE_CMD_ABSPOINTER_STATUS , 0 );
287255 if ((status & 0x0000ffff ) == 0 ) {
288256 psmouse_dbg (psmouse , "empty flags - assuming no device\n" );
289257 return - ENXIO ;
290258 }
291259
292- VMMOUSE_CMD ( ABSPOINTER_DATA , 1 /* single item */ ,
293- version , dummy1 , dummy2 , dummy3 );
260+ version = vmware_hypercall1 ( VMWARE_CMD_ABSPOINTER_DATA ,
261+ 1 /* single item */ );
294262 if (version != VMMOUSE_VERSION_ID ) {
295263 psmouse_dbg (psmouse , "Unexpected version value: %u vs %u\n" ,
296264 (unsigned ) version , VMMOUSE_VERSION_ID );
@@ -301,11 +269,11 @@ static int vmmouse_enable(struct psmouse *psmouse)
301269 /*
302270 * Restrict ioport access, if possible.
303271 */
304- VMMOUSE_CMD ( ABSPOINTER_RESTRICT , VMMOUSE_RESTRICT_CPL0 ,
305- dummy1 , dummy2 , dummy3 , dummy4 );
272+ vmware_hypercall1 ( VMWARE_CMD_ABSPOINTER_RESTRICT ,
273+ VMMOUSE_RESTRICT_CPL0 );
306274
307- VMMOUSE_CMD ( ABSPOINTER_COMMAND , VMMOUSE_CMD_REQUEST_ABSOLUTE ,
308- dummy1 , dummy2 , dummy3 , dummy4 );
275+ vmware_hypercall1 ( VMWARE_CMD_ABSPOINTER_COMMAND ,
276+ VMMOUSE_CMD_REQUEST_ABSOLUTE );
309277
310278 return 0 ;
311279}
@@ -342,7 +310,7 @@ static bool vmmouse_check_hypervisor(void)
342310 */
343311int vmmouse_detect (struct psmouse * psmouse , bool set_properties )
344312{
345- u32 response , version , dummy1 , dummy2 ;
313+ u32 response , version , type ;
346314
347315 if (!vmmouse_check_hypervisor ()) {
348316 psmouse_dbg (psmouse ,
@@ -351,9 +319,9 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
351319 }
352320
353321 /* Check if the device is present */
354- response = ~VMMOUSE_PROTO_MAGIC ;
355- VMMOUSE_CMD ( GETVERSION , 0 , version , response , dummy1 , dummy2 );
356- if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU )
322+ response = ~VMWARE_HYPERVISOR_MAGIC ;
323+ version = vmware_hypercall3 ( VMWARE_CMD_GETVERSION , 0 , & response , & type );
324+ if (response != VMWARE_HYPERVISOR_MAGIC || version == 0xffffffffU )
357325 return - ENXIO ;
358326
359327 if (set_properties ) {
0 commit comments