VirtualBox

Changeset 12615 in vbox for trunk/src


Ignore:
Timestamp:
Sep 20, 2008 1:52:37 PM (16 years ago)
Author:
vboxsync
Message:

per-LAPIC timers, cleanup, all LAPICs state save-restore, relocation

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevAPIC.cpp

    r12612 r12615  
    203203    QEMUTimer *timer;
    204204    struct APICState *next_apic;
     205#else
     206     /** The APIC timer - R3 Ptr. */
     207    PTMTIMERR3      pTimerR3;
     208   
     209    /** The APIC timer - R0 Ptr. */
     210    PTMTIMERR0      pTimerR0;
     211   
     212    /** The APIC timer - RC Ptr. */
     213    PTMTIMERRC      pTimerRC;
     214   
     215    /** Alignment */
     216    uint32_t Alignment1;
    205217#endif /* VBOX */
    206218} APICState;
     
    245257typedef struct
    246258{
    247     /** @todo: APIC timer must be per-APIC */
    248259    /** The device instance - R3 Ptr. */
    249260    PPDMDEVINSR3    pDevInsR3;
    250261    /** The APIC helpers - R3 Ptr. */
    251262    PCPDMAPICHLPR3  pApicHlpR3;
    252     /** The APIC timer - R3 Ptr. */
    253     PTMTIMERR3      pTimerR3;
    254263    /** LAPICs states - R3 Ptr */
    255264    RTR3PTR         pLapicsR3;
     
    259268    /** The APIC helpers - R0 Ptr. */
    260269    PCPDMAPICHLPR0  pApicHlpR0;
    261     /** The APIC timer - R0 Ptr. */
    262     PTMTIMERR0      pTimerR0;
    263270    /** LAPICs states - R0 Ptr */
    264271    RTR0PTR         pLapicsR0;
     
    268275    /** The APIC helpers - RC Ptr. */
    269276    PCPDMAPICHLPRC  pApicHlpRC;
    270     /** The APIC timer - RC Ptr. */
    271     PTMTIMERRC      pTimerRC;
    272      /** LAPICs states - RC Ptr */
     277    /** LAPICs states - RC Ptr */
    273278    RTRCPTR         pLapicsRC;
     279   
     280    /** Alignment */
     281    uint32_t Alignment0;
    274282
    275283    /** Number of attempts made to optimize TPR accesses. */
     
    318326
    319327#ifdef VBOX
    320 static uint32_t apic_get_delivery_bitmask(APICDeviceInfo* dev, APICState *s, uint8_t dest, uint8_t dest_mode);
     328static uint32_t apic_get_delivery_bitmask(APICDeviceInfo* dev, uint8_t dest, uint8_t dest_mode);
    321329__BEGIN_DECLS
    322330PDMBOTHCBDECL(int)  apicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
     
    347355#else /* VBOX */
    348356static void apic_bus_deliver(APICDeviceInfo* dev,
    349                              APICState *s, uint32_t deliver_bitmask, uint8_t delivery_mode,
     357                             uint32_t deliver_bitmask, uint8_t delivery_mode,
    350358                             uint8_t vector_num, uint8_t polarity,
    351359                             uint8_t trigger_mode)
     
    550558{
    551559    APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    552     APICState *s = getLapic(dev);
    553     LogFlow(("apicBusDeliverCallback: s=%p pDevIns=%p u8Dest=%#x u8DestMode=%#x u8DeliveryMode=%#x iVector=%#x u8Polarity=%#x u8TriggerMode=%#x\n",
    554              s, pDevIns, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode));
    555     apic_bus_deliver(dev, s, apic_get_delivery_bitmask(dev, s, u8Dest, u8DestMode),
     560    LogFlow(("apicBusDeliverCallback: pDevIns=%p u8Dest=%#x u8DestMode=%#x u8DeliveryMode=%#x iVector=%#x u8Polarity=%#x u8TriggerMode=%#x\n",
     561             pDevIns, u8Dest, u8DestMode, u8DeliveryMode, iVector, u8Polarity, u8TriggerMode));
     562    apic_bus_deliver(dev, apic_get_delivery_bitmask(dev, u8Dest, u8DestMode),
    556563                     u8DeliveryMode, iVector, u8Polarity, u8TriggerMode);
    557564}
     
    699706static uint32_t apic_get_delivery_bitmask(uint8_t dest, uint8_t dest_mode)
    700707#else /* VBOX */
    701 static uint32_t apic_get_delivery_bitmask(APICDeviceInfo *dev, APICState *s, uint8_t dest, uint8_t dest_mode)
     708static uint32_t apic_get_delivery_bitmask(APICDeviceInfo *dev, uint8_t dest, uint8_t dest_mode)
    702709#endif /* VBOX */
    703710{
     
    799806            deliver_bitmask = apic_get_delivery_bitmask(dest, dest_mode);
    800807#else /* VBOX */
    801             deliver_bitmask = apic_get_delivery_bitmask(dev, s, dest, dest_mode);
     808            deliver_bitmask = apic_get_delivery_bitmask(dev, dest, dest_mode);
    802809#endif /* !VBOX */
    803810            break;
     
    859866                     trigger_mode);
    860867#else /* VBOX */
    861     apic_bus_deliver(dev, s, deliver_bitmask, delivery_mode, vector_num, polarity,
     868    apic_bus_deliver(dev, deliver_bitmask, delivery_mode, vector_num, polarity,
    862869                     trigger_mode);
    863870#endif /* VBOX */
     
    912919        s->count_shift;
    913920#else /* VBOX */
    914     d = (TMTimerGet(dev->CTX_SUFF(pTimer)) - s->initial_count_load_time) >>
     921    d = (TMTimerGet(s->CTX_SUFF(pTimer)) - s->initial_count_load_time) >>
    915922        s->count_shift;
    916923#endif /* VBOX */
     
    945952        qemu_mod_timer(s->timer, next_time);
    946953#else
    947         TMTimerSet(dev->CTX_SUFF(pTimer), next_time);
     954        TMTimerSet(s->CTX_SUFF(pTimer), next_time);
    948955#endif
    949956        s->next_time = next_time;
     
    953960        qemu_del_timer(s->timer);
    954961#else
    955         TMTimerStop(dev->CTX_SUFF(pTimer));
     962        TMTimerStop(s->CTX_SUFF(pTimer));
    956963#endif
    957964    }
     
    12041211                apic_timer_update(s, qemu_get_clock(vm_clock));
    12051212#else /* VBOX */
    1206                 apic_timer_update(dev, s, TMTimerGet(dev->CTX_SUFF(pTimer)));
     1213                apic_timer_update(dev, s, TMTimerGet(s->CTX_SUFF(pTimer)));
    12071214#endif /* VBOX*/
    12081215        }
     
    12131220        s->initial_count_load_time = qemu_get_clock(vm_clock);
    12141221#else /* VBOX */
    1215         s->initial_count_load_time = TMTimerGet(dev->CTX_SUFF(pTimer));
     1222        s->initial_count_load_time = TMTimerGet(s->CTX_SUFF(pTimer));
    12161223#endif /* VBOX*/
    12171224        apic_timer_update(dev, s, s->initial_count_load_time);
     
    12721279    qemu_put_be64s(f, &s->initial_count_load_time);
    12731280    qemu_put_be64s(f, &s->next_time);
     1281
     1282#ifdef VBOX
     1283    TMR3TimerSave(s->CTX_SUFF(pTimer), f);
     1284#endif
    12741285}
    12751286
     
    13101321    qemu_get_be64s(f, (uint64_t *)&s->initial_count_load_time);
    13111322    qemu_get_be64s(f, (uint64_t *)&s->next_time);
    1312     return 0;
     1323
     1324#ifdef VBOX
     1325    TMR3TimerLoad(s->CTX_SUFF(pTimer), f);
     1326#endif
     1327
     1328    return VINF_SUCCESS;
    13131329}
    13141330#ifndef VBOX
     
    17281744    foreach_apic(dev, 0xffffffff, apic_save(pSSMHandle, apic));
    17291745
    1730     return TMR3TimerSave(dev->CTX_SUFF(pTimer), pSSMHandle);
     1746    return VINF_SUCCESS;
    17311747}
    17321748
     
    17451761                 }
    17461762                 );
    1747     return TMR3TimerLoad(dev->CTX_SUFF(pTimer), pSSMHandle);
     1763    return VINF_SUCCESS;
    17481764}
    17491765
     
    17541770{
    17551771    APICDeviceInfo* dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
     1772    APICState *s = getLapic(dev);
     1773
    17561774    dev->pApicHlpR3->pfnLock(pDevIns, VERR_INTERNAL_ERROR);
    17571775
    1758     TMTimerStop(dev->CTX_SUFF(pTimer));
    1759 
    1760      /* @todo: process all LAPICS? Or only one? */
    1761     APICState* s = LAPIC_BASE(dev);
     1776    TMTimerStop(s->CTX_SUFF(pTimer));
    17621777
    17631778    apic_init_ipi(s);
     
    17781793static DECLCALLBACK(void) apicRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    17791794{
    1780     APICDeviceInfo *pThis = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
     1795    APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    17811796   
    1782     pThis->pDevInsRC  = PDMDEVINS_2_RCPTR(pDevIns);
    1783     pThis->pApicHlpRC = pThis->pApicHlpR3->pfnGetRCHelpers(pDevIns);
    1784     pThis->pTimerRC   = TMTimerRCPtr(pThis->CTX_SUFF(pTimer));
     1797    dev->pDevInsRC  = PDMDEVINS_2_RCPTR(pDevIns);
     1798    dev->pApicHlpRC = dev->pApicHlpR3->pfnGetRCHelpers(pDevIns);
     1799    /** @todo: check if relocated pLapicsRC right */
     1800    dev->pLapicsRC  = MMHyperR3ToR0(PDMDevHlpGetVM(pDevIns), dev->pLapicsR3);
     1801    foreach_apic(dev, 0xffffffff,
     1802                 apic->pTimerRC = TMTimerRCPtr(apic->CTX_SUFF(pTimer)));
    17851803}
    17861804
     
    18091827    APICDeviceInfo  *pThis = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    18101828    uint32_t        cCpus;
     1829    APICState       *apic;
    18111830
    18121831    /*
     
    18651884    pThis->pLapicsRC = MMHyperR3ToRC(pVM, pThis->pLapicsR3);
    18661885   
    1867     for (i = 0; i < cCpus; i++)
     1886    for (i = 0, apic = LAPIC_BASE(pThis); i < cCpus; i++)
    18681887    {
    1869         initApicData((APICState*)pThis->pLapicsR3 + i, i);
     1888        initApicData(apic, i);
     1889        apic++;
    18701890    }
    18711891
     
    19731993
    19741994    /*
    1975      * Create the APIC timer.
     1995     * Create the APIC timers.
    19761996     */
    1977     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicTimer,
    1978                                 "APIC Timer", &pThis->CTX_SUFF(pTimer));
    1979     if (RT_FAILURE(rc))
    1980         return rc;
    1981     pThis->pTimerR0 = TMTimerR0Ptr(pThis->CTX_SUFF(pTimer));
    1982     pThis->pTimerRC = TMTimerRCPtr(pThis->CTX_SUFF(pTimer));
     1997    for (i = 0, apic = LAPIC_BASE(pThis); i < cCpus; i++)
     1998    {
     1999        rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicTimer,
     2000                                    "APIC Timer", &apic->pTimerR3);
     2001        if (RT_FAILURE(rc))
     2002            return rc;
     2003        apic->pTimerR0 = TMTimerR0Ptr(apic->pTimerR3);
     2004        apic->pTimerRC = TMTimerRCPtr(apic->pTimerR3);
     2005        apic++;
     2006    }
    19832007
    19842008    /*
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp

    r12588 r12615  
    567567    GEN_CHECK_OFF(APICState, initial_count_load_time);
    568568    GEN_CHECK_OFF(APICState, next_time);
     569    GEN_CHECK_OFF(APICState, pTimerR3);
     570    GEN_CHECK_OFF(APICState, pTimerR0);
     571    GEN_CHECK_OFF(APICState, pTimerRC);
    569572
    570573    GEN_CHECK_SIZE(APICDeviceInfo);
    571574    GEN_CHECK_OFF(APICDeviceInfo, pDevInsR3);
    572575    GEN_CHECK_OFF(APICDeviceInfo, pApicHlpR3);
    573     GEN_CHECK_OFF(APICDeviceInfo, pTimerR3);
    574576    GEN_CHECK_OFF(APICDeviceInfo, pDevInsR0);
    575577    GEN_CHECK_OFF(APICDeviceInfo, pApicHlpR0);
    576     GEN_CHECK_OFF(APICDeviceInfo, pTimerR0);
    577578    GEN_CHECK_OFF(APICDeviceInfo, pDevInsRC);
    578579    GEN_CHECK_OFF(APICDeviceInfo, pApicHlpRC);
    579     GEN_CHECK_OFF(APICDeviceInfo, pTimerRC);
    580580    GEN_CHECK_OFF(APICDeviceInfo, ulTPRPatchAttempts);
    581581#ifdef VBOX_WITH_STATISTICS
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