1 | /* $Id: VBoxGuestR3LibMisc.cpp 6538 2008-01-28 19:50:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Misc.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 innotek GmbH
|
---|
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 |
|
---|
18 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #ifndef VBOX_VBGLR3_XFREE86
|
---|
23 | # include <iprt/assert.h>
|
---|
24 | #endif
|
---|
25 | #include "VBGLR3Internal.h"
|
---|
26 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Cause any pending WaitEvent calls (VBOXGUEST_IOCTL_WAITEVENT) to return
|
---|
30 | * with a VERR_INTERRUPTED status.
|
---|
31 | *
|
---|
32 | * Can be used in combination with a termination flag variable for interrupting
|
---|
33 | * event loops. Avoiding race conditions is the responsibility of the caller.
|
---|
34 | *
|
---|
35 | * @returns IPRT status code
|
---|
36 | */
|
---|
37 | VBGLR3DECL(int) VbglR3InterruptEventWaits(void)
|
---|
38 | {
|
---|
39 | return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS, 0, 0);
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Write to the backdoor logger from ring 3 guest code.
|
---|
45 | *
|
---|
46 | * @returns IPRT status code
|
---|
47 | *
|
---|
48 | * @remarks This currently does not accept more than 255 bytes of data at
|
---|
49 | * one time. It should probably be rewritten to use pass a pointer
|
---|
50 | * in the IOCtl.
|
---|
51 | */
|
---|
52 | VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cb)
|
---|
53 | {
|
---|
54 | /*
|
---|
55 | * *BSD does not accept more than 4KB per ioctl request,
|
---|
56 | * so, split it up into 2KB chunks.
|
---|
57 | */
|
---|
58 | #define STEP 2048
|
---|
59 | int rc = VINF_SUCCESS;
|
---|
60 | for (size_t off = 0; off < cb && RT_SUCCESS(rc); off += STEP)
|
---|
61 | {
|
---|
62 | size_t cbStep = RT_MIN(cb - off, STEP);
|
---|
63 | rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_LOG(cbStep), (char *)pch + off, cbStep);
|
---|
64 | }
|
---|
65 | #undef STEP
|
---|
66 | return rc;
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Change the IRQ filter mask.
|
---|
72 | *
|
---|
73 | * @returns IPRT status code
|
---|
74 | * @param fOr The OR mask.
|
---|
75 | * @param fNo The NOT mask.
|
---|
76 | */
|
---|
77 | VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot)
|
---|
78 | {
|
---|
79 | VBoxGuestFilterMaskInfo Info;
|
---|
80 | Info.u32OrMask = fOr;
|
---|
81 | Info.u32NotMask = fNot;
|
---|
82 | return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CTL_FILTER_MASK, &Info, sizeof(Info));
|
---|
83 | }
|
---|