VirtualBox

Changeset 48214 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 31, 2013 4:16:58 PM (11 years ago)
Author:
vboxsync
Message:

Added new PS/2 mouse implementation (currently disabled).

Location:
trunk/src/VBox/Devices
Files:
1 added
6 edited

Legend:

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

    r48033 r48214  
    5454#include "PS2Dev.h"
    5555
    56 #define PCKBD_SAVED_STATE_VERSION 6
     56#define PCKBD_SAVED_STATE_VERSION 7
    5757
    5858
     
    119119#define KBD_MODE_RFU            0x80
    120120
     121#ifndef VBOX_WITH_NEW_PS2M
    121122/* Mouse Commands */
    122123#define AUX_SET_SCALE11         0xE6    /* Set 1:1 scaling */
     
    173174    int     count;
    174175} MouseEventQueue;
     176#endif
    175177
    176178/**
     
    181183typedef struct KBDState
    182184{
     185#ifndef VBOX_WITH_NEW_PS2M
    183186    MouseCmdQueue mouse_command_queue;
    184187    MouseEventQueue mouse_event_queue;
     188#endif
    185189    uint8_t write_cmd; /* if non zero, write data to port 60 is expected */
    186190    uint8_t status;
     
    190194    int32_t translate;
    191195    int32_t xlat_state;
     196#ifndef VBOX_WITH_NEW_PS2M
    192197    /* mouse state */
    193198    int32_t mouse_write_cmd;
     
    205210    uint8_t mouse_buttons;
    206211    uint8_t mouse_buttons_reported;
     212#endif
    207213
    208214    uint32_t    Alignment0;
     
    222228#endif
    223229
     230#ifdef VBOX_WITH_NEW_PS2M
     231    /** Mouse state (implemented in separate PS2M module). */
     232#ifdef VBOX_DEVICE_STRUCT_TESTCASE
     233    uint8_t                     AuxFiller[PS2M_STRUCT_FILLER];
     234#else
     235    PS2M                        Aux;
     236#endif
     237#else
    224238    /**
    225239     * Mouse port - LUN#1.
     
    240254        R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
    241255    } Mouse;
     256#endif
    242257} KBDState;
    243258
     
    247262static void kbd_update_irq(KBDState *s)
    248263{
     264#ifndef VBOX_WITH_NEW_PS2M
    249265    MouseCmdQueue *mcq = &s->mouse_command_queue;
    250266    MouseEventQueue *meq = &s->mouse_event_queue;
     267#endif
    251268    int irq12_level, irq1_level;
    252269    uint8_t val;
     
    292309            }
    293310        }
     311#ifdef VBOX_WITH_NEW_PS2M
     312        else if (!(s->mode & KBD_MODE_DISABLE_MOUSE) && PS2MByteFromAux(&s->Aux, &val) == VINF_SUCCESS)
     313        {
     314            s->dbbout = val;
     315            s->status |= KBD_STAT_OBF | KBD_STAT_MOUSE_OBF;
     316        }
     317#else
    294318        else if ((mcq->count || meq->count) && !(s->mode & KBD_MODE_DISABLE_MOUSE))
    295319        {
     
    310334            }
    311335        }
     336#endif
    312337    }
    313338    /* Determine new IRQ state. */
     
    334359}
    335360
     361#ifndef VBOX_WITH_NEW_PS2M
    336362static void kbd_queue(KBDState *s, int b, int aux)
    337363{
     
    375401    kbd_update_irq(s);
    376402}
     403#endif
    377404
    378405static void kbc_dbb_out(void *opaque, uint8_t val)
     
    385412    if (s->mode & KBD_MODE_KBD_INT)
    386413        PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 1, 1);
     414}
     415
     416static void kbc_dbb_out_aux(void *opaque, uint8_t val)
     417{
     418    KBDState *s = (KBDState*)opaque;
     419
     420    s->dbbout = val;
     421    /* Set the aux OBF and raise IRQ. */
     422    s->status |= KBD_STAT_OBF | KBD_STAT_MOUSE_OBF;
     423    if (s->mode & KBD_MODE_MOUSE_INT)
     424        PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 12, PDM_IRQ_LEVEL_HIGH);
    387425}
    388426
     
    557595}
    558596
     597PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns)
     598{
     599    KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *);
     600#ifdef VBOX_WITH_NEW_PS2M
     601    return &pThis->Aux;
     602#else
     603    return NULL;
     604#endif
     605}
     606
     607#ifndef VBOX_WITH_NEW_PS2M
    559608static void kbd_mouse_set_reported_buttons(KBDState *s, unsigned fButtons, unsigned fButtonMask)
    560609{
     
    914963    return rc;
    915964}
     965#endif
    916966
    917967static int kbd_write_data(void *opaque, uint32_t addr, uint32_t val)
     
    942992        break;
    943993    case KBD_CCMD_WRITE_AUX_OBUF:
    944         kbd_queue(s, val, 1);
     994        kbc_dbb_out_aux(s, val);
    945995        break;
    946996    case KBD_CCMD_WRITE_OUTPORT:
     
    9641014        /* Automatically enables aux interface. */
    9651015        s->mode &= ~KBD_MODE_DISABLE_MOUSE;
     1016#ifdef VBOX_WITH_NEW_PS2M
     1017        rc = PS2MByteToAux(&s->Aux, val);
     1018        if (rc == VINF_SUCCESS)
     1019            kbd_update_irq(s);
     1020#else
    9661021        rc = kbd_write_mouse(s, val);
     1022#endif
    9671023        break;
    9681024    default:
     
    9791035{
    9801036    KBDState *s = (KBDState*)opaque;
     1037#ifndef VBOX_WITH_NEW_PS2M
    9811038    MouseCmdQueue *mcq;
    9821039    MouseEventQueue *meq;
    9831040
    9841041    s->mouse_write_cmd = -1;
     1042#endif
    9851043    s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT;
    9861044    s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED;
     
    9881046    s->write_cmd = 0;
    9891047    s->translate = 0;
     1048#ifndef VBOX_WITH_NEW_PS2M
    9901049    if (s->mouse_status)
    9911050    {
     
    10131072    meq->wptr = 0;
    10141073    meq->count = 0;
     1074#endif
    10151075}
    10161076
    10171077static void kbd_save(QEMUFile* f, void* opaque)
    10181078{
     1079#ifndef VBOX_WITH_NEW_PS2M
    10191080    uint32_t    cItems;
    10201081    int i;
     1082#endif
    10211083    KBDState *s = (KBDState*)opaque;
    10221084
     
    10251087    qemu_put_8s(f, &s->mode);
    10261088    qemu_put_8s(f, &s->dbbout);
     1089#ifndef VBOX_WITH_NEW_PS2M
    10271090    qemu_put_be32s(f, &s->mouse_write_cmd);
    10281091    qemu_put_8s(f, &s->mouse_status);
     
    10511114        SSMR3PutU8(f, s->mouse_event_queue.data[i]);
    10521115    Log(("kbd_save: %d mouse event queue items stored\n", s->mouse_event_queue.count));
     1116#endif
    10531117
    10541118    /* terminator */
     
    10841148        qemu_get_8s(f, &s->dbbout);
    10851149    }
     1150#ifndef VBOX_WITH_NEW_PS2M
    10861151    qemu_get_be32s(f, (uint32_t *)&s->mouse_write_cmd);
    10871152    qemu_get_8s(f, &s->mouse_status);
     
    11151180    s->mouse_event_queue.rptr = 0;
    11161181    s->mouse_event_queue.wptr = 0;
     1182#endif
    11171183
    11181184    /* Determine the translation state. */
     
    11361202    }
    11371203
     1204#ifndef VBOX_WITH_NEW_PS2M
    11381205    rc = SSMR3GetU32(f, &u32);
    11391206    if (RT_FAILURE(rc))
     
    11711238    s->mouse_event_queue.count = u32;
    11721239    Log(("kbd_load: %d mouse event queue items loaded\n", u32));
     1240#else
     1241    if (version_id <= 6)
     1242    {
     1243        rc = SSMR3GetU32(f, &u32);
     1244        if (RT_FAILURE(rc))
     1245            return rc;
     1246        for (i = 0; i < u32; i++)
     1247        {
     1248            rc = SSMR3GetU8(f, &u8Dummy);
     1249            if (RT_FAILURE(rc))
     1250                return rc;
     1251        }
     1252        Log(("kbd_load: %d mouse event queue items discarded from old saved state\n", u32));
     1253    }
     1254#endif
    11731255
    11741256    /* terminator */
     
    11811263        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    11821264    }
     1265#ifndef VBOX_WITH_NEW_PS2M
    11831266    /* Resend a notification to Main if the device is active */
    11841267    kbd_mouse_update_downstream_status(s);
     1268#endif
    11851269    return 0;
    11861270}
     
    13081392    kbd_save(pSSM, pThis);
    13091393    PS2KSaveState(&pThis->Kbd, pSSM);
     1394#ifdef VBOX_WITH_NEW_PS2M
     1395    PS2MSaveState(&pThis->Aux, pSSM);
     1396#endif
    13101397    return VINF_SUCCESS;
    13111398}
     
    13301417    if (uVersion >= 6)
    13311418        rc = PS2KLoadState(&pThis->Kbd, pSSM, uVersion);
     1419#ifdef VBOX_WITH_NEW_PS2M
     1420    if (uVersion >= 7)
     1421        rc = PS2MLoadState(&pThis->Aux, pSSM, uVersion);
     1422#endif
    13321423    return rc;
    13331424}
     
    13451436    kbd_reset(pThis);
    13461437    PS2KReset(&pThis->Kbd);
    1347 }
    1348 
    1349 
     1438#ifdef VBOX_WITH_NEW_PS2M
     1439    PS2MReset(&pThis->Aux);
     1440#endif
     1441}
     1442
     1443
     1444#ifndef VBOX_WITH_NEW_PS2M
    13501445/* -=-=-=-=-=- Mouse: IBase  -=-=-=-=-=- */
    13511446
     
    14031498    NOREF(pInterface); NOREF(cContacts); NOREF(pau64Contacts); NOREF(u32ScanTime);
    14041499}
    1405 
     1500#endif
    14061501
    14071502/* -=-=-=-=-=- real code -=-=-=-=-=- */
     
    14441539        /* LUN #1: aux/mouse */
    14451540        case 1:
     1541#ifdef VBOX_WITH_NEW_PS2M
     1542            rc = PS2MAttach(&pThis->Aux, pDevIns, iLUN, fFlags);
     1543#else
    14461544            rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->Mouse.IBase, &pThis->Mouse.pDrvBase, "Aux (Mouse) Port");
    14471545            if (RT_SUCCESS(rc))
     
    14611559            else
    14621560                AssertLogRelMsgFailed(("Failed to attach LUN #1! rc=%Rrc\n", rc));
     1561#endif
    14631562            break;
    14641563
     
    15261625    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    15271626    PS2KRelocate(&pThis->Kbd, offDelta, pDevIns);
     1627#ifdef VBOX_WITH_NEW_PS2M
     1628    PS2MRelocate(&pThis->Aux, offDelta, pDevIns);
     1629#endif
    15281630}
    15291631
     
    15531655    if (RT_FAILURE(rc))
    15541656        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to query \"R0Enabled\" from the config"));
     1657fGCEnabled = fR0Enabled = false;
    15551658    Log(("pckbd: fGCEnabled=%RTbool fR0Enabled=%RTbool\n", fGCEnabled, fR0Enabled));
    15561659
     
    15671670        return rc;
    15681671
     1672#ifdef VBOX_WITH_NEW_PS2M
     1673    rc = PS2MConstruct(&pThis->Aux, pDevIns, pThis, iInstance);
     1674    if (RT_FAILURE(rc))
     1675        return rc;
     1676#else
    15691677    pThis->Mouse.IBase.pfnQueryInterface    = kbdMouseQueryInterface;
    15701678    pThis->Mouse.IPort.pfnPutEvent          = kbdMousePutEvent;
    15711679    pThis->Mouse.IPort.pfnPutEventAbs       = kbdMousePutEventAbs;
    15721680    pThis->Mouse.IPort.pfnPutEventMultiTouch = kbdMousePutEventMultiTouch;
     1681#endif
    15731682
    15741683    /*
  • trunk/src/VBox/Devices/Input/PS2Dev.h

    r44806 r48214  
    1818#define PS2DEV_H
    1919
    20 /** The size of the PS2K structure filler.
     20/** The size of the PS2K/PS2M structure fillers.
    2121 * @note Must be at least as big as the real struct. Compile time assert
    2222 *       makes sure this is so. */
    2323#define PS2K_STRUCT_FILLER  512
     24#define PS2M_STRUCT_FILLER  512
    2425
    2526/* Hide the internal structure. */
     
    3132#endif
    3233
     34#if !(defined(IN_PS2M) || defined(VBOX_DEVICE_STRUCT_TESTCASE))
     35typedef struct PS2M
     36{
     37    uint8_t     abFiller[PS2M_STRUCT_FILLER];
     38} PS2M;
     39#endif
     40
     41/* Internal PS/2 Keyboard interface. */
    3342typedef struct PS2K *PPS2K;
    3443
     
    4352int  PS2KLoadState(PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion);
    4453
     54PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns);
     55
     56
     57/* Internal PS/2 Auxiliary device interface. */
     58typedef struct PS2M *PPS2M;
     59
     60int  PS2MByteToAux(PPS2M pThis, uint8_t cmd);
     61int  PS2MByteFromAux(PPS2M pThis, uint8_t *pVal);
     62
     63int  PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, void *pParent, int iInstance);
     64int  PS2MAttach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
     65void PS2MReset(PPS2M pThis);
     66void PS2MRelocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns);
     67void PS2MSaveState(PPS2M pThis, PSSMHANDLE pSSM);
     68int  PS2MLoadState(PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion);
     69
     70PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns);
     71
     72
     73/* Shared keyboard/aux internal interface. */
    4574void KBCUpdateInterrupts(void *pKbc);
    4675
    47 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns);
    4876
    4977///@todo: This should live with the KBC implementation.
  • trunk/src/VBox/Devices/Makefile.kmk

    r48179 r48214  
    129129        Input/DevPS2.cpp \
    130130        Input/PS2K.cpp \
     131        Input/PS2M.cpp \
    131132        Input/UsbKbd.cpp \
    132133        Input/UsbMouse.cpp \
     
    453454
    454455
     456 # --- Input bits. ---
     457
     458 ifdef VBOX_WITH_NEW_PS2M
     459  VBoxDD_DEFS           += VBOX_WITH_NEW_PS2M
     460 endif
     461
     462
    455463 # --- Audio bits. ---
    456464
     
    757765        Input/DevPS2.cpp \
    758766        Input/PS2K.cpp \
     767        Input/PS2M.cpp \
    759768        PC/DevACPI.cpp \
    760769        PC/DevPit-i8254.cpp \
     
    836845  VBoxDDGC_SOURCES      += \
    837846        Storage/DevLsiLogicSCSI.cpp
     847  endif
     848
     849  ifdef VBOX_WITH_NEW_PS2M
     850  VBoxDDGC_DEFS         += VBOX_WITH_NEW_PS2M
    838851  endif
    839852
     
    894907        Input/DevPS2.cpp \
    895908        Input/PS2K.cpp \
     909        Input/PS2M.cpp \
    896910        PC/DevACPI.cpp \
    897911        PC/DevPit-i8254.cpp \
     
    984998 VBoxDDR0_SOURCES       += \
    985999        Storage/DevLsiLogicSCSI.cpp
     1000 endif
     1001
     1002 ifdef VBOX_WITH_NEW_PS2M
     1003  VBoxDDR0_DEFS         += VBOX_WITH_NEW_PS2M
    9861004 endif
    9871005
  • trunk/src/VBox/Devices/testcase/Makefile.kmk

    r41477 r48214  
    3636        $(if $(VBOX_WITH_BUSLOGIC),VBOX_WITH_BUSLOGIC,) \
    3737        $(if $(VBOX_WITH_LSILOGIC),VBOX_WITH_LSILOGIC,) \
     38        $(if $(VBOX_WITH_NEW_PS2M),VBOX_WITH_NEW_PS2M,) \
    3839        $(if $(VBOX_WITH_HGSMI),VBOX_WITH_HGSMI,) \
    3940        $(if $(VBOX_WITH_CRHGSMI),VBOX_WITH_CRHGSMI,) \
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp

    r47466 r48214  
    3737#undef LOG_GROUP
    3838#include "../Input/PS2K.cpp"
     39#undef LOG_GROUP
     40#include "../Input/PS2M.cpp"
    3941#ifdef VBOX_WITH_E1000
    4042# undef LOG_GROUP
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r47829 r48214  
    4646#undef LOG_GROUP
    4747#include "../Input/PS2K.cpp"
     48#undef LOG_GROUP
     49#include "../Input/PS2M.cpp"
    4850#undef LOG_GROUP
    4951#include "../Network/DevPCNet.cpp"
     
    362364
    363365    /* Input/pckbd.c */
     366#ifndef VBOX_WITH_NEW_PS2M
    364367    GEN_CHECK_SIZE(MouseCmdQueue);
    365368    GEN_CHECK_OFF(MouseCmdQueue, data);
     
    372375    GEN_CHECK_OFF(MouseEventQueue, wptr);
    373376    GEN_CHECK_OFF(MouseEventQueue, count);
     377#endif
    374378    GEN_CHECK_SIZE(KBDState);
    375     GEN_CHECK_OFF(KBDState, mouse_command_queue);
    376     GEN_CHECK_OFF(KBDState, mouse_event_queue);
    377379    GEN_CHECK_OFF(KBDState, write_cmd);
    378380    GEN_CHECK_OFF(KBDState, status);
    379381    GEN_CHECK_OFF(KBDState, mode);
     382#ifndef VBOX_WITH_NEW_PS2M
     383    GEN_CHECK_OFF(KBDState, mouse_command_queue);
     384    GEN_CHECK_OFF(KBDState, mouse_event_queue);
    380385    GEN_CHECK_OFF(KBDState, mouse_write_cmd);
    381386    GEN_CHECK_OFF(KBDState, mouse_status);
     
    390395    GEN_CHECK_OFF(KBDState, mouse_dw);
    391396    GEN_CHECK_OFF(KBDState, mouse_buttons);
     397#endif
    392398    GEN_CHECK_OFF(KBDState, pDevInsR3);
    393399    GEN_CHECK_OFF(KBDState, pDevInsR0);
     
    400406    GEN_CHECK_OFF(KbdCmdQ, abQueue);
    401407    GEN_CHECK_SIZE(KbdCmdQ);
     408    /* Input/PS2K.c */
     409    GEN_CHECK_SIZE(PS2K);
    402410    GEN_CHECK_OFF(PS2K, fScanning);
    403411    GEN_CHECK_OFF(PS2K, fNumLockOn);
     
    419427    GEN_CHECK_OFF(PS2K, Keyboard.pDrvBase);
    420428    GEN_CHECK_OFF(PS2K, Keyboard.pDrv);
     429#ifdef VBOX_WITH_NEW_PS2M
     430    /* Input/PS2M.c */
     431    GEN_CHECK_SIZE(PS2M);
     432    GEN_CHECK_OFF(PS2M, u8State);
     433    GEN_CHECK_OFF(PS2M, u8SampleRate);
     434    GEN_CHECK_OFF(PS2M, u8CurrCmd);
     435    GEN_CHECK_OFF(PS2M, fThrottleActive);
     436    GEN_CHECK_OFF(PS2M, enmMode);
     437    GEN_CHECK_OFF(PS2M, enmKnockState);
     438    GEN_CHECK_OFF(PS2M, iAccumX);
     439    GEN_CHECK_OFF(PS2M, fAccumB);
     440    GEN_CHECK_OFF(PS2M, uThrottleDelay);
     441    GEN_CHECK_OFF(PS2M, evtQ);
     442    GEN_CHECK_OFF(PS2M, cmdQ);
     443    GEN_CHECK_OFF(PS2M, pDelayTimerRC);
     444    GEN_CHECK_OFF(PS2M, pDelayTimerR3);
     445    GEN_CHECK_OFF(PS2M, pDelayTimerR0);
     446    GEN_CHECK_OFF(PS2M, pThrottleTimerRC);
     447    GEN_CHECK_OFF(PS2M, pThrottleTimerR3);
     448    GEN_CHECK_OFF(PS2M, pThrottleTimerR0);
     449    GEN_CHECK_OFF(PS2M, pCritSectR3);
     450    GEN_CHECK_OFF(PS2M, Mouse.IBase);
     451    GEN_CHECK_OFF(PS2M, Mouse.IPort);
     452    GEN_CHECK_OFF(PS2M, Mouse.pDrvBase);
     453    GEN_CHECK_OFF(PS2M, Mouse.pDrv);
     454#else
    421455    GEN_CHECK_OFF(KBDState, Mouse.IBase);
    422456    GEN_CHECK_OFF(KBDState, Mouse.IPort);
    423457    GEN_CHECK_OFF(KBDState, Mouse.pDrvBase);
    424458    GEN_CHECK_OFF(KBDState, Mouse.pDrv);
     459#endif
    425460
    426461    /* Network/DevPCNet.cpp */
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