VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp@ 10606

Last change on this file since 10606 was 10606, checked in by vboxsync, 16 years ago

Backed out r33286.

  • 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: VBoxGuestR3LibMisc.cpp 10606 2008-07-14 15:58:53Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Misc.
4 */
5
6/*
7 * Copyright (C) 2007 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <VBox/log.h>
27
28#include "VBGLR3Internal.h"
29
30/**
31 * Cause any pending WaitEvent calls (VBOXGUEST_IOCTL_WAITEVENT) to return
32 * with a VERR_INTERRUPTED status.
33 *
34 * Can be used in combination with a termination flag variable for interrupting
35 * event loops. Avoiding race conditions is the responsibility of the caller.
36 *
37 * @returns IPRT status code
38 */
39VBGLR3DECL(int) VbglR3InterruptEventWaits(void)
40{
41 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS, 0, 0);
42}
43
44
45/**
46 * Write to the backdoor logger from ring 3 guest code.
47 *
48 * @returns IPRT status code
49 *
50 * @remarks This currently does not accept more than 255 bytes of data at
51 * one time. It should probably be rewritten to use pass a pointer
52 * in the IOCtl.
53 */
54VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cb)
55{
56#if defined(RT_OS_WINDOWS) /** @todo more OSes could take this route (solaris and freebsd for instance). */
57 /*
58 * Handle the entire request in one go.
59 */
60 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_LOG(cb), (char *)pch, cb);
61
62#else
63 /*
64 * *BSD does not accept more than 4KB per ioctl request, while
65 * Linux can't express sizes above 8KB, so, split it up into 2KB chunks.
66 */
67# define STEP 2048
68 int rc = VINF_SUCCESS;
69 for (size_t off = 0; off < cb && RT_SUCCESS(rc); off += STEP)
70 {
71 size_t cbStep = RT_MIN(cb - off, STEP);
72 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_LOG(cbStep), (char *)pch + off, cbStep);
73 }
74# undef STEP
75 return rc;
76#endif
77}
78
79
80/**
81 * Change the IRQ filter mask.
82 *
83 * @returns IPRT status code
84 * @param fOr The OR mask.
85 * @param fNo The NOT mask.
86 */
87VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot)
88{
89#if defined(RT_OS_WINDOWS)
90 /** @todo Not yet implemented. */
91 return VERR_NOT_SUPPORTED;
92
93#else
94
95 VBoxGuestFilterMaskInfo Info;
96 Info.u32OrMask = fOr;
97 Info.u32NotMask = fNot;
98 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CTL_FILTER_MASK, &Info, sizeof(Info));
99#endif
100}
101
102
103/**
104 * Report a change in the capabilities that we support to the host.
105 *
106 * @returns IPRT status value
107 * @param fOr Capabilities which have been added.
108 * @param fNot Capabilities which have been removed.
109 *
110 * @todo Move to a different file.
111 */
112VBGLR3DECL(int) VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot)
113{
114 VMMDevReqGuestCapabilities2 vmmreqGuestCaps;
115 int rc;
116
117 vmmdevInitRequest(&vmmreqGuestCaps.header, VMMDevReq_SetGuestCapabilities);
118 vmmreqGuestCaps.u32OrMask = fOr;
119 vmmreqGuestCaps.u32NotMask = fNot;
120 rc = vbglR3GRPerform(&vmmreqGuestCaps.header);
121#ifdef DEBUG
122 if (RT_SUCCESS(rc))
123 LogRel(("Successfully changed guest capabilities: or mask 0x%x, not mask 0x%x.\n",
124 fOr, fNot));
125 else
126 LogRel(("Failed to change guest capabilities: or mask 0x%x, not mask 0x%x. rc = %Rrc.\n",
127 fOr, fNot, rc));
128#endif
129 return rc;
130}
131
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