VirtualBox

Changeset 23728 in vbox


Ignore:
Timestamp:
Oct 13, 2009 2:11:18 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53448
Message:

SUPDrv: Moving more stuff over.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r23726 r23728  
    32923292
    32933293/**
    3294  * Destructor for objects created by SUPSemEventCreate.
    3295  *
    3296  * @param   pvObj               The object handle.
    3297  * @param   pvUser1             The IPRT event handle.
    3298  * @param   pvUser2             NULL.
    3299  */
    3300 static DECLCALLBACK(void) supR0SemEventDestructor(void *pvObj, void *pvUser1, void *pvUser2)
    3301 {
    3302     Assert(pvUser2 == NULL);
    3303     NOREF(pvObj);
    3304     RTSemEventDestroy((RTSEMEVENT)pvUser1);
    3305 }
    3306 
    3307 
    3308 SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent)
    3309 {
    3310     int         rc;
    3311     RTSEMEVENT  hEventReal;
    3312 
    3313     /*
    3314      * Input validation.
    3315      */
    3316     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3317     AssertPtrReturn(phEvent, VERR_INVALID_POINTER);
    3318 
    3319     /*
    3320      * Create the event semaphore object.
    3321      */
    3322     rc = RTSemEventCreate(&hEventReal);
    3323     if (RT_SUCCESS(rc))
    3324     {
    3325         void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT, supR0SemEventDestructor, hEventReal, NULL);
    3326         if (pvObj)
    3327         {
    3328             uint32_t h32;
    3329             rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT, &h32);
    3330             if (RT_SUCCESS(rc))
    3331             {
    3332                 *phEvent = (SUPSEMEVENT)(uintptr_t)h32;
    3333                 return VINF_SUCCESS;
    3334             }
    3335             SUPR0ObjRelease(pvObj, pSession);
    3336         }
    3337         else
    3338             RTSemEventDestroy(hEventReal);
    3339     }
    3340     return rc;
    3341 }
    3342 
    3343 
    3344 SUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
    3345 {
    3346     uint32_t    h32;
    3347     PSUPDRVOBJ  pObj;
    3348 
    3349     /*
    3350      * Input validation.
    3351      */
    3352     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3353     if (hEvent == NIL_SUPSEMEVENT)
    3354         return VINF_SUCCESS;
    3355     h32 = (uint32_t)(uintptr_t)hEvent;
    3356     if (h32 != (uintptr_t)hEvent)
    3357         return VERR_INVALID_HANDLE;
    3358 
    3359     /*
    3360      * Do the job.
    3361      */
    3362     pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
    3363     if (!pObj)
    3364         return VERR_INVALID_HANDLE;
    3365 
    3366     Assert(pObj->cUsage >= 2);
    3367     SUPR0ObjRelease(pObj, pSession);        /* The free call above. */
    3368     return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
    3369 }
    3370 
    3371 
    3372 SUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
    3373 {
    3374     int         rc;
    3375     uint32_t    h32;
    3376     PSUPDRVOBJ  pObj;
    3377 
    3378     /*
    3379      * Input validation.
    3380      */
    3381     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3382     h32 = (uint32_t)(uintptr_t)hEvent;
    3383     if (h32 != (uintptr_t)hEvent)
    3384         return VERR_INVALID_HANDLE;
    3385     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
    3386     if (!pObj)
    3387         return VERR_INVALID_HANDLE;
    3388 
    3389     /*
    3390      * Do the job.
    3391      */
    3392     rc = RTSemEventSignal((RTSEMEVENT)pObj->pvUser1);
    3393 
    3394     SUPR0ObjRelease(pObj, pSession);
    3395     return rc;
    3396 }
    3397 
    3398 
    3399 SUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
    3400 {
    3401     int         rc;
    3402     uint32_t    h32;
    3403     PSUPDRVOBJ  pObj;
    3404 
    3405     /*
    3406      * Input validation.
    3407      */
    3408     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3409     h32 = (uint32_t)(uintptr_t)hEvent;
    3410     if (h32 != (uintptr_t)hEvent)
    3411         return VERR_INVALID_HANDLE;
    3412     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
    3413     if (!pObj)
    3414         return VERR_INVALID_HANDLE;
    3415 
    3416     /*
    3417      * Do the job.
    3418      */
    3419     rc = RTSemEventWait((RTSEMEVENT)pObj->pvUser1, cMillies);
    3420 
    3421     SUPR0ObjRelease(pObj, pSession);
    3422     return rc;
    3423 }
    3424 
    3425 
    3426 SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
    3427 {
    3428     int         rc;
    3429     uint32_t    h32;
    3430     PSUPDRVOBJ  pObj;
    3431 
    3432     /*
    3433      * Input validation.
    3434      */
    3435     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3436     h32 = (uint32_t)(uintptr_t)hEvent;
    3437     if (h32 != (uintptr_t)hEvent)
    3438         return VERR_INVALID_HANDLE;
    3439     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
    3440     if (!pObj)
    3441         return VERR_INVALID_HANDLE;
    3442 
    3443     /*
    3444      * Do the job.
    3445      */
    3446     rc = RTSemEventWaitNoResume((RTSEMEVENT)pObj->pvUser1, cMillies);
    3447 
    3448     SUPR0ObjRelease(pObj, pSession);
    3449     return rc;
    3450 }
    3451 
    3452 
    3453 /**
    3454  * Destructor for objects created by SUPSemEventMultiCreate.
    3455  *
    3456  * @param   pvObj               The object handle.
    3457  * @param   pvUser1             The IPRT event handle.
    3458  * @param   pvUser2             NULL.
    3459  */
    3460 static DECLCALLBACK(void) supR0SemEventMultiDestructor(void *pvObj, void *pvUser1, void *pvUser2)
    3461 {
    3462     Assert(pvUser2 == NULL);
    3463     NOREF(pvObj);
    3464     RTSemEventMultiDestroy((RTSEMEVENTMULTI)pvUser1);
    3465 }
    3466 
    3467 
    3468 SUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti)
    3469 {
    3470     int             rc;
    3471     RTSEMEVENTMULTI hEventMultReal;
    3472 
    3473     /*
    3474      * Input validation.
    3475      */
    3476     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3477     AssertPtrReturn(phEventMulti, VERR_INVALID_POINTER);
    3478 
    3479     /*
    3480      * Create the event semaphore object.
    3481      */
    3482     rc = RTSemEventMultiCreate(&hEventMultReal);
    3483     if (RT_SUCCESS(rc))
    3484     {
    3485         void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT_MULTI, supR0SemEventMultiDestructor, hEventMultReal, NULL);
    3486         if (pvObj)
    3487         {
    3488             uint32_t h32;
    3489             rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT_MULTI, &h32);
    3490             if (RT_SUCCESS(rc))
    3491             {
    3492                 *phEventMulti = (SUPSEMEVENTMULTI)(uintptr_t)h32;
    3493                 return VINF_SUCCESS;
    3494             }
    3495             SUPR0ObjRelease(pvObj, pSession);
    3496         }
    3497         else
    3498             RTSemEventMultiDestroy(hEventMultReal);
    3499     }
    3500     return rc;
    3501 }
    3502 
    3503 
    3504 SUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
    3505 {
    3506     uint32_t    h32;
    3507     PSUPDRVOBJ  pObj;
    3508 
    3509     /*
    3510      * Input validation.
    3511      */
    3512     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3513     if (hEventMulti == NIL_SUPSEMEVENTMULTI)
    3514         return VINF_SUCCESS;
    3515     h32 = (uint32_t)(uintptr_t)hEventMulti;
    3516     if (h32 != (uintptr_t)hEventMulti)
    3517         return VERR_INVALID_HANDLE;
    3518 
    3519     /*
    3520      * Do the job.
    3521      */
    3522     pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
    3523     if (!pObj)
    3524         return VERR_INVALID_HANDLE;
    3525 
    3526     Assert(pObj->cUsage >= 2);
    3527     SUPR0ObjRelease(pObj, pSession);        /* The free call above. */
    3528     return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
    3529 }
    3530 
    3531 
    3532 SUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
    3533 {
    3534     int         rc;
    3535     uint32_t    h32;
    3536     PSUPDRVOBJ  pObj;
    3537 
    3538     /*
    3539      * Input validation.
    3540      */
    3541     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3542     h32 = (uint32_t)(uintptr_t)hEventMulti;
    3543     if (h32 != (uintptr_t)hEventMulti)
    3544         return VERR_INVALID_HANDLE;
    3545     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
    3546     if (!pObj)
    3547         return VERR_INVALID_HANDLE;
    3548 
    3549     /*
    3550      * Do the job.
    3551      */
    3552     rc = RTSemEventMultiSignal((RTSEMEVENTMULTI)pObj->pvUser1);
    3553 
    3554     SUPR0ObjRelease(pObj, pSession);
    3555     return rc;
    3556 }
    3557 
    3558 
    3559 SUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
    3560 {
    3561     int         rc;
    3562     uint32_t    h32;
    3563     PSUPDRVOBJ  pObj;
    3564 
    3565     /*
    3566      * Input validation.
    3567      */
    3568     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3569     h32 = (uint32_t)(uintptr_t)hEventMulti;
    3570     if (h32 != (uintptr_t)hEventMulti)
    3571         return VERR_INVALID_HANDLE;
    3572     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
    3573     if (!pObj)
    3574         return VERR_INVALID_HANDLE;
    3575 
    3576     /*
    3577      * Do the job.
    3578      */
    3579     rc = RTSemEventMultiReset((RTSEMEVENTMULTI)pObj->pvUser1);
    3580 
    3581     SUPR0ObjRelease(pObj, pSession);
    3582     return rc;
    3583 }
    3584 
    3585 
    3586 SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
    3587 {
    3588     int         rc;
    3589     uint32_t    h32;
    3590     PSUPDRVOBJ  pObj;
    3591 
    3592     /*
    3593      * Input validation.
    3594      */
    3595     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3596     h32 = (uint32_t)(uintptr_t)hEventMulti;
    3597     if (h32 != (uintptr_t)hEventMulti)
    3598         return VERR_INVALID_HANDLE;
    3599     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
    3600     if (!pObj)
    3601         return VERR_INVALID_HANDLE;
    3602 
    3603     /*
    3604      * Do the job.
    3605      */
    3606     rc = RTSemEventMultiWait((RTSEMEVENTMULTI)pObj->pvUser1, cMillies);
    3607 
    3608     SUPR0ObjRelease(pObj, pSession);
    3609     return rc;
    3610 }
    3611 
    3612 
    3613 SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
    3614 {
    3615     int         rc;
    3616     uint32_t    h32;
    3617     PSUPDRVOBJ  pObj;
    3618 
    3619     /*
    3620      * Input validation.
    3621      */
    3622     AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
    3623     h32 = (uint32_t)(uintptr_t)hEventMulti;
    3624     if (h32 != (uintptr_t)hEventMulti)
    3625         return VERR_INVALID_HANDLE;
    3626     pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
    3627     if (!pObj)
    3628         return VERR_INVALID_HANDLE;
    3629 
    3630     /*
    3631      * Do the job.
    3632      */
    3633     rc = RTSemEventMultiWaitNoResume((RTSEMEVENTMULTI)pObj->pvUser1, cMillies);
    3634 
    3635     SUPR0ObjRelease(pObj, pSession);
    3636     return rc;
    3637 }
    3638 
    3639 
    3640 /**
    36413294 * Adds a memory object to the session.
    36423295 *
  • trunk/src/VBox/HostDrivers/Support/SUPDrvAgnostic.c

    r23726 r23728  
    251251    return VERR_UNSUPPORTED_CPU;
    252252}
     253
     254
     255/**
     256 * Destructor for objects created by SUPSemEventCreate.
     257 *
     258 * @param   pvObj               The object handle.
     259 * @param   pvUser1             The IPRT event handle.
     260 * @param   pvUser2             NULL.
     261 */
     262static DECLCALLBACK(void) supR0SemEventDestructor(void *pvObj, void *pvUser1, void *pvUser2)
     263{
     264    Assert(pvUser2 == NULL);
     265    NOREF(pvObj);
     266    RTSemEventDestroy((RTSEMEVENT)pvUser1);
     267}
     268
     269
     270SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent)
     271{
     272    int         rc;
     273    RTSEMEVENT  hEventReal;
     274
     275    /*
     276     * Input validation.
     277     */
     278    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     279    AssertPtrReturn(phEvent, VERR_INVALID_POINTER);
     280
     281    /*
     282     * Create the event semaphore object.
     283     */
     284    rc = RTSemEventCreate(&hEventReal);
     285    if (RT_SUCCESS(rc))
     286    {
     287        void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT, supR0SemEventDestructor, hEventReal, NULL);
     288        if (pvObj)
     289        {
     290            uint32_t h32;
     291            rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT, &h32);
     292            if (RT_SUCCESS(rc))
     293            {
     294                *phEvent = (SUPSEMEVENT)(uintptr_t)h32;
     295                return VINF_SUCCESS;
     296            }
     297            SUPR0ObjRelease(pvObj, pSession);
     298        }
     299        else
     300            RTSemEventDestroy(hEventReal);
     301    }
     302    return rc;
     303}
     304
     305
     306SUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
     307{
     308    uint32_t    h32;
     309    PSUPDRVOBJ  pObj;
     310
     311    /*
     312     * Input validation.
     313     */
     314    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     315    if (hEvent == NIL_SUPSEMEVENT)
     316        return VINF_SUCCESS;
     317    h32 = (uint32_t)(uintptr_t)hEvent;
     318    if (h32 != (uintptr_t)hEvent)
     319        return VERR_INVALID_HANDLE;
     320
     321    /*
     322     * Do the job.
     323     */
     324    pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
     325    if (!pObj)
     326        return VERR_INVALID_HANDLE;
     327
     328    Assert(pObj->cUsage >= 2);
     329    SUPR0ObjRelease(pObj, pSession);        /* The free call above. */
     330    return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
     331}
     332
     333
     334SUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
     335{
     336    int         rc;
     337    uint32_t    h32;
     338    PSUPDRVOBJ  pObj;
     339
     340    /*
     341     * Input validation.
     342     */
     343    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     344    h32 = (uint32_t)(uintptr_t)hEvent;
     345    if (h32 != (uintptr_t)hEvent)
     346        return VERR_INVALID_HANDLE;
     347    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
     348    if (!pObj)
     349        return VERR_INVALID_HANDLE;
     350
     351    /*
     352     * Do the job.
     353     */
     354    rc = RTSemEventSignal((RTSEMEVENT)pObj->pvUser1);
     355
     356    SUPR0ObjRelease(pObj, pSession);
     357    return rc;
     358}
     359
     360
     361SUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
     362{
     363    int         rc;
     364    uint32_t    h32;
     365    PSUPDRVOBJ  pObj;
     366
     367    /*
     368     * Input validation.
     369     */
     370    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     371    h32 = (uint32_t)(uintptr_t)hEvent;
     372    if (h32 != (uintptr_t)hEvent)
     373        return VERR_INVALID_HANDLE;
     374    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
     375    if (!pObj)
     376        return VERR_INVALID_HANDLE;
     377
     378    /*
     379     * Do the job.
     380     */
     381    rc = RTSemEventWait((RTSEMEVENT)pObj->pvUser1, cMillies);
     382
     383    SUPR0ObjRelease(pObj, pSession);
     384    return rc;
     385}
     386
     387
     388SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
     389{
     390    int         rc;
     391    uint32_t    h32;
     392    PSUPDRVOBJ  pObj;
     393
     394    /*
     395     * Input validation.
     396     */
     397    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     398    h32 = (uint32_t)(uintptr_t)hEvent;
     399    if (h32 != (uintptr_t)hEvent)
     400        return VERR_INVALID_HANDLE;
     401    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
     402    if (!pObj)
     403        return VERR_INVALID_HANDLE;
     404
     405    /*
     406     * Do the job.
     407     */
     408    rc = RTSemEventWaitNoResume((RTSEMEVENT)pObj->pvUser1, cMillies);
     409
     410    SUPR0ObjRelease(pObj, pSession);
     411    return rc;
     412}
     413
     414
     415/**
     416 * Destructor for objects created by SUPSemEventMultiCreate.
     417 *
     418 * @param   pvObj               The object handle.
     419 * @param   pvUser1             The IPRT event handle.
     420 * @param   pvUser2             NULL.
     421 */
     422static DECLCALLBACK(void) supR0SemEventMultiDestructor(void *pvObj, void *pvUser1, void *pvUser2)
     423{
     424    Assert(pvUser2 == NULL);
     425    NOREF(pvObj);
     426    RTSemEventMultiDestroy((RTSEMEVENTMULTI)pvUser1);
     427}
     428
     429
     430SUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti)
     431{
     432    int             rc;
     433    RTSEMEVENTMULTI hEventMultReal;
     434
     435    /*
     436     * Input validation.
     437     */
     438    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     439    AssertPtrReturn(phEventMulti, VERR_INVALID_POINTER);
     440
     441    /*
     442     * Create the event semaphore object.
     443     */
     444    rc = RTSemEventMultiCreate(&hEventMultReal);
     445    if (RT_SUCCESS(rc))
     446    {
     447        void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT_MULTI, supR0SemEventMultiDestructor, hEventMultReal, NULL);
     448        if (pvObj)
     449        {
     450            uint32_t h32;
     451            rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT_MULTI, &h32);
     452            if (RT_SUCCESS(rc))
     453            {
     454                *phEventMulti = (SUPSEMEVENTMULTI)(uintptr_t)h32;
     455                return VINF_SUCCESS;
     456            }
     457            SUPR0ObjRelease(pvObj, pSession);
     458        }
     459        else
     460            RTSemEventMultiDestroy(hEventMultReal);
     461    }
     462    return rc;
     463}
     464
     465
     466SUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
     467{
     468    uint32_t    h32;
     469    PSUPDRVOBJ  pObj;
     470
     471    /*
     472     * Input validation.
     473     */
     474    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     475    if (hEventMulti == NIL_SUPSEMEVENTMULTI)
     476        return VINF_SUCCESS;
     477    h32 = (uint32_t)(uintptr_t)hEventMulti;
     478    if (h32 != (uintptr_t)hEventMulti)
     479        return VERR_INVALID_HANDLE;
     480
     481    /*
     482     * Do the job.
     483     */
     484    pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
     485    if (!pObj)
     486        return VERR_INVALID_HANDLE;
     487
     488    Assert(pObj->cUsage >= 2);
     489    SUPR0ObjRelease(pObj, pSession);        /* The free call above. */
     490    return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
     491}
     492
     493
     494SUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
     495{
     496    int         rc;
     497    uint32_t    h32;
     498    PSUPDRVOBJ  pObj;
     499
     500    /*
     501     * Input validation.
     502     */
     503    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     504    h32 = (uint32_t)(uintptr_t)hEventMulti;
     505    if (h32 != (uintptr_t)hEventMulti)
     506        return VERR_INVALID_HANDLE;
     507    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
     508    if (!pObj)
     509        return VERR_INVALID_HANDLE;
     510
     511    /*
     512     * Do the job.
     513     */
     514    rc = RTSemEventMultiSignal((RTSEMEVENTMULTI)pObj->pvUser1);
     515
     516    SUPR0ObjRelease(pObj, pSession);
     517    return rc;
     518}
     519
     520
     521SUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
     522{
     523    int         rc;
     524    uint32_t    h32;
     525    PSUPDRVOBJ  pObj;
     526
     527    /*
     528     * Input validation.
     529     */
     530    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     531    h32 = (uint32_t)(uintptr_t)hEventMulti;
     532    if (h32 != (uintptr_t)hEventMulti)
     533        return VERR_INVALID_HANDLE;
     534    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
     535    if (!pObj)
     536        return VERR_INVALID_HANDLE;
     537
     538    /*
     539     * Do the job.
     540     */
     541    rc = RTSemEventMultiReset((RTSEMEVENTMULTI)pObj->pvUser1);
     542
     543    SUPR0ObjRelease(pObj, pSession);
     544    return rc;
     545}
     546
     547
     548SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
     549{
     550    int         rc;
     551    uint32_t    h32;
     552    PSUPDRVOBJ  pObj;
     553
     554    /*
     555     * Input validation.
     556     */
     557    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     558    h32 = (uint32_t)(uintptr_t)hEventMulti;
     559    if (h32 != (uintptr_t)hEventMulti)
     560        return VERR_INVALID_HANDLE;
     561    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
     562    if (!pObj)
     563        return VERR_INVALID_HANDLE;
     564
     565    /*
     566     * Do the job.
     567     */
     568    rc = RTSemEventMultiWait((RTSEMEVENTMULTI)pObj->pvUser1, cMillies);
     569
     570    SUPR0ObjRelease(pObj, pSession);
     571    return rc;
     572}
     573
     574
     575SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
     576{
     577    int         rc;
     578    uint32_t    h32;
     579    PSUPDRVOBJ  pObj;
     580
     581    /*
     582     * Input validation.
     583     */
     584    AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
     585    h32 = (uint32_t)(uintptr_t)hEventMulti;
     586    if (h32 != (uintptr_t)hEventMulti)
     587        return VERR_INVALID_HANDLE;
     588    pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
     589    if (!pObj)
     590        return VERR_INVALID_HANDLE;
     591
     592    /*
     593     * Do the job.
     594     */
     595    rc = RTSemEventMultiWaitNoResume((RTSEMEVENTMULTI)pObj->pvUser1, cMillies);
     596
     597    SUPR0ObjRelease(pObj, pSession);
     598    return rc;
     599}
     600
     601
    253602
    254603
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