1 | /* $Id: DevPS2M.cpp 83444 2020-03-26 17:38:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PS2M - PS/2 auxiliary device (mouse) emulation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*
|
---|
19 | * References:
|
---|
20 | *
|
---|
21 | * The Undocumented PC (2nd Ed.), Frank van Gilluwe, Addison-Wesley, 1996.
|
---|
22 | * IBM TrackPoint System Version 4.0 Engineering Specification, 1999.
|
---|
23 | * ELAN Microelectronics eKM8025 USB & PS/2 Mouse Controller, 2006.
|
---|
24 | *
|
---|
25 | *
|
---|
26 | * Notes:
|
---|
27 | *
|
---|
28 | * - The auxiliary device commands are very similar to keyboard commands.
|
---|
29 | * Most keyboard commands which do not specifically deal with the keyboard
|
---|
30 | * (enable, disable, reset) have identical counterparts.
|
---|
31 | * - The code refers to 'auxiliary device' and 'mouse'; these terms are not
|
---|
32 | * quite interchangeable. 'Auxiliary device' is used when referring to the
|
---|
33 | * generic PS/2 auxiliary device interface and 'mouse' when referring to
|
---|
34 | * a mouse attached to the auxiliary port.
|
---|
35 | * - The basic modes of operation are reset, stream, and remote. Those are
|
---|
36 | * mutually exclusive. Stream and remote modes can additionally have wrap
|
---|
37 | * mode enabled.
|
---|
38 | * - The auxiliary device sends unsolicited data to the host only when it is
|
---|
39 | * both in stream mode and enabled. Otherwise it only responds to commands.
|
---|
40 | *
|
---|
41 | *
|
---|
42 | * There are three report packet formats supported by the emulated device. The
|
---|
43 | * standard three-byte PS/2 format (with middle button support), IntelliMouse
|
---|
44 | * four-byte format with added scroll wheel, and IntelliMouse Explorer four-byte
|
---|
45 | * format with reduced scroll wheel range but two additional buttons. Note that
|
---|
46 | * the first three bytes of the report are always the same.
|
---|
47 | *
|
---|
48 | * Upon reset, the mouse is always in the standard PS/2 mode. A special 'knock'
|
---|
49 | * sequence can be used to switch to ImPS/2 or ImEx mode. Three consecutive
|
---|
50 | * Set Sampling Rate (0F3h) commands with arguments 200, 100, 80 switch to ImPS/2
|
---|
51 | * mode. While in ImPS/2 or PS/2 mode, three consecutive Set Sampling Rate
|
---|
52 | * commands with arguments 200, 200, 80 switch to ImEx mode. The Read ID (0F2h)
|
---|
53 | * command will report the currently selected protocol.
|
---|
54 | *
|
---|
55 | * There is an extended ImEx mode with support for horizontal scrolling. It is
|
---|
56 | * entered from ImEx mode with a 200, 80, 40 sequence of Set Sampling Rate
|
---|
57 | * commands. It does not change the reported protocol (it remains 4, or ImEx)
|
---|
58 | * but changes the meaning of the 4th byte.
|
---|
59 | *
|
---|
60 | *
|
---|
61 | * Standard PS/2 pointing device three-byte report packet format:
|
---|
62 | *
|
---|
63 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
64 | * |Bit/byte| bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
|
---|
65 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
66 | * | Byte 1 | Y ovfl | X ovfl | Y sign | X sign | Sync | M btn | R btn | L btn |
|
---|
67 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
68 | * | Byte 2 | X movement delta (two's complement) |
|
---|
69 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
70 | * | Byte 3 | Y movement delta (two's complement) |
|
---|
71 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
72 | *
|
---|
73 | * - The sync bit is always set. It allows software to synchronize data packets
|
---|
74 | * as the X/Y position data typically does not have bit 4 set.
|
---|
75 | * - The overflow bits are set if motion exceeds accumulator range. We use the
|
---|
76 | * maximum range (effectively 9 bits) and do not set the overflow bits.
|
---|
77 | * - Movement in the up/right direction is defined as having positive sign.
|
---|
78 | *
|
---|
79 | *
|
---|
80 | * IntelliMouse PS/2 (ImPS/2) fourth report packet byte:
|
---|
81 | *
|
---|
82 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
83 | * |Bit/byte| bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
|
---|
84 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
85 | * | Byte 4 | Z movement delta (two's complement) |
|
---|
86 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
87 | *
|
---|
88 | * - The valid range for Z delta values is only -8/+7, i.e. 4 bits.
|
---|
89 | *
|
---|
90 | * IntelliMouse Explorer (ImEx) fourth report packet byte:
|
---|
91 | *
|
---|
92 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
93 | * |Bit/byte| bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
|
---|
94 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
95 | * | Byte 4 | 0 | 0 | Btn 5 | Btn 4 | Z mov't delta (two's complement) |
|
---|
96 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
97 | *
|
---|
98 | * - The Z delta values are in practice only -1/+1; some mice (A4tech?) report
|
---|
99 | * horizontal scrolling as -2/+2.
|
---|
100 | *
|
---|
101 | * IntelliMouse Explorer (ImEx) fourth report packet byte when scrolling:
|
---|
102 | *
|
---|
103 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
104 | * |Bit/byte| bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0 |
|
---|
105 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
106 | * | Byte 4 | V | H | Z or W movement delta (two's complement) |
|
---|
107 | * +--------+--------+--------+--------+--------+--------+--------+--------+--------+
|
---|
108 | *
|
---|
109 | * - Buttons 4 and 5 are reported as with the regular ImEx protocol, but not when
|
---|
110 | * scrolling. This is a departure from the usual logic because when the mouse
|
---|
111 | * sends scroll events, the state of buttons 4/5 is not reported and the last
|
---|
112 | * reported state should be assumed.
|
---|
113 | *
|
---|
114 | * - When the V bit (bit 7) is set, vertical scroll (Z axis) is being reported.
|
---|
115 | * When the H bit (bit 6) is set, horizontal scroll (W axis) is being reported.
|
---|
116 | * The H and V bits are never set at the same time (also see below). When
|
---|
117 | * the H and V bits are both clear, button 4/5 state is being reported.
|
---|
118 | *
|
---|
119 | * - The Z/W delta is extended to 6 bits. Z (vertical) values are not restricted
|
---|
120 | * to -1/+1, although W (horizontal) values are. Z values of at least -20/+20
|
---|
121 | * can be seen in practice.
|
---|
122 | *
|
---|
123 | * - Horizontal and vertical scroll is mutually exclusive. When the button is
|
---|
124 | * tilted, no vertical scrolling is reported, i.e. horizontal scrolling
|
---|
125 | * has priority over vertical.
|
---|
126 | *
|
---|
127 | * - Positive values indicate down/right direction, negative values up/left.
|
---|
128 | *
|
---|
129 | * - When the scroll button is tilted to engage horizontal scrolling, the mouse
|
---|
130 | * keeps sending events at a rate of 4 or 5 per second as long as the button
|
---|
131 | * is tilted.
|
---|
132 | *
|
---|
133 | * All report formats were verified with a real Microsoft IntelliMouse Explorer 4.0
|
---|
134 | * mouse attached through a PS/2 port.
|
---|
135 | *
|
---|
136 | * The button "accumulator" is necessary to avoid missing brief button presses.
|
---|
137 | * Without it, a very fast mouse button press + release might be lost if it
|
---|
138 | * happened between sending reports. The accumulator latches button presses to
|
---|
139 | * prevent that.
|
---|
140 | *
|
---|
141 | */
|
---|
142 |
|
---|
143 |
|
---|
144 | /*********************************************************************************************************************************
|
---|
145 | * Header Files *
|
---|
146 | *********************************************************************************************************************************/
|
---|
147 | #define LOG_GROUP LOG_GROUP_DEV_KBD
|
---|
148 | #include <VBox/vmm/pdmdev.h>
|
---|
149 | #include <VBox/err.h>
|
---|
150 | #include <iprt/assert.h>
|
---|
151 | #include <iprt/uuid.h>
|
---|
152 | #include "VBoxDD.h"
|
---|
153 | #define IN_PS2M
|
---|
154 | #include "DevPS2.h"
|
---|
155 |
|
---|
156 |
|
---|
157 | /*********************************************************************************************************************************
|
---|
158 | * Defined Constants And Macros *
|
---|
159 | *********************************************************************************************************************************/
|
---|
160 | /** @name Auxiliary device commands sent by the system.
|
---|
161 | * @{ */
|
---|
162 | #define ACMD_SET_SCALE_11 0xE6 /* Set 1:1 scaling. */
|
---|
163 | #define ACMD_SET_SCALE_21 0xE7 /* Set 2:1 scaling. */
|
---|
164 | #define ACMD_SET_RES 0xE8 /* Set resolution. */
|
---|
165 | #define ACMD_REQ_STATUS 0xE9 /* Get device status. */
|
---|
166 | #define ACMD_SET_STREAM 0xEA /* Set stream mode. */
|
---|
167 | #define ACMD_READ_REMOTE 0xEB /* Read remote data. */
|
---|
168 | #define ACMD_RESET_WRAP 0xEC /* Exit wrap mode. */
|
---|
169 | #define ACMD_INVALID_1 0xED
|
---|
170 | #define ACMD_SET_WRAP 0xEE /* Set wrap (echo) mode. */
|
---|
171 | #define ACMD_INVALID_2 0xEF
|
---|
172 | #define ACMD_SET_REMOTE 0xF0 /* Set remote mode. */
|
---|
173 | #define ACMD_INVALID_3 0xF1
|
---|
174 | #define ACMD_READ_ID 0xF2 /* Read device ID. */
|
---|
175 | #define ACMD_SET_SAMP_RATE 0xF3 /* Set sampling rate. */
|
---|
176 | #define ACMD_ENABLE 0xF4 /* Enable (streaming mode). */
|
---|
177 | #define ACMD_DISABLE 0xF5 /* Disable (streaming mode). */
|
---|
178 | #define ACMD_SET_DEFAULT 0xF6 /* Set defaults. */
|
---|
179 | #define ACMD_INVALID_4 0xF7
|
---|
180 | #define ACMD_INVALID_5 0xF8
|
---|
181 | #define ACMD_INVALID_6 0xF9
|
---|
182 | #define ACMD_INVALID_7 0xFA
|
---|
183 | #define ACMD_INVALID_8 0xFB
|
---|
184 | #define ACMD_INVALID_9 0xFC
|
---|
185 | #define ACMD_INVALID_10 0xFD
|
---|
186 | #define ACMD_RESEND 0xFE /* Resend response. */
|
---|
187 | #define ACMD_RESET 0xFF /* Reset device. */
|
---|
188 | /** @} */
|
---|
189 |
|
---|
190 | /** @name Auxiliary device responses sent to the system.
|
---|
191 | * @{ */
|
---|
192 | #define ARSP_ID 0x00
|
---|
193 | #define ARSP_BAT_OK 0xAA /* Self-test passed. */
|
---|
194 | #define ARSP_ACK 0xFA /* Command acknowledged. */
|
---|
195 | #define ARSP_ERROR 0xFC /* Bad command. */
|
---|
196 | #define ARSP_RESEND 0xFE /* Requesting resend. */
|
---|
197 | /** @} */
|
---|
198 |
|
---|
199 |
|
---|
200 | /*********************************************************************************************************************************
|
---|
201 | * Test code function declarations *
|
---|
202 | *********************************************************************************************************************************/
|
---|
203 | #if defined(RT_STRICT) && defined(IN_RING3)
|
---|
204 | static void ps2mR3TestAccumulation(void);
|
---|
205 | #endif
|
---|
206 |
|
---|
207 |
|
---|
208 | #ifdef IN_RING3
|
---|
209 |
|
---|
210 | /* Report a change in status down (or is it up?) the driver chain. */
|
---|
211 | static void ps2mR3SetDriverState(PPS2MR3 pThisCC, bool fEnabled)
|
---|
212 | {
|
---|
213 | PPDMIMOUSECONNECTOR pDrv = pThisCC->Mouse.pDrv;
|
---|
214 | if (pDrv)
|
---|
215 | pDrv->pfnReportModes(pDrv, fEnabled, false, false);
|
---|
216 | }
|
---|
217 |
|
---|
218 | /* Reset the pointing device. */
|
---|
219 | static void ps2mR3Reset(PPS2M pThis, PPS2MR3 pThisCC)
|
---|
220 | {
|
---|
221 | LogFlowFunc(("Reset"));
|
---|
222 |
|
---|
223 | PS2Q_INSERT(&pThis->cmdQ, ARSP_BAT_OK);
|
---|
224 | PS2Q_INSERT(&pThis->cmdQ, 0);
|
---|
225 | pThis->enmMode = AUX_MODE_STD;
|
---|
226 | pThis->u8CurrCmd = 0;
|
---|
227 |
|
---|
228 | /// @todo move to its proper home!
|
---|
229 | ps2mR3SetDriverState(pThisCC, true);
|
---|
230 | }
|
---|
231 |
|
---|
232 | #endif /* IN_RING3 */
|
---|
233 |
|
---|
234 | static void ps2mSetRate(PPS2M pThis, uint8_t rate)
|
---|
235 | {
|
---|
236 | Assert(rate);
|
---|
237 | pThis->uThrottleDelay = rate ? 1000 / rate : 0;
|
---|
238 | pThis->u8SampleRate = rate;
|
---|
239 | LogFlowFunc(("Sampling rate %u, throttle delay %u ms\n", pThis->u8SampleRate, pThis->uThrottleDelay));
|
---|
240 | }
|
---|
241 |
|
---|
242 | static void ps2mSetDefaults(PPS2M pThis)
|
---|
243 | {
|
---|
244 | LogFlowFunc(("Set mouse defaults\n"));
|
---|
245 | /* Standard protocol, reporting disabled, resolution 2, 1:1 scaling. */
|
---|
246 | pThis->enmProtocol = PS2M_PROTO_PS2STD;
|
---|
247 | pThis->u8State = 0;
|
---|
248 | pThis->u8Resolution = 2;
|
---|
249 |
|
---|
250 | /* Sample rate 100 reports per second. */
|
---|
251 | ps2mSetRate(pThis, 100);
|
---|
252 |
|
---|
253 | /* Event queue, eccumulators, and button status bits are cleared. */
|
---|
254 | PS2Q_CLEAR(&pThis->evtQ);
|
---|
255 | pThis->iAccumX = pThis->iAccumY = pThis->iAccumZ = pThis->iAccumW = pThis->fAccumB = 0;
|
---|
256 | }
|
---|
257 |
|
---|
258 | /* Handle the sampling rate 'knock' sequence which selects protocol. */
|
---|
259 | static void ps2mRateProtocolKnock(PPS2M pThis, uint8_t rate)
|
---|
260 | {
|
---|
261 | PS2M_PROTO enmOldProtocol = pThis->enmProtocol;
|
---|
262 | LogFlowFunc(("rate=%u\n", rate));
|
---|
263 |
|
---|
264 | switch (pThis->enmKnockState)
|
---|
265 | {
|
---|
266 | case PS2M_KNOCK_INITIAL:
|
---|
267 | if (rate == 200)
|
---|
268 | pThis->enmKnockState = PS2M_KNOCK_1ST;
|
---|
269 | break;
|
---|
270 | case PS2M_KNOCK_1ST:
|
---|
271 | if (rate == 100)
|
---|
272 | pThis->enmKnockState = PS2M_KNOCK_IMPS2_2ND;
|
---|
273 | else if (rate == 200)
|
---|
274 | pThis->enmKnockState = PS2M_KNOCK_IMEX_2ND;
|
---|
275 | else if (rate == 80)
|
---|
276 | pThis->enmKnockState = PS2M_KNOCK_IMEX_HORZ_2ND;
|
---|
277 | else
|
---|
278 | pThis->enmKnockState = PS2M_KNOCK_INITIAL;
|
---|
279 | break;
|
---|
280 | case PS2M_KNOCK_IMPS2_2ND:
|
---|
281 | if (rate == 80)
|
---|
282 | {
|
---|
283 | pThis->enmProtocol = PS2M_PROTO_IMPS2;
|
---|
284 | LogRelFlow(("PS2M: Switching mouse to ImPS/2 protocol.\n"));
|
---|
285 | }
|
---|
286 | pThis->enmKnockState = PS2M_KNOCK_INITIAL;
|
---|
287 | break;
|
---|
288 | case PS2M_KNOCK_IMEX_2ND:
|
---|
289 | if (rate == 80)
|
---|
290 | {
|
---|
291 | pThis->enmProtocol = PS2M_PROTO_IMEX;
|
---|
292 | LogRelFlow(("PS2M: Switching mouse to ImEx protocol.\n"));
|
---|
293 | }
|
---|
294 | pThis->enmKnockState = PS2M_KNOCK_INITIAL;
|
---|
295 | break;
|
---|
296 | case PS2M_KNOCK_IMEX_HORZ_2ND:
|
---|
297 | if (rate == 40)
|
---|
298 | {
|
---|
299 | pThis->enmProtocol = PS2M_PROTO_IMEX_HORZ;
|
---|
300 | LogRelFlow(("PS2M: Switching mouse ImEx with horizontal scrolling.\n"));
|
---|
301 | }
|
---|
302 | RT_FALL_THRU();
|
---|
303 | default:
|
---|
304 | pThis->enmKnockState = PS2M_KNOCK_INITIAL;
|
---|
305 | }
|
---|
306 |
|
---|
307 | /* If the protocol changed, throw away any queued input because it now
|
---|
308 | * has the wrong format, which could severely confuse the guest.
|
---|
309 | */
|
---|
310 | if (enmOldProtocol != pThis->enmProtocol)
|
---|
311 | PS2Q_CLEAR(&pThis->evtQ);
|
---|
312 | }
|
---|
313 |
|
---|
314 | /* Three-button event mask. */
|
---|
315 | #define PS2M_STD_BTN_MASK (RT_BIT(0) | RT_BIT(1) | RT_BIT(2))
|
---|
316 | /* ImEx button 4/5 event mask. */
|
---|
317 | #define PS2M_IMEX_BTN_MASK (RT_BIT(3) | RT_BIT(4))
|
---|
318 |
|
---|
319 | /** Report accumulated movement and button presses, then clear the accumulators. */
|
---|
320 | static void ps2mReportAccumulatedEvents(PPS2M pThis, PPS2QHDR pQHdr, size_t cQElements, uint8_t *pbQElements, bool fAccumBtns)
|
---|
321 | {
|
---|
322 | uint32_t fBtnState = fAccumBtns ? pThis->fAccumB : pThis->fCurrB;
|
---|
323 | uint8_t val;
|
---|
324 | int dX, dY, dZ, dW;
|
---|
325 |
|
---|
326 | LogFlowFunc(("cQElements=%zu, fAccumBtns=%RTbool\n", cQElements, fAccumBtns));
|
---|
327 |
|
---|
328 | /* Clamp the accumulated delta values to the allowed range. */
|
---|
329 | dX = RT_MIN(RT_MAX(pThis->iAccumX, -255), 255);
|
---|
330 | dY = RT_MIN(RT_MAX(pThis->iAccumY, -255), 255);
|
---|
331 |
|
---|
332 | /* Start with the sync bit and buttons 1-3. */
|
---|
333 | val = RT_BIT(3) | (fBtnState & PS2M_STD_BTN_MASK);
|
---|
334 | /* Set the X/Y sign bits. */
|
---|
335 | if (dX < 0)
|
---|
336 | val |= RT_BIT(4);
|
---|
337 | if (dY < 0)
|
---|
338 | val |= RT_BIT(5);
|
---|
339 |
|
---|
340 | /* Send the standard 3-byte packet (always the same). */
|
---|
341 | LogFlowFunc(("Queuing standard 3-byte packet\n"));
|
---|
342 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val);
|
---|
343 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dX);
|
---|
344 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dY);
|
---|
345 |
|
---|
346 | /* Add fourth byte if an extended protocol is in use. */
|
---|
347 | if (pThis->enmProtocol > PS2M_PROTO_PS2STD)
|
---|
348 | {
|
---|
349 | /* Start out with 4-bit dZ range. */
|
---|
350 | dZ = RT_MIN(RT_MAX(pThis->iAccumZ, -8), 7);
|
---|
351 |
|
---|
352 | if (pThis->enmProtocol == PS2M_PROTO_IMPS2)
|
---|
353 | {
|
---|
354 | /* NB: Only uses 4-bit dZ range, despite using a full byte. */
|
---|
355 | LogFlowFunc(("Queuing ImPS/2 last byte\n"));
|
---|
356 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dZ);
|
---|
357 | pThis->iAccumZ -= dZ;
|
---|
358 | }
|
---|
359 | else if (pThis->enmProtocol == PS2M_PROTO_IMEX)
|
---|
360 | {
|
---|
361 | /* Z value uses 4 bits; buttons 4/5 in bits 4 and 5. */
|
---|
362 | val = (fBtnState & PS2M_IMEX_BTN_MASK) << 1;
|
---|
363 | val |= dZ & 0x0f;
|
---|
364 | pThis->iAccumZ -= dZ;
|
---|
365 | LogFlowFunc(("Queuing ImEx last byte\n"));
|
---|
366 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val);
|
---|
367 | }
|
---|
368 | else
|
---|
369 | {
|
---|
370 | Assert((pThis->enmProtocol == PS2M_PROTO_IMEX_HORZ));
|
---|
371 | /* With ImEx + horizontal reporting, prioritize buttons 4/5. */
|
---|
372 | if (pThis->iAccumZ || pThis->iAccumW)
|
---|
373 | {
|
---|
374 | /* ImEx + horizontal reporting Horizontal scroll has
|
---|
375 | * precedence over vertical. Buttons cannot be reported
|
---|
376 | * this way.
|
---|
377 | */
|
---|
378 | if (pThis->iAccumW)
|
---|
379 | {
|
---|
380 | dW = RT_MIN(RT_MAX(pThis->iAccumW, -32), 31);
|
---|
381 | val = (dW & 0x3F) | 0x40;
|
---|
382 | pThis->iAccumW -= dW;
|
---|
383 | }
|
---|
384 | else
|
---|
385 | {
|
---|
386 | Assert(pThis->iAccumZ);
|
---|
387 | /* We can use 6-bit dZ range. Wow! */
|
---|
388 | dZ = RT_MIN(RT_MAX(pThis->iAccumZ, -32), 31);
|
---|
389 | val = (dZ & 0x3F) | 0x80;
|
---|
390 | pThis->iAccumZ -= dZ;
|
---|
391 | }
|
---|
392 | }
|
---|
393 | else
|
---|
394 | {
|
---|
395 | /* Just Buttons 4/5 in bits 4 and 5. No scrolling. */
|
---|
396 | val = (fBtnState & PS2M_IMEX_BTN_MASK) << 1;
|
---|
397 | }
|
---|
398 | LogFlowFunc(("Queuing ImEx+horz last byte\n"));
|
---|
399 | PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val);
|
---|
400 | }
|
---|
401 | }
|
---|
402 |
|
---|
403 | /* Clear the movement accumulators, but not necessarily button state. */
|
---|
404 | pThis->iAccumX = pThis->iAccumY = 0;
|
---|
405 | /* Clear accumulated button state only when it's being used. */
|
---|
406 | if (fAccumBtns)
|
---|
407 | {
|
---|
408 | pThis->fReportedB = pThis->fCurrB | pThis->fAccumB;
|
---|
409 | pThis->fAccumB = 0;
|
---|
410 | }
|
---|
411 | }
|
---|
412 |
|
---|
413 |
|
---|
414 | /* Determine whether a reporting rate is one of the valid ones. */
|
---|
415 | bool ps2mIsRateSupported(uint8_t rate)
|
---|
416 | {
|
---|
417 | static uint8_t aValidRates[] = { 10, 20, 40, 60, 80, 100, 200 };
|
---|
418 | size_t i;
|
---|
419 | bool fValid = false;
|
---|
420 |
|
---|
421 | for (i = 0; i < RT_ELEMENTS(aValidRates); ++i)
|
---|
422 | if (aValidRates[i] == rate)
|
---|
423 | {
|
---|
424 | fValid = true;
|
---|
425 | break;
|
---|
426 | }
|
---|
427 |
|
---|
428 | return fValid;
|
---|
429 | }
|
---|
430 |
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * The keyboard controller disabled the auxiliary serial line.
|
---|
434 | *
|
---|
435 | * @param pThis The PS/2 auxiliary device shared instance data.
|
---|
436 | */
|
---|
437 | void PS2MLineDisable(PPS2M pThis)
|
---|
438 | {
|
---|
439 | LogFlowFunc(("Disabling mouse serial line\n"));
|
---|
440 |
|
---|
441 | pThis->fLineDisabled = true;
|
---|
442 | }
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * The keyboard controller enabled the auxiliary serial line.
|
---|
446 | *
|
---|
447 | * @param pThis The PS/2 auxiliary device shared instance data.
|
---|
448 | */
|
---|
449 | void PS2MLineEnable(PPS2M pThis)
|
---|
450 | {
|
---|
451 | LogFlowFunc(("Enabling mouse serial line\n"));
|
---|
452 |
|
---|
453 | pThis->fLineDisabled = false;
|
---|
454 |
|
---|
455 | /* If there was anything in the input queue,
|
---|
456 | * consider it lost and throw it away.
|
---|
457 | */
|
---|
458 | PS2Q_CLEAR(&pThis->evtQ);
|
---|
459 | }
|
---|
460 |
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * Receive and process a byte sent by the keyboard controller.
|
---|
464 | *
|
---|
465 | * @param pDevIns The device instance.
|
---|
466 | * @param pThis The PS/2 auxiliary device shared instance data.
|
---|
467 | * @param cmd The command (or data) byte.
|
---|
468 | */
|
---|
469 | int PS2MByteToAux(PPDMDEVINS pDevIns, PPS2M pThis, uint8_t cmd)
|
---|
470 | {
|
---|
471 | uint8_t u8Val;
|
---|
472 | bool fHandled = true;
|
---|
473 |
|
---|
474 | LogFlowFunc(("cmd=0x%02X, active cmd=0x%02X\n", cmd, pThis->u8CurrCmd));
|
---|
475 |
|
---|
476 | if (pThis->enmMode == AUX_MODE_RESET)
|
---|
477 | /* In reset mode, do not respond at all. */
|
---|
478 | return VINF_SUCCESS;
|
---|
479 |
|
---|
480 | /* If there's anything left in the command response queue, trash it. */
|
---|
481 | PS2Q_CLEAR(&pThis->cmdQ);
|
---|
482 |
|
---|
483 | if (pThis->enmMode == AUX_MODE_WRAP)
|
---|
484 | {
|
---|
485 | /* In wrap mode, bounce most data right back.*/
|
---|
486 | if (cmd == ACMD_RESET || cmd == ACMD_RESET_WRAP)
|
---|
487 | ; /* Handle as regular commands. */
|
---|
488 | else
|
---|
489 | {
|
---|
490 | PS2Q_INSERT(&pThis->cmdQ, cmd);
|
---|
491 | return VINF_SUCCESS;
|
---|
492 | }
|
---|
493 | }
|
---|
494 |
|
---|
495 | #ifndef IN_RING3
|
---|
496 | /* Reset, Enable, and Set Default commands must be run in R3. */
|
---|
497 | if (cmd == ACMD_RESET || cmd == ACMD_ENABLE || cmd == ACMD_SET_DEFAULT)
|
---|
498 | return VINF_IOM_R3_IOPORT_WRITE;
|
---|
499 | #endif
|
---|
500 |
|
---|
501 | switch (cmd)
|
---|
502 | {
|
---|
503 | case ACMD_SET_SCALE_11:
|
---|
504 | pThis->u8State &= ~AUX_STATE_SCALING;
|
---|
505 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
506 | pThis->u8CurrCmd = 0;
|
---|
507 | break;
|
---|
508 | case ACMD_SET_SCALE_21:
|
---|
509 | pThis->u8State |= AUX_STATE_SCALING;
|
---|
510 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
511 | pThis->u8CurrCmd = 0;
|
---|
512 | break;
|
---|
513 | case ACMD_REQ_STATUS:
|
---|
514 | /* Report current status, sample rate, and resolution. */
|
---|
515 | u8Val = (pThis->u8State & AUX_STATE_EXTERNAL) | (pThis->fCurrB & PS2M_STD_BTN_MASK);
|
---|
516 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
517 | PS2Q_INSERT(&pThis->cmdQ, u8Val);
|
---|
518 | PS2Q_INSERT(&pThis->cmdQ, pThis->u8Resolution);
|
---|
519 | PS2Q_INSERT(&pThis->cmdQ, pThis->u8SampleRate);
|
---|
520 | pThis->u8CurrCmd = 0;
|
---|
521 | break;
|
---|
522 | case ACMD_SET_STREAM:
|
---|
523 | pThis->u8State &= ~AUX_STATE_REMOTE;
|
---|
524 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
525 | pThis->u8CurrCmd = 0;
|
---|
526 | break;
|
---|
527 | case ACMD_READ_REMOTE:
|
---|
528 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
529 | ps2mReportAccumulatedEvents(pThis, &pThis->cmdQ.Hdr, RT_ELEMENTS(pThis->cmdQ.abQueue), pThis->cmdQ.abQueue, false);
|
---|
530 | pThis->u8CurrCmd = 0;
|
---|
531 | break;
|
---|
532 | case ACMD_RESET_WRAP:
|
---|
533 | pThis->enmMode = AUX_MODE_STD;
|
---|
534 | /* NB: Stream mode reporting remains disabled! */
|
---|
535 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
536 | pThis->u8CurrCmd = 0;
|
---|
537 | break;
|
---|
538 | case ACMD_SET_WRAP:
|
---|
539 | pThis->enmMode = AUX_MODE_WRAP;
|
---|
540 | pThis->u8State &= ~AUX_STATE_ENABLED;
|
---|
541 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
542 | pThis->u8CurrCmd = 0;
|
---|
543 | break;
|
---|
544 | case ACMD_SET_REMOTE:
|
---|
545 | pThis->u8State |= AUX_STATE_REMOTE;
|
---|
546 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
547 | pThis->u8CurrCmd = 0;
|
---|
548 | break;
|
---|
549 | case ACMD_READ_ID:
|
---|
550 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
551 | /* ImEx + horizontal is protocol 4, just like plain ImEx. */
|
---|
552 | u8Val = pThis->enmProtocol == PS2M_PROTO_IMEX_HORZ ? PS2M_PROTO_IMEX : pThis->enmProtocol;
|
---|
553 | PS2Q_INSERT(&pThis->cmdQ, u8Val);
|
---|
554 | pThis->u8CurrCmd = 0;
|
---|
555 | break;
|
---|
556 | case ACMD_ENABLE:
|
---|
557 | pThis->u8State |= AUX_STATE_ENABLED;
|
---|
558 | #ifdef IN_RING3
|
---|
559 | ps2mR3SetDriverState(&PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux, true);
|
---|
560 | #else
|
---|
561 | AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n"));
|
---|
562 | #endif
|
---|
563 | PS2Q_CLEAR(&pThis->evtQ);
|
---|
564 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
565 | pThis->u8CurrCmd = 0;
|
---|
566 | break;
|
---|
567 | case ACMD_DISABLE:
|
---|
568 | pThis->u8State &= ~AUX_STATE_ENABLED;
|
---|
569 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
570 | pThis->u8CurrCmd = 0;
|
---|
571 | break;
|
---|
572 | case ACMD_SET_DEFAULT:
|
---|
573 | ps2mSetDefaults(pThis);
|
---|
574 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
575 | pThis->u8CurrCmd = 0;
|
---|
576 | break;
|
---|
577 | case ACMD_RESEND:
|
---|
578 | pThis->u8CurrCmd = 0;
|
---|
579 | break;
|
---|
580 | case ACMD_RESET:
|
---|
581 | ps2mSetDefaults(pThis);
|
---|
582 | /// @todo reset more?
|
---|
583 | pThis->u8CurrCmd = cmd;
|
---|
584 | pThis->enmMode = AUX_MODE_RESET;
|
---|
585 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
586 | if (pThis->fDelayReset)
|
---|
587 | /* Slightly delay reset completion; it might take hundreds of ms. */
|
---|
588 | PDMDevHlpTimerSetMillies(pDevIns, pThis->hDelayTimer, 1);
|
---|
589 | else
|
---|
590 | #ifdef IN_RING3
|
---|
591 | ps2mR3Reset(pThis, &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux);
|
---|
592 | #else
|
---|
593 | AssertLogRelMsgFailed(("Invalid ACMD_RESET outside R3!\n"));
|
---|
594 | #endif
|
---|
595 | break;
|
---|
596 | /* The following commands need a parameter. */
|
---|
597 | case ACMD_SET_RES:
|
---|
598 | case ACMD_SET_SAMP_RATE:
|
---|
599 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
600 | pThis->u8CurrCmd = cmd;
|
---|
601 | break;
|
---|
602 | default:
|
---|
603 | /* Sending a command instead of a parameter starts the new command. */
|
---|
604 | switch (pThis->u8CurrCmd)
|
---|
605 | {
|
---|
606 | case ACMD_SET_RES:
|
---|
607 | if (cmd < 4) /* Valid resolutions are 0-3. */
|
---|
608 | {
|
---|
609 | pThis->u8Resolution = cmd;
|
---|
610 | pThis->u8State &= ~AUX_STATE_RES_ERR;
|
---|
611 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
612 | pThis->u8CurrCmd = 0;
|
---|
613 | }
|
---|
614 | else
|
---|
615 | {
|
---|
616 | /* Bad resolution. Reply with Resend or Error. */
|
---|
617 | if (pThis->u8State & AUX_STATE_RES_ERR)
|
---|
618 | {
|
---|
619 | pThis->u8State &= ~AUX_STATE_RES_ERR;
|
---|
620 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ERROR);
|
---|
621 | pThis->u8CurrCmd = 0;
|
---|
622 | }
|
---|
623 | else
|
---|
624 | {
|
---|
625 | pThis->u8State |= AUX_STATE_RES_ERR;
|
---|
626 | PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND);
|
---|
627 | /* NB: Current command remains unchanged. */
|
---|
628 | }
|
---|
629 | }
|
---|
630 | break;
|
---|
631 | case ACMD_SET_SAMP_RATE:
|
---|
632 | if (ps2mIsRateSupported(cmd))
|
---|
633 | {
|
---|
634 | pThis->u8State &= ~AUX_STATE_RATE_ERR;
|
---|
635 | ps2mSetRate(pThis, cmd);
|
---|
636 | ps2mRateProtocolKnock(pThis, cmd);
|
---|
637 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK);
|
---|
638 | pThis->u8CurrCmd = 0;
|
---|
639 | }
|
---|
640 | else
|
---|
641 | {
|
---|
642 | /* Bad rate. Reply with Resend or Error. */
|
---|
643 | if (pThis->u8State & AUX_STATE_RATE_ERR)
|
---|
644 | {
|
---|
645 | pThis->u8State &= ~AUX_STATE_RATE_ERR;
|
---|
646 | PS2Q_INSERT(&pThis->cmdQ, ARSP_ERROR);
|
---|
647 | pThis->u8CurrCmd = 0;
|
---|
648 | }
|
---|
649 | else
|
---|
650 | {
|
---|
651 | pThis->u8State |= AUX_STATE_RATE_ERR;
|
---|
652 | PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND);
|
---|
653 | /* NB: Current command remains unchanged. */
|
---|
654 | }
|
---|
655 | }
|
---|
656 | break;
|
---|
657 | default:
|
---|
658 | fHandled = false;
|
---|
659 | }
|
---|
660 | /* Fall through only to handle unrecognized commands. */
|
---|
661 | if (fHandled)
|
---|
662 | break;
|
---|
663 | RT_FALL_THRU();
|
---|
664 |
|
---|
665 | case ACMD_INVALID_1:
|
---|
666 | case ACMD_INVALID_2:
|
---|
667 | case ACMD_INVALID_3:
|
---|
668 | case ACMD_INVALID_4:
|
---|
669 | case ACMD_INVALID_5:
|
---|
670 | case ACMD_INVALID_6:
|
---|
671 | case ACMD_INVALID_7:
|
---|
672 | case ACMD_INVALID_8:
|
---|
673 | case ACMD_INVALID_9:
|
---|
674 | case ACMD_INVALID_10:
|
---|
675 | Log(("Unsupported command 0x%02X!\n", cmd));
|
---|
676 | PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND);
|
---|
677 | pThis->u8CurrCmd = 0;
|
---|
678 | break;
|
---|
679 | }
|
---|
680 | LogFlowFunc(("Active cmd now 0x%02X; updating interrupts\n", pThis->u8CurrCmd));
|
---|
681 | return VINF_SUCCESS;
|
---|
682 | }
|
---|
683 |
|
---|
684 | /**
|
---|
685 | * Send a byte (packet data or command response) to the keyboard controller.
|
---|
686 | *
|
---|
687 | * @returns VINF_SUCCESS or VINF_TRY_AGAIN.
|
---|
688 | * @param pThis The PS/2 auxiliary device shared instance data.
|
---|
689 | * @param pb Where to return the byte we've read.
|
---|
690 | * @remarks Caller must have entered the device critical section.
|
---|
691 | */
|
---|
692 | int PS2MByteFromAux(PPS2M pThis, uint8_t *pb)
|
---|
693 | {
|
---|
694 | int rc;
|
---|
695 |
|
---|
696 | AssertPtr(pb);
|
---|
697 |
|
---|
698 | /* Anything in the command queue has priority over data
|
---|
699 | * in the event queue. Additionally, packet data are
|
---|
700 | * blocked if a command is currently in progress, even if
|
---|
701 | * the command queue is empty.
|
---|
702 | */
|
---|
703 | /// @todo Probably should flush/not fill queue if stream mode reporting disabled?!
|
---|
704 | rc = PS2Q_REMOVE(&pThis->cmdQ, pb);
|
---|
705 | if (rc != VINF_SUCCESS && !pThis->u8CurrCmd && (pThis->u8State & AUX_STATE_ENABLED))
|
---|
706 | rc = PS2Q_REMOVE(&pThis->evtQ, pb);
|
---|
707 |
|
---|
708 | LogFlowFunc(("mouse sends 0x%02x (%svalid data)\n", *pb, rc == VINF_SUCCESS ? "" : "not "));
|
---|
709 |
|
---|
710 | return rc;
|
---|
711 | }
|
---|
712 |
|
---|
713 | #ifdef IN_RING3
|
---|
714 |
|
---|
715 | /** Is there any state change to send as events to the guest? */
|
---|
716 | static uint32_t ps2mR3HaveEvents(PPS2M pThis)
|
---|
717 | {
|
---|
718 | return pThis->iAccumX || pThis->iAccumY || pThis->iAccumZ || pThis->iAccumW
|
---|
719 | || ((pThis->fCurrB | pThis->fAccumB) != pThis->fReportedB);
|
---|
720 | }
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * @callback_method_impl{FNTMTIMERDEV,
|
---|
724 | * Event rate throttling timer to emulate the auxiliary device sampling rate.}
|
---|
725 | */
|
---|
726 | static DECLCALLBACK(void) ps2mR3ThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
|
---|
727 | {
|
---|
728 | RT_NOREF(pDevIns, pTimer);
|
---|
729 | PPS2M pThis = (PS2M *)pvUser;
|
---|
730 | uint32_t uHaveEvents;
|
---|
731 |
|
---|
732 | /* Grab the lock to avoid races with PutEvent(). */
|
---|
733 | int rc = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_SEM_BUSY);
|
---|
734 | AssertReleaseRC(rc);
|
---|
735 |
|
---|
736 | /* If more movement is accumulated, report it and restart the timer. */
|
---|
737 | uHaveEvents = ps2mR3HaveEvents(pThis);
|
---|
738 | LogFlowFunc(("Have%s events\n", uHaveEvents ? "" : " no"));
|
---|
739 |
|
---|
740 | if (uHaveEvents)
|
---|
741 | {
|
---|
742 | /* Report accumulated data, poke the KBC, and start the timer. */
|
---|
743 | ps2mReportAccumulatedEvents(pThis, &pThis->evtQ.Hdr, RT_ELEMENTS(pThis->evtQ.abQueue), pThis->evtQ.abQueue, true);
|
---|
744 | KBCUpdateInterrupts(pDevIns);
|
---|
745 | PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, pThis->uThrottleDelay);
|
---|
746 | }
|
---|
747 | else
|
---|
748 | pThis->fThrottleActive = false;
|
---|
749 |
|
---|
750 | PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3);
|
---|
751 | }
|
---|
752 |
|
---|
753 | /**
|
---|
754 | * @callback_method_impl{FNTMTIMERDEV}
|
---|
755 | *
|
---|
756 | * The auxiliary device reset is specified to take up to about 500 milliseconds.
|
---|
757 | * We need to delay sending the result to the host for at least a tiny little
|
---|
758 | * while.
|
---|
759 | */
|
---|
760 | static DECLCALLBACK(void) ps2mR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
|
---|
761 | {
|
---|
762 | PPS2M pThis = &PDMDEVINS_2_DATA(pDevIns, PKBDSTATE)->Aux;
|
---|
763 | PPS2MR3 pThisCC = &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux;
|
---|
764 | RT_NOREF(pvUser, pTimer);
|
---|
765 |
|
---|
766 | LogFlowFunc(("Delay timer: cmd %02X\n", pThis->u8CurrCmd));
|
---|
767 |
|
---|
768 | Assert(pThis->u8CurrCmd == ACMD_RESET);
|
---|
769 | ps2mR3Reset(pThis, pThisCC);
|
---|
770 |
|
---|
771 | /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC...
|
---|
772 | /* Give the KBC a kick. */
|
---|
773 | KBCUpdateInterrupts(pDevIns);
|
---|
774 | }
|
---|
775 |
|
---|
776 |
|
---|
777 | /**
|
---|
778 | * Debug device info handler. Prints basic auxiliary device state.
|
---|
779 | *
|
---|
780 | * @param pDevIns Device instance which registered the info.
|
---|
781 | * @param pHlp Callback functions for doing output.
|
---|
782 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
783 | */
|
---|
784 | static DECLCALLBACK(void) ps2mR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
785 | {
|
---|
786 | static const char * const s_apcszModes[] = { "normal", "reset", "wrap" };
|
---|
787 | static const char * const s_apcszProtocols[] = { "PS/2", NULL, NULL, "ImPS/2", "ImEx", "ImEx+horizontal" };
|
---|
788 | PKBDSTATE pParent = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
|
---|
789 | PPS2M pThis = &pParent->Aux;
|
---|
790 | NOREF(pszArgs);
|
---|
791 |
|
---|
792 | Assert(pThis->enmMode < RT_ELEMENTS(s_apcszModes));
|
---|
793 | pHlp->pfnPrintf(pHlp, "PS/2 mouse state: %s, %s mode, reporting %s, serial line %s\n",
|
---|
794 | s_apcszModes[pThis->enmMode],
|
---|
795 | pThis->u8State & AUX_STATE_REMOTE ? "remote" : "stream",
|
---|
796 | pThis->u8State & AUX_STATE_ENABLED ? "enabled" : "disabled",
|
---|
797 | pThis->fLineDisabled ? "disabled" : "enabled");
|
---|
798 | Assert(pThis->enmProtocol < RT_ELEMENTS(s_apcszProtocols));
|
---|
799 | pHlp->pfnPrintf(pHlp, "Protocol: %s, scaling %u:1\n",
|
---|
800 | s_apcszProtocols[pThis->enmProtocol],
|
---|
801 | pThis->u8State & AUX_STATE_SCALING ? 2 : 1);
|
---|
802 | pHlp->pfnPrintf(pHlp, "Active command %02X\n", pThis->u8CurrCmd);
|
---|
803 | pHlp->pfnPrintf(pHlp, "Sampling rate %u reports/sec, resolution %u counts/mm\n",
|
---|
804 | pThis->u8SampleRate, 1 << pThis->u8Resolution);
|
---|
805 | pHlp->pfnPrintf(pHlp, "Command queue: %d items (%d max)\n",
|
---|
806 | PS2Q_COUNT(&pThis->cmdQ), PS2Q_SIZE(&pThis->cmdQ));
|
---|
807 | pHlp->pfnPrintf(pHlp, "Event queue : %d items (%d max)\n",
|
---|
808 | PS2Q_COUNT(&pThis->evtQ), PS2Q_SIZE(&pThis->evtQ));
|
---|
809 | }
|
---|
810 |
|
---|
811 |
|
---|
812 | /* -=-=-=-=-=- Mouse: IMousePort -=-=-=-=-=- */
|
---|
813 |
|
---|
814 | /**
|
---|
815 | * Mouse event handler.
|
---|
816 | *
|
---|
817 | * @returns VBox status code.
|
---|
818 | * @param pDevIns The device instance.
|
---|
819 | * @param pThis The PS/2 auxiliary device shared instance data.
|
---|
820 | * @param dx X direction movement delta.
|
---|
821 | * @param dy Y direction movement delta.
|
---|
822 | * @param dz Z (vertical scroll) movement delta.
|
---|
823 | * @param dw W (horizontal scroll) movement delta.
|
---|
824 | * @param fButtons Depressed button mask.
|
---|
825 | */
|
---|
826 | static int ps2mR3PutEventWorker(PPDMDEVINS pDevIns, PPS2M pThis, int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons)
|
---|
827 | {
|
---|
828 | LogFlowFunc(("dx=%d, dy=%d, dz=%d, dw=%d, fButtons=%X\n", dx, dy, dz, dw, fButtons));
|
---|
829 |
|
---|
830 | /* Update internal accumulators and button state. Ignore any buttons beyond 5. */
|
---|
831 | pThis->iAccumX += dx;
|
---|
832 | pThis->iAccumY += dy;
|
---|
833 | pThis->iAccumZ += dz;
|
---|
834 | pThis->iAccumW += dw;
|
---|
835 | pThis->fCurrB = fButtons & (PS2M_STD_BTN_MASK | PS2M_IMEX_BTN_MASK);
|
---|
836 | pThis->fAccumB |= pThis->fCurrB;
|
---|
837 |
|
---|
838 | /* Ditch accumulated data that can't be reported by the current protocol.
|
---|
839 | * This avoids sending phantom empty reports when un-reportable events
|
---|
840 | * are received.
|
---|
841 | */
|
---|
842 | if (pThis->enmProtocol < PS2M_PROTO_IMEX_HORZ)
|
---|
843 | pThis->iAccumW = 0; /* No horizontal scroll. */
|
---|
844 |
|
---|
845 | if (pThis->enmProtocol < PS2M_PROTO_IMEX)
|
---|
846 | {
|
---|
847 | pThis->fAccumB &= PS2M_STD_BTN_MASK; /* Only buttons 1-3. */
|
---|
848 | pThis->fCurrB &= PS2M_STD_BTN_MASK;
|
---|
849 | }
|
---|
850 |
|
---|
851 | if (pThis->enmProtocol < PS2M_PROTO_IMPS2)
|
---|
852 | pThis->iAccumZ = 0; /* No vertical scroll. */
|
---|
853 |
|
---|
854 | /* Report the event (if any) and start the throttle timer unless it's already running. */
|
---|
855 | if (!pThis->fThrottleActive && ps2mR3HaveEvents(pThis))
|
---|
856 | {
|
---|
857 | ps2mReportAccumulatedEvents(pThis, &pThis->evtQ.Hdr, RT_ELEMENTS(pThis->evtQ.abQueue), pThis->evtQ.abQueue, true);
|
---|
858 | KBCUpdateInterrupts(pDevIns);
|
---|
859 | pThis->fThrottleActive = true;
|
---|
860 | PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, pThis->uThrottleDelay);
|
---|
861 | }
|
---|
862 |
|
---|
863 | return VINF_SUCCESS;
|
---|
864 | }
|
---|
865 |
|
---|
866 |
|
---|
867 | /* -=-=-=-=-=- Mouse: IMousePort -=-=-=-=-=- */
|
---|
868 |
|
---|
869 | /**
|
---|
870 | * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent}
|
---|
871 | */
|
---|
872 | static DECLCALLBACK(int) ps2mR3MousePort_PutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy,
|
---|
873 | int32_t dz, int32_t dw, uint32_t fButtons)
|
---|
874 | {
|
---|
875 | PPS2MR3 pThisCC = RT_FROM_MEMBER(pInterface, PS2MR3, Mouse.IPort);
|
---|
876 | PPDMDEVINS pDevIns = pThisCC->pDevIns;
|
---|
877 | PPS2M pThis = &PDMDEVINS_2_DATA(pDevIns, PKBDSTATE)->Aux;
|
---|
878 | int rc = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_SEM_BUSY);
|
---|
879 | AssertReleaseRC(rc);
|
---|
880 |
|
---|
881 | LogRelFlowFunc(("dX=%d dY=%d dZ=%d dW=%d buttons=%02X\n", dx, dy, dz, dw, fButtons));
|
---|
882 | /* NB: The PS/2 Y axis direction is inverted relative to ours. */
|
---|
883 | ps2mR3PutEventWorker(pDevIns, pThis, dx, -dy, dz, dw, fButtons);
|
---|
884 |
|
---|
885 | PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3);
|
---|
886 | return VINF_SUCCESS;
|
---|
887 | }
|
---|
888 |
|
---|
889 | /**
|
---|
890 | * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs}
|
---|
891 | */
|
---|
892 | static DECLCALLBACK(int) ps2mR3MousePort_PutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t x, uint32_t y,
|
---|
893 | int32_t dz, int32_t dw, uint32_t fButtons)
|
---|
894 | {
|
---|
895 | AssertFailedReturn(VERR_NOT_SUPPORTED);
|
---|
896 | NOREF(pInterface); NOREF(x); NOREF(y); NOREF(dz); NOREF(dw); NOREF(fButtons);
|
---|
897 | }
|
---|
898 |
|
---|
899 | /**
|
---|
900 | * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMultiTouch}
|
---|
901 | */
|
---|
902 | static DECLCALLBACK(int) ps2mR3MousePort_PutEventMT(PPDMIMOUSEPORT pInterface, uint8_t cContacts,
|
---|
903 | const uint64_t *pau64Contacts, uint32_t u32ScanTime)
|
---|
904 | {
|
---|
905 | AssertFailedReturn(VERR_NOT_SUPPORTED);
|
---|
906 | NOREF(pInterface); NOREF(cContacts); NOREF(pau64Contacts); NOREF(u32ScanTime);
|
---|
907 | }
|
---|
908 |
|
---|
909 |
|
---|
910 | /* -=-=-=-=-=- Mouse: IBase -=-=-=-=-=- */
|
---|
911 |
|
---|
912 | /**
|
---|
913 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
914 | */
|
---|
915 | static DECLCALLBACK(void *) ps2mR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
916 | {
|
---|
917 | PPS2MR3 pThisCC = RT_FROM_MEMBER(pInterface, PS2MR3, Mouse.IBase);
|
---|
918 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->Mouse.IBase);
|
---|
919 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSEPORT, &pThisCC->Mouse.IPort);
|
---|
920 | return NULL;
|
---|
921 | }
|
---|
922 |
|
---|
923 |
|
---|
924 | /* -=-=-=-=-=- Device management -=-=-=-=-=- */
|
---|
925 |
|
---|
926 | /**
|
---|
927 | * Attach command.
|
---|
928 | *
|
---|
929 | * This is called to let the device attach to a driver for a
|
---|
930 | * specified LUN.
|
---|
931 | *
|
---|
932 | * This is like plugging in the mouse after turning on the
|
---|
933 | * system.
|
---|
934 | *
|
---|
935 | * @returns VBox status code.
|
---|
936 | * @param pDevIns The device instance.
|
---|
937 | * @param pThisCC The PS/2 auxiliary device instance data for ring-3.
|
---|
938 | * @param iLUN The logical unit which is being detached.
|
---|
939 | * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
|
---|
940 | */
|
---|
941 | int PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags)
|
---|
942 | {
|
---|
943 | int rc;
|
---|
944 |
|
---|
945 | /* The LUN must be 1, i.e. mouse. */
|
---|
946 | Assert(iLUN == 1);
|
---|
947 | AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
|
---|
948 | ("PS/2 mouse does not support hotplugging\n"),
|
---|
949 | VERR_INVALID_PARAMETER);
|
---|
950 |
|
---|
951 | LogFlowFunc(("iLUN=%d\n", iLUN));
|
---|
952 |
|
---|
953 | rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->Mouse.IBase, &pThisCC->Mouse.pDrvBase, "Mouse Port");
|
---|
954 | if (RT_SUCCESS(rc))
|
---|
955 | {
|
---|
956 | pThisCC->Mouse.pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->Mouse.pDrvBase, PDMIMOUSECONNECTOR);
|
---|
957 | if (!pThisCC->Mouse.pDrv)
|
---|
958 | {
|
---|
959 | AssertLogRelMsgFailed(("LUN #1 doesn't have a mouse interface! rc=%Rrc\n", rc));
|
---|
960 | rc = VERR_PDM_MISSING_INTERFACE;
|
---|
961 | }
|
---|
962 | }
|
---|
963 | else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
964 | {
|
---|
965 | Log(("%s/%d: warning: no driver attached to LUN #1!\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
966 | rc = VINF_SUCCESS;
|
---|
967 | }
|
---|
968 | else
|
---|
969 | AssertLogRelMsgFailed(("Failed to attach LUN #1! rc=%Rrc\n", rc));
|
---|
970 |
|
---|
971 | return rc;
|
---|
972 | }
|
---|
973 |
|
---|
974 | void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM)
|
---|
975 | {
|
---|
976 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
977 | LogFlowFunc(("Saving PS2M state\n"));
|
---|
978 |
|
---|
979 | /* Save the core auxiliary device state. */
|
---|
980 | pHlp->pfnSSMPutU8(pSSM, pThis->u8State);
|
---|
981 | pHlp->pfnSSMPutU8(pSSM, pThis->u8SampleRate);
|
---|
982 | pHlp->pfnSSMPutU8(pSSM, pThis->u8Resolution);
|
---|
983 | pHlp->pfnSSMPutU8(pSSM, pThis->u8CurrCmd);
|
---|
984 | pHlp->pfnSSMPutU8(pSSM, pThis->enmMode);
|
---|
985 | pHlp->pfnSSMPutU8(pSSM, pThis->enmProtocol);
|
---|
986 | pHlp->pfnSSMPutU8(pSSM, pThis->enmKnockState);
|
---|
987 |
|
---|
988 | /* Save the command and event queues. */
|
---|
989 | PS2Q_SAVE(pHlp, pSSM, &pThis->cmdQ);
|
---|
990 | PS2Q_SAVE(pHlp, pSSM, &pThis->evtQ);
|
---|
991 |
|
---|
992 | /* Save the command delay timer. Note that the rate throttling
|
---|
993 | * timer is *not* saved.
|
---|
994 | */
|
---|
995 | PDMDevHlpTimerSave(pDevIns, pThis->hDelayTimer, pSSM);
|
---|
996 | }
|
---|
997 |
|
---|
998 | int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion)
|
---|
999 | {
|
---|
1000 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
1001 | uint8_t u8;
|
---|
1002 | int rc;
|
---|
1003 |
|
---|
1004 | NOREF(uVersion);
|
---|
1005 | LogFlowFunc(("Loading PS2M state version %u\n", uVersion));
|
---|
1006 |
|
---|
1007 | /* Load the basic auxiliary device state. */
|
---|
1008 | pHlp->pfnSSMGetU8(pSSM, &pThis->u8State);
|
---|
1009 | pHlp->pfnSSMGetU8(pSSM, &pThis->u8SampleRate);
|
---|
1010 | pHlp->pfnSSMGetU8(pSSM, &pThis->u8Resolution);
|
---|
1011 | pHlp->pfnSSMGetU8(pSSM, &pThis->u8CurrCmd);
|
---|
1012 | pHlp->pfnSSMGetU8(pSSM, &u8);
|
---|
1013 | pThis->enmMode = (PS2M_MODE)u8;
|
---|
1014 | pHlp->pfnSSMGetU8(pSSM, &u8);
|
---|
1015 | pThis->enmProtocol = (PS2M_PROTO)u8;
|
---|
1016 | pHlp->pfnSSMGetU8(pSSM, &u8);
|
---|
1017 | pThis->enmKnockState = (PS2M_KNOCK_STATE)u8;
|
---|
1018 |
|
---|
1019 | /* Load the command and event queues. */
|
---|
1020 | rc = PS2Q_LOAD(pHlp, pSSM, &pThis->cmdQ);
|
---|
1021 | AssertRCReturn(rc, rc);
|
---|
1022 | rc = PS2Q_LOAD(pHlp, pSSM, &pThis->evtQ);
|
---|
1023 | AssertRCReturn(rc, rc);
|
---|
1024 |
|
---|
1025 | /* Load the command delay timer, just in case. */
|
---|
1026 | rc = PDMDevHlpTimerLoad(pDevIns, pThis->hDelayTimer, pSSM);
|
---|
1027 | AssertRCReturn(rc, rc);
|
---|
1028 |
|
---|
1029 | /* Recalculate the throttling delay. */
|
---|
1030 | ps2mSetRate(pThis, pThis->u8SampleRate);
|
---|
1031 |
|
---|
1032 | ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED));
|
---|
1033 |
|
---|
1034 | return VINF_SUCCESS;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | void PS2MR3FixupState(PPS2M pThis, PPS2MR3 pThisCC, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)
|
---|
1038 | {
|
---|
1039 | LogFlowFunc(("Fixing up old PS2M state version\n"));
|
---|
1040 |
|
---|
1041 | /* Load the basic auxiliary device state. */
|
---|
1042 | pThis->u8State = u8State;
|
---|
1043 | pThis->u8SampleRate = u8Rate ? u8Rate : 40; /* In case it wasn't saved right. */
|
---|
1044 | pThis->enmProtocol = (PS2M_PROTO)u8Proto;
|
---|
1045 |
|
---|
1046 | /* Recalculate the throttling delay. */
|
---|
1047 | ps2mSetRate(pThis, pThis->u8SampleRate);
|
---|
1048 |
|
---|
1049 | ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED));
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | void PS2MR3Reset(PPS2M pThis)
|
---|
1053 | {
|
---|
1054 | LogFlowFunc(("Resetting PS2M\n"));
|
---|
1055 |
|
---|
1056 | pThis->u8CurrCmd = 0;
|
---|
1057 |
|
---|
1058 | /* Clear the queues. */
|
---|
1059 | PS2Q_CLEAR(&pThis->cmdQ);
|
---|
1060 | ps2mSetDefaults(pThis); /* Also clears event queue. */
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC)
|
---|
1064 | {
|
---|
1065 | LogFlowFunc(("\n"));
|
---|
1066 |
|
---|
1067 | pThis->cmdQ.Hdr.pszDesc = "Aux Cmd";
|
---|
1068 | pThis->evtQ.Hdr.pszDesc = "Aux Evt";
|
---|
1069 |
|
---|
1070 | #ifdef RT_STRICT
|
---|
1071 | ps2mR3TestAccumulation();
|
---|
1072 | #endif
|
---|
1073 |
|
---|
1074 | /*
|
---|
1075 | * Initialize the state.
|
---|
1076 | */
|
---|
1077 | pThisCC->pDevIns = pDevIns;
|
---|
1078 | pThisCC->Mouse.IBase.pfnQueryInterface = ps2mR3QueryInterface;
|
---|
1079 | pThisCC->Mouse.IPort.pfnPutEvent = ps2mR3MousePort_PutEvent;
|
---|
1080 | pThisCC->Mouse.IPort.pfnPutEventAbs = ps2mR3MousePort_PutEventAbs;
|
---|
1081 | pThisCC->Mouse.IPort.pfnPutEventMultiTouch = ps2mR3MousePort_PutEventMT;
|
---|
1082 |
|
---|
1083 | /*
|
---|
1084 | * Create the input rate throttling timer. Does not use virtual time!
|
---|
1085 | */
|
---|
1086 | int rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_REAL, ps2mR3ThrottleTimer, pThis,
|
---|
1087 | TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Throttle Timer", &pThis->hThrottleTimer);
|
---|
1088 | AssertRCReturn(rc, rc);
|
---|
1089 |
|
---|
1090 | /*
|
---|
1091 | * Create the command delay timer.
|
---|
1092 | */
|
---|
1093 | rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mR3DelayTimer, pThis,
|
---|
1094 | TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Delay Timer", &pThis->hDelayTimer);
|
---|
1095 | AssertRCReturn(rc, rc);
|
---|
1096 |
|
---|
1097 | /*
|
---|
1098 | * Register debugger info callbacks.
|
---|
1099 | */
|
---|
1100 | PDMDevHlpDBGFInfoRegister(pDevIns, "ps2m", "Display PS/2 mouse state.", ps2mR3InfoState);
|
---|
1101 |
|
---|
1102 | /// @todo Where should we do this?
|
---|
1103 | ps2mR3SetDriverState(pThisCC, true);
|
---|
1104 | pThis->u8State = 0;
|
---|
1105 | pThis->enmMode = AUX_MODE_STD;
|
---|
1106 |
|
---|
1107 | return rc;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | #endif
|
---|
1111 |
|
---|
1112 | #if defined(RT_STRICT) && defined(IN_RING3)
|
---|
1113 | /* -=-=-=-=-=- Test code -=-=-=-=-=- */
|
---|
1114 |
|
---|
1115 | /** Test the event accumulation mechanism which we use to delay events going
|
---|
1116 | * to the guest to one per 10ms (the default PS/2 mouse event rate). This
|
---|
1117 | * test depends on ps2mR3PutEventWorker() not touching the timer if
|
---|
1118 | * This.fThrottleActive is true. */
|
---|
1119 | /** @todo if we add any more tests it might be worth using a table of test
|
---|
1120 | * operations and checks. */
|
---|
1121 | static void ps2mR3TestAccumulation(void)
|
---|
1122 | {
|
---|
1123 | PS2M This;
|
---|
1124 | unsigned i;
|
---|
1125 | int rc;
|
---|
1126 | uint8_t b;
|
---|
1127 |
|
---|
1128 | RT_ZERO(This);
|
---|
1129 | This.u8State = AUX_STATE_ENABLED;
|
---|
1130 | This.fThrottleActive = true;
|
---|
1131 | This.cmdQ.Hdr.pszDesc = "Test Aux Cmd";
|
---|
1132 | This.evtQ.Hdr.pszDesc = "Test Aux Evt";
|
---|
1133 | /* Certain Windows touch pad drivers report a double tap as a press, then
|
---|
1134 | * a release-press-release all within a single 10ms interval. Simulate
|
---|
1135 | * this to check that it is handled right. */
|
---|
1136 | ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1);
|
---|
1137 | if (ps2mR3HaveEvents(&This))
|
---|
1138 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1139 | ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0);
|
---|
1140 | if (ps2mR3HaveEvents(&This))
|
---|
1141 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1142 | ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1);
|
---|
1143 | ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0);
|
---|
1144 | if (ps2mR3HaveEvents(&This))
|
---|
1145 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1146 | if (ps2mR3HaveEvents(&This))
|
---|
1147 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1148 | for (i = 0; i < 12; ++i)
|
---|
1149 | {
|
---|
1150 | const uint8_t abExpected[] = { 9, 0, 0, 8, 0, 0, 9, 0, 0, 8, 0, 0};
|
---|
1151 |
|
---|
1152 | rc = PS2MByteFromAux(&This, &b);
|
---|
1153 | AssertRCSuccess(rc);
|
---|
1154 | Assert(b == abExpected[i]);
|
---|
1155 | }
|
---|
1156 | rc = PS2MByteFromAux(&This, &b);
|
---|
1157 | Assert(rc != VINF_SUCCESS);
|
---|
1158 | /* Button hold down during mouse drags was broken at some point during
|
---|
1159 | * testing fixes for the previous issue. Test that that works. */
|
---|
1160 | ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1);
|
---|
1161 | if (ps2mR3HaveEvents(&This))
|
---|
1162 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1163 | if (ps2mR3HaveEvents(&This))
|
---|
1164 | ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true);
|
---|
1165 | for (i = 0; i < 3; ++i)
|
---|
1166 | {
|
---|
1167 | const uint8_t abExpected[] = { 9, 0, 0 };
|
---|
1168 |
|
---|
1169 | rc = PS2MByteFromAux(&This, &b);
|
---|
1170 | AssertRCSuccess(rc);
|
---|
1171 | Assert(b == abExpected[i]);
|
---|
1172 | }
|
---|
1173 | rc = PS2MByteFromAux(&This, &b);
|
---|
1174 | Assert(rc != VINF_SUCCESS);
|
---|
1175 | }
|
---|
1176 | #endif /* RT_STRICT && IN_RING3 */
|
---|
1177 |
|
---|