[55401] | 1 | /* $Id: SUPDrvSem.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
[23725] | 2 | /** @file
|
---|
| 3 | * VBoxDrv - The VirtualBox Support Driver - Common OS agnostic.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[23725] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
[23725] | 11 | *
|
---|
[96407] | 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
[23725] | 25 | * The contents of this file may alternatively be used under the terms
|
---|
| 26 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
| 28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
[23725] | 29 | * CDDL are applicable instead of those of the GPL.
|
---|
| 30 | *
|
---|
| 31 | * You may elect to license modified versions of this file under the
|
---|
| 32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[96407] | 33 | *
|
---|
| 34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[23725] | 35 | */
|
---|
| 36 |
|
---|
[57358] | 37 |
|
---|
| 38 | /*********************************************************************************************************************************
|
---|
| 39 | * Header Files *
|
---|
| 40 | *********************************************************************************************************************************/
|
---|
[23725] | 41 | #define LOG_GROUP LOG_GROUP_SUP_DRV
|
---|
| 42 | #define SUPDRV_AGNOSTIC
|
---|
| 43 | #include "SUPDrvInternal.h"
|
---|
| 44 |
|
---|
| 45 | /** @todo trim this down. */
|
---|
| 46 | #include <iprt/param.h>
|
---|
| 47 | #include <iprt/alloc.h>
|
---|
| 48 | #include <iprt/cpuset.h>
|
---|
| 49 | #include <iprt/handletable.h>
|
---|
| 50 | #include <iprt/mp.h>
|
---|
| 51 | #include <iprt/power.h>
|
---|
| 52 | #include <iprt/process.h>
|
---|
| 53 | #include <iprt/semaphore.h>
|
---|
| 54 | #include <iprt/spinlock.h>
|
---|
| 55 | #include <iprt/thread.h>
|
---|
| 56 | #include <iprt/uuid.h>
|
---|
| 57 |
|
---|
| 58 | #include <VBox/param.h>
|
---|
| 59 | #include <VBox/log.h>
|
---|
[76474] | 60 | #include <iprt/errcore.h>
|
---|
[23725] | 61 |
|
---|
| 62 |
|
---|
[23726] | 63 | /**
|
---|
[23728] | 64 | * Destructor for objects created by SUPSemEventCreate.
|
---|
| 65 | *
|
---|
| 66 | * @param pvObj The object handle.
|
---|
| 67 | * @param pvUser1 The IPRT event handle.
|
---|
| 68 | * @param pvUser2 NULL.
|
---|
| 69 | */
|
---|
| 70 | static DECLCALLBACK(void) supR0SemEventDestructor(void *pvObj, void *pvUser1, void *pvUser2)
|
---|
| 71 | {
|
---|
| 72 | Assert(pvUser2 == NULL);
|
---|
[62665] | 73 | RT_NOREF2(pvObj, pvUser2);
|
---|
[23728] | 74 | RTSemEventDestroy((RTSEMEVENT)pvUser1);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent)
|
---|
| 79 | {
|
---|
| 80 | int rc;
|
---|
| 81 | RTSEMEVENT hEventReal;
|
---|
| 82 |
|
---|
| 83 | /*
|
---|
| 84 | * Input validation.
|
---|
| 85 | */
|
---|
| 86 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 87 | AssertPtrReturn(phEvent, VERR_INVALID_POINTER);
|
---|
| 88 |
|
---|
| 89 | /*
|
---|
| 90 | * Create the event semaphore object.
|
---|
| 91 | */
|
---|
| 92 | rc = RTSemEventCreate(&hEventReal);
|
---|
| 93 | if (RT_SUCCESS(rc))
|
---|
| 94 | {
|
---|
| 95 | void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT, supR0SemEventDestructor, hEventReal, NULL);
|
---|
| 96 | if (pvObj)
|
---|
| 97 | {
|
---|
| 98 | uint32_t h32;
|
---|
| 99 | rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT, &h32);
|
---|
| 100 | if (RT_SUCCESS(rc))
|
---|
| 101 | {
|
---|
| 102 | *phEvent = (SUPSEMEVENT)(uintptr_t)h32;
|
---|
| 103 | return VINF_SUCCESS;
|
---|
| 104 | }
|
---|
| 105 | SUPR0ObjRelease(pvObj, pSession);
|
---|
| 106 | }
|
---|
| 107 | else
|
---|
| 108 | RTSemEventDestroy(hEventReal);
|
---|
| 109 | }
|
---|
| 110 | return rc;
|
---|
| 111 | }
|
---|
[87700] | 112 | SUPR0_EXPORT_SYMBOL(SUPSemEventCreate);
|
---|
[23728] | 113 |
|
---|
| 114 |
|
---|
| 115 | SUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
|
---|
| 116 | {
|
---|
| 117 | uint32_t h32;
|
---|
| 118 | PSUPDRVOBJ pObj;
|
---|
| 119 |
|
---|
| 120 | /*
|
---|
| 121 | * Input validation.
|
---|
| 122 | */
|
---|
| 123 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 124 | if (hEvent == NIL_SUPSEMEVENT)
|
---|
| 125 | return VINF_SUCCESS;
|
---|
| 126 | h32 = (uint32_t)(uintptr_t)hEvent;
|
---|
| 127 | if (h32 != (uintptr_t)hEvent)
|
---|
| 128 | return VERR_INVALID_HANDLE;
|
---|
| 129 |
|
---|
| 130 | /*
|
---|
| 131 | * Do the job.
|
---|
| 132 | */
|
---|
| 133 | pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
|
---|
| 134 | if (!pObj)
|
---|
| 135 | return VERR_INVALID_HANDLE;
|
---|
| 136 |
|
---|
| 137 | Assert(pObj->cUsage >= 2);
|
---|
| 138 | SUPR0ObjRelease(pObj, pSession); /* The free call above. */
|
---|
| 139 | return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
|
---|
| 140 | }
|
---|
[87700] | 141 | SUPR0_EXPORT_SYMBOL(SUPSemEventClose);
|
---|
[23728] | 142 |
|
---|
| 143 |
|
---|
| 144 | SUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
|
---|
| 145 | {
|
---|
| 146 | int rc;
|
---|
| 147 | uint32_t h32;
|
---|
| 148 | PSUPDRVOBJ pObj;
|
---|
| 149 |
|
---|
| 150 | /*
|
---|
| 151 | * Input validation.
|
---|
| 152 | */
|
---|
| 153 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 154 | h32 = (uint32_t)(uintptr_t)hEvent;
|
---|
| 155 | if (h32 != (uintptr_t)hEvent)
|
---|
| 156 | return VERR_INVALID_HANDLE;
|
---|
| 157 | pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
|
---|
| 158 | if (!pObj)
|
---|
| 159 | return VERR_INVALID_HANDLE;
|
---|
| 160 |
|
---|
| 161 | /*
|
---|
| 162 | * Do the job.
|
---|
| 163 | */
|
---|
| 164 | rc = RTSemEventSignal((RTSEMEVENT)pObj->pvUser1);
|
---|
| 165 |
|
---|
| 166 | SUPR0ObjRelease(pObj, pSession);
|
---|
| 167 | return rc;
|
---|
| 168 | }
|
---|
[87700] | 169 | SUPR0_EXPORT_SYMBOL(SUPSemEventSignal);
|
---|
[23728] | 170 |
|
---|
| 171 |
|
---|
[33167] | 172 | static int supR0SemEventWaitEx(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t fFlags, uint64_t uTimeout)
|
---|
[23728] | 173 | {
|
---|
| 174 | int rc;
|
---|
| 175 | uint32_t h32;
|
---|
| 176 | PSUPDRVOBJ pObj;
|
---|
| 177 |
|
---|
| 178 | /*
|
---|
| 179 | * Input validation.
|
---|
| 180 | */
|
---|
| 181 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 182 | h32 = (uint32_t)(uintptr_t)hEvent;
|
---|
| 183 | if (h32 != (uintptr_t)hEvent)
|
---|
| 184 | return VERR_INVALID_HANDLE;
|
---|
| 185 | pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
|
---|
| 186 | if (!pObj)
|
---|
| 187 | return VERR_INVALID_HANDLE;
|
---|
| 188 |
|
---|
| 189 | /*
|
---|
| 190 | * Do the job.
|
---|
| 191 | */
|
---|
[33167] | 192 | rc = RTSemEventWaitEx((RTSEMEVENT)pObj->pvUser1, fFlags, uTimeout);
|
---|
[23728] | 193 |
|
---|
| 194 | SUPR0ObjRelease(pObj, pSession);
|
---|
| 195 | return rc;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 |
|
---|
[33167] | 199 | SUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
|
---|
| 200 | {
|
---|
| 201 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_UNINTERRUPTIBLE;
|
---|
| 202 | if (cMillies == RT_INDEFINITE_WAIT)
|
---|
| 203 | fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
|
---|
| 204 | return supR0SemEventWaitEx(pSession, hEvent, fFlags, cMillies);
|
---|
| 205 | }
|
---|
[87700] | 206 | SUPR0_EXPORT_SYMBOL(SUPSemEventWait);
|
---|
[33167] | 207 |
|
---|
| 208 |
|
---|
[23728] | 209 | SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
|
---|
| 210 | {
|
---|
[33167] | 211 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 212 | if (cMillies == RT_INDEFINITE_WAIT)
|
---|
| 213 | fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
|
---|
| 214 | return supR0SemEventWaitEx(pSession, hEvent, fFlags, cMillies);
|
---|
| 215 | }
|
---|
[87700] | 216 | SUPR0_EXPORT_SYMBOL(SUPSemEventWaitNoResume);
|
---|
[23728] | 217 |
|
---|
| 218 |
|
---|
[33167] | 219 | SUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout)
|
---|
| 220 | {
|
---|
| 221 | uint32_t fFlags = RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 222 | return supR0SemEventWaitEx(pSession, hEvent, fFlags, uNsTimeout);
|
---|
| 223 | }
|
---|
[87700] | 224 | SUPR0_EXPORT_SYMBOL(SUPSemEventWaitNsAbsIntr);
|
---|
[23728] | 225 |
|
---|
[33167] | 226 |
|
---|
| 227 | SUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout)
|
---|
| 228 | {
|
---|
| 229 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 230 | return supR0SemEventWaitEx(pSession, hEvent, fFlags, cNsTimeout);
|
---|
[23728] | 231 | }
|
---|
[87700] | 232 | SUPR0_EXPORT_SYMBOL(SUPSemEventWaitNsRelIntr);
|
---|
[23728] | 233 |
|
---|
| 234 |
|
---|
[33167] | 235 | SUPDECL(uint32_t) SUPSemEventGetResolution(PSUPDRVSESSION pSession)
|
---|
| 236 | {
|
---|
[62665] | 237 | RT_NOREF1(pSession);
|
---|
[33167] | 238 | Assert(SUP_IS_SESSION_VALID(pSession));
|
---|
| 239 | return RTSemEventGetResolution();
|
---|
| 240 | }
|
---|
[87700] | 241 | SUPR0_EXPORT_SYMBOL(SUPSemEventGetResolution);
|
---|
[33167] | 242 |
|
---|
| 243 |
|
---|
[23728] | 244 | /**
|
---|
| 245 | * Destructor for objects created by SUPSemEventMultiCreate.
|
---|
| 246 | *
|
---|
| 247 | * @param pvObj The object handle.
|
---|
| 248 | * @param pvUser1 The IPRT event handle.
|
---|
| 249 | * @param pvUser2 NULL.
|
---|
| 250 | */
|
---|
| 251 | static DECLCALLBACK(void) supR0SemEventMultiDestructor(void *pvObj, void *pvUser1, void *pvUser2)
|
---|
| 252 | {
|
---|
| 253 | Assert(pvUser2 == NULL);
|
---|
[62665] | 254 | RT_NOREF2(pvObj, pvUser2);
|
---|
[23728] | 255 | RTSemEventMultiDestroy((RTSEMEVENTMULTI)pvUser1);
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 |
|
---|
| 259 | SUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti)
|
---|
| 260 | {
|
---|
| 261 | int rc;
|
---|
| 262 | RTSEMEVENTMULTI hEventMultReal;
|
---|
| 263 |
|
---|
| 264 | /*
|
---|
| 265 | * Input validation.
|
---|
| 266 | */
|
---|
| 267 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 268 | AssertPtrReturn(phEventMulti, VERR_INVALID_POINTER);
|
---|
| 269 |
|
---|
| 270 | /*
|
---|
| 271 | * Create the event semaphore object.
|
---|
| 272 | */
|
---|
| 273 | rc = RTSemEventMultiCreate(&hEventMultReal);
|
---|
| 274 | if (RT_SUCCESS(rc))
|
---|
| 275 | {
|
---|
| 276 | void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT_MULTI, supR0SemEventMultiDestructor, hEventMultReal, NULL);
|
---|
| 277 | if (pvObj)
|
---|
| 278 | {
|
---|
| 279 | uint32_t h32;
|
---|
| 280 | rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT_MULTI, &h32);
|
---|
| 281 | if (RT_SUCCESS(rc))
|
---|
| 282 | {
|
---|
| 283 | *phEventMulti = (SUPSEMEVENTMULTI)(uintptr_t)h32;
|
---|
| 284 | return VINF_SUCCESS;
|
---|
| 285 | }
|
---|
| 286 | SUPR0ObjRelease(pvObj, pSession);
|
---|
| 287 | }
|
---|
| 288 | else
|
---|
| 289 | RTSemEventMultiDestroy(hEventMultReal);
|
---|
| 290 | }
|
---|
| 291 | return rc;
|
---|
| 292 | }
|
---|
[87700] | 293 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiCreate);
|
---|
[23728] | 294 |
|
---|
| 295 |
|
---|
| 296 | SUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
| 297 | {
|
---|
| 298 | uint32_t h32;
|
---|
| 299 | PSUPDRVOBJ pObj;
|
---|
| 300 |
|
---|
| 301 | /*
|
---|
| 302 | * Input validation.
|
---|
| 303 | */
|
---|
| 304 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 305 | if (hEventMulti == NIL_SUPSEMEVENTMULTI)
|
---|
| 306 | return VINF_SUCCESS;
|
---|
| 307 | h32 = (uint32_t)(uintptr_t)hEventMulti;
|
---|
| 308 | if (h32 != (uintptr_t)hEventMulti)
|
---|
| 309 | return VERR_INVALID_HANDLE;
|
---|
| 310 |
|
---|
| 311 | /*
|
---|
| 312 | * Do the job.
|
---|
| 313 | */
|
---|
| 314 | pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
|
---|
| 315 | if (!pObj)
|
---|
| 316 | return VERR_INVALID_HANDLE;
|
---|
| 317 |
|
---|
| 318 | Assert(pObj->cUsage >= 2);
|
---|
| 319 | SUPR0ObjRelease(pObj, pSession); /* The free call above. */
|
---|
| 320 | return SUPR0ObjRelease(pObj, pSession); /* The handle table reference. */
|
---|
| 321 | }
|
---|
[87700] | 322 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiClose);
|
---|
[23728] | 323 |
|
---|
| 324 |
|
---|
| 325 | SUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
| 326 | {
|
---|
| 327 | int rc;
|
---|
| 328 | uint32_t h32;
|
---|
| 329 | PSUPDRVOBJ pObj;
|
---|
| 330 |
|
---|
| 331 | /*
|
---|
| 332 | * Input validation.
|
---|
| 333 | */
|
---|
| 334 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 335 | h32 = (uint32_t)(uintptr_t)hEventMulti;
|
---|
| 336 | if (h32 != (uintptr_t)hEventMulti)
|
---|
| 337 | return VERR_INVALID_HANDLE;
|
---|
| 338 | pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
|
---|
| 339 | if (!pObj)
|
---|
| 340 | return VERR_INVALID_HANDLE;
|
---|
| 341 |
|
---|
| 342 | /*
|
---|
| 343 | * Do the job.
|
---|
| 344 | */
|
---|
| 345 | rc = RTSemEventMultiSignal((RTSEMEVENTMULTI)pObj->pvUser1);
|
---|
| 346 |
|
---|
| 347 | SUPR0ObjRelease(pObj, pSession);
|
---|
| 348 | return rc;
|
---|
| 349 | }
|
---|
[87700] | 350 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiSignal);
|
---|
[23728] | 351 |
|
---|
| 352 |
|
---|
| 353 | SUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
| 354 | {
|
---|
| 355 | int rc;
|
---|
| 356 | uint32_t h32;
|
---|
| 357 | PSUPDRVOBJ pObj;
|
---|
| 358 |
|
---|
| 359 | /*
|
---|
| 360 | * Input validation.
|
---|
| 361 | */
|
---|
| 362 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 363 | h32 = (uint32_t)(uintptr_t)hEventMulti;
|
---|
| 364 | if (h32 != (uintptr_t)hEventMulti)
|
---|
| 365 | return VERR_INVALID_HANDLE;
|
---|
| 366 | pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
|
---|
| 367 | if (!pObj)
|
---|
| 368 | return VERR_INVALID_HANDLE;
|
---|
| 369 |
|
---|
| 370 | /*
|
---|
| 371 | * Do the job.
|
---|
| 372 | */
|
---|
| 373 | rc = RTSemEventMultiReset((RTSEMEVENTMULTI)pObj->pvUser1);
|
---|
| 374 |
|
---|
| 375 | SUPR0ObjRelease(pObj, pSession);
|
---|
| 376 | return rc;
|
---|
| 377 | }
|
---|
[87700] | 378 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiReset);
|
---|
[23728] | 379 |
|
---|
| 380 |
|
---|
[33167] | 381 | static int supR0SemEventMultiWaitEx(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t fFlags, uint64_t uTimeout)
|
---|
[23728] | 382 | {
|
---|
| 383 | int rc;
|
---|
| 384 | uint32_t h32;
|
---|
| 385 | PSUPDRVOBJ pObj;
|
---|
| 386 |
|
---|
| 387 | /*
|
---|
| 388 | * Input validation.
|
---|
| 389 | */
|
---|
| 390 | AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
|
---|
| 391 | h32 = (uint32_t)(uintptr_t)hEventMulti;
|
---|
| 392 | if (h32 != (uintptr_t)hEventMulti)
|
---|
| 393 | return VERR_INVALID_HANDLE;
|
---|
| 394 | pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
|
---|
| 395 | if (!pObj)
|
---|
| 396 | return VERR_INVALID_HANDLE;
|
---|
| 397 |
|
---|
| 398 | /*
|
---|
| 399 | * Do the job.
|
---|
| 400 | */
|
---|
[33167] | 401 | rc = RTSemEventMultiWaitEx((RTSEMEVENTMULTI)pObj->pvUser1, fFlags, uTimeout);
|
---|
[23728] | 402 |
|
---|
| 403 | SUPR0ObjRelease(pObj, pSession);
|
---|
| 404 | return rc;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[87700] | 407 |
|
---|
[33167] | 408 | SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
|
---|
| 409 | {
|
---|
| 410 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_UNINTERRUPTIBLE;
|
---|
| 411 | if (cMillies == RT_INDEFINITE_WAIT)
|
---|
| 412 | fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
|
---|
| 413 | return supR0SemEventMultiWaitEx(pSession, hEventMulti, fFlags, cMillies);
|
---|
| 414 | }
|
---|
[87700] | 415 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiWait);
|
---|
[23728] | 416 |
|
---|
[33167] | 417 |
|
---|
| 418 |
|
---|
[23728] | 419 | SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
|
---|
| 420 | {
|
---|
[33167] | 421 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 422 | if (cMillies == RT_INDEFINITE_WAIT)
|
---|
| 423 | fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
|
---|
| 424 | return supR0SemEventMultiWaitEx(pSession, hEventMulti, fFlags, cMillies);
|
---|
| 425 | }
|
---|
[87700] | 426 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiWaitNoResume);
|
---|
[23728] | 427 |
|
---|
| 428 |
|
---|
[33167] | 429 | SUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout)
|
---|
| 430 | {
|
---|
| 431 | uint32_t fFlags = RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 432 | return supR0SemEventMultiWaitEx(pSession, hEventMulti, fFlags, uNsTimeout);
|
---|
| 433 | }
|
---|
[87700] | 434 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiWaitNsAbsIntr);
|
---|
[23728] | 435 |
|
---|
[33167] | 436 |
|
---|
| 437 | SUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout)
|
---|
| 438 | {
|
---|
| 439 | uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
|
---|
| 440 | return supR0SemEventMultiWaitEx(pSession, hEventMulti, fFlags, cNsTimeout);
|
---|
[23728] | 441 | }
|
---|
[87700] | 442 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiWaitNsRelIntr);
|
---|
[23728] | 443 |
|
---|
[33167] | 444 |
|
---|
| 445 | SUPDECL(uint32_t) SUPSemEventMultiGetResolution(PSUPDRVSESSION pSession)
|
---|
| 446 | {
|
---|
[62665] | 447 | RT_NOREF1(pSession);
|
---|
[33167] | 448 | Assert(SUP_IS_SESSION_VALID(pSession));
|
---|
| 449 | return RTSemEventMultiGetResolution();
|
---|
| 450 | }
|
---|
[87700] | 451 | SUPR0_EXPORT_SYMBOL(SUPSemEventMultiGetResolution);
|
---|