VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibEvent.cpp

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id Revision
File size: 4.1 KB
RevLine 
[6447]1/* $Id: VBoxGuestR3LibEvent.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
[5824]2/** @file
[27083]3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Events.
[5824]4 */
5
6/*
[98103]7 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
[5824]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
[8155]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 *
[26425]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
[26425]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
[5824]35 */
36
37
[57358]38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
[7437]41#include <VBox/log.h>
[68688]42#include <iprt/assert.h>
[68650]43#include "VBoxGuestR3LibInternal.h"
[5824]44
[21211]45
[5824]46/**
[21978]47 * Wait for the host to signal one or more events and return which.
[21912]48 *
[21978]49 * The events will only be delivered by the host if they have been enabled
50 * previously using @a VbglR3CtlFilterMask. If one or several of the events
51 * have already been signalled but not yet waited for, this function will return
52 * immediately and return those events.
53 *
[27080]54 * @returns IPRT status code.
[21978]55 *
56 * @param fMask The events we want to wait for, or-ed together.
57 * @param cMillies How long to wait before giving up and returning
58 * (VERR_TIMEOUT). Use RT_INDEFINITE_WAIT to wait until we
59 * are interrupted or one of the events is signalled.
60 * @param pfEvents Where to store the events signalled. Optional.
[21912]61 */
[21978]62VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents)
[21912]63{
[68550]64 LogFlow(("VbglR3WaitEvent: fMask=%#x, cMillies=%u, pfEvents=%p\n", fMask, cMillies, pfEvents));
[21978]65 AssertReturn((fMask & ~VMMDEV_EVENT_VALID_EVENT_MASK) == 0, VERR_INVALID_PARAMETER);
66 AssertPtrNullReturn(pfEvents, VERR_INVALID_POINTER);
[21912]67
[68550]68 VBGLIOCWAITFOREVENTS WaitEvents;
69 VBGLREQHDR_INIT(&WaitEvents.Hdr, WAIT_FOR_EVENTS);
70 WaitEvents.u.In.fEvents = fMask;
71 WaitEvents.u.In.cMsTimeOut = cMillies;
72 int rc = vbglR3DoIOCtl(VBGL_IOCTL_WAIT_FOR_EVENTS, &WaitEvents.Hdr, sizeof(WaitEvents));
73 if (pfEvents)
[21978]74 {
[68550]75 if (RT_SUCCESS(rc))
76 *pfEvents = WaitEvents.u.Out.fEvents;
77 else
78 *pfEvents = 0;
[21978]79 }
80
[68550]81 LogFlow(("VbglR3WaitEvent: rc=%Rrc fEvents=%#x\n", rc, WaitEvents.u.Out.fEvents));
[21912]82 return rc;
83}
84
85
86/**
[68550]87 * Causes any pending VbglR3WaitEvent calls (VBGL_IOCTL_WAIT_FOR_EVENTS) to
88 * return with a VERR_INTERRUPTED status.
[6246]89 *
90 * Can be used in combination with a termination flag variable for interrupting
[68550]91 * event loops. After calling this, VBGL_IOCTL_WAIT_FOR_EVENTS should no longer
[67798]92 * be called in the same session. At the time of writing this is not enforced;
93 * at the time of reading it may be.
[5824]94 *
[27080]95 * @returns IPRT status code.
[5824]96 */
97VBGLR3DECL(int) VbglR3InterruptEventWaits(void)
98{
[68550]99 VBGLREQHDR Req;
100 VBGLREQHDR_INIT(&Req, INTERRUPT_ALL_WAIT_FOR_EVENTS);
101 return vbglR3DoIOCtl(VBGL_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS, &Req, sizeof(Req));
[5824]102}
[6231]103
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use