VirtualBox

Changeset 81800 in vbox


Ignore:
Timestamp:
Nov 12, 2019 12:59:38 PM (5 years ago)
Author:
vboxsync
Message:

DevBusLogic.cpp: Converting it to the new PDM device style... bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevBusLogic.cpp

    r81765 r81800  
    9595{
    9696    /** Pointer to the owning buslogic device instance. - R3 pointer */
    97     R3PTRTYPE(struct BUSLOGIC *)  pBusLogicR3;
     97    R3PTRTYPE(struct BUSLOGIC *)    pBusLogicR3;
    9898    /** Pointer to the owning buslogic device instance. - R0 pointer */
    99     R0PTRTYPE(struct BUSLOGIC *)  pBusLogicR0;
     99    R0PTRTYPE(struct BUSLOGIC *)    pBusLogicR0;
    100100    /** Pointer to the owning buslogic device instance. - RC pointer */
    101     RCPTRTYPE(struct BUSLOGIC *)  pBusLogicRC;
     101    RCPTRTYPE(struct BUSLOGIC *)    pBusLogicRC;
     102
     103    /** LUN of the device. */
     104    uint32_t                        iLUN;
    102105
    103106    /** Flag whether device is present. */
    104     bool                          fPresent;
    105     /** LUN of the device. */
    106     RTUINT                        iLUN;
     107    bool                            fPresent;
     108    bool                            afAlignment[HC_ARCH_BITS == 64 ? 3 : 7];
     109
     110    /** Our base interface. */
     111    PDMIBASE                        IBase;
     112    /** Media port interface. */
     113    PDMIMEDIAPORT                   IMediaPort;
     114    /** Extended media port interface. */
     115    PDMIMEDIAEXPORT                 IMediaExPort;
     116    /** Led interface. */
     117    PDMILEDPORTS                    ILed;
     118    /** Pointer to the attached driver's base interface. */
     119    R3PTRTYPE(PPDMIBASE)            pDrvBase;
     120    /** Pointer to the attached driver's media interface. */
     121    R3PTRTYPE(PPDMIMEDIA)           pDrvMedia;
     122    /** Pointer to the attached driver's extended media interface. */
     123    R3PTRTYPE(PPDMIMEDIAEX)         pDrvMediaEx;
     124    /** The status LED state for this device. */
     125    PDMLED                          Led;
     126
     127    /** Number of outstanding tasks on the port. */
     128    volatile uint32_t               cOutstandingRequests;
    107129
    108130#if HC_ARCH_BITS == 64
    109     uint32_t                      Alignment0;
     131    uint32_t                        u32Alignment1;
    110132#endif
    111 
    112     /** Our base interface. */
    113     PDMIBASE                      IBase;
    114     /** Media port interface. */
    115     PDMIMEDIAPORT                 IMediaPort;
    116     /** Extended media port interface. */
    117     PDMIMEDIAEXPORT               IMediaExPort;
    118     /** Led interface. */
    119     PDMILEDPORTS                  ILed;
    120     /** Pointer to the attached driver's base interface. */
    121     R3PTRTYPE(PPDMIBASE)          pDrvBase;
    122     /** Pointer to the attached driver's media interface. */
    123     R3PTRTYPE(PPDMIMEDIA)         pDrvMedia;
    124     /** Pointer to the attached driver's extended media interface. */
    125     R3PTRTYPE(PPDMIMEDIAEX)       pDrvMediaEx;
    126     /** The status LED state for this device. */
    127     PDMLED                        Led;
    128 
    129 #if HC_ARCH_BITS == 64
    130     uint32_t                      Alignment1;
    131 #endif
    132 
    133     /** Number of outstanding tasks on the port. */
    134     volatile uint32_t             cOutstandingRequests;
    135 
    136133} BUSLOGICDEVICE, *PBUSLOGICDEVICE;
    137134
     
    330327
    331328/**
    332  * Main BusLogic device state.
     329 * The shared BusLogic device emulation state.
    333330 *
    334331 * @implements  PDMILEDPORTS
     
    502499#endif
    503500
    504 } BUSLOGIC, *PBUSLOGIC;
     501} BUSLOGIC;
     502/** Pointer to the shared BusLogic device emulation state. */
     503typedef BUSLOGIC *PBUSLOGIC;
     504
    505505
    506506/** Register offsets in the I/O port space. */
     
    41944194static DECLCALLBACK(int) buslogicR3Destruct(PPDMDEVINS pDevIns)
    41954195{
     4196    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    41964197    PBUSLOGIC  pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    4197     PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    41984198
    41994199    PDMR3CritSectDelete(&pThis->CritSectIntr);
     
    42134213static DECLCALLBACK(int) buslogicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    42144214{
    4215     PBUSLOGIC  pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    4216     int        rc = VINF_SUCCESS;
    4217     bool       fBootable = true;
    4218     char       achCfgStr[16];
    42194215    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4216    PBUSLOGIC       pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     4217    PCPDMDEVHLPR3   pHlp = pDevIns->pHlpR3;
     4218    int             rc = VINF_SUCCESS;
     4219    char            szCfgStr[16];
    42204220
    42214221    /*
     
    42484248     * Validate and read configuration.
    42494249     */
    4250     if (!CFGMR3AreValuesValid(pCfg,
    4251                               "GCEnabled\0"
    4252                               "R0Enabled\0"
    4253                               "Bootable\0"
    4254                               "AdapterType\0"
    4255                               "ISACompat\0"))
    4256         return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    4257                                 N_("BusLogic configuration error: unknown option specified"));
    4258 
    4259     rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &pThis->fGCEnabled, true);
     4250    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Bootable|AdapterType|ISACompat", "");
     4251
     4252    pThis->fGCEnabled = pDevIns->fRCEnabled;
     4253    pThis->fR0Enabled = pDevIns->fR0Enabled;
     4254
     4255    bool fBootable = true;
     4256    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Bootable", &fBootable, true);
    42604257    if (RT_FAILURE(rc))
    4261         return PDMDEV_SET_ERROR(pDevIns, rc,
    4262                                 N_("BusLogic configuration error: failed to read GCEnabled as boolean"));
    4263     Log(("%s: fGCEnabled=%d\n", __FUNCTION__, pThis->fGCEnabled));
    4264 
    4265     rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, true);
     4258        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic configuration error: failed to read Bootable as boolean"));
     4259    Log(("%s: fBootable=%RTbool\n", __FUNCTION__, fBootable));
     4260
     4261    /* Figure out the emulated device type. */
     4262    rc = pHlp->pfnCFGMQueryStringDef(pCfg, "AdapterType", szCfgStr, sizeof(szCfgStr), "BT-958D");
    42664263    if (RT_FAILURE(rc))
    4267         return PDMDEV_SET_ERROR(pDevIns, rc,
    4268                                 N_("BusLogic configuration error: failed to read R0Enabled as boolean"));
    4269     Log(("%s: fR0Enabled=%d\n", __FUNCTION__, pThis->fR0Enabled));
    4270     rc = CFGMR3QueryBoolDef(pCfg, "Bootable", &fBootable, true);
    4271     if (RT_FAILURE(rc))
    4272         return PDMDEV_SET_ERROR(pDevIns, rc,
    4273                                 N_("BusLogic configuration error: failed to read Bootable as boolean"));
    4274     Log(("%s: fBootable=%RTbool\n", __FUNCTION__, fBootable));
    4275 
    4276     /* Figure out the emulated device type. */
    4277     rc = CFGMR3QueryStringDef(pCfg, "AdapterType", achCfgStr, sizeof(achCfgStr), "BT-958D");
    4278     if (RT_FAILURE(rc))
    4279         return PDMDEV_SET_ERROR(pDevIns, rc,
    4280                                 N_("BusLogic configuration error: failed to read AdapterType as string"));
    4281     Log(("%s: AdapterType=%s\n", __FUNCTION__, achCfgStr));
     4264        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic configuration error: failed to read AdapterType as string"));
     4265    Log(("%s: AdapterType=%s\n", __FUNCTION__, szCfgStr));
    42824266
    42834267    /* Grok the AdapterType setting. */
    4284     if (!strcmp(achCfgStr, "BT-958D"))          /* Default PCI device, 32-bit and 24-bit addressing. */
     4268    if (!strcmp(szCfgStr, "BT-958D"))          /* Default PCI device, 32-bit and 24-bit addressing. */
    42854269    {
    42864270        pThis->uDevType = DEV_BT_958D;
    42874271        pThis->uDefaultISABaseCode = ISA_BASE_DISABLED;
    42884272    }
    4289     else if (!strcmp(achCfgStr, "BT-545C"))     /* ISA device, 24-bit addressing only. */
     4273    else if (!strcmp(szCfgStr, "BT-545C"))     /* ISA device, 24-bit addressing only. */
    42904274    {
    42914275        pThis->uDevType = DEV_BT_545C;
    42924276        pThis->uIsaIrq = 11;
    42934277    }
    4294     else if (!strcmp(achCfgStr, "AHA-1540B"))   /* Competitor ISA device. */
     4278    else if (!strcmp(szCfgStr, "AHA-1540B"))   /* Competitor ISA device. */
    42954279    {
    42964280        pThis->uDevType = DEV_AHA_1540B;
     
    43034287    /* Only the first instance defaults to having the ISA compatibility ports enabled. */
    43044288    if (iInstance == 0)
    4305         rc = CFGMR3QueryStringDef(pCfg, "ISACompat", achCfgStr, sizeof(achCfgStr), "Alternate");
     4289        rc = pHlp->pfnCFGMQueryStringDef(pCfg, "ISACompat", szCfgStr, sizeof(szCfgStr), "Alternate");
    43064290    else
    4307         rc = CFGMR3QueryStringDef(pCfg, "ISACompat", achCfgStr, sizeof(achCfgStr), "Disabled");
     4291        rc = pHlp->pfnCFGMQueryStringDef(pCfg, "ISACompat", szCfgStr, sizeof(szCfgStr), "Disabled");
    43084292    if (RT_FAILURE(rc))
    4309         return PDMDEV_SET_ERROR(pDevIns, rc,
    4310                                 N_("BusLogic configuration error: failed to read ISACompat as string"));
    4311     Log(("%s: ISACompat=%s\n", __FUNCTION__, achCfgStr));
     4293        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic configuration error: failed to read ISACompat as string"));
     4294    Log(("%s: ISACompat=%s\n", __FUNCTION__, szCfgStr));
    43124295
    43134296    /* Grok the ISACompat setting. */
    4314     if (!strcmp(achCfgStr, "Disabled"))
     4297    if (!strcmp(szCfgStr, "Disabled"))
    43154298        pThis->uDefaultISABaseCode = ISA_BASE_DISABLED;
    4316     else if (!strcmp(achCfgStr, "Primary"))
     4299    else if (!strcmp(szCfgStr, "Primary"))
    43174300        pThis->uDefaultISABaseCode = 0;     /* I/O base at 330h. */
    4318     else if (!strcmp(achCfgStr, "Alternate"))
     4301    else if (!strcmp(szCfgStr, "Alternate"))
    43194302        pThis->uDefaultISABaseCode = 1;     /* I/O base at 334h. */
    43204303    else
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