Index: trunk/src/VBox/Devices/Input/DevPS2.cpp
===================================================================
--- trunk/src/VBox/Devices/Input/DevPS2.cpp	(revision 82172)
+++ trunk/src/VBox/Devices/Input/DevPS2.cpp	(revision 82173)
@@ -125,42 +125,4 @@
 
 
-/**
- * The keyboard controller/device state.
- *
- * @note We use the default critical section for serialize data access.
- */
-typedef struct KBDState
-{
-    uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
-    uint8_t status;
-    uint8_t mode;
-    uint8_t dbbout;    /* data buffer byte */
-    /* keyboard state */
-    int32_t translate;
-    int32_t xlat_state;
-
-    /** Pointer to the device instance - RC. */
-    PPDMDEVINSRC                pDevInsRC;
-    /** Pointer to the device instance - R3 . */
-    PPDMDEVINSR3                pDevInsR3;
-    /** Pointer to the device instance. */
-    PPDMDEVINSR0                pDevInsR0;
-
-    /** Keyboard state (implemented in separate PS2K module). */
-#ifdef VBOX_DEVICE_STRUCT_TESTCASE
-    uint8_t                     KbdFiller[PS2K_STRUCT_FILLER];
-#else
-    PS2K                        Kbd;
-#endif
-
-    /** Mouse state (implemented in separate PS2M module). */
-#ifdef VBOX_DEVICE_STRUCT_TESTCASE
-    uint8_t                     AuxFiller[PS2M_STRUCT_FILLER];
-#else
-    PS2M                        Aux;
-#endif
-} KBDState;
-
-#ifndef VBOX_DEVICE_STRUCT_TESTCASE
 
 /* update irq and KBD_STAT_[MOUSE_]OBF */
@@ -1118,4 +1080,2 @@
 };
 
-#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
-
Index: trunk/src/VBox/Devices/Input/DevPS2.h
===================================================================
--- trunk/src/VBox/Devices/Input/DevPS2.h	(revision 82172)
+++ trunk/src/VBox/Devices/Input/DevPS2.h	(revision 82173)
@@ -16,38 +16,163 @@
  */
 
-#ifndef VBOX_INCLUDED_SRC_Input_PS2Dev_h
-#define VBOX_INCLUDED_SRC_Input_PS2Dev_h
+#ifndef VBOX_INCLUDED_SRC_Input_DevPS2_h
+#define VBOX_INCLUDED_SRC_Input_DevPS2_h
 #ifndef RT_WITHOUT_PRAGMA_ONCE
 # pragma once
 #endif
 
-/** The size of the PS2K/PS2M structure fillers.
- * @note Must be at least as big as the real struct. Compile time assert
- *       makes sure this is so. */
-#define PS2K_STRUCT_FILLER  512
-#define PS2M_STRUCT_FILLER  512
-
-/* Hide the internal structure. */
-#if !(defined(IN_PS2K) || defined(VBOX_DEVICE_STRUCT_TESTCASE))
+/** @defgroup grp_devps2    PS/2 Device
+ * @{
+ */
+
+/** Pointer to the shared keyboard (PS/2) controller / device state. */
+typedef struct KBDSTATE *PKBDSTATE;
+
+/** Define a simple PS/2 input device queue. */
+#define DEF_PS2Q_TYPE(name, size)   \
+     typedef struct {               \
+        uint32_t    rpos;           \
+        uint32_t    wpos;           \
+        uint32_t    cUsed;          \
+        uint32_t    cSize;          \
+        uint8_t     abQueue[size];  \
+     } name
+
+DEF_PS2Q_TYPE(GeneriQ, 1);
+
+
+/** @defgroup grp_devps2k   DevPS2K - Keyboard
+ * @{
+ */
+
+/** @name HID modifier range.
+ * @{ */
+#define HID_MODIFIER_FIRST  0xE0
+#define HID_MODIFIER_LAST   0xE8
+/** @} */
+
+/** @name USB HID additional constants
+ * @{ */
+/** The highest USB usage code reported by VirtualBox. */
+#define VBOX_USB_MAX_USAGE_CODE     0xE7
+/** The size of an array needed to store all USB usage codes */
+#define VBOX_USB_USAGE_ARRAY_SIZE   (VBOX_USB_MAX_USAGE_CODE + 1)
+/** USB HID Keyboard Usage Page. */
+#define USB_HID_KB_PAGE             7
+/** USB HID Consumer Control Usage Page. */
+#define USB_HID_CC_PAGE             12
+/** @} */
+
+/* Internal keyboard queue sizes. The input queue doesn't need to be
+ * extra huge and the command queue only needs to handle a few bytes.
+ */
+#define KBD_KEY_QUEUE_SIZE         64
+#define KBD_CMD_QUEUE_SIZE          4
+
+DEF_PS2Q_TYPE(KbdKeyQ, KBD_KEY_QUEUE_SIZE);
+DEF_PS2Q_TYPE(KbdCmdQ, KBD_CMD_QUEUE_SIZE);
+
+/** Typematic state. */
+typedef enum {
+    KBD_TMS_IDLE    = 0,    /* No typematic key active. */
+    KBD_TMS_DELAY   = 1,    /* In the initial delay period. */
+    KBD_TMS_REPEAT  = 2,    /* Key repeating at set rate. */
+    KBD_TMS_32BIT_HACK = 0x7fffffff
+} tmatic_state_t;
+
+
+/**
+ * The shared PS/2 keyboard instance data.
+ */
 typedef struct PS2K
 {
-    uint8_t     abFiller[PS2K_STRUCT_FILLER];
+    /** Pointer to parent device (keyboard controller). */
+    R3PTRTYPE(PKBDSTATE) pParent;
+    /** Set if keyboard is enabled ('scans' for input). */
+    bool                fScanning;
+    /** Set NumLock is on. */
+    bool                fNumLockOn;
+    /** Selected scan set. */
+    uint8_t             u8ScanSet;
+    /** Modifier key state. */
+    uint8_t             u8Modifiers;
+    /** Currently processed command (if any). */
+    uint8_t             u8CurrCmd;
+    /** Status indicator (LED) state. */
+    uint8_t             u8LEDs;
+    /** Selected typematic delay/rate. */
+    uint8_t             u8TypematicCfg;
+    /** Usage code of current typematic key, if any. */
+    uint32_t            u32TypematicKey;
+    /** Current typematic repeat state. */
+    tmatic_state_t      enmTypematicState;
+    /** Buffer holding scan codes to be sent to the host. */
+    KbdKeyQ             keyQ;
+    /** Command response queue (priority). */
+    KbdCmdQ             cmdQ;
+    /** Currently depressed keys. */
+    uint8_t             abDepressedKeys[VBOX_USB_USAGE_ARRAY_SIZE];
+    /** Typematic delay in milliseconds. */
+    unsigned            uTypematicDelay;
+    /** Typematic repeat period in milliseconds. */
+    unsigned            uTypematicRepeat;
+    /** Set if the throttle delay is currently active. */
+    bool                fThrottleActive;
+    /** Set if the input rate should be throttled. */
+    bool                fThrottleEnabled;
+
+    uint8_t             Alignment0[2];
+
+    /** Command delay timer - RC Ptr. */
+    PTMTIMERRC          pKbdDelayTimerRC;
+    /** Typematic timer - RC Ptr. */
+    PTMTIMERRC          pKbdTypematicTimerRC;
+    /** Input throttle timer - RC Ptr. */
+    PTMTIMERRC          pThrottleTimerRC;
+
+    /** The device critical section protecting everything - R3 Ptr */
+    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
+
+    /** Command delay timer - R3 Ptr. */
+    PTMTIMERR3          pKbdDelayTimerR3;
+    /** Typematic timer - R3 Ptr. */
+    PTMTIMERR3          pKbdTypematicTimerR3;
+    /** Input throttle timer - R3 Ptr. */
+    PTMTIMERR3          pThrottleTimerR3;
+
+    /** Command delay timer - R0 Ptr. */
+    PTMTIMERR0          pKbdDelayTimerR0;
+    /** Typematic timer - R0 Ptr. */
+    PTMTIMERR0          pKbdTypematicTimerR0;
+    /** Input throttle timer - R0 Ptr. */
+    PTMTIMERR0          pThrottleTimerR0;
+
+    /**
+     * Keyboard port - LUN#0.
+     *
+     * @implements  PDMIBASE
+     * @implements  PDMIKEYBOARDPORT
+     */
+    struct
+    {
+        /** The base interface for the keyboard port. */
+        PDMIBASE                            IBase;
+        /** The keyboard port base interface. */
+        PDMIKEYBOARDPORT                    IPort;
+
+        /** The base interface of the attached keyboard driver. */
+        R3PTRTYPE(PPDMIBASE)                pDrvBase;
+        /** The keyboard interface of the attached keyboard driver. */
+        R3PTRTYPE(PPDMIKEYBOARDCONNECTOR)   pDrv;
+    } Keyboard;
 } PS2K;
-#endif
-
-#if !(defined(IN_PS2M) || defined(VBOX_DEVICE_STRUCT_TESTCASE))
-typedef struct PS2M
-{
-    uint8_t     abFiller[PS2M_STRUCT_FILLER];
-} PS2M;
-#endif
-
-/* Internal PS/2 Keyboard interface. */
-typedef struct PS2K *PPS2K;
+/** Pointer to the PS/2 keyboard instance data. */
+typedef PS2K *PPS2K;
+
 
 int  PS2KByteToKbd(PPS2K pThis, uint8_t cmd);
 int  PS2KByteFromKbd(PPS2K pThis, uint8_t *pVal);
 
-int  PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance, PCFGMNODE pCfg);
+int  PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg);
 int  PS2KAttach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
 void PS2KReset(PPS2K pThis);
@@ -59,12 +184,146 @@
 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns);
 
-
-/* Internal PS/2 Auxiliary device interface. */
-typedef struct PS2M *PPS2M;
+/** @} */
+
+
+/** @defgroup grp_devps2m DevPS2M - Auxiliary Device (Mouse)
+ * @{
+ */
+
+/* Internal mouse queue sizes. The input queue is relatively large,
+ * but the command queue only needs to handle a few bytes.
+ */
+#define AUX_EVT_QUEUE_SIZE        256
+#define AUX_CMD_QUEUE_SIZE          8
+
+DEF_PS2Q_TYPE(AuxEvtQ, AUX_EVT_QUEUE_SIZE);
+DEF_PS2Q_TYPE(AuxCmdQ, AUX_CMD_QUEUE_SIZE);
+
+/** Auxiliary device special modes of operation. */
+typedef enum {
+    AUX_MODE_STD,           /* Standard operation. */
+    AUX_MODE_RESET,         /* Currently in reset. */
+    AUX_MODE_WRAP           /* Wrap mode (echoing input). */
+} PS2M_MODE;
+
+/** Auxiliary device operational state. */
+typedef enum {
+    AUX_STATE_RATE_ERR  = RT_BIT(0),    /* Invalid rate received. */
+    AUX_STATE_RES_ERR   = RT_BIT(1),    /* Invalid resolution received. */
+    AUX_STATE_SCALING   = RT_BIT(4),    /* 2:1 scaling in effect. */
+    AUX_STATE_ENABLED   = RT_BIT(5),    /* Reporting enabled in stream mode. */
+    AUX_STATE_REMOTE    = RT_BIT(6)     /* Remote mode (reports on request). */
+} PS2M_STATE;
+
+/** Externally visible state bits. */
+#define AUX_STATE_EXTERNAL  (AUX_STATE_SCALING | AUX_STATE_ENABLED | AUX_STATE_REMOTE)
+
+/** Protocols supported by the PS/2 mouse. */
+typedef enum {
+    PS2M_PROTO_PS2STD      = 0,  /* Standard PS/2 mouse protocol. */
+    PS2M_PROTO_IMPS2       = 3,  /* IntelliMouse PS/2 protocol. */
+    PS2M_PROTO_IMEX        = 4,  /* IntelliMouse Explorer protocol. */
+    PS2M_PROTO_IMEX_HORZ   = 5   /* IntelliMouse Explorer with horizontal reports. */
+} PS2M_PROTO;
+
+/** Protocol selection 'knock' states. */
+typedef enum {
+    PS2M_KNOCK_INITIAL,
+    PS2M_KNOCK_1ST,
+    PS2M_KNOCK_IMPS2_2ND,
+    PS2M_KNOCK_IMEX_2ND,
+    PS2M_KNOCK_IMEX_HORZ_2ND
+} PS2M_KNOCK_STATE;
+
+/**
+ * The PS/2 auxiliary device instance data.
+ */
+typedef struct PS2M
+{
+    /** Pointer to parent device (keyboard controller). */
+    R3PTRTYPE(PKBDSTATE) pParent;
+    /** Operational state. */
+    uint8_t             u8State;
+    /** Configured sampling rate. */
+    uint8_t             u8SampleRate;
+    /** Configured resolution. */
+    uint8_t             u8Resolution;
+    /** Currently processed command (if any). */
+    uint8_t             u8CurrCmd;
+    /** Set if the throttle delay is active. */
+    bool                fThrottleActive;
+    /** Set if the throttle delay is active. */
+    bool                fDelayReset;
+    /** Operational mode. */
+    PS2M_MODE           enmMode;
+    /** Currently used protocol. */
+    PS2M_PROTO          enmProtocol;
+    /** Currently used protocol. */
+    PS2M_KNOCK_STATE    enmKnockState;
+    /** Buffer holding mouse events to be sent to the host. */
+    AuxEvtQ             evtQ;
+    /** Command response queue (priority). */
+    AuxCmdQ             cmdQ;
+    /** Accumulated horizontal movement. */
+    int32_t             iAccumX;
+    /** Accumulated vertical movement. */
+    int32_t             iAccumY;
+    /** Accumulated Z axis (vertical scroll) movement. */
+    int32_t             iAccumZ;
+    /** Accumulated W axis (horizontal scroll) movement. */
+    int32_t             iAccumW;
+    /** Accumulated button presses. */
+    uint32_t            fAccumB;
+    /** Instantaneous button data. */
+    uint32_t            fCurrB;
+    /** Button state last sent to the guest. */
+    uint32_t            fReportedB;
+    /** Throttling delay in milliseconds. */
+    uint32_t            uThrottleDelay;
+
+    /** The device critical section protecting everything - R3 Ptr */
+    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
+    /** Command delay timer - R3 Ptr. */
+    PTMTIMERR3          pDelayTimerR3;
+    /** Interrupt throttling timer - R3 Ptr. */
+    PTMTIMERR3          pThrottleTimerR3;
+    RTR3PTR             Alignment1;
+
+    /** Command delay timer - RC Ptr. */
+    PTMTIMERRC          pDelayTimerRC;
+    /** Interrupt throttling timer - RC Ptr. */
+    PTMTIMERRC          pThrottleTimerRC;
+
+    /** Command delay timer - R0 Ptr. */
+    PTMTIMERR0          pDelayTimerR0;
+    /** Interrupt throttling timer - R0 Ptr. */
+    PTMTIMERR0          pThrottleTimerR0;
+
+    /**
+     * Mouse port - LUN#1.
+     *
+     * @implements  PDMIBASE
+     * @implements  PDMIMOUSEPORT
+     */
+    struct
+    {
+        /** The base interface for the mouse port. */
+        PDMIBASE                            IBase;
+        /** The keyboard port base interface. */
+        PDMIMOUSEPORT                       IPort;
+
+        /** The base interface of the attached mouse driver. */
+        R3PTRTYPE(PPDMIBASE)                pDrvBase;
+        /** The keyboard interface of the attached mouse driver. */
+        R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
+    } Mouse;
+} PS2M;
+/** Pointer to the PS/2 auxiliary device instance data. */
+typedef PS2M *PPS2M;
 
 int  PS2MByteToAux(PPS2M pThis, uint8_t cmd);
 int  PS2MByteFromAux(PPS2M pThis, uint8_t *pVal);
 
-int  PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance);
+int  PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance);
 int  PS2MAttach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
 void PS2MReset(PPS2M pThis);
@@ -75,4 +334,36 @@
 
 PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns);
+
+/** @} */
+
+
+/**
+ * The shared keyboard controller/device state.
+ *
+ * @note We use the default critical section for serialize data access.
+ */
+typedef struct KBDSTATE
+{
+    uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
+    uint8_t status;
+    uint8_t mode;
+    uint8_t dbbout;    /* data buffer byte */
+    /* keyboard state */
+    int32_t translate;
+    int32_t xlat_state;
+
+    /** Pointer to the device instance - RC. */
+    PPDMDEVINSRC                pDevInsRC;
+    /** Pointer to the device instance - R3 . */
+    PPDMDEVINSR3                pDevInsR3;
+    /** Pointer to the device instance. */
+    PPDMDEVINSR0                pDevInsR0;
+
+    /** Keyboard state (implemented in separate PS2K module). */
+    PS2K                        Kbd;
+
+    /** Mouse state (implemented in separate PS2M module). */
+    PS2M                        Aux;
+} KBDSTATE, KBDState;
 
 
@@ -92,3 +383,6 @@
 int32_t XlateAT2PC(int32_t state, uint8_t scanIn, uint8_t *pScanOut);
 
-#endif /* !VBOX_INCLUDED_SRC_Input_PS2Dev_h */
+/** @}  */
+
+#endif /* !VBOX_INCLUDED_SRC_Input_DevPS2_h */
+
Index: trunk/src/VBox/Devices/Input/DevPS2K.cpp
===================================================================
--- trunk/src/VBox/Devices/Input/DevPS2K.cpp	(revision 82172)
+++ trunk/src/VBox/Devices/Input/DevPS2K.cpp	(revision 82173)
@@ -86,22 +86,4 @@
 /** @} */
 
-/** @name HID modifier range.
- * @{ */
-#define HID_MODIFIER_FIRST  0xE0
-#define HID_MODIFIER_LAST   0xE8
-/** @} */
-
-/** @name USB HID additional constants
- * @{ */
-/** The highest USB usage code reported by VirtualBox. */
-#define VBOX_USB_MAX_USAGE_CODE     0xE7
-/** The size of an array needed to store all USB usage codes */
-#define VBOX_USB_USAGE_ARRAY_SIZE   (VBOX_USB_MAX_USAGE_CODE + 1)
-/** USB HID Keyboard Usage Page. */
-#define USB_HID_KB_PAGE             7
-/** USB HID Consumer Control Usage Page. */
-#define USB_HID_CC_PAGE             12
-/** @} */
-
 /** @name Modifier key states. Sorted in USB HID code order.
  * @{ */
@@ -122,126 +104,8 @@
 #define KBD_THROTTLE_DELAY  1
 
-/** Define a simple PS/2 input device queue. */
-#define DEF_PS2Q_TYPE(name, size)   \
-     typedef struct {               \
-        uint32_t    rpos;           \
-        uint32_t    wpos;           \
-        uint32_t    cUsed;          \
-        uint32_t    cSize;          \
-        uint8_t     abQueue[size];  \
-     } name
-
-/* Internal keyboard queue sizes. The input queue doesn't need to be
- * extra huge and the command queue only needs to handle a few bytes.
- */
-#define KBD_KEY_QUEUE_SIZE         64
-#define KBD_CMD_QUEUE_SIZE          4
-
 
 /*********************************************************************************************************************************
 *   Structures and Typedefs                                                                                                      *
 *********************************************************************************************************************************/
-
-/** Typematic state. */
-typedef enum {
-    KBD_TMS_IDLE    = 0,    /* No typematic key active. */
-    KBD_TMS_DELAY   = 1,    /* In the initial delay period. */
-    KBD_TMS_REPEAT  = 2,    /* Key repeating at set rate. */
-    KBD_TMS_32BIT_HACK = 0x7fffffff
-} tmatic_state_t;
-
-
-DEF_PS2Q_TYPE(KbdKeyQ, KBD_KEY_QUEUE_SIZE);
-DEF_PS2Q_TYPE(KbdCmdQ, KBD_CMD_QUEUE_SIZE);
-DEF_PS2Q_TYPE(GeneriQ, 1);
-
-/**
- * The PS/2 keyboard instance data.
- */
-typedef struct PS2K
-{
-    /** Pointer to parent device (keyboard controller). */
-    R3PTRTYPE(void *)   pParent;
-    /** Set if keyboard is enabled ('scans' for input). */
-    bool                fScanning;
-    /** Set NumLock is on. */
-    bool                fNumLockOn;
-    /** Selected scan set. */
-    uint8_t             u8ScanSet;
-    /** Modifier key state. */
-    uint8_t             u8Modifiers;
-    /** Currently processed command (if any). */
-    uint8_t             u8CurrCmd;
-    /** Status indicator (LED) state. */
-    uint8_t             u8LEDs;
-    /** Selected typematic delay/rate. */
-    uint8_t             u8TypematicCfg;
-    /** Usage code of current typematic key, if any. */
-    uint32_t            u32TypematicKey;
-    /** Current typematic repeat state. */
-    tmatic_state_t      enmTypematicState;
-    /** Buffer holding scan codes to be sent to the host. */
-    KbdKeyQ             keyQ;
-    /** Command response queue (priority). */
-    KbdCmdQ             cmdQ;
-    /** Currently depressed keys. */
-    uint8_t             abDepressedKeys[VBOX_USB_USAGE_ARRAY_SIZE];
-    /** Typematic delay in milliseconds. */
-    unsigned            uTypematicDelay;
-    /** Typematic repeat period in milliseconds. */
-    unsigned            uTypematicRepeat;
-    /** Set if the throttle delay is currently active. */
-    bool                fThrottleActive;
-    /** Set if the input rate should be throttled. */
-    bool                fThrottleEnabled;
-
-    uint8_t             Alignment0[2];
-
-    /** Command delay timer - RC Ptr. */
-    PTMTIMERRC          pKbdDelayTimerRC;
-    /** Typematic timer - RC Ptr. */
-    PTMTIMERRC          pKbdTypematicTimerRC;
-    /** Input throttle timer - RC Ptr. */
-    PTMTIMERRC          pThrottleTimerRC;
-
-    /** The device critical section protecting everything - R3 Ptr */
-    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
-
-    /** Command delay timer - R3 Ptr. */
-    PTMTIMERR3          pKbdDelayTimerR3;
-    /** Typematic timer - R3 Ptr. */
-    PTMTIMERR3          pKbdTypematicTimerR3;
-    /** Input throttle timer - R3 Ptr. */
-    PTMTIMERR3          pThrottleTimerR3;
-
-    /** Command delay timer - R0 Ptr. */
-    PTMTIMERR0          pKbdDelayTimerR0;
-    /** Typematic timer - R0 Ptr. */
-    PTMTIMERR0          pKbdTypematicTimerR0;
-    /** Input throttle timer - R0 Ptr. */
-    PTMTIMERR0          pThrottleTimerR0;
-
-    /**
-     * Keyboard port - LUN#0.
-     *
-     * @implements  PDMIBASE
-     * @implements  PDMIKEYBOARDPORT
-     */
-    struct
-    {
-        /** The base interface for the keyboard port. */
-        PDMIBASE                            IBase;
-        /** The keyboard port base interface. */
-        PDMIKEYBOARDPORT                    IPort;
-
-        /** The base interface of the attached keyboard driver. */
-        R3PTRTYPE(PPDMIBASE)                pDrvBase;
-        /** The keyboard interface of the attached keyboard driver. */
-        R3PTRTYPE(PPDMIKEYBOARDCONNECTOR)   pDrv;
-    } Keyboard;
-} PS2K, *PPS2K;
-
-AssertCompile(PS2K_STRUCT_FILLER >= sizeof(PS2K));
-
 #ifndef VBOX_DEVICE_STRUCT_TESTCASE
 
@@ -1181,5 +1045,5 @@
 static DECLCALLBACK(void) ps2kThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
-    RT_NOREF2(pDevIns, pTimer);
+    RT_NOREF(pDevIns, pTimer);
     PPS2K       pThis = (PS2K *)pvUser;
     unsigned    uHaveData;
@@ -1206,5 +1070,5 @@
 static DECLCALLBACK(void) ps2kTypematicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
-    RT_NOREF2(pDevIns, pTimer);
+    RT_NOREF(pDevIns, pTimer);
     PPS2K pThis = (PS2K *)pvUser;
     LogFlowFunc(("Typematic state=%d, key %08X\n", pThis->enmTypematicState, pThis->u32TypematicKey));
@@ -1231,5 +1095,5 @@
 static DECLCALLBACK(void) ps2kDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
-    RT_NOREF2(pDevIns, pTimer);
+    RT_NOREF(pDevIns, pTimer);
     PPS2K pThis = (PS2K *)pvUser;
 
@@ -1553,5 +1417,5 @@
 int PS2KLoadDone(PPS2K pThis, PSSMHANDLE pSSM)
 {
-    RT_NOREF1(pSSM);
+    RT_NOREF(pSSM);
 
     /* This *must* be done after the inital load because it may trigger
@@ -1587,5 +1451,5 @@
 void PS2KRelocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
 {
-    RT_NOREF1(pDevIns);
+    RT_NOREF(pDevIns);
     LogFlowFunc(("Relocating PS2K\n"));
     pThis->pKbdDelayTimerRC     = TMTimerRCPtr(pThis->pKbdDelayTimerR3);
@@ -1595,8 +1459,8 @@
 }
 
-int PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance, PCFGMNODE pCfg)
-{
-    RT_NOREF2(pDevIns, iInstance);
-    LogFlowFunc(("iInstance=%d\n", iInstance));
+int PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg)
+{
+    RT_NOREF(pDevIns, iInstance);
+    LogFlowFunc(("iInstance=%u\n", iInstance));
 
     pThis->pParent = pParent;
Index: trunk/src/VBox/Devices/Input/DevPS2M.cpp
===================================================================
--- trunk/src/VBox/Devices/Input/DevPS2M.cpp	(revision 82172)
+++ trunk/src/VBox/Devices/Input/DevPS2M.cpp	(revision 82173)
@@ -197,152 +197,4 @@
 /** @} */
 
-/** Define a simple PS/2 input device queue. */
-#define DEF_PS2Q_TYPE(name, size)   \
-     typedef struct {               \
-        uint32_t    rpos;           \
-        uint32_t    wpos;           \
-        uint32_t    cUsed;          \
-        uint32_t    cSize;          \
-        uint8_t     abQueue[size];  \
-     } name
-
-/* Internal mouse queue sizes. The input queue is relatively large,
- * but the command queue only needs to handle a few bytes.
- */
-#define AUX_EVT_QUEUE_SIZE        256
-#define AUX_CMD_QUEUE_SIZE          8
-
-
-/*********************************************************************************************************************************
-*   Structures and Typedefs                                                                                                      *
-*********************************************************************************************************************************/
-
-DEF_PS2Q_TYPE(AuxEvtQ, AUX_EVT_QUEUE_SIZE);
-DEF_PS2Q_TYPE(AuxCmdQ, AUX_CMD_QUEUE_SIZE);
-#ifndef VBOX_DEVICE_STRUCT_TESTCASE /// @todo hack
-DEF_PS2Q_TYPE(GeneriQ, 1);
-#endif
-
-/* Auxiliary device special modes of operation. */
-typedef enum {
-    AUX_MODE_STD,           /* Standard operation. */
-    AUX_MODE_RESET,         /* Currently in reset. */
-    AUX_MODE_WRAP           /* Wrap mode (echoing input). */
-} PS2M_MODE;
-
-/* Auxiliary device operational state. */
-typedef enum {
-    AUX_STATE_RATE_ERR  = RT_BIT(0),    /* Invalid rate received. */
-    AUX_STATE_RES_ERR   = RT_BIT(1),    /* Invalid resolution received. */
-    AUX_STATE_SCALING   = RT_BIT(4),    /* 2:1 scaling in effect. */
-    AUX_STATE_ENABLED   = RT_BIT(5),    /* Reporting enabled in stream mode. */
-    AUX_STATE_REMOTE    = RT_BIT(6)     /* Remote mode (reports on request). */
-} PS2M_STATE;
-
-/* Externally visible state bits. */
-#define AUX_STATE_EXTERNAL  (AUX_STATE_SCALING | AUX_STATE_ENABLED | AUX_STATE_REMOTE)
-
-/* Protocols supported by the PS/2 mouse. */
-typedef enum {
-    PS2M_PROTO_PS2STD      = 0,  /* Standard PS/2 mouse protocol. */
-    PS2M_PROTO_IMPS2       = 3,  /* IntelliMouse PS/2 protocol. */
-    PS2M_PROTO_IMEX        = 4,  /* IntelliMouse Explorer protocol. */
-    PS2M_PROTO_IMEX_HORZ   = 5   /* IntelliMouse Explorer with horizontal reports. */
-} PS2M_PROTO;
-
-/* Protocol selection 'knock' states. */
-typedef enum {
-    PS2M_KNOCK_INITIAL,
-    PS2M_KNOCK_1ST,
-    PS2M_KNOCK_IMPS2_2ND,
-    PS2M_KNOCK_IMEX_2ND,
-    PS2M_KNOCK_IMEX_HORZ_2ND
-} PS2M_KNOCK_STATE;
-
-/**
- * The PS/2 auxiliary device instance data.
- */
-typedef struct PS2M
-{
-    /** Pointer to parent device (keyboard controller). */
-    R3PTRTYPE(void *)   pParent;
-    /** Operational state. */
-    uint8_t             u8State;
-    /** Configured sampling rate. */
-    uint8_t             u8SampleRate;
-    /** Configured resolution. */
-    uint8_t             u8Resolution;
-    /** Currently processed command (if any). */
-    uint8_t             u8CurrCmd;
-    /** Set if the throttle delay is active. */
-    bool                fThrottleActive;
-    /** Set if the throttle delay is active. */
-    bool                fDelayReset;
-    /** Operational mode. */
-    PS2M_MODE           enmMode;
-    /** Currently used protocol. */
-    PS2M_PROTO          enmProtocol;
-    /** Currently used protocol. */
-    PS2M_KNOCK_STATE    enmKnockState;
-    /** Buffer holding mouse events to be sent to the host. */
-    AuxEvtQ             evtQ;
-    /** Command response queue (priority). */
-    AuxCmdQ             cmdQ;
-    /** Accumulated horizontal movement. */
-    int32_t             iAccumX;
-    /** Accumulated vertical movement. */
-    int32_t             iAccumY;
-    /** Accumulated Z axis (vertical scroll) movement. */
-    int32_t             iAccumZ;
-    /** Accumulated W axis (horizontal scroll) movement. */
-    int32_t             iAccumW;
-    /** Accumulated button presses. */
-    uint32_t            fAccumB;
-    /** Instantaneous button data. */
-    uint32_t            fCurrB;
-    /** Button state last sent to the guest. */
-    uint32_t            fReportedB;
-    /** Throttling delay in milliseconds. */
-    uint32_t            uThrottleDelay;
-
-    /** The device critical section protecting everything - R3 Ptr */
-    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
-    /** Command delay timer - R3 Ptr. */
-    PTMTIMERR3          pDelayTimerR3;
-    /** Interrupt throttling timer - R3 Ptr. */
-    PTMTIMERR3          pThrottleTimerR3;
-    RTR3PTR             Alignment1;
-
-    /** Command delay timer - RC Ptr. */
-    PTMTIMERRC          pDelayTimerRC;
-    /** Interrupt throttling timer - RC Ptr. */
-    PTMTIMERRC          pThrottleTimerRC;
-
-    /** Command delay timer - R0 Ptr. */
-    PTMTIMERR0          pDelayTimerR0;
-    /** Interrupt throttling timer - R0 Ptr. */
-    PTMTIMERR0          pThrottleTimerR0;
-
-    /**
-     * Mouse port - LUN#1.
-     *
-     * @implements  PDMIBASE
-     * @implements  PDMIMOUSEPORT
-     */
-    struct
-    {
-        /** The base interface for the mouse port. */
-        PDMIBASE                            IBase;
-        /** The keyboard port base interface. */
-        PDMIMOUSEPORT                       IPort;
-
-        /** The base interface of the attached mouse driver. */
-        R3PTRTYPE(PPDMIBASE)                pDrvBase;
-        /** The keyboard interface of the attached mouse driver. */
-        R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
-    } Mouse;
-} PS2M, *PPS2M;
-
-AssertCompile(PS2M_STRUCT_FILLER >= sizeof(PS2M));
 
 #ifndef VBOX_DEVICE_STRUCT_TESTCASE
@@ -355,14 +207,4 @@
 static void ps2mTestAccumulation(void);
 #endif
-
-
-/*********************************************************************************************************************************
-*   Global Variables                                                                                                             *
-*********************************************************************************************************************************/
-
-
-/*********************************************************************************************************************************
-*   Internal Functions                                                                                                           *
-*********************************************************************************************************************************/
 
 
@@ -952,5 +794,5 @@
 static DECLCALLBACK(void) ps2mThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
-    RT_NOREF2(pDevIns, pTimer);
+    RT_NOREF(pDevIns, pTimer);
     PPS2M       pThis = (PS2M *)pvUser;
     uint32_t    uHaveEvents;
@@ -982,5 +824,5 @@
 static DECLCALLBACK(void) ps2mDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
 {
-    RT_NOREF2(pDevIns, pTimer);
+    RT_NOREF(pDevIns, pTimer);
     PPS2M pThis = (PS2M *)pvUser;
 
@@ -1275,5 +1117,5 @@
 void PS2MRelocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
 {
-    RT_NOREF2(pDevIns, offDelta);
+    RT_NOREF(pDevIns, offDelta);
     LogFlowFunc(("Relocating PS2M\n"));
     pThis->pDelayTimerRC    = TMTimerRCPtr(pThis->pDelayTimerR3);
@@ -1281,9 +1123,9 @@
 }
 
-int PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance)
-{
-    RT_NOREF1(iInstance);
-
-    LogFlowFunc(("iInstance=%d\n", iInstance));
+int PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)
+{
+    RT_NOREF(iInstance);
+
+    LogFlowFunc(("iInstance=%u\n", iInstance));
 
 #ifdef RT_STRICT
Index: trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp
===================================================================
--- trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp	(revision 82172)
+++ trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp	(revision 82173)
@@ -58,9 +58,5 @@
 #include "../Graphics/DevVGA.cpp"
 #undef LOG_GROUP
-#include "../Input/DevPS2.cpp"
-#undef LOG_GROUP
-#include "../Input/DevPS2K.cpp"
-#undef LOG_GROUP
-#include "../Input/DevPS2M.cpp"
+#include "../Input/DevPS2.h"
 #ifdef VBOX_WITH_E1000
 # undef LOG_GROUP
