VirtualBox

Changeset 81909 in vbox


Ignore:
Timestamp:
Nov 17, 2019 6:23:56 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134706
Message:

VMM,DevPIC: Refactored the PIC registration. bugreF:9218

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmdev.h

    r81853 r81909  
    12541254
    12551255/**
    1256  * Programmable Interrupt Controller registration structure.
     1256 * Programmable Interrupt Controller registration structure (all contexts).
    12571257 */
    12581258typedef struct PDMPICREG
     
    12701270     * @remarks Caller enters the PDM critical section.
    12711271     */
    1272     DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc));
     1272    DECLCALLBACKMEMBER(void, pfnSetIrq)(PPDMDEVINS pDevIns, int iIrq, int iLevel, uint32_t uTagSrc);
    12731273
    12741274    /**
     
    12801280     * @remarks Caller enters the PDM critical section.
    12811281     */
    1282     DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns, uint32_t *puTagSrc));
    1283 
    1284     /** The name of the RC SetIrq entry point. */
    1285     const char         *pszSetIrqRC;
    1286     /** The name of the RC GetInterrupt entry point. */
    1287     const char         *pszGetInterruptRC;
    1288 
    1289     /** The name of the R0 SetIrq entry point. */
    1290     const char         *pszSetIrqR0;
    1291     /** The name of the R0 GetInterrupt entry point. */
    1292     const char         *pszGetInterruptR0;
     1282    DECLCALLBACKMEMBER(int, pfnGetInterrupt)(PPDMDEVINS pDevIns, uint32_t *puTagSrc);
     1283
     1284    /** Just a safety precaution. */
     1285    uint32_t                    u32TheEnd;
    12931286} PDMPICREG;
    12941287/** Pointer to a PIC registration structure. */
     
    12961289
    12971290/** Current PDMPICREG version number. */
    1298 #define PDM_PICREG_VERSION                      PDM_VERSION_MAKE(0xfffa, 2, 0)
    1299 
    1300 /**
    1301  * PIC RC helpers.
    1302  */
    1303 typedef struct PDMPICHLPRC
    1304 {
    1305     /** Structure version. PDM_PICHLPRC_VERSION defines the current version. */
     1291#define PDM_PICREG_VERSION                      PDM_VERSION_MAKE(0xfffa, 3, 0)
     1292
     1293/**
     1294 * PIC helpers, same in all contexts.
     1295 */
     1296typedef struct PDMPICHLP
     1297{
     1298    /** Structure version. PDM_PICHLP_VERSION defines the current version. */
    13061299    uint32_t                u32Version;
    13071300
     
    13111304     * @param   pDevIns         Device instance of the PIC.
    13121305     */
    1313     DECLRCCALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
     1306    DECLCALLBACKMEMBER(void, pfnSetInterruptFF)(PPDMDEVINS pDevIns);
    13141307
    13151308    /**
     
    13181311     * @param   pDevIns         Device instance of the PIC.
    13191312     */
    1320     DECLRCCALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
     1313    DECLCALLBACKMEMBER(void, pfnClearInterruptFF)(PPDMDEVINS pDevIns);
    13211314
    13221315    /**
     
    13281321     * @param   rc              What to return if we fail to acquire the lock.
    13291322     */
    1330     DECLRCCALLBACKMEMBER(int,   pfnLock,(PPDMDEVINS pDevIns, int rc));
     1323    DECLCALLBACKMEMBER(int,   pfnLock)(PPDMDEVINS pDevIns, int rc);
    13311324
    13321325    /**
     
    13351328     * @param   pDevIns         The PIC device instance.
    13361329     */
    1337     DECLRCCALLBACKMEMBER(void,  pfnUnlock,(PPDMDEVINS pDevIns));
     1330    DECLCALLBACKMEMBER(void,  pfnUnlock)(PPDMDEVINS pDevIns);
    13381331
    13391332    /** Just a safety precaution. */
    13401333    uint32_t                u32TheEnd;
    1341 } PDMPICHLPRC;
    1342 
    1343 /** Pointer to PIC RC helpers. */
    1344 typedef RCPTRTYPE(PDMPICHLPRC *) PPDMPICHLPRC;
    1345 /** Pointer to const PIC RC helpers. */
    1346 typedef RCPTRTYPE(const PDMPICHLPRC *) PCPDMPICHLPRC;
    1347 
    1348 /** Current PDMPICHLPRC version number. */
    1349 #define PDM_PICHLPRC_VERSION                    PDM_VERSION_MAKE(0xfff9, 2, 0)
    1350 
    1351 
    1352 /**
    1353  * PIC R0 helpers.
    1354  */
    1355 typedef struct PDMPICHLPR0
    1356 {
    1357     /** Structure version. PDM_PICHLPR0_VERSION defines the current version. */
    1358     uint32_t                u32Version;
    1359 
    1360     /**
    1361      * Set the interrupt force action flag.
    1362      *
    1363      * @param   pDevIns         Device instance of the PIC.
    1364      */
    1365     DECLR0CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
    1366 
    1367     /**
    1368      * Clear the interrupt force action flag.
    1369      *
    1370      * @param   pDevIns         Device instance of the PIC.
    1371      */
    1372     DECLR0CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
    1373 
    1374     /**
    1375      * Acquires the PDM lock.
    1376      *
    1377      * @returns VINF_SUCCESS on success.
    1378      * @returns rc if we failed to acquire the lock.
    1379      * @param   pDevIns         The PIC device instance.
    1380      * @param   rc              What to return if we fail to acquire the lock.
    1381      */
    1382     DECLR0CALLBACKMEMBER(int,   pfnLock,(PPDMDEVINS pDevIns, int rc));
    1383 
    1384     /**
    1385      * Releases the PDM lock.
    1386      *
    1387      * @param   pDevIns         The PCI device instance.
    1388      */
    1389     DECLR0CALLBACKMEMBER(void,  pfnUnlock,(PPDMDEVINS pDevIns));
    1390 
    1391     /** Just a safety precaution. */
    1392     uint32_t                u32TheEnd;
    1393 } PDMPICHLPR0;
    1394 
    1395 /** Pointer to PIC R0 helpers. */
    1396 typedef R0PTRTYPE(PDMPICHLPR0 *) PPDMPICHLPR0;
    1397 /** Pointer to const PIC R0 helpers. */
    1398 typedef R0PTRTYPE(const PDMPICHLPR0 *) PCPDMPICHLPR0;
    1399 
    1400 /** Current PDMPICHLPR0 version number. */
    1401 #define PDM_PICHLPR0_VERSION                    PDM_VERSION_MAKE(0xfff8, 1, 0)
    1402 
    1403 /**
    1404  * PIC R3 helpers.
    1405  */
    1406 typedef struct PDMPICHLPR3
    1407 {
    1408     /** Structure version. PDM_PICHLP_VERSION defines the current version. */
    1409     uint32_t                u32Version;
    1410 
    1411     /**
    1412      * Set the interrupt force action flag.
    1413      *
    1414      * @param   pDevIns         Device instance of the PIC.
    1415      */
    1416     DECLR3CALLBACKMEMBER(void, pfnSetInterruptFF,(PPDMDEVINS pDevIns));
    1417 
    1418     /**
    1419      * Clear the interrupt force action flag.
    1420      *
    1421      * @param   pDevIns         Device instance of the PIC.
    1422      */
    1423     DECLR3CALLBACKMEMBER(void, pfnClearInterruptFF,(PPDMDEVINS pDevIns));
    1424 
    1425     /**
    1426      * Acquires the PDM lock.
    1427      *
    1428      * @returns VINF_SUCCESS on success.
    1429      * @returns Fatal error on failure.
    1430      * @param   pDevIns         The PIC device instance.
    1431      * @param   rc              Dummy for making the interface identical to the RC and R0 versions.
    1432      */
    1433     DECLR3CALLBACKMEMBER(int,   pfnLock,(PPDMDEVINS pDevIns, int rc));
    1434 
    1435     /**
    1436      * Releases the PDM lock.
    1437      *
    1438      * @param   pDevIns         The PIC device instance.
    1439      */
    1440     DECLR3CALLBACKMEMBER(void,  pfnUnlock,(PPDMDEVINS pDevIns));
    1441 
    1442     /**
    1443      * Gets the address of the RC PIC helpers.
    1444      *
    1445      * This should be called at both construction and relocation time
    1446      * to obtain the correct address of the RC helpers.
    1447      *
    1448      * @returns RC pointer to the PIC helpers.
    1449      * @param   pDevIns         Device instance of the PIC.
    1450      */
    1451     DECLR3CALLBACKMEMBER(PCPDMPICHLPRC, pfnGetRCHelpers,(PPDMDEVINS pDevIns));
    1452 
    1453     /**
    1454      * Gets the address of the R0 PIC helpers.
    1455      *
    1456      * This should be called at both construction and relocation time
    1457      * to obtain the correct address of the R0 helpers.
    1458      *
    1459      * @returns R0 pointer to the PIC helpers.
    1460      * @param   pDevIns         Device instance of the PIC.
    1461      */
    1462     DECLR3CALLBACKMEMBER(PCPDMPICHLPR0, pfnGetR0Helpers,(PPDMDEVINS pDevIns));
    1463 
    1464     /** Just a safety precaution. */
    1465     uint32_t                u32TheEnd;
    1466 } PDMPICHLPR3;
    1467 
    1468 /** Pointer to PIC R3 helpers. */
    1469 typedef R3PTRTYPE(PDMPICHLPR3 *) PPDMPICHLPR3;
    1470 /** Pointer to const PIC R3 helpers. */
    1471 typedef R3PTRTYPE(const PDMPICHLPR3 *) PCPDMPICHLPR3;
    1472 
    1473 /** Current PDMPICHLPR3 version number. */
    1474 #define PDM_PICHLPR3_VERSION                    PDM_VERSION_MAKE(0xfff7, 1, 0)
    1475 
     1334} PDMPICHLP;
     1335/** Pointer to PIC helpers. */
     1336typedef PDMPICHLP *PPDMPICHLP;
     1337/** Pointer to const PIC helpers. */
     1338typedef const PDMPICHLP *PCPDMPICHLP;
     1339
     1340/** Current PDMPICHLP version number. */
     1341#define PDM_PICHLP_VERSION                      PDM_VERSION_MAKE(0xfff9, 3, 0)
    14761342
    14771343
     
    40333899     * @param   pDevIns             The device instance.
    40343900     * @param   pPicReg             Pointer to a PIC registration structure.
    4035      * @param   ppPicHlpR3          Where to store the pointer to the PIC HC
     3901     * @param   ppPicHlp            Where to store the pointer to the ring-3 PIC
    40363902     *                              helpers.
    4037      */
    4038     DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3));
     3903     * @sa      PDMDevHlpPICSetUpContext
     3904     */
     3905    DECLR3CALLBACKMEMBER(int, pfnPICRegister,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
    40393906
    40403907    /**
     
    49554822    DECLRCCALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGRC pPciBusReg, PCPDMPCIHLPRC *ppPciHlp));
    49564823
     4824    /**
     4825     * Sets up the PIC for the raw-mode context.
     4826     *
     4827     * This must be called after ring-3 has registered the PIC using
     4828     * PDMDevHlpPICRegister().
     4829     *
     4830     * @returns VBox status code.
     4831     * @param   pDevIns     The device instance.
     4832     * @param   pPicReg     The PIC registration information for ring-0,
     4833     *                      considered volatile and copied.
     4834     * @param   ppPciHlp    Where to return the raw-mode PIC helpers.
     4835     */
     4836    DECLRCCALLBACKMEMBER(int, pfnPCISetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
     4837
    49574838    /** Space reserved for future members.
    49584839     * @{ */
     
    49784859
    49794860/** Current PDMDEVHLP version number. */
    4980 #define PDM_DEVHLPRC_VERSION                    PDM_VERSION_MAKE(0xffe6, 10, 0)
     4861#define PDM_DEVHLPRC_VERSION                    PDM_VERSION_MAKE(0xffe6, 11, 0)
    49814862
    49824863
     
    54155296     * @param   pDevIns     The device instance.
    54165297     * @param   pPciBusReg  The PCI bus registration information for ring-0,
    5417      *                      considered volatile.
     5298     *                      considered volatile and copied.
    54185299     * @param   ppPciHlp    Where to return the ring-0 PCI bus helpers.
    54195300     */
    54205301    DECLR0CALLBACKMEMBER(int, pfnPCIBusSetUpContext,(PPDMDEVINS pDevIns, PPDMPCIBUSREGR0 pPciBusReg, PCPDMPCIHLPR0 *ppPciHlp));
     5302
     5303    /**
     5304     * Sets up the PIC for the ring-0 context.
     5305     *
     5306     * This must be called after ring-3 has registered the PIC using
     5307     * PDMDevHlpPICRegister().
     5308     *
     5309     * @returns VBox status code.
     5310     * @param   pDevIns     The device instance.
     5311     * @param   pPicReg     The PIC registration information for ring-0,
     5312     *                      considered volatile and copied.
     5313     * @param   ppPciHlp    Where to return the ring-0 PIC helpers.
     5314     */
     5315    DECLR0CALLBACKMEMBER(int, pfnPICSetUpContext,(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp));
    54215316
    54225317    /** Space reserved for future members.
     
    54435338
    54445339/** Current PDMDEVHLP version number. */
    5445 #define PDM_DEVHLPR0_VERSION                    PDM_VERSION_MAKE(0xffe5, 11, 0)
     5340#define PDM_DEVHLPR0_VERSION                    PDM_VERSION_MAKE(0xffe5, 12, 0)
    54465341
    54475342
     
    77597654#endif
    77607655
    7761 #ifdef IN_RING3
     7656#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
    77627657
    77637658/**
     
    78767771 * @copydoc PDMDEVHLPR3::pfnPICRegister
    78777772 */
    7878 DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
    7879 {
    7880     return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlpR3);
     7773DECLINLINE(int) PDMDevHlpPICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
     7774{
     7775    return pDevIns->pHlpR3->pfnPICRegister(pDevIns, pPicReg, ppPicHlp);
    78817776}
    78827777
     
    80177912}
    80187913
    8019 #else  /* !IN_RING3 */
    8020 
    8021 /**
    8022  * @copydoc PDMDEVHLPR0::pfnPCIBusSetUp
     7914#endif /* IN_RING3 || DOXYGEN_RUNNING */
     7915
     7916#if !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
     7917
     7918/**
     7919 * @copydoc PDMDEVHLPR0::pfnPCIBusSetUpContext
    80237920 */
    80247921DECLINLINE(int) PDMDevHlpPCIBusSetUpContext(PPDMDEVINS pDevIns, CTX_SUFF(PPDMPCIBUSREG) pPciBusReg, CTX_SUFF(PCPDMPCIHLP) *ppPciHlp)
    80257922{
    80267923    return pDevIns->CTX_SUFF(pHlp)->pfnPCIBusSetUpContext(pDevIns, pPciBusReg, ppPciHlp);
     7924}
     7925
     7926/**
     7927 * @copydoc PDMDEVHLPR0::pfnPICSetUpContext
     7928 */
     7929DECLINLINE(int) PDMDevHlpPICSetUpContext(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
     7930{
     7931    return pDevIns->CTX_SUFF(pHlp)->pfnPICSetUpContext(pDevIns, pPicReg, ppPicHlp);
    80277932}
    80287933
  • trunk/src/VBox/Devices/PC/DevPIC.cpp

    r81591 r81909  
    124124    PPDMDEVINSR3            pDevInsR3;
    125125    /** Pointer to the PIC R3 helpers. */
    126     PCPDMPICHLPR3           pPicHlpR3;
     126    R3PTRTYPE(PCPDMPICHLP)  pPicHlpR3;
    127127    /** Pointer to the device instance - R0 Ptr. */
    128128    PPDMDEVINSR0            pDevInsR0;
    129129    /** Pointer to the PIC R0 helpers. */
    130     PCPDMPICHLPR0           pPicHlpR0;
     130    R0PTRTYPE(PCPDMPICHLP)  pPicHlpR0;
    131131    /** Pointer to the device instance - RC Ptr. */
    132132    PPDMDEVINSRC            pDevInsRC;
    133133    /** Pointer to the PIC RC helpers. */
    134     PCPDMPICHLPRC           pPicHlpRC;
     134    RCPTRTYPE(PCPDMPICHLP)  pPicHlpRC;
    135135    /** Number of release log entries. Used to prevent flooding. */
    136136    uint32_t                cRelLogEntries;
     
    725725 * @callback_method_impl{FNDBGFHANDLERDEV}
    726726 */
    727 static DECLCALLBACK(void) picInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     727static DECLCALLBACK(void) picIR3nfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    728728{
    729729    PDEVPIC pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     
    757757 * @callback_method_impl{FNSSMDEVSAVEEXEC}
    758758 */
    759 static DECLCALLBACK(int) picSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    760 {
    761     PDEVPIC     pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     759static DECLCALLBACK(int) picR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     760{
     761    PDEVPIC         pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     762    PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
     763
    762764    for (unsigned i = 0; i < RT_ELEMENTS(pThis->aPics); i++)
    763765    {
    764         SSMR3PutU8(pSSM, pThis->aPics[i].last_irr);
    765         SSMR3PutU8(pSSM, pThis->aPics[i].irr);
    766         SSMR3PutU8(pSSM, pThis->aPics[i].imr);
    767         SSMR3PutU8(pSSM, pThis->aPics[i].isr);
    768         SSMR3PutU8(pSSM, pThis->aPics[i].priority_add);
    769         SSMR3PutU8(pSSM, pThis->aPics[i].irq_base);
    770         SSMR3PutU8(pSSM, pThis->aPics[i].read_reg_select);
    771         SSMR3PutU8(pSSM, pThis->aPics[i].poll);
    772         SSMR3PutU8(pSSM, pThis->aPics[i].special_mask);
    773         SSMR3PutU8(pSSM, pThis->aPics[i].init_state);
    774         SSMR3PutU8(pSSM, pThis->aPics[i].auto_eoi);
    775         SSMR3PutU8(pSSM, pThis->aPics[i].rotate_on_auto_eoi);
    776         SSMR3PutU8(pSSM, pThis->aPics[i].special_fully_nested_mode);
    777         SSMR3PutU8(pSSM, pThis->aPics[i].init4);
    778         SSMR3PutU8(pSSM, pThis->aPics[i].elcr);
     766        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].last_irr);
     767        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].irr);
     768        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].imr);
     769        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].isr);
     770        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].priority_add);
     771        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].irq_base);
     772        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].read_reg_select);
     773        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].poll);
     774        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].special_mask);
     775        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].init_state);
     776        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].auto_eoi);
     777        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].rotate_on_auto_eoi);
     778        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].special_fully_nested_mode);
     779        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].init4);
     780        pHlp->pfnSSMPutU8(pSSM, pThis->aPics[i].elcr);
    779781    }
    780782    return VINF_SUCCESS;
     
    785787 * @callback_method_impl{FNSSMDEVLOADEXEC}
    786788 */
    787 static DECLCALLBACK(int) picLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    788 {
    789     PDEVPIC pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     789static DECLCALLBACK(int) picR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     790{
     791    PDEVPIC         pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     792    PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
    790793
    791794    if (uVersion != 1)
     
    795798    for (unsigned i = 0; i < RT_ELEMENTS(pThis->aPics); i++)
    796799    {
    797         SSMR3GetU8(pSSM, &pThis->aPics[i].last_irr);
    798         SSMR3GetU8(pSSM, &pThis->aPics[i].irr);
    799         SSMR3GetU8(pSSM, &pThis->aPics[i].imr);
    800         SSMR3GetU8(pSSM, &pThis->aPics[i].isr);
    801         SSMR3GetU8(pSSM, &pThis->aPics[i].priority_add);
    802         SSMR3GetU8(pSSM, &pThis->aPics[i].irq_base);
    803         SSMR3GetU8(pSSM, &pThis->aPics[i].read_reg_select);
    804         SSMR3GetU8(pSSM, &pThis->aPics[i].poll);
    805         SSMR3GetU8(pSSM, &pThis->aPics[i].special_mask);
    806         SSMR3GetU8(pSSM, &pThis->aPics[i].init_state);
    807         SSMR3GetU8(pSSM, &pThis->aPics[i].auto_eoi);
    808         SSMR3GetU8(pSSM, &pThis->aPics[i].rotate_on_auto_eoi);
    809         SSMR3GetU8(pSSM, &pThis->aPics[i].special_fully_nested_mode);
    810         SSMR3GetU8(pSSM, &pThis->aPics[i].init4);
    811         SSMR3GetU8(pSSM, &pThis->aPics[i].elcr);
     800        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].last_irr);
     801        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].irr);
     802        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].imr);
     803        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].isr);
     804        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].priority_add);
     805        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].irq_base);
     806        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].read_reg_select);
     807        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].poll);
     808        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].special_mask);
     809        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].init_state);
     810        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].auto_eoi);
     811        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].rotate_on_auto_eoi);
     812        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].special_fully_nested_mode);
     813        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].init4);
     814        pHlp->pfnSSMGetU8(pSSM, &pThis->aPics[i].elcr);
    812815    }
    813816
     
    822825 * @interface_method_impl{PDMDEVREG,pfnReset}
    823826 */
    824 static DECLCALLBACK(void)  picReset(PPDMDEVINS pDevIns)
     827static DECLCALLBACK(void)  picR3Reset(PPDMDEVINS pDevIns)
    825828{
    826829    PDEVPIC     pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
    827830    unsigned    i;
    828     LogFlow(("picReset:\n"));
     831    LogFlow(("picR3Reset:\n"));
    829832    pThis->pPicHlpR3->pfnLock(pDevIns, VERR_INTERNAL_ERROR);
    830833
     
    839842 * @interface_method_impl{PDMDEVREG,pfnRelocate}
    840843 */
    841 static DECLCALLBACK(void) picRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     844static DECLCALLBACK(void) picR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    842845{
    843846    RT_NOREF1(offDelta);
     
    846849
    847850    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    848     pThis->pPicHlpRC = pThis->pPicHlpR3->pfnGetRCHelpers(pDevIns);
     851    pThis->pPicHlpRC += offDelta;
    849852    for (i = 0; i < RT_ELEMENTS(pThis->aPics); i++)
    850853        pThis->aPics[i].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     
    855858 * @interface_method_impl{PDMDEVREG,pfnConstruct}
    856859 */
    857 static DECLCALLBACK(int)  picConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
     860static DECLCALLBACK(int)  picR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    858861{
    859862    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    860     RT_NOREF1(iInstance);
    861863    PDEVPIC         pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
    862864    int             rc;
    863     bool            fGCEnabled;
    864     bool            fR0Enabled;
     865    RT_NOREF(iInstance, pCfg);
     866
    865867    Assert(iInstance == 0);
    866868
     
    868870     * Validate and read configuration.
    869871     */
    870     if (!CFGMR3AreValuesValid(pCfg, "GCEnabled\0" "R0Enabled\0"))
    871         return VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES;
    872 
    873     rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &fGCEnabled, true);
    874     if (RT_FAILURE(rc))
    875         return PDMDEV_SET_ERROR(pDevIns, rc,
    876                                 N_("Configuration error: failed to read GCEnabled as boolean"));
    877 
    878     rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &fR0Enabled, true);
    879     if (RT_FAILURE(rc))
    880         return PDMDEV_SET_ERROR(pDevIns, rc,
    881                                 N_("Configuration error: failed to read R0Enabled as boolean"));
    882 
    883     Log(("DevPIC: fGCEnabled=%RTbool fR0Enabled=%RTbool\n", fGCEnabled, fR0Enabled));
     872    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "", "");
     873    Log(("DevPIC: fRCEnabled=%RTbool fR0Enabled=%RTbool\n", pDevIns->fRCEnabled, pDevIns->fR0Enabled));
    884874
    885875    /*
     
    907897    PDMPICREG PicReg;
    908898    PicReg.u32Version           = PDM_PICREG_VERSION;
    909     PicReg.pfnSetIrqR3          = picSetIrq;
    910     PicReg.pfnGetInterruptR3    = picGetInterrupt;
    911 
    912     if (fGCEnabled)
    913     {
    914         PicReg.pszSetIrqRC          = "picSetIrq";
    915         PicReg.pszGetInterruptRC    = "picGetInterrupt";
    916     }
    917     else
    918     {
    919         PicReg.pszSetIrqRC          = NULL;
    920         PicReg.pszGetInterruptRC    = NULL;
    921     }
    922 
    923     if (fR0Enabled)
    924     {
    925         PicReg.pszSetIrqR0          = "picSetIrq";
    926         PicReg.pszGetInterruptR0    = "picGetInterrupt";
    927     }
    928     else
    929     {
    930         PicReg.pszSetIrqR0          = NULL;
    931         PicReg.pszGetInterruptR0    = NULL;
    932     }
    933 
     899    PicReg.pfnSetIrq            = picSetIrq;
     900    PicReg.pfnGetInterrupt      = picGetInterrupt;
     901    PicReg.u32TheEnd            = PDM_PICREG_VERSION;
    934902    rc = PDMDevHlpPICRegister(pDevIns, &PicReg, &pThis->pPicHlpR3);
    935     AssertLogRelMsgRCReturn(rc, ("PICRegister -> %Rrc\n", rc), rc);
    936     if (fGCEnabled)
    937         pThis->pPicHlpRC = pThis->pPicHlpR3->pfnGetRCHelpers(pDevIns);
    938     if (fR0Enabled)
    939         pThis->pPicHlpR0 = pThis->pPicHlpR3->pfnGetR0Helpers(pDevIns);
     903    AssertLogRelMsgRCReturn(rc, ("PDMDevHlpPICRegister -> %Rrc\n", rc), rc);
    940904
    941905    /*
     
    955919    if (RT_FAILURE(rc))
    956920        return rc;
    957     if (fGCEnabled)
     921    if (pDevIns->fRCEnabled)
    958922    {
    959923        rc = PDMDevHlpIOPortRegisterRC(pDevIns,  0x20, 2, 0, "picIOPortWrite", "picIOPortRead", NULL, NULL, "i8259 PIC #0");
     
    964928            return rc;
    965929    }
    966     if (fR0Enabled)
     930    if (pDevIns->fR0Enabled)
    967931    {
    968932        rc = PDMDevHlpIOPortRegisterR0(pDevIns,  0x20, 2, 0, "picIOPortWrite", "picIOPortRead", NULL, NULL, "i8259 PIC #0");
     
    982946    if (RT_FAILURE(rc))
    983947        return rc;
    984     if (fGCEnabled)
     948    if (pDevIns->fRCEnabled)
    985949    {
    986950        RTRCPTR pDataRC = PDMINS_2_DATA_RCPTR(pDevIns);
     
    994958            return rc;
    995959    }
    996     if (fR0Enabled)
     960    if (pDevIns->fR0Enabled)
    997961    {
    998962        RTR0PTR pDataR0 = PDMINS_2_DATA_R0PTR(pDevIns);
     
    1007971    }
    1008972
    1009     rc = PDMDevHlpSSMRegister(pDevIns, 1 /* uVersion */, sizeof(*pThis), picSaveExec, picLoadExec);
     973    rc = PDMDevHlpSSMRegister(pDevIns, 1 /* uVersion */, sizeof(*pThis), picR3SaveExec, picR3LoadExec);
    1010974    if (RT_FAILURE(rc))
    1011975        return rc;
     
    1015979     * Register the info item.
    1016980     */
    1017     PDMDevHlpDBGFInfoRegister(pDevIns, "pic", "PIC info.", picInfo);
     981    PDMDevHlpDBGFInfoRegister(pDevIns, "pic", "PIC info.", picIR3nfo);
    1018982
    1019983    /*
    1020984     * Initialize the device state.
    1021985     */
    1022     picReset(pDevIns);
     986    picR3Reset(pDevIns);
    1023987
    1024988#ifdef VBOX_WITH_STATISTICS
     
    10371001}
    10381002
    1039 #endif /* IN_RING3 */
     1003#else  /* !IN_RING3 */
     1004
     1005/**
     1006 * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
     1007 */
     1008static DECLCALLBACK(int) picRZConstruct(PPDMDEVINS pDevIns)
     1009{
     1010    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     1011    PDEVPIC pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPIC);
     1012
     1013    int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
     1014    AssertRCReturn(rc, rc);
     1015
     1016    PDMPICREG PicReg;
     1017    PicReg.u32Version           = PDM_PICREG_VERSION;
     1018    PicReg.pfnSetIrq            = picSetIrq;
     1019    PicReg.pfnGetInterrupt      = picGetInterrupt;
     1020    PicReg.u32TheEnd            = PDM_PICREG_VERSION;
     1021    rc = PDMDevHlpPICSetUpContext(pDevIns, &PicReg, &pThis->CTX_SUFF(pPicHlp));
     1022    AssertLogRelMsgRCReturn(rc, ("PDMDevHlpPICSetUpContext -> %Rrc\n", rc), rc);
     1023
     1024    return VINF_SUCCESS;
     1025}
     1026
     1027#endif /* !IN_RING3 */
    10401028
    10411029/**
     
    10601048    /* .pszRCMod = */               "VBoxDDRC.rc",
    10611049    /* .pszR0Mod = */               "VBoxDDR0.r0",
    1062     /* .pfnConstruct = */           picConstruct,
     1050    /* .pfnConstruct = */           picR3Construct,
    10631051    /* .pfnDestruct = */            NULL,
    1064     /* .pfnRelocate = */            picRelocate,
     1052    /* .pfnRelocate = */            picR3Relocate,
    10651053    /* .pfnMemSetup = */            NULL,
    10661054    /* .pfnPowerOn = */             NULL,
    1067     /* .pfnReset = */               picReset,
     1055    /* .pfnReset = */               picR3Reset,
    10681056    /* .pfnSuspend = */             NULL,
    10691057    /* .pfnResume = */              NULL,
     
    10841072#elif defined(IN_RING0)
    10851073    /* .pfnEarlyConstruct = */      NULL,
    1086     /* .pfnConstruct = */           NULL,
     1074    /* .pfnConstruct = */           picRZConstruct,
    10871075    /* .pfnDestruct = */            NULL,
    10881076    /* .pfnFinalDestruct = */       NULL,
     
    10971085    /* .pfnReserved7 = */           NULL,
    10981086#elif defined(IN_RC)
    1099     /* .pfnConstruct = */           NULL,
     1087    /* .pfnConstruct = */           picRZConstruct,
    11001088    /* .pfnReserved0 = */           NULL,
    11011089    /* .pfnReserved1 = */           NULL,
  • trunk/src/VBox/VMM/VMMAll/APICAll.cpp

    r81591 r81909  
    26832683 * @param   rcRZ        The return code if the operation cannot be performed in
    26842684 *                      the current context.
     2685 *
     2686 * @note    All callers totally ignores the status code!
    26852687 */
    26862688VMM_INT_DECL(VBOXSTRICTRC) APICLocalInterrupt(PVMCPUCC pVCpu, uint8_t u8Pin, uint8_t u8Level, int rcRZ)
     
    28082810                default:
    28092811                {
    2810                     rcStrict = VERR_INTERNAL_ERROR_3;
    28112812                    AssertMsgFailed(("APIC%u: LocalInterrupt: Invalid delivery mode %#x (%s) on LINT%d\n", pVCpu->idCpu,
    28122813                                     enmDeliveryMode, apicGetDeliveryModeName(enmDeliveryMode), u8Pin));
     2814                    rcStrict = VERR_INTERNAL_ERROR_3;
    28132815                    break;
    28142816                }
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r81850 r81909  
    5454RT_C_DECLS_BEGIN
    5555extern DECLEXPORT(const PDMDEVHLPR0)    g_pdmR0DevHlp;
    56 extern DECLEXPORT(const PDMPICHLPR0)    g_pdmR0PicHlp;
     56extern DECLEXPORT(const PDMPICHLP    g_pdmR0PicHlp;
    5757extern DECLEXPORT(const PDMIOAPICHLPR0) g_pdmR0IoApicHlp;
    5858extern DECLEXPORT(const PDMPCIHLPR0)    g_pdmR0PciHlp;
     
    10931093
    10941094    LogFlow(("pdmR0DevHlp_PCIBusSetUpContext: caller='%p'/%d: returns VINF_SUCCESS\n", pDevIns, pDevIns->iInstance));
     1095    return VINF_SUCCESS;
     1096}
     1097
     1098
     1099/** @interface_method_impl{PDMDEVHLPR0,pfnPICSetUpContext} */
     1100static DECLCALLBACK(int) pdmR0DevHlp_PICSetUpContext(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
     1101{
     1102    PDMDEV_ASSERT_DEVINS(pDevIns);
     1103    LogFlow(("pdmR0DevHlp_PICSetUpContext: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlp=%p\n",
     1104             pDevIns->pReg->szName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrq, pPicReg->pfnGetInterrupt, ppPicHlp));
     1105    PGVM pGVM = pDevIns->Internal.s.pGVM;
     1106
     1107    /*
     1108     * Validate input.
     1109     */
     1110    AssertMsgReturn(pPicReg->u32Version == PDM_PICREG_VERSION,
     1111                    ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32Version, PDM_PICREG_VERSION),
     1112                    VERR_INVALID_PARAMETER);
     1113    AssertPtrReturn(pPicReg->pfnSetIrq, VERR_INVALID_POINTER);
     1114    AssertPtrReturn(pPicReg->pfnGetInterrupt, VERR_INVALID_POINTER);
     1115    AssertMsgReturn(pPicReg->u32TheEnd == PDM_PICREG_VERSION,
     1116                    ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32TheEnd, PDM_PICREG_VERSION),
     1117                    VERR_INVALID_PARAMETER);
     1118    AssertPtrReturn(ppPicHlp, VERR_INVALID_POINTER);
     1119
     1120    VM_ASSERT_STATE_RETURN(pGVM, VMSTATE_CREATING, VERR_WRONG_ORDER);
     1121    VM_ASSERT_EMT0_RETURN(pGVM, VERR_VM_THREAD_NOT_EMT);
     1122
     1123    /* Check that it's the same device as made the ring-3 registrations: */
     1124    AssertLogRelMsgReturn(pGVM->pdm.s.Pic.pDevInsR3 == pDevIns->pDevInsForR3,
     1125                          ("%p vs %p\n", pGVM->pdm.s.Pic.pDevInsR3, pDevIns->pDevInsForR3), VERR_NOT_OWNER);
     1126
     1127    /* Check that it isn't already registered in ring-0: */
     1128    AssertLogRelMsgReturn(pGVM->pdm.s.Pic.pDevInsR0 == NULL, ("%p (caller pDevIns=%p)\n", pGVM->pdm.s.Pic.pDevInsR0, pDevIns),
     1129                          VERR_ALREADY_EXISTS);
     1130
     1131    /*
     1132     * Take down the callbacks and instance.
     1133     */
     1134    pGVM->pdm.s.Pic.pDevInsR0 = pDevIns;
     1135    pGVM->pdm.s.Pic.pfnSetIrqR0 = pPicReg->pfnSetIrq;
     1136    pGVM->pdm.s.Pic.pfnGetInterruptR0 = pPicReg->pfnGetInterrupt;
     1137    Log(("PDM: Registered PIC device '%s'/%d pDevIns=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, pDevIns));
     1138
     1139    /* set the helper pointer and return. */
     1140    *ppPicHlp = &g_pdmR0PicHlp;
     1141    LogFlow(("pdmR0DevHlp_PICSetUpContext: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
    10951142    return VINF_SUCCESS;
    10961143}
     
    11741221    pdmR0DevHlp_DBGFTraceBuf,
    11751222    pdmR0DevHlp_PCIBusSetUpContext,
     1223    pdmR0DevHlp_PICSetUpContext,
    11761224    NULL /*pfnReserved1*/,
    11771225    NULL /*pfnReserved2*/,
     
    11961244 */
    11971245
    1198 /** @interface_method_impl{PDMPICHLPR0,pfnSetInterruptFF} */
     1246/** @interface_method_impl{PDMPICHLP,pfnSetInterruptFF} */
    11991247static DECLCALLBACK(void) pdmR0PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
    12001248{
     
    12071255
    12081256
    1209 /** @interface_method_impl{PDMPICHLPR0,pfnClearInterruptFF} */
     1257/** @interface_method_impl{PDMPICHLP,pfnClearInterruptFF} */
    12101258static DECLCALLBACK(void) pdmR0PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
    12111259{
     
    12181266
    12191267
    1220 /** @interface_method_impl{PDMPICHLPR0,pfnLock} */
     1268/** @interface_method_impl{PDMPICHLP,pfnLock} */
    12211269static DECLCALLBACK(int) pdmR0PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
    12221270{
     
    12261274
    12271275
    1228 /** @interface_method_impl{PDMPICHLPR0,pfnUnlock} */
     1276/** @interface_method_impl{PDMPICHLP,pfnUnlock} */
    12291277static DECLCALLBACK(void) pdmR0PicHlp_Unlock(PPDMDEVINS pDevIns)
    12301278{
     
    12371285 * The Ring-0 PIC Helper Callbacks.
    12381286 */
    1239 extern DECLEXPORT(const PDMPICHLPR0) g_pdmR0PicHlp =
    1240 {
    1241     PDM_PICHLPR0_VERSION,
     1287extern DECLEXPORT(const PDMPICHLP) g_pdmR0PicHlp =
     1288{
     1289    PDM_PICHLP_VERSION,
    12421290    pdmR0PicHlp_SetInterruptFF,
    12431291    pdmR0PicHlp_ClearInterruptFF,
    12441292    pdmR0PicHlp_Lock,
    12451293    pdmR0PicHlp_Unlock,
    1246     PDM_PICHLPR0_VERSION
     1294    PDM_PICHLP_VERSION
    12471295};
    12481296
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r81850 r81909  
    36783678
    36793679/** @interface_method_impl{PDMDEVHLPR3,pfnPICRegister} */
    3680 static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLPR3 *ppPicHlpR3)
     3680static DECLCALLBACK(int) pdmR3DevHlp_PICRegister(PPDMDEVINS pDevIns, PPDMPICREG pPicReg, PCPDMPICHLP *ppPicHlp)
    36813681{
    36823682    PDMDEV_ASSERT_DEVINS(pDevIns);
    36833683    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    3684     LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlpR3=%p\n",
    3685              pDevIns->pReg->szName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrqR3, pPicReg->pfnGetInterruptR3,
    3686              pPicReg->pszSetIrqRC, pPicReg->pszSetIrqRC, pPicReg->pszGetInterruptRC, pPicReg->pszGetInterruptRC,
    3687              pPicReg->pszSetIrqR0, pPicReg->pszSetIrqR0, pPicReg->pszGetInterruptR0, pPicReg->pszGetInterruptR0,
    3688              ppPicHlpR3));
     3684    LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: pPicReg=%p:{.u32Version=%#x, .pfnSetIrqR3=%p, .pfnGetInterruptR3=%p, .pszGetIrqRC=%p:{%s}, .pszGetInterruptRC=%p:{%s}, .pszGetIrqR0=%p:{%s}, .pszGetInterruptR0=%p:{%s} } ppPicHlp=%p\n",
     3685             pDevIns->pReg->szName, pDevIns->iInstance, pPicReg, pPicReg->u32Version, pPicReg->pfnSetIrq, pPicReg->pfnGetInterrupt, ppPicHlp));
     3686    PVM pVM = pDevIns->Internal.s.pVMR3;
    36893687
    36903688    /*
    36913689     * Validate input.
    36923690     */
    3693     if (pPicReg->u32Version != PDM_PICREG_VERSION)
    3694     {
    3695         AssertMsgFailed(("u32Version=%#x expected %#x\n", pPicReg->u32Version, PDM_PICREG_VERSION));
    3696         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (version)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3697         return VERR_INVALID_PARAMETER;
    3698     }
    3699     if (    !pPicReg->pfnSetIrqR3
    3700         ||  !pPicReg->pfnGetInterruptR3)
    3701     {
    3702         Assert(pPicReg->pfnSetIrqR3);
    3703         Assert(pPicReg->pfnGetInterruptR3);
    3704         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R3 callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3705         return VERR_INVALID_PARAMETER;
    3706     }
    3707     if (    (   pPicReg->pszSetIrqRC
    3708              || pPicReg->pszGetInterruptRC)
    3709         &&  (   !VALID_PTR(pPicReg->pszSetIrqRC)
    3710              || !VALID_PTR(pPicReg->pszGetInterruptRC))
    3711        )
    3712     {
    3713         Assert(VALID_PTR(pPicReg->pszSetIrqRC));
    3714         Assert(VALID_PTR(pPicReg->pszGetInterruptRC));
    3715         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC callbacks)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3716         return VERR_INVALID_PARAMETER;
    3717     }
    3718     if (    pPicReg->pszSetIrqRC
    3719         &&  !(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_RC))
    3720     {
    3721         Assert(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_RC);
    3722         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (RC flag)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3723         return VERR_INVALID_PARAMETER;
    3724     }
    3725     if (    pPicReg->pszSetIrqR0
    3726         &&  !(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0))
    3727     {
    3728         Assert(pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0);
    3729         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (R0 flag)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3730         return VERR_INVALID_PARAMETER;
    3731     }
    3732     if (!ppPicHlpR3)
    3733     {
    3734         Assert(ppPicHlpR3);
    3735         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc (ppPicHlpR3)\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3736         return VERR_INVALID_PARAMETER;
    3737     }
     3691    AssertMsgReturn(pPicReg->u32Version == PDM_PICREG_VERSION,
     3692                    ("%s/%d: u32Version=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32Version, PDM_PICREG_VERSION),
     3693                    VERR_INVALID_PARAMETER);
     3694    AssertPtrReturn(pPicReg->pfnSetIrq, VERR_INVALID_POINTER);
     3695    AssertPtrReturn(pPicReg->pfnGetInterrupt, VERR_INVALID_POINTER);
     3696    AssertMsgReturn(pPicReg->u32TheEnd == PDM_PICREG_VERSION,
     3697                    ("%s/%d: u32TheEnd=%#x expected %#x\n", pDevIns->pReg->szName, pDevIns->iInstance, pPicReg->u32TheEnd, PDM_PICREG_VERSION),
     3698                    VERR_INVALID_PARAMETER);
     3699    AssertPtrReturn(ppPicHlp, VERR_INVALID_POINTER);
     3700
     3701    VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_WRONG_ORDER);
     3702    VM_ASSERT_EMT0_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
    37383703
    37393704    /*
    37403705     * Only one PIC device.
    37413706     */
    3742     PVM pVM = pDevIns->Internal.s.pVMR3;
    3743     if (pVM->pdm.s.Pic.pDevInsR3)
    3744     {
    3745         AssertMsgFailed(("Only one pic device is supported!\n"));
    3746         LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    3747         return VERR_INVALID_PARAMETER;
    3748     }
    3749 
    3750     /*
    3751      * RC stuff.
    3752      */
    3753     if (pPicReg->pszSetIrqRC)
    3754     {
    3755         int rc = pdmR3DevGetSymbolRCLazy(pDevIns, pPicReg->pszSetIrqRC, &pVM->pdm.s.Pic.pfnSetIrqRC);
    3756         AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszRCMod, pPicReg->pszSetIrqRC, rc));
    3757         if (RT_SUCCESS(rc))
    3758         {
    3759             rc = pdmR3DevGetSymbolRCLazy(pDevIns, pPicReg->pszGetInterruptRC, &pVM->pdm.s.Pic.pfnGetInterruptRC);
    3760             AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszRCMod, pPicReg->pszGetInterruptRC, rc));
    3761         }
    3762         if (RT_FAILURE(rc))
    3763         {
    3764             LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    3765             return rc;
    3766         }
    3767         pVM->pdm.s.Pic.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    3768     }
    3769     else
    3770     {
    3771         pVM->pdm.s.Pic.pDevInsRC = 0;
    3772         pVM->pdm.s.Pic.pfnSetIrqRC = 0;
    3773         pVM->pdm.s.Pic.pfnGetInterruptRC = 0;
    3774     }
    3775 
    3776     /*
    3777      * R0 stuff.
    3778      */
    3779     if (pPicReg->pszSetIrqR0)
    3780     {
    3781         int rc = pdmR3DevGetSymbolR0Lazy(pDevIns, pPicReg->pszSetIrqR0, &pVM->pdm.s.Pic.pfnSetIrqR0);
    3782         AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszR0Mod, pPicReg->pszSetIrqR0, rc));
    3783         if (RT_SUCCESS(rc))
    3784         {
    3785             rc = pdmR3DevGetSymbolR0Lazy(pDevIns, pPicReg->pszGetInterruptR0, &pVM->pdm.s.Pic.pfnGetInterruptR0);
    3786             AssertMsgRC(rc, ("%s::%s rc=%Rrc\n", pDevIns->pReg->pszR0Mod, pPicReg->pszGetInterruptR0, rc));
    3787         }
    3788         if (RT_FAILURE(rc))
    3789         {
    3790             LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    3791             return rc;
    3792         }
    3793         pVM->pdm.s.Pic.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    3794         Assert(pVM->pdm.s.Pic.pDevInsR0);
    3795     }
    3796     else
    3797     {
    3798         pVM->pdm.s.Pic.pfnSetIrqR0 = 0;
    3799         pVM->pdm.s.Pic.pfnGetInterruptR0 = 0;
    3800         pVM->pdm.s.Pic.pDevInsR0 = 0;
    3801     }
    3802 
    3803     /*
    3804      * R3 stuff.
     3707    AssertMsgReturn(pVM->pdm.s.Pic.pDevInsR3 == NULL, ("%s/%d: Only one PIC!\n", pDevIns->pReg->szName, pDevIns->iInstance),
     3708                    VERR_ALREADY_EXISTS);
     3709
     3710    /*
     3711     * Take down the callbacks and instance.
    38053712     */
    38063713    pVM->pdm.s.Pic.pDevInsR3 = pDevIns;
    3807     pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrqR3;
    3808     pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterruptR3;
     3714    pVM->pdm.s.Pic.pfnSetIrqR3 = pPicReg->pfnSetIrq;
     3715    pVM->pdm.s.Pic.pfnGetInterruptR3 = pPicReg->pfnGetInterrupt;
    38093716    Log(("PDM: Registered PIC device '%s'/%d pDevIns=%p\n", pDevIns->pReg->szName, pDevIns->iInstance, pDevIns));
    38103717
    38113718    /* set the helper pointer and return. */
    3812     *ppPicHlpR3 = &g_pdmR3DevPicHlp;
     3719    *ppPicHlp = &g_pdmR3DevPicHlp;
    38133720    LogFlow(("pdmR3DevHlp_PICRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
    38143721    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r81369 r81909  
    4545 */
    4646
    47 /** @interface_method_impl{PDMPICHLPR3,pfnSetInterruptFF} */
     47/** @interface_method_impl{PDMPICHLP,pfnSetInterruptFF} */
    4848static DECLCALLBACK(void) pdmR3PicHlp_SetInterruptFF(PPDMDEVINS pDevIns)
    4949{
    5050    PDMDEV_ASSERT_DEVINS(pDevIns);
    5151    PVM    pVM = pDevIns->Internal.s.pVMR3;
    52     PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     52    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
    5353
    5454    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     
    5959
    6060
    61 /** @interface_method_impl{PDMPICHLPR3,pfnClearInterruptFF} */
     61/** @interface_method_impl{PDMPICHLP,pfnClearInterruptFF} */
    6262static DECLCALLBACK(void) pdmR3PicHlp_ClearInterruptFF(PPDMDEVINS pDevIns)
    6363{
    6464    PDMDEV_ASSERT_DEVINS(pDevIns);
    6565    PVM pVM = pDevIns->Internal.s.pVMR3;
    66     PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     66    PVMCPU pVCpu = pVM->apCpusR3[0];  /* for PIC we always deliver to CPU 0, SMP uses APIC */
    6767
    6868    /* IRQ state should be loaded as-is by "LoadExec". Changes can be made from LoadDone. */
     
    7373
    7474
    75 /** @interface_method_impl{PDMPICHLPR3,pfnLock} */
     75/** @interface_method_impl{PDMPICHLP,pfnLock} */
    7676static DECLCALLBACK(int) pdmR3PicHlp_Lock(PPDMDEVINS pDevIns, int rc)
    7777{
     
    8181
    8282
    83 /** @interface_method_impl{PDMPICHLPR3,pfnUnlock} */
     83/** @interface_method_impl{PDMPICHLP,pfnUnlock} */
    8484static DECLCALLBACK(void) pdmR3PicHlp_Unlock(PPDMDEVINS pDevIns)
    8585{
     
    8989
    9090
    91 /** @interface_method_impl{PDMPICHLPR3,pfnGetRCHelpers} */
    92 static DECLCALLBACK(PCPDMPICHLPRC) pdmR3PicHlp_GetRCHelpers(PPDMDEVINS pDevIns)
    93 {
    94     PDMDEV_ASSERT_DEVINS(pDevIns);
    95     PVM pVM = pDevIns->Internal.s.pVMR3;
    96     VM_ASSERT_EMT(pVM);
    97 
    98     RTRCPTR pRCHelpers = NIL_RTRCPTR;
    99     if (VM_IS_RAW_MODE_ENABLED(pVM))
    100     {
    101         int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCPicHlp", &pRCHelpers);
    102         AssertReleaseRC(rc);
    103         AssertRelease(pRCHelpers);
    104     }
    105 
    106     LogFlow(("pdmR3PicHlp_GetRCHelpers: caller='%s'/%d: returns %RRv\n",
    107              pDevIns->pReg->szName, pDevIns->iInstance, pRCHelpers));
    108     return pRCHelpers;
    109 }
    110 
    111 
    112 /** @interface_method_impl{PDMPICHLPR3,pfnGetR0Helpers} */
    113 static DECLCALLBACK(PCPDMPICHLPR0) pdmR3PicHlp_GetR0Helpers(PPDMDEVINS pDevIns)
    114 {
    115     PDMDEV_ASSERT_DEVINS(pDevIns);
    116     PVM pVM = pDevIns->Internal.s.pVMR3;
    117     VM_ASSERT_EMT(pVM);
    118     PCPDMPICHLPR0 pR0Helpers = 0;
    119     int rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0PicHlp", &pR0Helpers);
    120     AssertReleaseRC(rc);
    121     AssertRelease(pR0Helpers);
    122     LogFlow(("pdmR3PicHlp_GetR0Helpers: caller='%s'/%d: returns %RHv\n",
    123              pDevIns->pReg->szName, pDevIns->iInstance, pR0Helpers));
    124     return pR0Helpers;
    125 }
    126 
    127 
    12891/**
    12992 * PIC Device Helpers.
    13093 */
    131 const PDMPICHLPR3 g_pdmR3DevPicHlp =
    132 {
    133     PDM_PICHLPR3_VERSION,
     94const PDMPICHLP g_pdmR3DevPicHlp =
     95{
     96    PDM_PICHLP_VERSION,
    13497    pdmR3PicHlp_SetInterruptFF,
    13598    pdmR3PicHlp_ClearInterruptFF,
    13699    pdmR3PicHlp_Lock,
    137100    pdmR3PicHlp_Unlock,
    138     pdmR3PicHlp_GetRCHelpers,
    139     pdmR3PicHlp_GetR0Helpers,
    140     PDM_PICHLPR3_VERSION /* the end */
     101    PDM_PICHLP_VERSION /* the end */
    141102};
    142103
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r81841 r81909  
    13881388extern const PDMDEVHLPR3    g_pdmR3DevHlpTrusted;
    13891389extern const PDMDEVHLPR3    g_pdmR3DevHlpUnTrusted;
    1390 extern const PDMPICHLPR3    g_pdmR3DevPicHlp;
     1390extern const PDMPICHLP      g_pdmR3DevPicHlp;
    13911391extern const PDMIOAPICHLPR3 g_pdmR3DevIoApicHlp;
    13921392extern const PDMFWHLPR3     g_pdmR3DevFirmwareHlp;
Note: See TracChangeset for help on using the changeset viewer.

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