at v4.17-rc2 2.3 kB view raw
1/* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */ 2/* Copyright (C) 2006-2016 Oracle Corporation */ 3 4#ifndef __VBOX_UTILS_H__ 5#define __VBOX_UTILS_H__ 6 7#include <linux/printk.h> 8#include <linux/vbox_vmmdev_types.h> 9 10struct vbg_dev; 11 12/** 13 * vboxguest logging functions, these log both to the backdoor and call 14 * the equivalent kernel pr_foo function. 15 */ 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, ...); 19 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, ...); 23#else 24#define vbg_debug pr_debug 25#endif 26 27/** 28 * Allocate memory for generic request and initialize the request header. 29 * 30 * Return: the allocated memory 31 * @len: Size of memory block required for the request. 32 * @req_type: The generic request type. 33 */ 34void *vbg_req_alloc(size_t len, enum vmmdev_request_type req_type); 35 36/** 37 * Perform a generic request. 38 * 39 * Return: VBox status code 40 * @gdev: The Guest extension device. 41 * @req: Pointer to the request structure. 42 */ 43int vbg_req_perform(struct vbg_dev *gdev, void *req); 44 45int vbg_hgcm_connect(struct vbg_dev *gdev, 46 struct vmmdev_hgcm_service_location *loc, 47 u32 *client_id, int *vbox_status); 48 49int vbg_hgcm_disconnect(struct vbg_dev *gdev, u32 client_id, int *vbox_status); 50 51int vbg_hgcm_call(struct vbg_dev *gdev, u32 client_id, u32 function, 52 u32 timeout_ms, struct vmmdev_hgcm_function_parameter *parms, 53 u32 parm_count, int *vbox_status); 54 55int vbg_hgcm_call32( 56 struct vbg_dev *gdev, u32 client_id, u32 function, u32 timeout_ms, 57 struct vmmdev_hgcm_function_parameter32 *parm32, u32 parm_count, 58 int *vbox_status); 59 60/** 61 * Convert a VirtualBox status code to a standard Linux kernel return value. 62 * Return: 0 or negative errno value. 63 * @rc: VirtualBox status code to convert. 64 */ 65int vbg_status_code_to_errno(int rc); 66 67/** 68 * Helper for the vboxsf driver to get a reference to the guest device. 69 * Return: a pointer to the gdev; or a ERR_PTR value on error. 70 */ 71struct vbg_dev *vbg_get_gdev(void); 72 73/** 74 * Helper for the vboxsf driver to put a guest device reference. 75 * @gdev: Reference returned by vbg_get_gdev to put. 76 */ 77void vbg_put_gdev(struct vbg_dev *gdev); 78 79#endif