VirtualBox

Changeset 64415 in vbox for trunk


Ignore:
Timestamp:
Oct 25, 2016 3:01:40 PM (8 years ago)
Author:
vboxsync
Message:

DevPci: Working on merging ICH9PCIGLOBALS and PCIGLOBALS.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevPCI.cpp

    r64414 r64415  
    9999typedef struct PCIGLOBALS
    100100{
     101    /** PCI bus which is attached to the host-to-PCI bridge.
     102     * This must come first!  */
     103    DEVPCIBUS           PciBus;
     104
     105    /** R3 pointer to the device instance. */
     106    PPDMDEVINSR3        pDevInsR3;
     107    /** R0 pointer to the device instance. */
     108    PPDMDEVINSR0        pDevInsR0;
     109    /** RC pointer to the device instance. */
     110    PPDMDEVINSRC        pDevInsRC;
     111
     112    /** I/O APIC usage flag */
     113    bool                fUseIoApic;
     114    /** Reserved for future config flags. */
     115    bool                afFutureFlags[3];
     116
     117    /** Value latched in Configuration Address Port (0CF8h) */
     118    uint32_t            uConfigReg;
     119    /** ACPI IRQ level */
     120    uint32_t            acpi_irq_level;
     121    /** ACPI PIC IRQ */
     122    int                 acpi_irq;
     123    uint32_t            u32Alignment;
     124
     125    /** I/O APIC irq levels */
     126    volatile uint32_t   uaPciApicIrqLevels[PCI_APIC_IRQ_PINS];
     127
    101128    /** Irq levels for the four PCI Irqs.
    102      * These count how many devices asserted the IRQ line. If greater 0 an IRQ is
    103      * sent to the guest.  If it drops to 0 the IRQ is deasserted.
     129     * These count how many devices asserted the IRQ line.  If greater 0 an IRQ
     130     * is sent to the guest.  If it drops to 0 the IRQ is deasserted.
    104131     */
    105132    volatile uint32_t   pci_irq_levels[PCI_IRQ_PINS];
     133
     134    /** ISA bridge state. */
     135    PIIX3               PIIX3State;
    106136
    107137#if 1 /* Will be moved into the BIOS "soon". */
     
    112142    /** Actual bus number. */
    113143    uint8_t             uBus;
    114     uint8_t             uAlignment0[2];
     144    uint8_t             uAlignment0[7];
    115145#endif
    116 
    117     /** I/O APIC usage flag */
    118     bool                fUseIoApic;
    119     /** I/O APIC irq levels */
    120     volatile uint32_t   uaPciApicIrqLevels[PCI_APIC_IRQ_PINS];
    121     /** ACPI IRQ level */
    122     uint32_t            acpi_irq_level;
    123     /** ACPI PIC IRQ */
    124     int                 acpi_irq;
    125     /** Value latched in Configuration Address Port (0CF8h) */
    126     uint32_t            uConfigReg;
    127 
    128     /** R3 pointer to the device instance. */
    129     PPDMDEVINSR3        pDevInsR3;
    130     /** R0 pointer to the device instance. */
    131     PPDMDEVINSR0        pDevInsR0;
    132     /** RC pointer to the device instance. */
    133     PPDMDEVINSRC        pDevInsRC;
    134 
    135 #if HC_ARCH_BITS == 64
    136     uint32_t            Alignment0;
    137 #endif
    138 
    139     /** ISA bridge state. */
    140     PIIX3               PIIX3State;
    141     /** PCI bus which is attached to the host-to-PCI bridge. */
    142     DEVPCIBUS           PciBus;
    143146
    144147} PCIGLOBALS;
    145148/** Pointer to per VM data. */
    146149typedef PCIGLOBALS *PPCIGLOBALS;
     150
    147151
    148152
     
    20022006     */
    20032007    PPCIGLOBALS pGlobals = PDMINS_2_DATA(pDevIns, PPCIGLOBALS);
    2004     pGlobals->uPciBiosIo    = 0xc000;
    2005     pGlobals->uPciBiosMmio   = 0xf0000000;
     2008    pGlobals->uPciBiosIo   = 0xc000;
     2009    pGlobals->uPciBiosMmio = 0xf0000000;
    20062010    memset((void *)&pGlobals->pci_irq_levels, 0, sizeof(pGlobals->pci_irq_levels));
    2007     pGlobals->fUseIoApic          = fUseIoApic;
     2011    pGlobals->fUseIoApic   = fUseIoApic;
    20082012    memset((void *)&pGlobals->uaPciApicIrqLevels, 0, sizeof(pGlobals->uaPciApicIrqLevels));
    20092013
     
    20122016    pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    20132017
     2018    pGlobals->PciBus.fTypePiix3  = true;
     2019    pGlobals->PciBus.fTypeIch9   = false;
     2020    pGlobals->PciBus.fPureBridge = false;
    20142021    pGlobals->PciBus.pDevInsR3 = pDevIns;
    20152022    pGlobals->PciBus.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    20162023    pGlobals->PciBus.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    2017     pGlobals->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns,   sizeof(PPDMPCIDEV)
    2018                                                                                  * RT_ELEMENTS(pGlobals->PciBus.apDevices));
     2024    pGlobals->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns,
     2025                                                                        sizeof(PPDMPCIDEV)
     2026                                                                        * RT_ELEMENTS(pGlobals->PciBus.apDevices));
     2027    AssertLogRelReturn(pGlobals->PciBus.papBridgesR3, VERR_NO_MEMORY);
     2028
    20192029
    20202030    PDMPCIBUSREG PciBusReg;
     
    23642374     */
    23652375    PPCIBUS pBus = PDMINS_2_DATA(pDevIns, PPCIBUS);
     2376    pBus->fTypePiix3  = true;
     2377    pBus->fTypeIch9   = false;
     2378    pBus->fPureBridge = true;
    23662379    pBus->pDevInsR3 = pDevIns;
    23672380    pBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    23682381    pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    23692382    pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices));
     2383    AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY);
    23702384
    23712385    PDMPCIBUSREG PciBusReg;
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r64414 r64415  
    6666typedef struct
    6767{
     68    /** PCI bus which is attached to the host-to-PCI bridge.
     69     * This must come first so we can share more code with the bridges!  */
     70    DEVPCIBUS           PciBus;
     71
    6872    /** R3 pointer to the device instance. */
    6973    PPDMDEVINSR3        pDevInsR3;
     
    7377    PPDMDEVINSRC        pDevInsRC;
    7478
     79    /** I/O APIC usage flag (always true of ICH9, see constructor). */
     80    bool                fUseIoApic;
     81    /** Reserved for future config flags. */
     82    bool                afFutureFlags[3];
     83    /** Physical address of PCI config space MMIO region. */
     84    uint64_t            u64PciConfigMMioAddress;
     85    /** Length of PCI config space MMIO region. */
     86    uint64_t            u64PciConfigMMioLength;
     87
     88    /** I/O APIC irq levels */
     89    volatile uint32_t   uaPciApicIrqLevels[PCI_APIC_IRQ_PINS];
    7590    /** Value latched in Configuration Address Port (0CF8h) */
    7691    uint32_t            uConfigReg;
    7792
    78     /** I/O APIC irq levels */
    79     volatile uint32_t   uaPciApicIrqLevels[PCI_APIC_IRQ_PINS];
    80 
    8193#if 1 /* Will be moved into the BIOS "soon". */
     94    /** Current bus number (?). */
     95    uint8_t             uPciBiosBus;
     96    uint8_t             Alignment0[3];
    8297    /** The next I/O port address which the PCI BIOS will use. */
    8398    uint32_t            uPciBiosIo;
     
    86101    /** The next 64-bit MMIO address which the PCI BIOS will use. */
    87102    uint64_t            uPciBiosMmio64;
    88     /** Actual bus number. */
    89     uint8_t             uBus;
    90     uint8_t             Alignment0[7];
    91103#endif
    92     /** Physical address of PCI config space MMIO region. */
    93     uint64_t            u64PciConfigMMioAddress;
    94     /** Length of PCI config space MMIO region. */
    95     uint64_t            u64PciConfigMMioLength;
    96 
    97     /** PCI bus which is attached to the host-to-PCI bridge. */
    98     DEVPCIBUS           PciBus;
     104
    99105} ICH9PCIGLOBALS, *PICH9PCIGLOBALS;
    100106
     
    16881694        case 0x0604:
    16891695            /* PCI-to-PCI bridge. */
    1690             AssertMsg(pGlobals->uBus < 255, ("Too many bridges on the bus\n"));
     1696            AssertMsg(pGlobals->uPciBiosBus < 255, ("Too many bridges on the bus\n"));
    16911697            ich9pciBiosInitBridge(pGlobals, uBus, uDevFn);
    16921698            break;
     
    18861892                  ("Device is not a PCI bridge but on the list of PCI bridges\n"));
    18871893        PICH9PCIBUS pChildBus = PDMINS_2_DATA(pBridge->Int.s.CTX_SUFF(pDevIns), PICH9PCIBUS);
    1888         pGlobals->uBus++;
    1889         ich9pciInitBridgeTopology(pGlobals, pChildBus, uBusSecondary, pGlobals->uBus);
    1890     }
    1891     PCIDevSetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uBus);
     1894        pGlobals->uPciBiosBus++;
     1895        ich9pciInitBridgeTopology(pGlobals, pChildBus, uBusSecondary, pGlobals->uPciBiosBus);
     1896    }
     1897    PCIDevSetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uPciBiosBus);
    18921898    Log2(("ich9pciInitBridgeTopology: for bus %p: primary=%d secondary=%d subordinate=%d\n",
    18931899          pBus,
     
    19091915     * Set the start addresses.
    19101916     */
     1917    pGlobals->uPciBiosBus    = 0;
    19111918    pGlobals->uPciBiosIo     = 0xd000;
    19121919    pGlobals->uPciBiosMmio   = cbBelow4GB;
    19131920    pGlobals->uPciBiosMmio64 = cbAbove4GB + _4G;
    1914     pGlobals->uBus = 0;
    19151921
    19161922    /* NB: Assume that if MMIO range is enabled, it is at the bottom of the memory hole. */
     
    24162422                                N_("Configuration error: Failed to read \"McfgLength\""));
    24172423
     2424    pGlobals->fUseIoApic = fUseIoApic;
    24182425    pGlobals->pDevInsR3 = pDevIns;
    24192426    pGlobals->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    24202427    pGlobals->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    24212428
     2429    pGlobals->PciBus.fTypePiix3  = false;
     2430    pGlobals->PciBus.fTypeIch9   = true;
     2431    pGlobals->PciBus.fPureBridge = false;
    24222432    pGlobals->PciBus.pDevInsR3 = pDevIns;
    24232433    pGlobals->PciBus.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    24242434    pGlobals->PciBus.pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    24252435    pGlobals->PciBus.papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pGlobals->PciBus.apDevices));
     2436    AssertLogRelReturn(pGlobals->PciBus.papBridgesR3, VERR_NO_MEMORY);
    24262437
    24272438    /*
     
    26792690     */
    26802691    PICH9PCIBUS pBus = PDMINS_2_DATA(pDevIns, PICH9PCIBUS);
     2692    pBus->fTypePiix3  = false;
     2693    pBus->fTypeIch9   = true;
     2694    pBus->fPureBridge = true;
    26812695    pBus->pDevInsR3 = pDevIns;
    26822696    pBus->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    26832697    pBus->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    26842698    pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices));
     2699    AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY);
    26852700
    26862701    PDMPCIBUSREG PciBusReg;
  • trunk/src/VBox/Devices/Bus/DevPciInternal.h

    r64414 r64415  
    3636    /** Start device number - always zero (only for DevPCI source compat). */
    3737    uint32_t                iDevSearch;
    38     /** Size alignemnt padding. */
    39     uint32_t                u32Alignment0;
     38    /** Set if PIIX3 type. */
     39    uint32_t                fTypePiix3 : 1;
     40    /** Set if ICH9 type. */
     41    uint32_t                fTypeIch9: 1;
     42    /** Set if this is a pure bridge, i.e. not part of DEVPCIGLOBALS struct. */
     43    uint32_t                fPureBridge : 1;
     44    uint32_t                uUnused : 29;
    4045
    4146    /** R3 pointer to the device instance. */
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r64414 r64415  
    219219    GEN_CHECK_OFF(ICH9PCIGLOBALS, uaPciApicIrqLevels);
    220220    GEN_CHECK_OFF(ICH9PCIGLOBALS, uaPciApicIrqLevels[1]);
     221    GEN_CHECK_OFF(ICH9PCIGLOBALS, uPciBiosBus);
    221222    GEN_CHECK_OFF(ICH9PCIGLOBALS, uPciBiosIo);
    222223    GEN_CHECK_OFF(ICH9PCIGLOBALS, uPciBiosMmio);
    223224    GEN_CHECK_OFF(ICH9PCIGLOBALS, uPciBiosMmio64);
    224     GEN_CHECK_OFF(ICH9PCIGLOBALS, uBus);
    225225    GEN_CHECK_OFF(ICH9PCIGLOBALS, u64PciConfigMMioAddress);
    226226    GEN_CHECK_OFF(ICH9PCIGLOBALS, u64PciConfigMMioLength);
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