Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
0002 /* Copyright (C) 2006-2016 Oracle Corporation */
0003 
0004 #ifndef __VBOX_UTILS_H__
0005 #define __VBOX_UTILS_H__
0006 
0007 #include <linux/printk.h>
0008 #include <linux/vbox_vmmdev_types.h>
0009 
0010 struct vbg_dev;
0011 
0012 /**
0013  * vboxguest logging functions, these log both to the backdoor and call
0014  * the equivalent kernel pr_foo function.
0015  */
0016 __printf(1, 2) void vbg_info(const char *fmt, ...);
0017 __printf(1, 2) void vbg_warn(const char *fmt, ...);
0018 __printf(1, 2) void vbg_err(const char *fmt, ...);
0019 __printf(1, 2) void vbg_err_ratelimited(const char *fmt, ...);
0020 
0021 /* Only use backdoor logging for non-dynamic debug builds */
0022 #if defined(DEBUG) && !defined(CONFIG_DYNAMIC_DEBUG)
0023 __printf(1, 2) void vbg_debug(const char *fmt, ...);
0024 #else
0025 #define vbg_debug pr_debug
0026 #endif
0027 
0028 int vbg_hgcm_connect(struct vbg_dev *gdev, u32 requestor,
0029              struct vmmdev_hgcm_service_location *loc,
0030              u32 *client_id, int *vbox_status);
0031 
0032 int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 requestor,
0033             u32 client_id, int *vbox_status);
0034 
0035 int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id,
0036           u32 function, u32 timeout_ms,
0037           struct vmmdev_hgcm_function_parameter *parms, u32 parm_count,
0038           int *vbox_status);
0039 
0040 /**
0041  * Convert a VirtualBox status code to a standard Linux kernel return value.
0042  * Return: 0 or negative errno value.
0043  * @rc:         VirtualBox status code to convert.
0044  */
0045 int vbg_status_code_to_errno(int rc);
0046 
0047 /**
0048  * Helper for the vboxsf driver to get a reference to the guest device.
0049  * Return: a pointer to the gdev; or a ERR_PTR value on error.
0050  */
0051 struct vbg_dev *vbg_get_gdev(void);
0052 
0053 /**
0054  * Helper for the vboxsf driver to put a guest device reference.
0055  * @gdev:       Reference returned by vbg_get_gdev to put.
0056  */
0057 void vbg_put_gdev(struct vbg_dev *gdev);
0058 
0059 #endif