Changeset 20087 in vbox
- Timestamp:
- May 27, 2009 2:31:18 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 47833
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/iom.h
r19993 r20087 269 269 270 270 VMMR3DECL(void) IOMR3ReleaseOwnedLocks(PVM pVM); 271 VMMR3DECL(PPDMCRITSECT) IOMR3GetCritSect(PVM pVM); 271 272 272 273 /** @} */ -
trunk/include/VBox/pdmcritsect.h
r20008 r20087 54 54 #endif 55 55 } PDMCRITSECT; 56 /** Pointer to a PDM critical section. */57 typedef PDMCRITSECT *PPDMCRITSECT;58 /** Pointer to a const PDM critical section. */59 typedef const PDMCRITSECT *PCPDMCRITSECT;60 56 61 57 VMMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, const char *pszName); … … 69 65 VMMDECL(bool) PDMCritSectIsInitialized(PCPDMCRITSECT pCritSect); 70 66 VMMDECL(uint32_t) PDMCritSectGetRecursion(PCPDMCRITSECT pCritSect); 67 VMMR3DECL(const char *) PDMR3CritSectName(PCPDMCRITSECT pCritSect); 71 68 VMMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal); 72 69 VMMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect); -
trunk/include/VBox/pdmdev.h
r20056 r20087 1303 1303 */ 1304 1304 DECLR3CALLBACKMEMBER(void, pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector)); 1305 1306 /** 1307 * Sends init IPI to given virtual CPU, should result in reset and 1305 1306 /** 1307 * Sends init IPI to given virtual CPU, should result in reset and 1308 1308 * halting till SIPI. 1309 1309 * … … 1951 1951 * @param enmClock The clock to use on this timer. 1952 1952 * @param pfnCallback Callback function. 1953 * @param pvUser User argument for the callback. 1954 * @param fFlags Flags, see TMTIMER_FLAGS_*. 1953 1955 * @param pszDesc Pointer to description string which must stay around 1954 1956 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()). 1955 1957 * @param ppTimer Where to store the timer on success. 1956 1958 */ 1957 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer));1959 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)); 1958 1960 1959 1961 /** … … 3463 3465 * @copydoc PDMDEVHLPR3::pfnTMTimerCreate 3464 3466 */ 3465 DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer) 3466 { 3467 return pDevIns->pDevHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pszDesc, ppTimer); 3467 DECLINLINE(int) PDMDevHlpTMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, 3468 const char *pszDesc, PPTMTIMERR3 ppTimer) 3469 { 3470 return pDevIns->pDevHlpR3->pfnTMTimerCreate(pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer); 3468 3471 } 3469 3472 -
trunk/include/VBox/tm.h
r19821 r20087 73 73 74 74 75 /** @defgroup grp_tm_timer_flags Timer flags. 76 * @{ */ 77 /** Use the default critical section for the class of timers. 78 * Only devices have one at the moment. */ 79 #define TMTIMER_FLAGS_DEFAULT_CRIT_SECT 0 80 /** No critical section needed or a custom one is set using 81 * TMR3TimerSetCritSect(). */ 82 #define TMTIMER_FLAGS_NO_CRIT_SECT RT_BIT_32(0) 83 /** @} */ 84 85 75 86 VMMDECL(void) TMNotifyStartOfExecution(PVMCPU pVCpu); 76 87 VMMDECL(void) TMNotifyEndOfExecution(PVMCPU pVCpu); … … 132 143 * @param pDevIns Device instance of the device which registered the timer. 133 144 * @param pTimer The timer handle. 134 */ 135 typedef DECLCALLBACK(void) FNTMTIMERDEV(PPDMDEVINS pDevIns, PTMTIMER pTimer); 145 * @param pvUser User argument specified upon timer creation. 146 */ 147 typedef DECLCALLBACK(void) FNTMTIMERDEV(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 136 148 /** Pointer to a device timer callback function. */ 137 149 typedef FNTMTIMERDEV *PFNTMTIMERDEV; … … 218 230 VMMR3DECL(void) TMR3Reset(PVM pVM); 219 231 VMMR3DECL(int) TMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue); 220 VMMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer);232 VMMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer); 221 233 VMMR3DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer); 222 234 VMMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer); … … 227 239 VMMR3DECL(int) TMR3TimerSave(PTMTIMERR3 pTimer, PSSMHANDLE pSSM); 228 240 VMMR3DECL(int) TMR3TimerLoad(PTMTIMERR3 pTimer, PSSMHANDLE pSSM); 241 VMMR3DECL(int) TMR3TimerSetCritSect(PTMTIMERR3 pTimer, PPDMCRITSECT pCritSect); 229 242 VMMR3DECL(void) TMR3TimerQueuesDo(PVM pVM); 230 243 VMMR3DECL(void) TMR3VirtualSyncFF(PVM pVM, PVMCPU pVCpu); -
trunk/include/VBox/types.h
r19405 r20087 203 203 /** Pointer to a pointer to a PDM Service Instance. */ 204 204 typedef PPDMSRVINS *PPPDMSRVINS; 205 206 /** Pointer to a PDM critical section. */ 207 typedef union PDMCRITSECT *PPDMCRITSECT; 208 /** Pointer to a const PDM critical section. */ 209 typedef const union PDMCRITSECT *PCPDMCRITSECT; 205 210 206 211 /** R3 pointer to a timer. */ -
trunk/include/VBox/vusb.h
r15076 r20087 779 779 /** 780 780 * USB Timer Interface. 781 * @todo r=bird: why is this code still here? 781 782 */ 782 783 typedef struct VUSBITIMER -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r18645 r20087 280 280 } 281 281 #else /* VBOX */ 282 static DECLCALLBACK(void) sb16Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer )283 { 284 SB16State *s = PDMINS_2_DATA(pDevIns, SB16State *);282 static DECLCALLBACK(void) sb16Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvThis) 283 { 284 SB16State *s = (SB16State *)pvThis; 285 285 s->can_write = 1; 286 286 PDMDevHlpISASetIrq(s->pDevIns, s->irq, 1); … … 1795 1795 * Create timer, register & attach stuff. 1796 1796 */ 1797 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, sb16Timer, "SB16 timer", &s->pTimer); 1797 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, sb16Timer, s, 1798 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "SB16 timer", &s->pTimer); 1798 1799 if (RT_FAILURE(rc)) 1799 1800 AssertMsgFailedReturn(("pfnTMTimerCreate -> %Rrc\n", rc), rc); -
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r19844 r20087 5071 5071 5072 5072 5073 static DECLCALLBACK(void) vgaTimerRefresh(PPDMDEVINS pDevIns, PTMTIMER pTimer )5074 { 5075 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);5073 static DECLCALLBACK(void) vgaTimerRefresh(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 5074 { 5075 PVGASTATE pThis = (PVGASTATE)pvUser; 5076 5076 5077 5077 if (pThis->pDrv) … … 5783 5783 * Create the refresh timer. 5784 5784 */ 5785 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, vgaTimerRefresh, "VGA Refresh Timer", &pThis->RefreshTimer); 5785 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, vgaTimerRefresh, 5786 pThis, TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo This needs to be fixed! We cannot take the I/O lock at this point! */ 5787 "VGA Refresh Timer", &pThis->RefreshTimer); 5786 5788 if (RT_FAILURE(rc)) 5787 5789 return rc; -
trunk/src/VBox/Devices/Network/DevE1000.cpp
r19840 r20087 2466 2466 * @param pDevIns Pointer to device instance structure. 2467 2467 * @param pTimer Pointer to the timer. 2468 * @thread EMT 2469 */ 2470 static DECLCALLBACK(void) e1kTxIntDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2471 { 2472 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2468 * @param pvUser NULL. 2469 * @thread EMT 2470 */ 2471 static DECLCALLBACK(void) e1kTxIntDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2472 { 2473 E1KSTATE *pState = (E1KSTATE *)pvUser; 2473 2474 2474 2475 if (RT_LIKELY(e1kMutexAcquire(pState, VERR_SEM_BUSY, RT_SRC_POS) == VINF_SUCCESS)) … … 2491 2492 * @param pDevIns Pointer to device instance structure. 2492 2493 * @param pTimer Pointer to the timer. 2493 * @thread EMT 2494 */ 2495 static DECLCALLBACK(void) e1kTxAbsDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2496 { 2497 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2494 * @param pvUser NULL. 2495 * @thread EMT 2496 */ 2497 static DECLCALLBACK(void) e1kTxAbsDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2498 { 2499 E1KSTATE *pState = (E1KSTATE *)pvUser; 2498 2500 2499 2501 if (RT_LIKELY(e1kMutexAcquire(pState, VERR_SEM_BUSY, RT_SRC_POS) == VINF_SUCCESS)) … … 2516 2518 * @param pDevIns Pointer to device instance structure. 2517 2519 * @param pTimer Pointer to the timer. 2518 * @thread EMT 2519 */ 2520 static DECLCALLBACK(void) e1kRxIntDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2521 { 2522 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2520 * @param pvUser NULL. 2521 * @thread EMT 2522 */ 2523 static DECLCALLBACK(void) e1kRxIntDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2524 { 2525 E1KSTATE *pState = (E1KSTATE *)pvUser; 2523 2526 2524 2527 if (RT_LIKELY(e1kMutexAcquire(pState, VERR_SEM_BUSY, RT_SRC_POS) == VINF_SUCCESS)) … … 2539 2542 * @param pDevIns Pointer to device instance structure. 2540 2543 * @param pTimer Pointer to the timer. 2541 * @thread EMT 2542 */ 2543 static DECLCALLBACK(void) e1kRxAbsDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2544 { 2545 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2544 * @param pvUser NULL. 2545 * @thread EMT 2546 */ 2547 static DECLCALLBACK(void) e1kRxAbsDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2548 { 2549 E1KSTATE *pState = (E1KSTATE *)pvUser; 2546 2550 2547 2551 if (RT_LIKELY(e1kMutexAcquire(pState, VERR_SEM_BUSY, RT_SRC_POS) == VINF_SUCCESS)) … … 2561 2565 * @param pDevIns Pointer to device instance structure. 2562 2566 * @param pTimer Pointer to the timer. 2563 * @thread EMT 2564 */ 2565 static DECLCALLBACK(void) e1kLateIntTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2566 { 2567 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2567 * @param pvUser NULL. 2568 * @thread EMT 2569 */ 2570 static DECLCALLBACK(void) e1kLateIntTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2571 { 2572 E1KSTATE *pState = (E1KSTATE *)pvUser; 2568 2573 2569 2574 STAM_PROFILE_ADV_START(&pState->StatLateIntTimer, a); … … 2587 2592 * @param pDevIns Pointer to device instance structure. 2588 2593 * @param pTimer Pointer to the timer. 2589 * @thread EMT 2590 */ 2591 static DECLCALLBACK(void) e1kLinkUpTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 2592 { 2593 E1KSTATE *pState = PDMINS_2_DATA(pDevIns, E1KSTATE *); 2594 * @param pvUser NULL. 2595 * @thread EMT 2596 */ 2597 static DECLCALLBACK(void) e1kLinkUpTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2598 { 2599 E1KSTATE *pState = (E1KSTATE *)pvUser; 2594 2600 2595 2601 if (RT_LIKELY(e1kMutexAcquire(pState, VERR_SEM_BUSY, RT_SRC_POS) == VINF_SUCCESS)) … … 4812 4818 #ifdef E1K_USE_TX_TIMERS 4813 4819 /* Create Transmit Interrupt Delay Timer */ 4814 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kTxIntDelayTimer, 4820 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kTxIntDelayTimer, pState, 4821 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4815 4822 "E1000 Transmit Interrupt Delay Timer", &pState->pTIDTimerR3); 4816 4823 if (RT_FAILURE(rc)) … … 4821 4828 # ifndef E1K_NO_TAD 4822 4829 /* Create Transmit Absolute Delay Timer */ 4823 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kTxAbsDelayTimer, 4830 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kTxAbsDelayTimer, pState, 4831 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4824 4832 "E1000 Transmit Absolute Delay Timer", &pState->pTADTimerR3); 4825 4833 if (RT_FAILURE(rc)) … … 4832 4840 #ifdef E1K_USE_RX_TIMERS 4833 4841 /* Create Receive Interrupt Delay Timer */ 4834 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kRxIntDelayTimer, 4842 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kRxIntDelayTimer, pState, 4843 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4835 4844 "E1000 Receive Interrupt Delay Timer", &pState->pRIDTimerR3); 4836 4845 if (RT_FAILURE(rc)) … … 4840 4849 4841 4850 /* Create Receive Absolute Delay Timer */ 4842 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kRxAbsDelayTimer, 4851 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kRxAbsDelayTimer, pState, 4852 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4843 4853 "E1000 Receive Absolute Delay Timer", &pState->pRADTimerR3); 4844 4854 if (RT_FAILURE(rc)) … … 4849 4859 4850 4860 /* Create Late Interrupt Timer */ 4851 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kLateIntTimer, 4861 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kLateIntTimer, pState, 4862 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4852 4863 "E1000 Late Interrupt Timer", &pState->pIntTimerR3); 4853 4864 if (RT_FAILURE(rc)) … … 4857 4868 4858 4869 /* Create Link Up Timer */ 4859 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kLinkUpTimer, 4870 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, e1kLinkUpTimer, pState, 4871 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, /** @todo check locking here. */ 4860 4872 "E1000 Link Up Timer", &pState->pLUTimer); 4861 4873 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/Network/DevINIP.cpp
r17802 r20087 146 146 * @param pTimer Pointer to timer. 147 147 */ 148 static DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer )149 { 150 PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);148 static DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 149 { 150 PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser; 151 151 LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer)); 152 152 lwip_etharp_tmr(); … … 161 161 * @param pTimer Pointer to timer. 162 162 */ 163 static DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer )164 { 165 PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);163 static DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 164 { 165 PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser; 166 166 LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer)); 167 167 lwip_tcp_fasttmr(); … … 176 176 * @param pTimer Pointer to timer. 177 177 */ 178 static DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer )179 { 180 PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);178 static DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 179 { 180 PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser; 181 181 LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer)); 182 182 lwip_tcp_slowtmr(); … … 590 590 lwip_pbuf_init(); 591 591 lwip_netif_init(); 592 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPARPTimer, "lwIP ARP", &pThis->ARPTimer); 593 if (RT_FAILURE(rc)) 594 goto out; 595 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPFastTimer, "lwIP fast TCP", &pThis->TCPFastTimer); 592 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPARPTimer, pThis, 593 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP ARP", &pThis->ARPTimer); 594 if (RT_FAILURE(rc)) 595 goto out; 596 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPFastTimer, pThis, 597 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP fast TCP", &pThis->TCPFastTimer); 596 598 if (RT_FAILURE(rc)) 597 599 goto out; 598 600 TMTimerSetMillies(pThis->TCPFastTimer, TCP_FAST_INTERVAL); 599 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPSlowTimer, "lwIP slow TCP", &pThis->TCPSlowTimer); 601 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPSlowTimer, pThis, 602 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP slow TCP", &pThis->TCPSlowTimer); 600 603 if (RT_FAILURE(rc)) 601 604 goto out; -
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r19113 r20087 3802 3802 * @thread EMT 3803 3803 */ 3804 static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 3805 { 3806 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3807 int rc; 3808 3804 static DECLCALLBACK(void) pcnetTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3805 { 3806 PCNetState *pThis = (PCNetState *)pvUser; 3809 3807 STAM_PROFILE_ADV_START(&pThis->StatTimer, a); 3810 rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);3811 AssertReleaseRC(rc);3812 3813 3808 pcnetPollTimer(pThis); 3814 3815 PDMCritSectLeave(&pThis->CritSect);3816 3809 STAM_PROFILE_ADV_STOP(&pThis->StatTimer, a); 3817 3810 } … … 3825 3818 * @thread EMT 3826 3819 */ 3827 static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer) 3828 { 3829 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3830 3820 static DECLCALLBACK(void) pcnetTimerSoftInt(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3821 { 3822 PCNetState *pThis = (PCNetState *)pvUser; 3823 3824 /** @todo why aren't we taking any critsect here?!? */ 3831 3825 pThis->aCSR[7] |= 0x0800; /* STINT */ 3832 3826 pcnetUpdateIrq(pThis); … … 3845 3839 * @param pTimer The timer handle. 3846 3840 */ 3847 static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer )3841 static DECLCALLBACK(void) pcnetTimerRestore(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3848 3842 { 3849 3843 PCNetState *pThis = PDMINS_2_DATA(pDevIns, PCNetState *); 3850 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 3851 AssertReleaseRC(rc); 3852 3853 rc = VERR_GENERAL_FAILURE; 3844 3845 int rc = VERR_GENERAL_FAILURE; 3854 3846 if (pThis->cLinkDownReported <= PCNET_MAX_LINKDOWN_REPORTED) 3855 3847 rc = TMTimerSetMillies(pThis->pTimerRestore, 1500); … … 3870 3862 Log(("#%d pcnetTimerRestore: cLinkDownReported=%d, wait another 1500ms...\n", 3871 3863 pDevIns->iInstance, pThis->cLinkDownReported)); 3872 3873 PDMCritSectLeave(&pThis->CritSect);3874 3864 } 3875 3865 … … 4678 4668 pThis->cLinkDownReported = 0x10000; 4679 4669 TMTimerStop(pThis->pTimerRestore); 4680 pcnetTimerRestore(pDevIns, pThis->pTimerRestore );4670 pcnetTimerRestore(pDevIns, pThis->pTimerRestore, pThis); 4681 4671 } 4682 4672 if (pThis->pSharedMMIOR3) … … 4919 4909 } 4920 4910 4911 /* 4912 * Initialize critical section. 4913 * This must be done before register the critsect with the timer code, and also before 4914 * attaching drivers or anything else that may call us back. 4915 */ 4916 char szName[24]; 4917 RTStrPrintf(szName, sizeof(szName), "PCNet#%d", iInstance); 4918 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, szName); 4919 if (RT_FAILURE(rc)) 4920 return rc; 4921 4922 rc = RTSemEventCreate(&pThis->hEventOutOfRxSpace); 4923 AssertRC(rc); 4924 4921 4925 #ifdef PCNET_NO_POLLING 4922 4926 /* … … 4928 4932 AssertLogRelMsgRCReturn(rc, ("PDMR3LdrGetSymbolRCLazy(EMInterpretInstruction) -> %Rrc\n", rc), rc); 4929 4933 #else 4930 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimer, 4931 "PCNet Poll Timer", &pThis->pTimerPollR3);4934 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimer, pThis, 4935 TMTIMER_FLAGS_NO_CRIT_SECT, "PCNet Poll Timer", &pThis->pTimerPollR3); 4932 4936 if (RT_FAILURE(rc)) 4933 4937 return rc; 4934 4938 pThis->pTimerPollR0 = TMTimerR0Ptr(pThis->pTimerPollR3); 4935 4939 pThis->pTimerPollRC = TMTimerRCPtr(pThis->pTimerPollR3); 4940 TMR3TimerSetCritSect(pThis->pTimerPollR3, &pThis->CritSect); 4936 4941 #endif 4937 4942 if (pThis->fAm79C973) 4938 4943 { 4939 4944 /* Software Interrupt timer */ 4940 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerSoftInt, 4941 "PCNet SoftInt Timer", &pThis->pTimerSoftIntR3);4945 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerSoftInt, pThis, /** @todo r=bird: the locking here looks bogus now with SMP... */ 4946 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PCNet SoftInt Timer", &pThis->pTimerSoftIntR3); 4942 4947 if (RT_FAILURE(rc)) 4943 4948 return rc; … … 4945 4950 pThis->pTimerSoftIntRC = TMTimerRCPtr(pThis->pTimerSoftIntR3); 4946 4951 } 4947 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerRestore, 4948 "PCNet Restore Timer", &pThis->pTimerRestore);4952 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerRestore, pThis, 4953 TMTIMER_FLAGS_NO_CRIT_SECT, "PCNet Restore Timer", &pThis->pTimerRestore); 4949 4954 if (RT_FAILURE(rc)) 4950 4955 return rc; 4956 TMR3TimerSetCritSect(pThis->pTimerRestore, &pThis->CritSect); 4951 4957 4952 4958 rc = PDMDevHlpSSMRegister(pDevIns, pDevIns->pDevReg->szDeviceName, iInstance, … … 4956 4962 if (RT_FAILURE(rc)) 4957 4963 return rc; 4958 4959 /*4960 * Initialize critical section.4961 * This must of course be done before attaching drivers or anything else which can call us back.4962 */4963 char szName[24];4964 RTStrPrintf(szName, sizeof(szName), "PCNet#%d", iInstance);4965 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, szName);4966 if (RT_FAILURE(rc))4967 return rc;4968 4969 rc = RTSemEventCreate(&pThis->hEventOutOfRxSpace);4970 AssertRC(rc);4971 4964 4972 4965 /* -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r19646 r20087 1068 1068 } 1069 1069 1070 static DECLCALLBACK(void) acpiTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer )1071 { 1072 ACPIState *s = PDMINS_2_DATA(pDevIns, ACPIState *);1070 static DECLCALLBACK(void) acpiTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1071 { 1072 ACPIState *s = (ACPIState *)pvUser; 1073 1073 1074 1074 Log(("acpi: pm timer sts %#x (%d), en %#x (%d)\n", … … 1320 1320 : 0; 1321 1321 break; 1322 1322 1323 1323 case SYSTEM_INFO_INDEX_CPU0_STATUS: 1324 1324 case SYSTEM_INFO_INDEX_CPU1_STATUS: … … 1933 1933 } 1934 1934 1935 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiTimer, "ACPI Timer", &s->tsR3); 1935 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiTimer, dev, 1936 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "ACPI Timer", &s->tsR3); 1936 1937 if (RT_FAILURE(rc)) 1937 1938 { -
trunk/src/VBox/Devices/PC/DevAPIC.cpp
r20056 r20087 1296 1296 1297 1297 #ifdef IN_RING3 1298 # ifndef VBOX1298 # ifndef VBOX 1299 1299 static void apic_timer(void *opaque) 1300 1300 { 1301 1301 APICState *s = opaque; 1302 # else /* VBOX */1303 static DECLCALLBACK(void) apicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer )1302 # else /* VBOX */ 1303 static DECLCALLBACK(void) apicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1304 1304 { 1305 1305 APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *); 1306 APICState *s = getLapic(dev); 1307 if (s->pTimerR3 != pTimer) 1308 { 1309 for (uint32_t iCpu = 0; iCpu < dev->cCpus; iCpu++) 1310 { 1311 s = getLapicById(dev, iCpu); 1312 if (s->pTimerR3 == pTimer) 1313 break; 1314 } 1315 Assert(s->pTimerR3 == pTimer); 1316 } 1306 APICState *s = (APICState *)pvUser; 1307 Assert(s->pTimerR3 == pTimer); 1317 1308 1318 1309 APIC_LOCK_VOID(dev, VERR_INTERNAL_ERROR); 1319 # endif /* VBOX */1310 # endif /* VBOX */ 1320 1311 1321 1312 if (!(s->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED)) { … … 1325 1316 apic_timer_update(dev, s, s->next_time); 1326 1317 1327 # ifdef VBOX1318 # ifdef VBOX 1328 1319 APIC_UNLOCK(dev); 1329 # endif1320 # endif 1330 1321 } 1331 1322 #endif /* IN_RING3 */ … … 2407 2398 for (i = 0, apic = LAPIC_BASE(pThis); i < cCpus; i++) 2408 2399 { 2409 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicTimer, 2410 "APIC Timer", &apic->pTimerR3);2400 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, apicTimer, apic, 2401 TMTIMER_FLAGS_NO_CRIT_SECT, "APIC Timer", &apic->pTimerR3); 2411 2402 if (RT_FAILURE(rc)) 2412 2403 return rc; 2413 2404 apic->pTimerR0 = TMTimerR0Ptr(apic->pTimerR3); 2414 2405 apic->pTimerRC = TMTimerRCPtr(apic->pTimerR3); 2406 /// @todo TMTimerSetCritSect(apic->pTimerR3, pThis->pApicHlpR3->pfnGetCritSect(..)); 2415 2407 apic++; 2416 2408 } -
trunk/src/VBox/Devices/PC/DevPit-i8254.cpp
r20049 r20087 809 809 * @param pDevIns Device instance of the device which registered the timer. 810 810 * @param pTimer The timer handle. 811 * /812 static DECLCALLBACK(void) pitTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer) 813 { 814 PITState *pThis = PDMINS_2_DATA(pDevIns, PITState *); 815 PITChannelState *s = &pThis->channels[0];811 * @param pvUser Pointer to the PIT channel state. 812 */ 813 static DECLCALLBACK(void) pitTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 814 { 815 PITChannelState *s = (PITChannelState *)pvUser; 816 816 STAM_PROFILE_ADV_START(&s->CTX_SUFF(pPit)->StatPITHandler, a); 817 817 Log(("pitTimer\n")); … … 994 994 * Create timer, register I/O Ports and save state. 995 995 */ 996 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, pitTimer, "i8254 Programmable Interval Timer", 996 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, pitTimer, &pThis->channels[0], 997 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "i8254 Programmable Interval Timer", 997 998 &pThis->channels[0].pTimerR3); 998 999 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/PC/DevRTC.cpp
r19706 r20087 73 73 PDMBOTHCBDECL(int) rtcIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); 74 74 PDMBOTHCBDECL(int) rtcIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 75 PDMBOTHCBDECL(void) rtcTimerPeriodic(PPDMDEVINS pDevIns, PTMTIMER pTimer );76 PDMBOTHCBDECL(void) rtcTimerSecond(PPDMDEVINS pDevIns, PTMTIMER pTimer );77 PDMBOTHCBDECL(void) rtcTimerSecond2(PPDMDEVINS pDevIns, PTMTIMER pTimer );75 PDMBOTHCBDECL(void) rtcTimerPeriodic(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 76 PDMBOTHCBDECL(void) rtcTimerSecond(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 77 PDMBOTHCBDECL(void) rtcTimerSecond2(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 78 78 __END_DECLS 79 79 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ … … 553 553 * @param pDevIns Device instance of the device which registered the timer. 554 554 * @param pTimer The timer handle. 555 */ 556 PDMBOTHCBDECL(void) rtcTimerPeriodic(PPDMDEVINS pDevIns, PTMTIMER pTimer) 557 { 558 rtc_periodic_timer(PDMINS_2_DATA(pDevIns, RTCState *)); 555 * @param pvUser Pointer to the RTC state. 556 */ 557 PDMBOTHCBDECL(void) rtcTimerPeriodic(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 558 { 559 rtc_periodic_timer((RTCState *)pvUser); 559 560 } 560 561 … … 565 566 * @param pDevIns Device instance of the device which registered the timer. 566 567 * @param pTimer The timer handle. 567 */ 568 PDMBOTHCBDECL(void) rtcTimerSecond(PPDMDEVINS pDevIns, PTMTIMER pTimer) 569 { 570 rtc_update_second(PDMINS_2_DATA(pDevIns, RTCState *)); 568 * @param pvUser Pointer to the RTC state. 569 */ 570 PDMBOTHCBDECL(void) rtcTimerSecond(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 571 { 572 rtc_update_second((RTCState *)pvUser); 571 573 } 572 574 … … 577 579 * @param pDevIns Device instance of the device which registered the timer. 578 580 * @param pTimer The timer handle. 579 */ 580 PDMBOTHCBDECL(void) rtcTimerSecond2(PPDMDEVINS pDevIns, PTMTIMER pTimer) 581 { 582 rtc_update_second2(PDMINS_2_DATA(pDevIns, RTCState *)); 581 * @param pvUser Pointer to the RTC state. 582 */ 583 PDMBOTHCBDECL(void) rtcTimerSecond2(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 584 { 585 rtc_update_second2((RTCState *)pvUser); 583 586 } 584 587 … … 869 872 * Create timers, arm them, register I/O Ports and save state. 870 873 */ 871 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerPeriodic, "MC146818 RTC/CMOS - Periodic", &pThis->pPeriodicTimerR3); 874 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerPeriodic, pThis, 875 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Periodic", 876 &pThis->pPeriodicTimerR3); 872 877 if (RT_FAILURE(rc)) 873 878 return rc; … … 875 880 pThis->pPeriodicTimerRC = TMTimerRCPtr(pThis->pPeriodicTimerR3); 876 881 877 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond, "MC146818 RTC/CMOS - Second", &pThis->pSecondTimerR3); 882 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond, pThis, 883 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Second", 884 &pThis->pSecondTimerR3); 878 885 if (RT_FAILURE(rc)) 879 886 return rc; … … 881 888 pThis->pSecondTimerRC = TMTimerRCPtr(pThis->pSecondTimerR3); 882 889 883 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond2, "MC146818 RTC/CMOS - Second2", &pThis->pSecondTimer2R3); 890 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond2, pThis, 891 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Second2", 892 &pThis->pSecondTimer2R3); 884 893 if (RT_FAILURE(rc)) 885 894 return rc; -
trunk/src/VBox/Devices/Storage/fdc.c
r13080 r20087 2343 2343 2344 2344 #ifdef VBOX 2345 static DECLCALLBACK(void) fdc_timer (PPDMDEVINS pDevIns, PTMTIMER pTimer )2346 { 2347 fdctrl_t *fdctrl = PDMINS_2_DATA (pDevIns, fdctrl_t *);2345 static DECLCALLBACK(void) fdc_timer (PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2346 { 2347 fdctrl_t *fdctrl = (fdctrl_t *)pvUser; 2348 2348 fdctrl_result_timer (fdctrl); 2349 2349 } … … 2849 2849 * Create the FDC timer. 2850 2850 */ 2851 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, fdc_timer, "FDC Timer", &fdctrl->result_timer); 2851 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, fdc_timer, fdctrl, 2852 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "FDC Timer", &fdctrl->result_timer); 2852 2853 if (RT_FAILURE (rc)) 2853 2854 return rc; -
trunk/src/VBox/VMM/IOM.cpp
r19793 r20087 1654 1654 while (PDMCritSectIsOwner(&pVM->iom.s.EmtLock)) 1655 1655 PDMCritSectLeave(&pVM->iom.s.EmtLock); 1656 } 1657 1658 1659 /** 1660 * For TM only! 1661 * 1662 * @returns Pointer to the critical section. 1663 * @param pVM The VM handle. 1664 */ 1665 VMMR3DECL(PPDMCRITSECT) IOMR3GetCritSect(PVM pVM) 1666 { 1667 return &pVM->iom.s.EmtLock; 1656 1668 } 1657 1669 -
trunk/src/VBox/VMM/PDMCritSect.cpp
r20008 r20087 351 351 352 352 /** 353 * Gets the name of the critical section. 354 * 355 * 356 * @returns Pointer to the critical section name (read only) on success, 357 * NULL on failure (invalid critical section). 358 * @param pCritSect The critical section. 359 */ 360 VMMR3DECL(const char *) PDMR3CritSectName(PCPDMCRITSECT pCritSect) 361 { 362 AssertPtrReturn(pCritSect, NULL); 363 AssertReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, NULL); 364 return pCritSect->s.pszName; 365 } 366 367 368 /** 353 369 * Schedule a event semaphore for signalling upon critsect exit. 354 370 * -
trunk/src/VBox/VMM/PDMDevHlp.cpp
r19400 r20087 381 381 382 382 /** @copydoc PDMDEVHLPR3::pfnTMTimerCreate */ 383 static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer)383 static DECLCALLBACK(int) pdmR3DevHlp_TMTimerCreate(PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer) 384 384 { 385 385 PDMDEV_ASSERT_DEVINS(pDevIns); 386 386 VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3); 387 LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pszDesc=%p:{%s} ppTimer=%p\n", 388 pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, enmClock, pfnCallback, pszDesc, pszDesc, ppTimer)); 389 390 int rc = TMR3TimerCreateDevice(pDevIns->Internal.s.pVMR3, pDevIns, enmClock, pfnCallback, pszDesc, ppTimer); 387 LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n", 388 pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer)); 389 390 391 int rc = TMR3TimerCreateDevice(pDevIns->Internal.s.pVMR3, pDevIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer); 391 392 392 393 LogFlow(("pdmR3DevHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc)); -
trunk/src/VBox/VMM/TM.cpp
r20050 r20087 1206 1206 pTimer->offNext = 0; 1207 1207 pTimer->offPrev = 0; 1208 pTimer->pvUser = NULL; 1209 pTimer->pCritSect = NULL; 1208 1210 pTimer->pszDesc = pszDesc; 1209 1211 … … 1233 1235 * @param enmClock The clock to use on this timer. 1234 1236 * @param pfnCallback Callback function. 1237 * @param pvUser The user argument to the callback. 1238 * @param fFlags Timer creation flags, see grp_tm_timer_flags. 1235 1239 * @param pszDesc Pointer to description string which must stay around 1236 1240 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()). 1237 1241 * @param ppTimer Where to store the timer on success. 1238 1242 */ 1239 VMMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer) 1240 { 1243 VMMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer) 1244 { 1245 AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT)), VERR_INVALID_PARAMETER); 1246 1241 1247 /* 1242 1248 * Allocate and init stuff. … … 1248 1254 (*ppTimer)->u.Dev.pfnTimer = pfnCallback; 1249 1255 (*ppTimer)->u.Dev.pDevIns = pDevIns; 1256 (*ppTimer)->pvUser = pvUser; 1257 if (fFlags & TMTIMER_FLAGS_DEFAULT_CRIT_SECT) 1258 (*ppTimer)->pCritSect = IOMR3GetCritSect(pVM); 1250 1259 Log(("TM: Created device timer %p clock %d callback %p '%s'\n", (*ppTimer), enmClock, pfnCallback, pszDesc)); 1251 1260 } … … 1308 1317 pTimer->enmType = TMTIMERTYPE_INTERNAL; 1309 1318 pTimer->u.Internal.pfnTimer = pfnCallback; 1310 pTimer-> u.Internal.pvUser= pvUser;1319 pTimer->pvUser = pvUser; 1311 1320 *ppTimer = pTimer; 1312 1321 Log(("TM: Created internal timer %p clock %d callback %p '%s'\n", pTimer, enmClock, pfnCallback, pszDesc)); … … 1339 1348 pTimer->enmType = TMTIMERTYPE_EXTERNAL; 1340 1349 pTimer->u.External.pfnTimer = pfnCallback; 1341 pTimer-> u.External.pvUser= pvUser;1350 pTimer->pvUser = pvUser; 1342 1351 Log(("TM: Created external timer %p clock %d callback %p '%s'\n", pTimer, enmClock, pfnCallback, pszDesc)); 1343 1352 return pTimer; … … 1799 1808 while (pNext && pNext->u64Expire <= u64Now) 1800 1809 { 1801 PTMTIMER pTimer= pNext;1810 PTMTIMER pTimer = pNext; 1802 1811 pNext = TMTIMER_GET_NEXT(pTimer); 1812 PPDMCRITSECT pCritSect = pTimer->pCritSect; 1813 if (pCritSect) 1814 PDMCritSectEnter(pCritSect, VERR_INTERNAL_ERROR); 1803 1815 Log2(("tmR3TimerQueueRun: %p:{.enmState=%s, .enmClock=%d, .enmType=%d, u64Expire=%llx (now=%llx) .pszDesc=%s}\n", 1804 1816 pTimer, tmTimerState(pTimer->enmState), pTimer->enmClock, pTimer->enmType, pTimer->u64Expire, u64Now, pTimer->pszDesc)); … … 1825 1837 /* fire */ 1826 1838 TM_SET_STATE(pTimer, TMTIMERSTATE_EXPIRED_DELIVER); 1827 // tmUnlock(pVM);1828 1839 switch (pTimer->enmType) 1829 1840 { 1830 case TMTIMERTYPE_DEV: 1831 // iomLock(pVM); 1832 pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer); 1833 // iomUnlock(pVM); 1834 break; 1835 1836 case TMTIMERTYPE_DRV: pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer); break; 1837 case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->u.Internal.pvUser); break; 1838 case TMTIMERTYPE_EXTERNAL: pTimer->u.External.pfnTimer(pTimer->u.External.pvUser); break; 1841 case TMTIMERTYPE_DEV: pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer, pTimer->pvUser); break; 1842 case TMTIMERTYPE_DRV: pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer /*, pTimer->pvUser*/); break; 1843 case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->pvUser); break; 1844 case TMTIMERTYPE_EXTERNAL: pTimer->u.External.pfnTimer(pTimer->pvUser); break; 1839 1845 default: 1840 1846 AssertMsgFailed(("Invalid timer type %d (%s)\n", pTimer->enmType, pTimer->pszDesc)); 1841 1847 break; 1842 1848 } 1843 // tmLock(pVM);1844 1849 1845 1850 /* change the state if it wasn't changed already in the handler. */ … … 1847 1852 Log2(("tmR3TimerQueueRun: new state %s\n", tmTimerState(pTimer->enmState))); 1848 1853 } 1854 if (pCritSect) 1855 PDMCritSectLeave(pCritSect); 1849 1856 } /* run loop */ 1850 1857 } … … 2002 2009 switch (pTimer->enmType) 2003 2010 { 2004 case TMTIMERTYPE_DEV: pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer ); break;2005 case TMTIMERTYPE_DRV: pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer ); break;2006 case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer-> u.Internal.pvUser); break;2007 case TMTIMERTYPE_EXTERNAL: pTimer->u.External.pfnTimer(pTimer-> u.External.pvUser); break;2011 case TMTIMERTYPE_DEV: pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer, pTimer->pvUser); break; 2012 case TMTIMERTYPE_DRV: pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer /*, pTimer->pvUser*/); break; 2013 case TMTIMERTYPE_INTERNAL: pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->pvUser); break; 2014 case TMTIMERTYPE_EXTERNAL: pTimer->u.External.pfnTimer(pTimer->pvUser); break; 2008 2015 default: 2009 2016 AssertMsgFailed(("Invalid timer type %d (%s)\n", pTimer->enmType, pTimer->pszDesc)); … … 2311 2318 2312 2319 /** 2320 * Associates a critical section with a timer. 2321 * 2322 * The critical section will be entered prior to doing the timer call back, thus 2323 * avoiding potential races between the timer thread and other threads trying to 2324 * stop or adjust the timer expiration while it's being delivered. The timer 2325 * thread will leave the critical section when the timer callback returns. 2326 * 2327 * In strict builds, ownership of the critical section will be asserted by 2328 * TMTimerSet and TMTimerStop. 2329 * 2330 * @retval VINF_SUCCESS on success. 2331 * @retval VERR_INVALID_HANDLE if the timer handle is NULL or invalid 2332 * (asserted). 2333 * @retval VERR_INVALID_PARAMETER if pCritSect is NULL or has an invalid magic 2334 * (asserted). 2335 * @retval VERR_ALREADY_EXISTS if a critical section was already associated 2336 * with the timer (asserted). 2337 * @retval VERR_INVALID_STATE if the timer isn't stopped. 2338 * 2339 * @param pTimer The timer handle. 2340 * @param pCritSect The critical section. The caller must make sure this 2341 * is around for the life time of the timer. 2342 * 2343 * @thread Any, but the caller is responsible for making sure the timer is not 2344 * active. 2345 */ 2346 VMMR3DECL(int) TMR3TimerSetCritSect(PTMTIMERR3 pTimer, PPDMCRITSECT pCritSect) 2347 { 2348 AssertPtrReturn(pTimer, VERR_INVALID_HANDLE); 2349 AssertPtrReturn(pCritSect, VERR_INVALID_PARAMETER); 2350 const char *pszName = PDMR3CritSectName(pCritSect); /* exploited for validation */ 2351 AssertReturn(pszName, VERR_INVALID_PARAMETER); 2352 AssertReturn(!pTimer->pCritSect, VERR_ALREADY_EXISTS); 2353 AssertReturn(pTimer->enmState == TMTIMERSTATE_STOPPED, VERR_INVALID_STATE); 2354 LogFlow(("pTimer=%p (%s) pCritSect=%p (%s)\n", pTimer, pTimer->pszDesc, pCritSect, pszName)); 2355 2356 pTimer->pCritSect = pCritSect; 2357 return VINF_SUCCESS; 2358 } 2359 2360 2361 /** 2313 2362 * Get the real world UTC time adjusted for VM lag. 2314 2363 * -
trunk/src/VBox/VMM/TMInternal.h
r20050 r20087 153 153 /** Callback. */ 154 154 R3PTRTYPE(PFNTMTIMERINT) pfnTimer; 155 /** User argument. */156 RTR3PTR pvUser;157 155 } Internal; 158 156 … … 162 160 /** Callback. */ 163 161 R3PTRTYPE(PFNTMTIMEREXT) pfnTimer; 164 /** User data. */165 RTR3PTR pvUser;166 162 } External; 167 163 } u; … … 176 172 /** Timer relative offset to the previous timer in the chain. */ 177 173 int32_t offPrev; 174 175 /** User argument. */ 176 RTR3PTR pvUser; 177 /** The critical section associated with the lock. */ 178 R3PTRTYPE(PPDMCRITSECT) pCritSect; 178 179 179 180 /** Pointer to the next timer in the list of created or free timers. (TM::pTimers or TM::pFree) */ -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r20060 r20087 839 839 GEN_CHECK_OFF(TMTIMER, u.Drv.pDrvIns); 840 840 GEN_CHECK_OFF(TMTIMER, u.Internal.pfnTimer); 841 GEN_CHECK_OFF(TMTIMER, u.Internal.pvUser);842 841 GEN_CHECK_OFF(TMTIMER, u.External.pfnTimer); 843 GEN_CHECK_OFF(TMTIMER, u.External.pvUser);844 842 GEN_CHECK_OFF(TMTIMER, enmState); 845 843 GEN_CHECK_OFF(TMTIMER, offScheduleNext); 846 844 GEN_CHECK_OFF(TMTIMER, offNext); 847 845 GEN_CHECK_OFF(TMTIMER, offPrev); 846 GEN_CHECK_OFF(TMTIMER, pvUser); 847 GEN_CHECK_OFF(TMTIMER, pCritSect); 848 848 GEN_CHECK_OFF(TMTIMER, pBigNext); 849 849 GEN_CHECK_OFF(TMTIMER, pBigPrev);
Note:
See TracChangeset
for help on using the changeset viewer.