vbox_utils.h 1.6 KB

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