VirtualBox

Changeset 82202 in vbox for trunk/src


Ignore:
Timestamp:
Nov 25, 2019 9:50:56 PM (5 years ago)
Author:
vboxsync
Message:

DevPS2: simplifying fluff. bugref:9218

File:
1 edited

Legend:

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

    r82201 r82202  
    454454}
    455455
    456 static int kbd_write_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t val)
    457 {
    458     int rc = VINF_SUCCESS;
     456static VBOXSTRICTRC kbd_write_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t val)
     457{
     458    VBOXSTRICTRC rc = VINF_SUCCESS;
    459459
    460460#ifdef DEBUG_KBD
     
    488488#  else /* IN_RING3 */
    489489        PDMDevHlpA20Set(s->CTX_SUFF(pDevIns), !!(val & 2));
    490 #  endif /* !IN_RING3 */
     490#  endif /* IN_RING3 */
    491491#endif
    492492        if (!(val & 1)) {
     
    643643/* -=-=-=-=-=- wrappers -=-=-=-=-=- */
    644644
     645/** Fluff bits indexed by size (1,2,4). */
     646static uint32_t const g_afFluff[5] =
     647{
     648    /* [0] = */ 0,
     649    /* [1] = */ 0,
     650    /* [2] = */ UINT32_C(0xff00),
     651    /* [3] = */ 0,
     652    /* [4] = */ UINT32_C(0xffffff00) /* Crazy Apple (Darwin 6.0.2 and earlier). */
     653};
     654
    645655/**
    646656 * @callback_method_impl{FNIOMIOPORTNEWIN,
     
    652662    RT_NOREF(pvUser, offPort);
    653663    Assert(offPort == 0);
    654 
    655     switch (cb)
    656     {
    657         case 1:
    658             *pu32 = kbd_read_data(pDevIns, pThis);
    659             Log2(("kbdIOPortDataRead: *pu32=%#x\n", *pu32));
    660             return VINF_SUCCESS;
    661 
    662         case 4:
    663         case 2:
    664         {
    665             uint32_t const uFluff = cb == 2 ? UINT32_C(0x0000ff00)
    666                                  :            UINT32_C(0xffffff00) /* Crazy Apple (Darwin 6.0.2 and earlier). */;
    667             *pu32 = uFluff | kbd_read_data(pDevIns, pThis);
    668             Log2(("kbdIOPortDataRead: cb=%u *pu32=%#x\n", cb, *pu32));
    669             return VINF_SUCCESS;
    670         }
    671 
    672         default:
    673             ASSERT_GUEST_MSG_FAILED(("Port=0x60+%x cb=%d\n", offPort, cb));
    674             return VERR_IOM_IOPORT_UNUSED;
    675     }
     664    Assert(cb == 1 || cb == 2 || cb == 4);
     665
     666    *pu32 = kbd_read_data(pDevIns, pThis) | g_afFluff[cb];
     667    Log2(("kbdIOPortDataRead: cb=%u *pu32=%#x\n", cb, *pu32));
     668    return VINF_SUCCESS;
    676669}
    677670
     
    682675static DECLCALLBACK(VBOXSTRICTRC) kbdIOPortDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    683676{
    684     VBOXSTRICTRC rc = VINF_SUCCESS;
    685677    RT_NOREF(offPort, pvUser);
    686678    Assert(offPort == 0);
     
    689681    {
    690682        PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
    691         rc = kbd_write_data(pDevIns, pThis, (uint8_t)u32);
    692         Log2(("kbdIOPortDataWrite: Port=0x60+%x cb=%d u32=%#x\n", offPort, cb, u32));
    693     }
    694     else
    695         ASSERT_GUEST_MSG_FAILED(("Port=0x60+%x cb=%d\n", offPort, cb));
    696     return rc;
     683        VBOXSTRICTRC rc = kbd_write_data(pDevIns, pThis, (uint8_t)u32);
     684        Log2(("kbdIOPortDataWrite: Port=0x60+%x cb=%d u32=%#x rc=%Rrc\n", offPort, cb, u32, VBOXSTRICTRC_VAL(rc)));
     685        return rc;
     686    }
     687    Assert(cb == 4);
     688    ASSERT_GUEST_MSG_FAILED(("Port=0x60+%x cb=%d\n", offPort, cb));
     689    return VINF_SUCCESS;
    697690}
    698691
     
    706699    RT_NOREF(offPort, pvUser);
    707700    Assert(offPort == 0);
    708 
    709     switch (cb)
    710     {
    711         case 1:
    712             *pu32 = pThis->status;
    713             Log2(("kbdIOPortStatusRead: -> *pu32=%#x\n", *pu32));
    714             return VINF_SUCCESS;
    715 
    716         case 2:
    717         case 4:
    718         {
    719             uint32_t const uFluff = cb == 2 ? UINT32_C(0x0000ff00)
    720                                  :            UINT32_C(0xffffff00) /* Crazy Apple (Darwin 6.0.2 and earlier). */;
    721             *pu32 = uFluff | pThis->status;
    722             Log2(("kbdIOPortStatusRead: cb=%u -> *pu32=%#x\n", cb, *pu32));
    723             return VINF_SUCCESS;
    724         }
    725 
    726         default:
    727             ASSERT_GUEST_MSG_FAILED(("Port=0x64+%x cb=%d\n", offPort, cb));
    728             return VERR_IOM_IOPORT_UNUSED;
    729     }
     701    Assert(cb == 1 || cb == 2 || cb == 4);
     702
     703    *pu32 = pThis->status | g_afFluff[cb];
     704    Log2(("kbdIOPortStatusRead: cb=%u -> *pu32=%#x\n", cb, *pu32));
     705    return VINF_SUCCESS;
    730706}
    731707
     
    746722        return rc;
    747723    }
     724    Assert(cb == 4);
    748725    ASSERT_GUEST_MSG_FAILED(("offPort=0x64+%x cb=%d\n", offPort, cb));
    749726    return VINF_SUCCESS;
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