View | Details | Raw Unified | Return to bug 625041
Collapse All | Expand All

(-)a/shared/vmmouse_proto.c (-1 / +44 lines)
Lines 33-39 Link Here
33
 */
33
 */
34
34
35
35
36
#include <sys/io.h>
36
#include "vmmouse_proto.h"
37
#include "vmmouse_proto.h"
38
#include "vmmouse_client.h"
37
39
38
40
39
/*
41
/*
Lines 119-124 VMMouseProtoInOut(VMMouseProtoCmd *cmd) // IN/OUT Link Here
119
#endif
121
#endif
120
}
122
}
121
123
124
/*
125
 *-----------------------------------------------------------------------------
126
 *
127
 * VMMouseGetIOPL --
128
 *
129
 *      Helper to figure out the current I/O privilege level (idea by
130
 *      Jiri Kosina <jkosina@suse.cz>)
131
 *
132
 * Results:
133
 *      Returns I/O privilege level
134
 *
135
 * Side effects:
136
 *      None
137
 *
138
 *-----------------------------------------------------------------------------
139
 */
140
141
int 
142
VMMouseGetIOPL()
143
{
144
        unsigned long eflags;
145
146
        asm ("pushf\n\tpop %0" : "=r" (eflags));
147
        return (eflags >> 12) & 3;
148
}
122
149
123
/*
150
/*
124
 *-----------------------------------------------------------------------------
151
 *-----------------------------------------------------------------------------
Lines 140-147 VMMouseProtoInOut(VMMouseProtoCmd *cmd) // IN/OUT Link Here
140
void
167
void
141
VMMouseProto_SendCmd(VMMouseProtoCmd *cmd) // IN/OUT
168
VMMouseProto_SendCmd(VMMouseProtoCmd *cmd) // IN/OUT
142
{
169
{
170
   int cpl;
171
143
   cmd->in.magic = VMMOUSE_PROTO_MAGIC;
172
   cmd->in.magic = VMMOUSE_PROTO_MAGIC;
144
   cmd->in.port = VMMOUSE_PROTO_PORT;
173
   cmd->in.port = VMMOUSE_PROTO_PORT;
145
174
175
#if defined __i386__ || defined __x86_64__ 
176
   cpl = VMMouseGetIOPL();
177
   VMwareLog(("Current I/O privilege level: %d", cpl));
178
   /*
179
    * To access i/o ports above 0x3ff, we need to be in iopl(3).
180
    */
181
   VMwareLog(("Switching to I/O privilege level 3."));
182
   iopl(3);
183
#endif
184
146
   VMMouseProtoInOut(cmd);
185
   VMMouseProtoInOut(cmd);
186
187
#if defined __i386__ || defined __x86_64__ 
188
   VMwareLog(("Switching back to previous I/O privilege level %d.\n", cpl));
189
   iopl(cpl);
190
#endif
147
}
191
}
148
- 

Return to bug 625041