vbox_utils.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /**
  22. * Allocate memory for generic request and initialize the request header.
  23. *
  24. * Return: the allocated memory
  25. * @len: Size of memory block required for the request.
  26. * @req_type: The generic request type.
  27. */
  28. void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type);
  29. /**
  30. * Perform a generic request.
  31. *
  32. * Return: VBox status code
  33. * @gdev: The Guest extension device.
  34. * @req: Pointer to the request structure.
  35. */
  36. int vbg_req_perform(struct vbg_dev *gdev, void *req);
  37. int vbg_hgcm_connect(struct vbg_dev *gdev,
  38. struct vmmdev_hgcm_service_location *loc,
  39. u32 *client_id, int *vbox_status);
  40. int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status);
  41. int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function,
  42. u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms,
  43. u32 parm_count, int *vbox_status);
  44. int vbg_hgcm_call32(
  45. struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms,
  46. struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count,
  47. int *vbox_status);
  48. /**
  49. * Convert a VirtualBox status code to a standard Linux kernel return value.
  50. * Return: 0 or negative errno value.
  51. * @rc: VirtualBox status code to convert.
  52. */
  53. int vbg_status_code_to_errno(int rc);
  54. /**
  55. * Helper for the vboxsf driver to get a reference to the guest device.
  56. * Return: a pointer to the gdev; or a ERR_PTR value on error.
  57. */
  58. struct vbg_dev *vbg_get_gdev(void);
  59. /**
  60. * Helper for the vboxsf driver to put a guest device reference.
  61. * @gdev: Reference returned by vbg_get_gdev to put.
  62. */
  63. void vbg_put_gdev(struct vbg_dev *gdev);
  64. #endif