VirtualBox

Changeset 4012 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Aug 2, 2007 11:48:45 PM (17 years ago)
Author:
vboxsync
Message:

Hooked up the PDMThread stuff.

Location:
trunk/include/VBox
Files:
3 edited

Legend:

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

    r4011 r4012  
    21832183    DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnUTCNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
    21842184
     2185    /**
     2186     * Creates a PDM thread.
     2187     *
     2188     * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
     2189     * resuming, and destroying the thread as the VM state changes.
     2190     *
     2191     * @returns VBox status code.
     2192     * @param   pDevIns     The device instance.
     2193     * @param   ppThread    Where to store the thread 'handle'.
     2194     * @param   pvUser      The user argument to the thread function.
     2195     * @param   pfnThread   The thread function.
     2196     * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     2197     *                      a state change is pending.
     2198     * @param   cbStack     See RTThreadCreate.
     2199     * @param   enmType     See RTThreadCreate.
     2200     * @param   pszName     See RTThreadCreate.
     2201     */
     2202    DECLR3CALLBACKMEMBER(int, pfnPDMThreadCreate,(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
     2203                                                  PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
     2204
     2205   
    21852206    /** Space reserved for future members.
    21862207     * @{ */
    2187     DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
    21882208    DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
    21892209    DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
     
    32963316    pDevIns->pDevHlp->pfnGetCpuId(pDevIns, iLeaf, pEax, pEbx, pEcx, pEdx);
    32973317}
     3318
     3319/**
     3320 * @copydoc PDMDEVHLP::pfnPDMThreadCreate
     3321 */
     3322DECLINLINE(int) PDMDevHlpPDMThreadCreate(PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
     3323                                         PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     3324{
     3325    return pDevIns->pDevHlp->pfnPDMThreadCreate(pDevIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
     3326}
    32983327#endif /* IN_RING3 */
    32993328
  • trunk/include/VBox/pdmdrv.h

    r4011 r4012  
    555555    DECLR3CALLBACKMEMBER(int, pfnUSBRegisterHub,(PPDMDRVINS pDrvIns, void *pvReservedIn, void **ppvReservedHlp));
    556556
     557    /**
     558     * Creates a PDM thread.
     559     *
     560     * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
     561     * resuming, and destroying the thread as the VM state changes.
     562     *
     563     * @returns VBox status code.
     564     * @param   pDrvIns     The driver instance.
     565     * @param   ppThread    Where to store the thread 'handle'.
     566     * @param   pvUser      The user argument to the thread function.
     567     * @param   pfnThread   The thread function.
     568     * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     569     *                      a state change is pending.
     570     * @param   cbStack     See RTThreadCreate.
     571     * @param   enmType     See RTThreadCreate.
     572     * @param   pszName     See RTThreadCreate.
     573     */
     574    DECLR3CALLBACKMEMBER(int, pfnPDMThreadCreate,(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
     575                                                  PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
     576
    557577    /** Just a safety precaution. */
    558578    uint32_t                        u32TheEnd;
     
    702722    return pDrvIns->pDrvHlp->pfnUSBRegisterHub(pDrvIns, pvReservedIn, ppvReservedHlp);
    703723}
     724
     725/**
     726 * @copydoc PDMDRVHLP::pfnPDMThreadCreate
     727 */
     728DECLINLINE(int) PDMDrvHlpPDMThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
     729                                         PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     730{
     731    return pDrvIns->pDrvHlp->pfnPDMThreadCreate(pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
     732}
    704733#endif /* IN_RING3 */
    705734
  • trunk/include/VBox/pdmthread.h

    r4010 r4012  
    274274#define PDMTHREAD_VERSION   0xef010000
    275275
     276#ifdef IN_RING3
     277/**
     278 * Creates a PDM thread for internal use in the VM.
     279 *
     280 * @returns VBox status code.
     281 * @param   pVM         The VM handle.
     282 * @param   ppThread    Where to store the thread 'handle'.
     283 * @param   pvUser      The user argument to the thread function.
     284 * @param   pfnThread   The thread function.
     285 * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     286 *                      a state change is pending.
     287 * @param   cbStack     See RTThreadCreate.
     288 * @param   enmType     See RTThreadCreate.
     289 * @param   pszName     See RTThreadCreate.
     290 */
     291PDMR3DECL(int) PDMR3ThreadCreate(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
     292                                 PFNPDMTHREADWAKEUPINT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
     293
     294/**
     295 * Creates a PDM thread for VM use by some external party.
     296 *
     297 * @returns VBox status code.
     298 * @param   pVM         The VM handle.
     299 * @param   ppThread    Where to store the thread 'handle'.
     300 * @param   pvUser      The user argument to the thread function.
     301 * @param   pfnThread   The thread function.
     302 * @param   pfnWakeup   The wakup callback. This is called on the EMT thread when
     303 *                      a state change is pending.
     304 * @param   cbStack     See RTThreadCreate.
     305 * @param   enmType     See RTThreadCreate.
     306 * @param   pszName     See RTThreadCreate.
     307 */
     308PDMR3DECL(int) PDMR3ThreadCreateExternal(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
     309                                         PFNPDMTHREADWAKEUPEXT pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
     310
     311/**
     312 * Destroys a PDM thread.
     313 *
     314 * This will wakeup the thread, tell it to terminate, and wait for it terminate.
     315 *
     316 * @returns VBox status code.
     317 *          This reflects the success off destroying the thread and not the exit code
     318 *          of the thread as this is stored in *pRcThread.
     319 * @param   pThread         The thread to destroy.
     320 * @param   pRcThread       Where to store the thread exit code. Optional.
     321 * @thread  The emulation thread (EMT).
     322 */
     323PDMR3DECL(int) PDMR3ThreadDestroy(PPDMTHREAD pThread, int *pRcThread);
     324
     325/**
     326 * Called by the PDM thread in response to a wakeup call with
     327 * suspending as the new state.
     328 *
     329 * The thread will block in side this call until the state is changed in
     330 * response to a VM state change or to the device/driver/whatever calling the
     331 * PDMR3ThreadResume API.
     332 *
     333 * @returns VBox status code.
     334 *          On failure, terminate the thread.
     335 * @param   pThread     The PDM thread.
     336 */
     337PDMR3DECL(int) PDMR3ThreadIAmSuspending(PPDMTHREAD pThread);
     338
     339/**
     340 * Called by the PDM thread in response to a resuming state.
     341 *
     342 * The purpose of this API is to tell the PDMR3ThreadResume caller that
     343 * the the PDM thread has successfully resumed. It will also do the
     344 * state transition from the resuming to the running state.
     345 *
     346 * @returns VBox status code.
     347 *          On failure, terminate the thread.
     348 * @param   pThread     The PDM thread.
     349 */
     350PDMR3DECL(int) PDMR3ThreadIAmRunning(PPDMTHREAD pThread);
     351
     352/**
     353 * Suspends the thread.
     354 *
     355 * This can be called at the power off / suspend notifications to suspend the
     356 * PDM thread a bit early. The thread will be automatically suspend upon
     357 * completion of the device/driver notification cycle.
     358 *
     359 * The caller is responsible for serializing the control operations on the
     360 * thread. That basically means, always do these calls from the EMT.
     361 *
     362 * @returns VBox status code.
     363 * @param   pThread     The PDM thread.
     364 */
     365PDMR3DECL(int) PDMR3ThreadSuspend(PPDMTHREAD pThread);
     366
     367/**
     368 * Resumes the thread.
     369 *
     370 * This can be called the power on / resume notifications to resume the
     371 * PDM thread a bit early. The thread will be automatically resumed upon
     372 * return from these two notification callbacks (devices/drivers).
     373 *
     374 * The caller is responsible for serializing the control operations on the
     375 * thread. That basically means, always do these calls from the EMT.
     376 *
     377 * @returns VBox status code.
     378 * @param   pThread     The PDM thread.
     379 */
     380PDMR3DECL(int) PDMR3ThreadResume(PPDMTHREAD pThread);
     381#endif /* IN_RING3 */
    276382
    277383/** @} */
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