1d075918cSmrg/*
2d075918cSmrg * Copyright 1999-2006 by VMware, Inc.
3d075918cSmrg *
4d075918cSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5d075918cSmrg * copy of this software and associated documentation files (the "Software"),
6d075918cSmrg * to deal in the Software without restriction, including without limitation
7d075918cSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d075918cSmrg * and/or sell copies of the Software, and to permit persons to whom the
9d075918cSmrg * Software is furnished to do so, subject to the following conditions:
10d075918cSmrg *
11d075918cSmrg * The above copyright notice and this permission notice shall be included in
12d075918cSmrg * all copies or substantial portions of the Software.
13d075918cSmrg *
14d075918cSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15d075918cSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16d075918cSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17d075918cSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18d075918cSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19d075918cSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20d075918cSmrg * OTHER DEALINGS IN THE SOFTWARE.
21d075918cSmrg *
22d075918cSmrg * Except as contained in this notice, the name of the copyright holder(s)
23d075918cSmrg * and author(s) shall not be used in advertising or otherwise to promote
24d075918cSmrg * the sale, use or other dealings in this Software without prior written
25d075918cSmrg * authorization from the copyright holder(s) and author(s).
26d075918cSmrg */
27d075918cSmrg
28d075918cSmrg/*
29d075918cSmrg * vmmouse_proto.h --
30d075918cSmrg *
31d075918cSmrg *      The communication protocol between the guest and the vmmouse
32d075918cSmrg *      virtual device.
33d075918cSmrg */
34d075918cSmrg
35d075918cSmrg
36d075918cSmrg#ifndef _VMMOUSE_PROTO_H_
37d075918cSmrg#define _VMMOUSE_PROTO_H_
38d075918cSmrg
39d075918cSmrg#include <stdint.h>
40d075918cSmrg
41d075918cSmrg#ifdef HAVE_XORG_SERVER_1_1_0
42d075918cSmrg#include <unistd.h>
43d075918cSmrg#else
44d075918cSmrg#include "xf86_libc.h"
45d075918cSmrg#endif
46d075918cSmrg
47d075918cSmrg/* Map Solaris/Sun compiler #defines to gcc equivalents */
48d075918cSmrg#if !defined __i386__ && defined __i386
49d075918cSmrg# define __i386__
50d075918cSmrg#endif
51d075918cSmrg
52d075918cSmrg#if !defined __x86_64__ && defined __amd64
53d075918cSmrg# define __x86_64__
54d075918cSmrg#endif
55d075918cSmrg
56d075918cSmrg#if !defined __i386__ && !defined __x86_64__
57d075918cSmrg#error The vmmouse protocol is only supported on x86 architectures.
58d075918cSmrg#endif
59d075918cSmrg
60d075918cSmrg#define VMMOUSE_PROTO_MAGIC 0x564D5868
61d075918cSmrg#define VMMOUSE_PROTO_PORT 0x5658
62d075918cSmrg
63d075918cSmrg#define VMMOUSE_PROTO_CMD_GETVERSION		10
64d075918cSmrg#define VMMOUSE_PROTO_CMD_ABSPOINTER_DATA	39
65d075918cSmrg#define VMMOUSE_PROTO_CMD_ABSPOINTER_STATUS	40
66d075918cSmrg#define VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND	41
678746cb53Smrg#define VMMOUSE_PROTO_CMD_ABSPOINTER_RESTRICT   86
68d075918cSmrg
69d075918cSmrg#define DECLARE_REG32_STRUCT(_r) \
70d075918cSmrg   union { \
71d075918cSmrg      struct { \
72d075918cSmrg         uint16_t low; \
73d075918cSmrg         uint16_t high; \
74d075918cSmrg      } vE##_r##_; \
75d075918cSmrg      uint32_t vE##_r; \
76d075918cSmrg   }
77d075918cSmrg
78d075918cSmrg#ifdef __x86_64__
79d075918cSmrg
80d075918cSmrg#define DECLARE_REG64_STRUCT(_r) \
81d075918cSmrg   union { \
82d075918cSmrg      DECLARE_REG32_STRUCT(_r); \
83d075918cSmrg      struct { \
84d075918cSmrg         uint32_t low; \
85d075918cSmrg         uint32_t high; \
86d075918cSmrg      } vR##_r##_; \
87d075918cSmrg      uint64_t vR##_r; \
88d075918cSmrg   }
89d075918cSmrg
90d075918cSmrg#define DECLARE_REG_STRUCT(x) DECLARE_REG64_STRUCT(x)
91d075918cSmrg
92d075918cSmrg#else
93d075918cSmrg
94d075918cSmrg#define DECLARE_REG_STRUCT(x) DECLARE_REG32_STRUCT(x)
95d075918cSmrg
96d075918cSmrg#endif
97d075918cSmrg
98d075918cSmrgtypedef union {
99d075918cSmrg   struct {
100d075918cSmrg      union {
101d075918cSmrg         uint32_t magic;
102d075918cSmrg         DECLARE_REG_STRUCT(ax);
103d075918cSmrg      };
104d075918cSmrg      union {
105d075918cSmrg         size_t size;
106d075918cSmrg         DECLARE_REG_STRUCT(bx);
107d075918cSmrg      };
108d075918cSmrg      union {
109d075918cSmrg         uint16_t command;
110d075918cSmrg         DECLARE_REG_STRUCT(cx);
111d075918cSmrg      };
112d075918cSmrg      union {
113d075918cSmrg         uint16_t port;
114d075918cSmrg         DECLARE_REG_STRUCT(dx);
115d075918cSmrg      };
116d075918cSmrg      DECLARE_REG_STRUCT(si);
117d075918cSmrg      DECLARE_REG_STRUCT(di);
118d075918cSmrg   } in;
119d075918cSmrg   struct {
120d075918cSmrg      DECLARE_REG_STRUCT(ax);
121d075918cSmrg      DECLARE_REG_STRUCT(bx);
122d075918cSmrg      DECLARE_REG_STRUCT(cx);
123d075918cSmrg      DECLARE_REG_STRUCT(dx);
124d075918cSmrg      DECLARE_REG_STRUCT(si);
125d075918cSmrg      DECLARE_REG_STRUCT(di);
126d075918cSmrg   } out;
127d075918cSmrg} VMMouseProtoCmd;
128d075918cSmrg
129d075918cSmrg
130d075918cSmrgvoid
131d075918cSmrgVMMouseProto_SendCmd(VMMouseProtoCmd *cmd); // IN/OUT
132d075918cSmrg
133d075918cSmrg
134d075918cSmrg#undef DECLARE_REG_STRUCT
135d075918cSmrg
136d075918cSmrg#endif /* _VMMOUSE_PROTO_H_ */
137