1 /* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
2 /* Copyright (C) 2006-2016 Oracle Corporation */
4 #ifndef __VBOX_UTILS_H__
5 #define __VBOX_UTILS_H__
7 #include <linux/printk.h>
8 #include <linux/vbox_vmmdev_types.h>
13 * vboxguest logging functions, these log both to the backdoor and call
14 * the equivalent kernel pr_foo function.
16 __printf(1, 2) void vbg_info(const char *fmt, ...);
17 __printf(1, 2) void vbg_warn(const char *fmt, ...);
18 __printf(1, 2) void vbg_err(const char *fmt, ...);
20 /* Only use backdoor logging for non-dynamic debug builds */
21 #if defined(DEBUG) && !defined(CONFIG_DYNAMIC_DEBUG)
22 __printf(1, 2) void vbg_debug(const char *fmt, ...);
24 #define vbg_debug pr_debug
27 int vbg_hgcm_connect(struct vbg_dev *gdev, u32 requestor,
28 struct vmmdev_hgcm_service_location *loc,
29 u32 *client_id, int *vbox_status);
31 int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 requestor,
32 u32 client_id, int *vbox_status);
34 int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id,
35 u32 function, u32 timeout_ms,
36 struct vmmdev_hgcm_function_parameter *parms, u32 parm_count,
40 * Convert a VirtualBox status code to a standard Linux kernel return value.
41 * Return: 0 or negative errno value.
42 * @rc: VirtualBox status code to convert.
44 int vbg_status_code_to_errno(int rc);
47 * Helper for the vboxsf driver to get a reference to the guest device.
48 * Return: a pointer to the gdev; or a ERR_PTR value on error.
50 struct vbg_dev *vbg_get_gdev(void);
53 * Helper for the vboxsf driver to put a guest device reference.
54 * @gdev: Reference returned by vbg_get_gdev to put.
56 void vbg_put_gdev(struct vbg_dev *gdev);