vbox_utils.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. __printf(1, 2) void vbg_err_ratelimited(const char *fmt, ...);
  16. /* Only use backdoor logging for non-dynamic debug builds */
  17. #if defined(DEBUG) && !defined(CONFIG_DYNAMIC_DEBUG)
  18. __printf(1, 2) void vbg_debug(const char *fmt, ...);
  19. #else
  20. #define vbg_debug pr_debug
  21. #endif
  22. int vbg_hgcm_connect(struct vbg_dev *gdev, u32 requestor,
  23. struct vmmdev_hgcm_service_location *loc,
  24. u32 *client_id, int *vbox_status);
  25. int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 requestor,
  26. u32 client_id, int *vbox_status);
  27. int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id,
  28. u32 function, u32 timeout_ms,
  29. struct vmmdev_hgcm_function_parameter *parms, u32 parm_count,
  30. int *vbox_status);
  31. /**
  32. * Convert a VirtualBox status code to a standard Linux kernel return value.
  33. * Return: 0 or negative errno value.
  34. * @rc: VirtualBox status code to convert.
  35. */
  36. int vbg_status_code_to_errno(int rc);
  37. /**
  38. * Helper for the vboxsf driver to get a reference to the guest device.
  39. * Return: a pointer to the gdev; or a ERR_PTR value on error.
  40. */
  41. struct vbg_dev *vbg_get_gdev(void);
  42. /**
  43. * Helper for the vboxsf driver to put a guest device reference.
  44. * @gdev: Reference returned by vbg_get_gdev to put.
  45. */
  46. void vbg_put_gdev(struct vbg_dev *gdev);
  47. #endif