VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibEvent.cpp@ 27083

Last change on this file since 27083 was 27083, checked in by vboxsync, 15 years ago

VBoxGuestLib: split up VBoxGuestR3LibMisc.cpp.

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1/* $Id: VBoxGuestR3LibEvent.cpp 27083 2010-03-05 13:05:51Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Events.
4 */
5
6/*
7 * Copyright (C) 2007-2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include <VBox/log.h>
36#include "VBGLR3Internal.h"
37
38
39/**
40 * Wait for the host to signal one or more events and return which.
41 *
42 * The events will only be delivered by the host if they have been enabled
43 * previously using @a VbglR3CtlFilterMask. If one or several of the events
44 * have already been signalled but not yet waited for, this function will return
45 * immediately and return those events.
46 *
47 * @returns IPRT status code.
48 *
49 * @param fMask The events we want to wait for, or-ed together.
50 * @param cMillies How long to wait before giving up and returning
51 * (VERR_TIMEOUT). Use RT_INDEFINITE_WAIT to wait until we
52 * are interrupted or one of the events is signalled.
53 * @param pfEvents Where to store the events signalled. Optional.
54 */
55VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents)
56{
57#ifndef VBOX_VBGLR3_XFREE86
58 LogFlow(("VbglR3WaitEvent: fMask=0x%x, cMillies=%u, pfEvents=%p\n",
59 fMask, cMillies, pfEvents));
60 AssertReturn((fMask & ~VMMDEV_EVENT_VALID_EVENT_MASK) == 0, VERR_INVALID_PARAMETER);
61 AssertPtrNullReturn(pfEvents, VERR_INVALID_POINTER);
62#endif
63
64 VBoxGuestWaitEventInfo waitEvent;
65 waitEvent.u32TimeoutIn = cMillies;
66 waitEvent.u32EventMaskIn = fMask;
67 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
68 waitEvent.u32EventFlagsOut = 0;
69 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
70 if (RT_SUCCESS(rc))
71 {
72#if !defined(VBOX_VBGLR3_XFREE86) && !defined(RT_OS_WINDOWS)
73 AssertMsg(waitEvent.u32Result == VBOXGUEST_WAITEVENT_OK, ("%d rc=%Rrc\n", waitEvent.u32Result, rc));
74#endif
75 if (pfEvents)
76 *pfEvents = waitEvent.u32EventFlagsOut;
77 }
78
79#ifndef VBOX_VBGLR3_XFREE86
80 LogFlow(("VbglR3WaitEvent: rc=%Rrc, u32EventFlagsOut=0x%x. u32Result=%d\n",
81 rc, waitEvent.u32EventFlagsOut, waitEvent.u32Result));
82#endif
83 return rc;
84}
85
86
87/**
88 * Cause any pending WaitEvent calls (VBOXGUEST_IOCTL_WAITEVENT) to return
89 * with a VERR_INTERRUPTED status.
90 *
91 * Can be used in combination with a termination flag variable for interrupting
92 * event loops. Avoiding race conditions is the responsibility of the caller.
93 *
94 * @returns IPRT status code.
95 */
96VBGLR3DECL(int) VbglR3InterruptEventWaits(void)
97{
98 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS, 0, 0);
99}
100
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette