VirtualBox

Changeset 82173 in vbox for trunk/src


Ignore:
Timestamp:
Nov 25, 2019 1:00:55 PM (5 years ago)
Author:
vboxsync
Message:

DevPS2: Less opaque and structure duplicatication. (The opaque stuff would become very tedious later when splitting up the state structures.) bugref:9218

Location:
trunk/src/VBox/Devices
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/DevPS2.cpp

    r82170 r82173  
    125125
    126126
    127 /**
    128  * The keyboard controller/device state.
    129  *
    130  * @note We use the default critical section for serialize data access.
    131  */
    132 typedef struct KBDState
    133 {
    134     uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
    135     uint8_t status;
    136     uint8_t mode;
    137     uint8_t dbbout;    /* data buffer byte */
    138     /* keyboard state */
    139     int32_t translate;
    140     int32_t xlat_state;
    141 
    142     /** Pointer to the device instance - RC. */
    143     PPDMDEVINSRC                pDevInsRC;
    144     /** Pointer to the device instance - R3 . */
    145     PPDMDEVINSR3                pDevInsR3;
    146     /** Pointer to the device instance. */
    147     PPDMDEVINSR0                pDevInsR0;
    148 
    149     /** Keyboard state (implemented in separate PS2K module). */
    150 #ifdef VBOX_DEVICE_STRUCT_TESTCASE
    151     uint8_t                     KbdFiller[PS2K_STRUCT_FILLER];
    152 #else
    153     PS2K                        Kbd;
    154 #endif
    155 
    156     /** Mouse state (implemented in separate PS2M module). */
    157 #ifdef VBOX_DEVICE_STRUCT_TESTCASE
    158     uint8_t                     AuxFiller[PS2M_STRUCT_FILLER];
    159 #else
    160     PS2M                        Aux;
    161 #endif
    162 } KBDState;
    163 
    164 #ifndef VBOX_DEVICE_STRUCT_TESTCASE
    165127
    166128/* update irq and KBD_STAT_[MOUSE_]OBF */
     
    11181080};
    11191081
    1120 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
    1121 
  • trunk/src/VBox/Devices/Input/DevPS2.h

    r82170 r82173  
    1616 */
    1717
    18 #ifndef VBOX_INCLUDED_SRC_Input_PS2Dev_h
    19 #define VBOX_INCLUDED_SRC_Input_PS2Dev_h
     18#ifndef VBOX_INCLUDED_SRC_Input_DevPS2_h
     19#define VBOX_INCLUDED_SRC_Input_DevPS2_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
    24 /** The size of the PS2K/PS2M structure fillers.
    25  * @note Must be at least as big as the real struct. Compile time assert
    26  *       makes sure this is so. */
    27 #define PS2K_STRUCT_FILLER  512
    28 #define PS2M_STRUCT_FILLER  512
    29 
    30 /* Hide the internal structure. */
    31 #if !(defined(IN_PS2K) || defined(VBOX_DEVICE_STRUCT_TESTCASE))
     24/** @defgroup grp_devps2    PS/2 Device
     25 * @{
     26 */
     27
     28/** Pointer to the shared keyboard (PS/2) controller / device state. */
     29typedef struct KBDSTATE *PKBDSTATE;
     30
     31/** Define a simple PS/2 input device queue. */
     32#define DEF_PS2Q_TYPE(name, size)   \
     33     typedef struct {               \
     34        uint32_t    rpos;           \
     35        uint32_t    wpos;           \
     36        uint32_t    cUsed;          \
     37        uint32_t    cSize;          \
     38        uint8_t     abQueue[size];  \
     39     } name
     40
     41DEF_PS2Q_TYPE(GeneriQ, 1);
     42
     43
     44/** @defgroup grp_devps2k   DevPS2K - Keyboard
     45 * @{
     46 */
     47
     48/** @name HID modifier range.
     49 * @{ */
     50#define HID_MODIFIER_FIRST  0xE0
     51#define HID_MODIFIER_LAST   0xE8
     52/** @} */
     53
     54/** @name USB HID additional constants
     55 * @{ */
     56/** The highest USB usage code reported by VirtualBox. */
     57#define VBOX_USB_MAX_USAGE_CODE     0xE7
     58/** The size of an array needed to store all USB usage codes */
     59#define VBOX_USB_USAGE_ARRAY_SIZE   (VBOX_USB_MAX_USAGE_CODE + 1)
     60/** USB HID Keyboard Usage Page. */
     61#define USB_HID_KB_PAGE             7
     62/** USB HID Consumer Control Usage Page. */
     63#define USB_HID_CC_PAGE             12
     64/** @} */
     65
     66/* Internal keyboard queue sizes. The input queue doesn't need to be
     67 * extra huge and the command queue only needs to handle a few bytes.
     68 */
     69#define KBD_KEY_QUEUE_SIZE         64
     70#define KBD_CMD_QUEUE_SIZE          4
     71
     72DEF_PS2Q_TYPE(KbdKeyQ, KBD_KEY_QUEUE_SIZE);
     73DEF_PS2Q_TYPE(KbdCmdQ, KBD_CMD_QUEUE_SIZE);
     74
     75/** Typematic state. */
     76typedef enum {
     77    KBD_TMS_IDLE    = 0,    /* No typematic key active. */
     78    KBD_TMS_DELAY   = 1,    /* In the initial delay period. */
     79    KBD_TMS_REPEAT  = 2,    /* Key repeating at set rate. */
     80    KBD_TMS_32BIT_HACK = 0x7fffffff
     81} tmatic_state_t;
     82
     83
     84/**
     85 * The shared PS/2 keyboard instance data.
     86 */
    3287typedef struct PS2K
    3388{
    34     uint8_t     abFiller[PS2K_STRUCT_FILLER];
     89    /** Pointer to parent device (keyboard controller). */
     90    R3PTRTYPE(PKBDSTATE) pParent;
     91    /** Set if keyboard is enabled ('scans' for input). */
     92    bool                fScanning;
     93    /** Set NumLock is on. */
     94    bool                fNumLockOn;
     95    /** Selected scan set. */
     96    uint8_t             u8ScanSet;
     97    /** Modifier key state. */
     98    uint8_t             u8Modifiers;
     99    /** Currently processed command (if any). */
     100    uint8_t             u8CurrCmd;
     101    /** Status indicator (LED) state. */
     102    uint8_t             u8LEDs;
     103    /** Selected typematic delay/rate. */
     104    uint8_t             u8TypematicCfg;
     105    /** Usage code of current typematic key, if any. */
     106    uint32_t            u32TypematicKey;
     107    /** Current typematic repeat state. */
     108    tmatic_state_t      enmTypematicState;
     109    /** Buffer holding scan codes to be sent to the host. */
     110    KbdKeyQ             keyQ;
     111    /** Command response queue (priority). */
     112    KbdCmdQ             cmdQ;
     113    /** Currently depressed keys. */
     114    uint8_t             abDepressedKeys[VBOX_USB_USAGE_ARRAY_SIZE];
     115    /** Typematic delay in milliseconds. */
     116    unsigned            uTypematicDelay;
     117    /** Typematic repeat period in milliseconds. */
     118    unsigned            uTypematicRepeat;
     119    /** Set if the throttle delay is currently active. */
     120    bool                fThrottleActive;
     121    /** Set if the input rate should be throttled. */
     122    bool                fThrottleEnabled;
     123
     124    uint8_t             Alignment0[2];
     125
     126    /** Command delay timer - RC Ptr. */
     127    PTMTIMERRC          pKbdDelayTimerRC;
     128    /** Typematic timer - RC Ptr. */
     129    PTMTIMERRC          pKbdTypematicTimerRC;
     130    /** Input throttle timer - RC Ptr. */
     131    PTMTIMERRC          pThrottleTimerRC;
     132
     133    /** The device critical section protecting everything - R3 Ptr */
     134    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
     135
     136    /** Command delay timer - R3 Ptr. */
     137    PTMTIMERR3          pKbdDelayTimerR3;
     138    /** Typematic timer - R3 Ptr. */
     139    PTMTIMERR3          pKbdTypematicTimerR3;
     140    /** Input throttle timer - R3 Ptr. */
     141    PTMTIMERR3          pThrottleTimerR3;
     142
     143    /** Command delay timer - R0 Ptr. */
     144    PTMTIMERR0          pKbdDelayTimerR0;
     145    /** Typematic timer - R0 Ptr. */
     146    PTMTIMERR0          pKbdTypematicTimerR0;
     147    /** Input throttle timer - R0 Ptr. */
     148    PTMTIMERR0          pThrottleTimerR0;
     149
     150    /**
     151     * Keyboard port - LUN#0.
     152     *
     153     * @implements  PDMIBASE
     154     * @implements  PDMIKEYBOARDPORT
     155     */
     156    struct
     157    {
     158        /** The base interface for the keyboard port. */
     159        PDMIBASE                            IBase;
     160        /** The keyboard port base interface. */
     161        PDMIKEYBOARDPORT                    IPort;
     162
     163        /** The base interface of the attached keyboard driver. */
     164        R3PTRTYPE(PPDMIBASE)                pDrvBase;
     165        /** The keyboard interface of the attached keyboard driver. */
     166        R3PTRTYPE(PPDMIKEYBOARDCONNECTOR)   pDrv;
     167    } Keyboard;
    35168} PS2K;
    36 #endif
    37 
    38 #if !(defined(IN_PS2M) || defined(VBOX_DEVICE_STRUCT_TESTCASE))
    39 typedef struct PS2M
    40 {
    41     uint8_t     abFiller[PS2M_STRUCT_FILLER];
    42 } PS2M;
    43 #endif
    44 
    45 /* Internal PS/2 Keyboard interface. */
    46 typedef struct PS2K *PPS2K;
     169/** Pointer to the PS/2 keyboard instance data. */
     170typedef PS2K *PPS2K;
     171
    47172
    48173int  PS2KByteToKbd(PPS2K pThis, uint8_t cmd);
    49174int  PS2KByteFromKbd(PPS2K pThis, uint8_t *pVal);
    50175
    51 int  PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance, PCFGMNODE pCfg);
     176int  PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg);
    52177int  PS2KAttach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
    53178void PS2KReset(PPS2K pThis);
     
    59184PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns);
    60185
    61 
    62 /* Internal PS/2 Auxiliary device interface. */
    63 typedef struct PS2M *PPS2M;
     186/** @} */
     187
     188
     189/** @defgroup grp_devps2m DevPS2M - Auxiliary Device (Mouse)
     190 * @{
     191 */
     192
     193/* Internal mouse queue sizes. The input queue is relatively large,
     194 * but the command queue only needs to handle a few bytes.
     195 */
     196#define AUX_EVT_QUEUE_SIZE        256
     197#define AUX_CMD_QUEUE_SIZE          8
     198
     199DEF_PS2Q_TYPE(AuxEvtQ, AUX_EVT_QUEUE_SIZE);
     200DEF_PS2Q_TYPE(AuxCmdQ, AUX_CMD_QUEUE_SIZE);
     201
     202/** Auxiliary device special modes of operation. */
     203typedef enum {
     204    AUX_MODE_STD,           /* Standard operation. */
     205    AUX_MODE_RESET,         /* Currently in reset. */
     206    AUX_MODE_WRAP           /* Wrap mode (echoing input). */
     207} PS2M_MODE;
     208
     209/** Auxiliary device operational state. */
     210typedef enum {
     211    AUX_STATE_RATE_ERR  = RT_BIT(0),    /* Invalid rate received. */
     212    AUX_STATE_RES_ERR   = RT_BIT(1),    /* Invalid resolution received. */
     213    AUX_STATE_SCALING   = RT_BIT(4),    /* 2:1 scaling in effect. */
     214    AUX_STATE_ENABLED   = RT_BIT(5),    /* Reporting enabled in stream mode. */
     215    AUX_STATE_REMOTE    = RT_BIT(6)     /* Remote mode (reports on request). */
     216} PS2M_STATE;
     217
     218/** Externally visible state bits. */
     219#define AUX_STATE_EXTERNAL  (AUX_STATE_SCALING | AUX_STATE_ENABLED | AUX_STATE_REMOTE)
     220
     221/** Protocols supported by the PS/2 mouse. */
     222typedef enum {
     223    PS2M_PROTO_PS2STD      = 0,  /* Standard PS/2 mouse protocol. */
     224    PS2M_PROTO_IMPS2       = 3,  /* IntelliMouse PS/2 protocol. */
     225    PS2M_PROTO_IMEX        = 4,  /* IntelliMouse Explorer protocol. */
     226    PS2M_PROTO_IMEX_HORZ   = 5   /* IntelliMouse Explorer with horizontal reports. */
     227} PS2M_PROTO;
     228
     229/** Protocol selection 'knock' states. */
     230typedef enum {
     231    PS2M_KNOCK_INITIAL,
     232    PS2M_KNOCK_1ST,
     233    PS2M_KNOCK_IMPS2_2ND,
     234    PS2M_KNOCK_IMEX_2ND,
     235    PS2M_KNOCK_IMEX_HORZ_2ND
     236} PS2M_KNOCK_STATE;
     237
     238/**
     239 * The PS/2 auxiliary device instance data.
     240 */
     241typedef struct PS2M
     242{
     243    /** Pointer to parent device (keyboard controller). */
     244    R3PTRTYPE(PKBDSTATE) pParent;
     245    /** Operational state. */
     246    uint8_t             u8State;
     247    /** Configured sampling rate. */
     248    uint8_t             u8SampleRate;
     249    /** Configured resolution. */
     250    uint8_t             u8Resolution;
     251    /** Currently processed command (if any). */
     252    uint8_t             u8CurrCmd;
     253    /** Set if the throttle delay is active. */
     254    bool                fThrottleActive;
     255    /** Set if the throttle delay is active. */
     256    bool                fDelayReset;
     257    /** Operational mode. */
     258    PS2M_MODE           enmMode;
     259    /** Currently used protocol. */
     260    PS2M_PROTO          enmProtocol;
     261    /** Currently used protocol. */
     262    PS2M_KNOCK_STATE    enmKnockState;
     263    /** Buffer holding mouse events to be sent to the host. */
     264    AuxEvtQ             evtQ;
     265    /** Command response queue (priority). */
     266    AuxCmdQ             cmdQ;
     267    /** Accumulated horizontal movement. */
     268    int32_t             iAccumX;
     269    /** Accumulated vertical movement. */
     270    int32_t             iAccumY;
     271    /** Accumulated Z axis (vertical scroll) movement. */
     272    int32_t             iAccumZ;
     273    /** Accumulated W axis (horizontal scroll) movement. */
     274    int32_t             iAccumW;
     275    /** Accumulated button presses. */
     276    uint32_t            fAccumB;
     277    /** Instantaneous button data. */
     278    uint32_t            fCurrB;
     279    /** Button state last sent to the guest. */
     280    uint32_t            fReportedB;
     281    /** Throttling delay in milliseconds. */
     282    uint32_t            uThrottleDelay;
     283
     284    /** The device critical section protecting everything - R3 Ptr */
     285    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
     286    /** Command delay timer - R3 Ptr. */
     287    PTMTIMERR3          pDelayTimerR3;
     288    /** Interrupt throttling timer - R3 Ptr. */
     289    PTMTIMERR3          pThrottleTimerR3;
     290    RTR3PTR             Alignment1;
     291
     292    /** Command delay timer - RC Ptr. */
     293    PTMTIMERRC          pDelayTimerRC;
     294    /** Interrupt throttling timer - RC Ptr. */
     295    PTMTIMERRC          pThrottleTimerRC;
     296
     297    /** Command delay timer - R0 Ptr. */
     298    PTMTIMERR0          pDelayTimerR0;
     299    /** Interrupt throttling timer - R0 Ptr. */
     300    PTMTIMERR0          pThrottleTimerR0;
     301
     302    /**
     303     * Mouse port - LUN#1.
     304     *
     305     * @implements  PDMIBASE
     306     * @implements  PDMIMOUSEPORT
     307     */
     308    struct
     309    {
     310        /** The base interface for the mouse port. */
     311        PDMIBASE                            IBase;
     312        /** The keyboard port base interface. */
     313        PDMIMOUSEPORT                       IPort;
     314
     315        /** The base interface of the attached mouse driver. */
     316        R3PTRTYPE(PPDMIBASE)                pDrvBase;
     317        /** The keyboard interface of the attached mouse driver. */
     318        R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
     319    } Mouse;
     320} PS2M;
     321/** Pointer to the PS/2 auxiliary device instance data. */
     322typedef PS2M *PPS2M;
    64323
    65324int  PS2MByteToAux(PPS2M pThis, uint8_t cmd);
    66325int  PS2MByteFromAux(PPS2M pThis, uint8_t *pVal);
    67326
    68 int  PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance);
     327int  PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance);
    69328int  PS2MAttach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
    70329void PS2MReset(PPS2M pThis);
     
    75334
    76335PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns);
     336
     337/** @} */
     338
     339
     340/**
     341 * The shared keyboard controller/device state.
     342 *
     343 * @note We use the default critical section for serialize data access.
     344 */
     345typedef struct KBDSTATE
     346{
     347    uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
     348    uint8_t status;
     349    uint8_t mode;
     350    uint8_t dbbout;    /* data buffer byte */
     351    /* keyboard state */
     352    int32_t translate;
     353    int32_t xlat_state;
     354
     355    /** Pointer to the device instance - RC. */
     356    PPDMDEVINSRC                pDevInsRC;
     357    /** Pointer to the device instance - R3 . */
     358    PPDMDEVINSR3                pDevInsR3;
     359    /** Pointer to the device instance. */
     360    PPDMDEVINSR0                pDevInsR0;
     361
     362    /** Keyboard state (implemented in separate PS2K module). */
     363    PS2K                        Kbd;
     364
     365    /** Mouse state (implemented in separate PS2M module). */
     366    PS2M                        Aux;
     367} KBDSTATE, KBDState;
    77368
    78369
     
    92383int32_t XlateAT2PC(int32_t state, uint8_t scanIn, uint8_t *pScanOut);
    93384
    94 #endif /* !VBOX_INCLUDED_SRC_Input_PS2Dev_h */
     385/** @}  */
     386
     387#endif /* !VBOX_INCLUDED_SRC_Input_DevPS2_h */
     388
  • trunk/src/VBox/Devices/Input/DevPS2K.cpp

    r82170 r82173  
    8686/** @} */
    8787
    88 /** @name HID modifier range.
    89  * @{ */
    90 #define HID_MODIFIER_FIRST  0xE0
    91 #define HID_MODIFIER_LAST   0xE8
    92 /** @} */
    93 
    94 /** @name USB HID additional constants
    95  * @{ */
    96 /** The highest USB usage code reported by VirtualBox. */
    97 #define VBOX_USB_MAX_USAGE_CODE     0xE7
    98 /** The size of an array needed to store all USB usage codes */
    99 #define VBOX_USB_USAGE_ARRAY_SIZE   (VBOX_USB_MAX_USAGE_CODE + 1)
    100 /** USB HID Keyboard Usage Page. */
    101 #define USB_HID_KB_PAGE             7
    102 /** USB HID Consumer Control Usage Page. */
    103 #define USB_HID_CC_PAGE             12
    104 /** @} */
    105 
    10688/** @name Modifier key states. Sorted in USB HID code order.
    10789 * @{ */
     
    122104#define KBD_THROTTLE_DELAY  1
    123105
    124 /** Define a simple PS/2 input device queue. */
    125 #define DEF_PS2Q_TYPE(name, size)   \
    126      typedef struct {               \
    127         uint32_t    rpos;           \
    128         uint32_t    wpos;           \
    129         uint32_t    cUsed;          \
    130         uint32_t    cSize;          \
    131         uint8_t     abQueue[size];  \
    132      } name
    133 
    134 /* Internal keyboard queue sizes. The input queue doesn't need to be
    135  * extra huge and the command queue only needs to handle a few bytes.
    136  */
    137 #define KBD_KEY_QUEUE_SIZE         64
    138 #define KBD_CMD_QUEUE_SIZE          4
    139 
    140106
    141107/*********************************************************************************************************************************
    142108*   Structures and Typedefs                                                                                                      *
    143109*********************************************************************************************************************************/
    144 
    145 /** Typematic state. */
    146 typedef enum {
    147     KBD_TMS_IDLE    = 0,    /* No typematic key active. */
    148     KBD_TMS_DELAY   = 1,    /* In the initial delay period. */
    149     KBD_TMS_REPEAT  = 2,    /* Key repeating at set rate. */
    150     KBD_TMS_32BIT_HACK = 0x7fffffff
    151 } tmatic_state_t;
    152 
    153 
    154 DEF_PS2Q_TYPE(KbdKeyQ, KBD_KEY_QUEUE_SIZE);
    155 DEF_PS2Q_TYPE(KbdCmdQ, KBD_CMD_QUEUE_SIZE);
    156 DEF_PS2Q_TYPE(GeneriQ, 1);
    157 
    158 /**
    159  * The PS/2 keyboard instance data.
    160  */
    161 typedef struct PS2K
    162 {
    163     /** Pointer to parent device (keyboard controller). */
    164     R3PTRTYPE(void *)   pParent;
    165     /** Set if keyboard is enabled ('scans' for input). */
    166     bool                fScanning;
    167     /** Set NumLock is on. */
    168     bool                fNumLockOn;
    169     /** Selected scan set. */
    170     uint8_t             u8ScanSet;
    171     /** Modifier key state. */
    172     uint8_t             u8Modifiers;
    173     /** Currently processed command (if any). */
    174     uint8_t             u8CurrCmd;
    175     /** Status indicator (LED) state. */
    176     uint8_t             u8LEDs;
    177     /** Selected typematic delay/rate. */
    178     uint8_t             u8TypematicCfg;
    179     /** Usage code of current typematic key, if any. */
    180     uint32_t            u32TypematicKey;
    181     /** Current typematic repeat state. */
    182     tmatic_state_t      enmTypematicState;
    183     /** Buffer holding scan codes to be sent to the host. */
    184     KbdKeyQ             keyQ;
    185     /** Command response queue (priority). */
    186     KbdCmdQ             cmdQ;
    187     /** Currently depressed keys. */
    188     uint8_t             abDepressedKeys[VBOX_USB_USAGE_ARRAY_SIZE];
    189     /** Typematic delay in milliseconds. */
    190     unsigned            uTypematicDelay;
    191     /** Typematic repeat period in milliseconds. */
    192     unsigned            uTypematicRepeat;
    193     /** Set if the throttle delay is currently active. */
    194     bool                fThrottleActive;
    195     /** Set if the input rate should be throttled. */
    196     bool                fThrottleEnabled;
    197 
    198     uint8_t             Alignment0[2];
    199 
    200     /** Command delay timer - RC Ptr. */
    201     PTMTIMERRC          pKbdDelayTimerRC;
    202     /** Typematic timer - RC Ptr. */
    203     PTMTIMERRC          pKbdTypematicTimerRC;
    204     /** Input throttle timer - RC Ptr. */
    205     PTMTIMERRC          pThrottleTimerRC;
    206 
    207     /** The device critical section protecting everything - R3 Ptr */
    208     R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
    209 
    210     /** Command delay timer - R3 Ptr. */
    211     PTMTIMERR3          pKbdDelayTimerR3;
    212     /** Typematic timer - R3 Ptr. */
    213     PTMTIMERR3          pKbdTypematicTimerR3;
    214     /** Input throttle timer - R3 Ptr. */
    215     PTMTIMERR3          pThrottleTimerR3;
    216 
    217     /** Command delay timer - R0 Ptr. */
    218     PTMTIMERR0          pKbdDelayTimerR0;
    219     /** Typematic timer - R0 Ptr. */
    220     PTMTIMERR0          pKbdTypematicTimerR0;
    221     /** Input throttle timer - R0 Ptr. */
    222     PTMTIMERR0          pThrottleTimerR0;
    223 
    224     /**
    225      * Keyboard port - LUN#0.
    226      *
    227      * @implements  PDMIBASE
    228      * @implements  PDMIKEYBOARDPORT
    229      */
    230     struct
    231     {
    232         /** The base interface for the keyboard port. */
    233         PDMIBASE                            IBase;
    234         /** The keyboard port base interface. */
    235         PDMIKEYBOARDPORT                    IPort;
    236 
    237         /** The base interface of the attached keyboard driver. */
    238         R3PTRTYPE(PPDMIBASE)                pDrvBase;
    239         /** The keyboard interface of the attached keyboard driver. */
    240         R3PTRTYPE(PPDMIKEYBOARDCONNECTOR)   pDrv;
    241     } Keyboard;
    242 } PS2K, *PPS2K;
    243 
    244 AssertCompile(PS2K_STRUCT_FILLER >= sizeof(PS2K));
    245 
    246110#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    247111
     
    11811045static DECLCALLBACK(void) ps2kThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    11821046{
    1183     RT_NOREF2(pDevIns, pTimer);
     1047    RT_NOREF(pDevIns, pTimer);
    11841048    PPS2K       pThis = (PS2K *)pvUser;
    11851049    unsigned    uHaveData;
     
    12061070static DECLCALLBACK(void) ps2kTypematicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    12071071{
    1208     RT_NOREF2(pDevIns, pTimer);
     1072    RT_NOREF(pDevIns, pTimer);
    12091073    PPS2K pThis = (PS2K *)pvUser;
    12101074    LogFlowFunc(("Typematic state=%d, key %08X\n", pThis->enmTypematicState, pThis->u32TypematicKey));
     
    12311095static DECLCALLBACK(void) ps2kDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    12321096{
    1233     RT_NOREF2(pDevIns, pTimer);
     1097    RT_NOREF(pDevIns, pTimer);
    12341098    PPS2K pThis = (PS2K *)pvUser;
    12351099
     
    15531417int PS2KLoadDone(PPS2K pThis, PSSMHANDLE pSSM)
    15541418{
    1555     RT_NOREF1(pSSM);
     1419    RT_NOREF(pSSM);
    15561420
    15571421    /* This *must* be done after the inital load because it may trigger
     
    15871451void PS2KRelocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
    15881452{
    1589     RT_NOREF1(pDevIns);
     1453    RT_NOREF(pDevIns);
    15901454    LogFlowFunc(("Relocating PS2K\n"));
    15911455    pThis->pKbdDelayTimerRC     = TMTimerRCPtr(pThis->pKbdDelayTimerR3);
     
    15951459}
    15961460
    1597 int PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance, PCFGMNODE pCfg)
    1598 {
    1599     RT_NOREF2(pDevIns, iInstance);
    1600     LogFlowFunc(("iInstance=%d\n", iInstance));
     1461int PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg)
     1462{
     1463    RT_NOREF(pDevIns, iInstance);
     1464    LogFlowFunc(("iInstance=%u\n", iInstance));
    16011465
    16021466    pThis->pParent = pParent;
  • trunk/src/VBox/Devices/Input/DevPS2M.cpp

    r82170 r82173  
    197197/** @} */
    198198
    199 /** Define a simple PS/2 input device queue. */
    200 #define DEF_PS2Q_TYPE(name, size)   \
    201      typedef struct {               \
    202         uint32_t    rpos;           \
    203         uint32_t    wpos;           \
    204         uint32_t    cUsed;          \
    205         uint32_t    cSize;          \
    206         uint8_t     abQueue[size];  \
    207      } name
    208 
    209 /* Internal mouse queue sizes. The input queue is relatively large,
    210  * but the command queue only needs to handle a few bytes.
    211  */
    212 #define AUX_EVT_QUEUE_SIZE        256
    213 #define AUX_CMD_QUEUE_SIZE          8
    214 
    215 
    216 /*********************************************************************************************************************************
    217 *   Structures and Typedefs                                                                                                      *
    218 *********************************************************************************************************************************/
    219 
    220 DEF_PS2Q_TYPE(AuxEvtQ, AUX_EVT_QUEUE_SIZE);
    221 DEF_PS2Q_TYPE(AuxCmdQ, AUX_CMD_QUEUE_SIZE);
    222 #ifndef VBOX_DEVICE_STRUCT_TESTCASE /// @todo hack
    223 DEF_PS2Q_TYPE(GeneriQ, 1);
    224 #endif
    225 
    226 /* Auxiliary device special modes of operation. */
    227 typedef enum {
    228     AUX_MODE_STD,           /* Standard operation. */
    229     AUX_MODE_RESET,         /* Currently in reset. */
    230     AUX_MODE_WRAP           /* Wrap mode (echoing input). */
    231 } PS2M_MODE;
    232 
    233 /* Auxiliary device operational state. */
    234 typedef enum {
    235     AUX_STATE_RATE_ERR  = RT_BIT(0),    /* Invalid rate received. */
    236     AUX_STATE_RES_ERR   = RT_BIT(1),    /* Invalid resolution received. */
    237     AUX_STATE_SCALING   = RT_BIT(4),    /* 2:1 scaling in effect. */
    238     AUX_STATE_ENABLED   = RT_BIT(5),    /* Reporting enabled in stream mode. */
    239     AUX_STATE_REMOTE    = RT_BIT(6)     /* Remote mode (reports on request). */
    240 } PS2M_STATE;
    241 
    242 /* Externally visible state bits. */
    243 #define AUX_STATE_EXTERNAL  (AUX_STATE_SCALING | AUX_STATE_ENABLED | AUX_STATE_REMOTE)
    244 
    245 /* Protocols supported by the PS/2 mouse. */
    246 typedef enum {
    247     PS2M_PROTO_PS2STD      = 0,  /* Standard PS/2 mouse protocol. */
    248     PS2M_PROTO_IMPS2       = 3,  /* IntelliMouse PS/2 protocol. */
    249     PS2M_PROTO_IMEX        = 4,  /* IntelliMouse Explorer protocol. */
    250     PS2M_PROTO_IMEX_HORZ   = 5   /* IntelliMouse Explorer with horizontal reports. */
    251 } PS2M_PROTO;
    252 
    253 /* Protocol selection 'knock' states. */
    254 typedef enum {
    255     PS2M_KNOCK_INITIAL,
    256     PS2M_KNOCK_1ST,
    257     PS2M_KNOCK_IMPS2_2ND,
    258     PS2M_KNOCK_IMEX_2ND,
    259     PS2M_KNOCK_IMEX_HORZ_2ND
    260 } PS2M_KNOCK_STATE;
    261 
    262 /**
    263  * The PS/2 auxiliary device instance data.
    264  */
    265 typedef struct PS2M
    266 {
    267     /** Pointer to parent device (keyboard controller). */
    268     R3PTRTYPE(void *)   pParent;
    269     /** Operational state. */
    270     uint8_t             u8State;
    271     /** Configured sampling rate. */
    272     uint8_t             u8SampleRate;
    273     /** Configured resolution. */
    274     uint8_t             u8Resolution;
    275     /** Currently processed command (if any). */
    276     uint8_t             u8CurrCmd;
    277     /** Set if the throttle delay is active. */
    278     bool                fThrottleActive;
    279     /** Set if the throttle delay is active. */
    280     bool                fDelayReset;
    281     /** Operational mode. */
    282     PS2M_MODE           enmMode;
    283     /** Currently used protocol. */
    284     PS2M_PROTO          enmProtocol;
    285     /** Currently used protocol. */
    286     PS2M_KNOCK_STATE    enmKnockState;
    287     /** Buffer holding mouse events to be sent to the host. */
    288     AuxEvtQ             evtQ;
    289     /** Command response queue (priority). */
    290     AuxCmdQ             cmdQ;
    291     /** Accumulated horizontal movement. */
    292     int32_t             iAccumX;
    293     /** Accumulated vertical movement. */
    294     int32_t             iAccumY;
    295     /** Accumulated Z axis (vertical scroll) movement. */
    296     int32_t             iAccumZ;
    297     /** Accumulated W axis (horizontal scroll) movement. */
    298     int32_t             iAccumW;
    299     /** Accumulated button presses. */
    300     uint32_t            fAccumB;
    301     /** Instantaneous button data. */
    302     uint32_t            fCurrB;
    303     /** Button state last sent to the guest. */
    304     uint32_t            fReportedB;
    305     /** Throttling delay in milliseconds. */
    306     uint32_t            uThrottleDelay;
    307 
    308     /** The device critical section protecting everything - R3 Ptr */
    309     R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
    310     /** Command delay timer - R3 Ptr. */
    311     PTMTIMERR3          pDelayTimerR3;
    312     /** Interrupt throttling timer - R3 Ptr. */
    313     PTMTIMERR3          pThrottleTimerR3;
    314     RTR3PTR             Alignment1;
    315 
    316     /** Command delay timer - RC Ptr. */
    317     PTMTIMERRC          pDelayTimerRC;
    318     /** Interrupt throttling timer - RC Ptr. */
    319     PTMTIMERRC          pThrottleTimerRC;
    320 
    321     /** Command delay timer - R0 Ptr. */
    322     PTMTIMERR0          pDelayTimerR0;
    323     /** Interrupt throttling timer - R0 Ptr. */
    324     PTMTIMERR0          pThrottleTimerR0;
    325 
    326     /**
    327      * Mouse port - LUN#1.
    328      *
    329      * @implements  PDMIBASE
    330      * @implements  PDMIMOUSEPORT
    331      */
    332     struct
    333     {
    334         /** The base interface for the mouse port. */
    335         PDMIBASE                            IBase;
    336         /** The keyboard port base interface. */
    337         PDMIMOUSEPORT                       IPort;
    338 
    339         /** The base interface of the attached mouse driver. */
    340         R3PTRTYPE(PPDMIBASE)                pDrvBase;
    341         /** The keyboard interface of the attached mouse driver. */
    342         R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
    343     } Mouse;
    344 } PS2M, *PPS2M;
    345 
    346 AssertCompile(PS2M_STRUCT_FILLER >= sizeof(PS2M));
    347199
    348200#ifndef VBOX_DEVICE_STRUCT_TESTCASE
     
    355207static void ps2mTestAccumulation(void);
    356208#endif
    357 
    358 
    359 /*********************************************************************************************************************************
    360 *   Global Variables                                                                                                             *
    361 *********************************************************************************************************************************/
    362 
    363 
    364 /*********************************************************************************************************************************
    365 *   Internal Functions                                                                                                           *
    366 *********************************************************************************************************************************/
    367209
    368210
     
    952794static DECLCALLBACK(void) ps2mThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    953795{
    954     RT_NOREF2(pDevIns, pTimer);
     796    RT_NOREF(pDevIns, pTimer);
    955797    PPS2M       pThis = (PS2M *)pvUser;
    956798    uint32_t    uHaveEvents;
     
    982824static DECLCALLBACK(void) ps2mDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    983825{
    984     RT_NOREF2(pDevIns, pTimer);
     826    RT_NOREF(pDevIns, pTimer);
    985827    PPS2M pThis = (PS2M *)pvUser;
    986828
     
    12751117void PS2MRelocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
    12761118{
    1277     RT_NOREF2(pDevIns, offDelta);
     1119    RT_NOREF(pDevIns, offDelta);
    12781120    LogFlowFunc(("Relocating PS2M\n"));
    12791121    pThis->pDelayTimerRC    = TMTimerRCPtr(pThis->pDelayTimerR3);
     
    12811123}
    12821124
    1283 int PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance)
    1284 {
    1285     RT_NOREF1(iInstance);
    1286 
    1287     LogFlowFunc(("iInstance=%d\n", iInstance));
     1125int PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)
     1126{
     1127    RT_NOREF(iInstance);
     1128
     1129    LogFlowFunc(("iInstance=%u\n", iInstance));
    12881130
    12891131#ifdef RT_STRICT
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp

    r82170 r82173  
    5858#include "../Graphics/DevVGA.cpp"
    5959#undef LOG_GROUP
    60 #include "../Input/DevPS2.cpp"
    61 #undef LOG_GROUP
    62 #include "../Input/DevPS2K.cpp"
    63 #undef LOG_GROUP
    64 #include "../Input/DevPS2M.cpp"
     60#include "../Input/DevPS2.h"
    6561#ifdef VBOX_WITH_E1000
    6662# undef LOG_GROUP
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette