Home | History | Annotate | Line # | Download | only in gvt
      1  1.1  riastrad /*	$NetBSD: hypercall.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     14  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     15  1.1  riastrad  * Software.
     16  1.1  riastrad  *
     17  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  1.1  riastrad  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     21  1.1  riastrad  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     22  1.1  riastrad  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     23  1.1  riastrad  * SOFTWARE.
     24  1.1  riastrad  *
     25  1.1  riastrad  * Authors:
     26  1.1  riastrad  *    Eddie Dong <eddie.dong (at) intel.com>
     27  1.1  riastrad  *    Dexuan Cui
     28  1.1  riastrad  *    Jike Song <jike.song (at) intel.com>
     29  1.1  riastrad  *
     30  1.1  riastrad  * Contributors:
     31  1.1  riastrad  *    Zhi Wang <zhi.a.wang (at) intel.com>
     32  1.1  riastrad  *
     33  1.1  riastrad  */
     34  1.1  riastrad 
     35  1.1  riastrad #ifndef _GVT_HYPERCALL_H_
     36  1.1  riastrad #define _GVT_HYPERCALL_H_
     37  1.1  riastrad 
     38  1.1  riastrad #include <linux/types.h>
     39  1.1  riastrad 
     40  1.1  riastrad struct device;
     41  1.1  riastrad 
     42  1.1  riastrad enum hypervisor_type {
     43  1.1  riastrad 	INTEL_GVT_HYPERVISOR_XEN = 0,
     44  1.1  riastrad 	INTEL_GVT_HYPERVISOR_KVM,
     45  1.1  riastrad };
     46  1.1  riastrad 
     47  1.1  riastrad /*
     48  1.1  riastrad  * Specific GVT-g MPT modules function collections. Currently GVT-g supports
     49  1.1  riastrad  * both Xen and KVM by providing dedicated hypervisor-related MPT modules.
     50  1.1  riastrad  */
     51  1.1  riastrad struct intel_gvt_mpt {
     52  1.1  riastrad 	enum hypervisor_type type;
     53  1.1  riastrad 	int (*host_init)(struct device *dev, void *gvt, const void *ops);
     54  1.1  riastrad 	void (*host_exit)(struct device *dev);
     55  1.1  riastrad 	int (*attach_vgpu)(void *vgpu, unsigned long *handle);
     56  1.1  riastrad 	void (*detach_vgpu)(void *vgpu);
     57  1.1  riastrad 	int (*inject_msi)(unsigned long handle, u32 addr, u16 data);
     58  1.1  riastrad 	unsigned long (*from_virt_to_mfn)(void *p);
     59  1.1  riastrad 	int (*enable_page_track)(unsigned long handle, u64 gfn);
     60  1.1  riastrad 	int (*disable_page_track)(unsigned long handle, u64 gfn);
     61  1.1  riastrad 	int (*read_gpa)(unsigned long handle, unsigned long gpa, void *buf,
     62  1.1  riastrad 			unsigned long len);
     63  1.1  riastrad 	int (*write_gpa)(unsigned long handle, unsigned long gpa, void *buf,
     64  1.1  riastrad 			 unsigned long len);
     65  1.1  riastrad 	unsigned long (*gfn_to_mfn)(unsigned long handle, unsigned long gfn);
     66  1.1  riastrad 
     67  1.1  riastrad 	int (*dma_map_guest_page)(unsigned long handle, unsigned long gfn,
     68  1.1  riastrad 				  unsigned long size, dma_addr_t *dma_addr);
     69  1.1  riastrad 	void (*dma_unmap_guest_page)(unsigned long handle, dma_addr_t dma_addr);
     70  1.1  riastrad 
     71  1.1  riastrad 	int (*dma_pin_guest_page)(unsigned long handle, dma_addr_t dma_addr);
     72  1.1  riastrad 
     73  1.1  riastrad 	int (*map_gfn_to_mfn)(unsigned long handle, unsigned long gfn,
     74  1.1  riastrad 			      unsigned long mfn, unsigned int nr, bool map);
     75  1.1  riastrad 	int (*set_trap_area)(unsigned long handle, u64 start, u64 end,
     76  1.1  riastrad 			     bool map);
     77  1.1  riastrad 	int (*set_opregion)(void *vgpu);
     78  1.1  riastrad 	int (*set_edid)(void *vgpu, int port_num);
     79  1.1  riastrad 	int (*get_vfio_device)(void *vgpu);
     80  1.1  riastrad 	void (*put_vfio_device)(void *vgpu);
     81  1.1  riastrad 	bool (*is_valid_gfn)(unsigned long handle, unsigned long gfn);
     82  1.1  riastrad };
     83  1.1  riastrad 
     84  1.1  riastrad extern struct intel_gvt_mpt xengt_mpt;
     85  1.1  riastrad 
     86  1.1  riastrad #endif /* _GVT_HYPERCALL_H_ */
     87