18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next
128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
138c2ecf20Sopenharmony_ci * Software.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
208c2ecf20Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
218c2ecf20Sopenharmony_ci * SOFTWARE.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#ifndef _I915_PVINFO_H_
258c2ecf20Sopenharmony_ci#define _I915_PVINFO_H_
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <linux/types.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* The MMIO offset of the shared info between guest and host emulator */
308c2ecf20Sopenharmony_ci#define VGT_PVINFO_PAGE	0x78000
318c2ecf20Sopenharmony_ci#define VGT_PVINFO_SIZE	0x1000
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * The following structure pages are defined in GEN MMIO space
358c2ecf20Sopenharmony_ci * for virtualization. (One page for now)
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci#define VGT_MAGIC         0x4776544776544776ULL	/* 'vGTvGTvG' */
388c2ecf20Sopenharmony_ci#define VGT_VERSION_MAJOR 1
398c2ecf20Sopenharmony_ci#define VGT_VERSION_MINOR 0
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/*
428c2ecf20Sopenharmony_ci * notifications from guest to vgpu device model
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_cienum vgt_g2v_type {
458c2ecf20Sopenharmony_ci	VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE = 2,
468c2ecf20Sopenharmony_ci	VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY,
478c2ecf20Sopenharmony_ci	VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE,
488c2ecf20Sopenharmony_ci	VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY,
498c2ecf20Sopenharmony_ci	VGT_G2V_EXECLIST_CONTEXT_CREATE,
508c2ecf20Sopenharmony_ci	VGT_G2V_EXECLIST_CONTEXT_DESTROY,
518c2ecf20Sopenharmony_ci	VGT_G2V_MAX,
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * VGT capabilities type
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci#define VGT_CAPS_FULL_PPGTT		BIT(2)
588c2ecf20Sopenharmony_ci#define VGT_CAPS_HWSP_EMULATION		BIT(3)
598c2ecf20Sopenharmony_ci#define VGT_CAPS_HUGE_GTT		BIT(4)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistruct vgt_if {
628c2ecf20Sopenharmony_ci	u64 magic;		/* VGT_MAGIC */
638c2ecf20Sopenharmony_ci	u16 version_major;
648c2ecf20Sopenharmony_ci	u16 version_minor;
658c2ecf20Sopenharmony_ci	u32 vgt_id;		/* ID of vGT instance */
668c2ecf20Sopenharmony_ci	u32 vgt_caps;		/* VGT capabilities */
678c2ecf20Sopenharmony_ci	u32 rsv1[11];		/* pad to offset 0x40 */
688c2ecf20Sopenharmony_ci	/*
698c2ecf20Sopenharmony_ci	 *  Data structure to describe the balooning info of resources.
708c2ecf20Sopenharmony_ci	 *  Each VM can only have one portion of continuous area for now.
718c2ecf20Sopenharmony_ci	 *  (May support scattered resource in future)
728c2ecf20Sopenharmony_ci	 *  (starting from offset 0x40)
738c2ecf20Sopenharmony_ci	 */
748c2ecf20Sopenharmony_ci	struct {
758c2ecf20Sopenharmony_ci		/* Aperture register balooning */
768c2ecf20Sopenharmony_ci		struct {
778c2ecf20Sopenharmony_ci			u32 base;
788c2ecf20Sopenharmony_ci			u32 size;
798c2ecf20Sopenharmony_ci		} mappable_gmadr;	/* aperture */
808c2ecf20Sopenharmony_ci		/* GMADR register balooning */
818c2ecf20Sopenharmony_ci		struct {
828c2ecf20Sopenharmony_ci			u32 base;
838c2ecf20Sopenharmony_ci			u32 size;
848c2ecf20Sopenharmony_ci		} nonmappable_gmadr;	/* non aperture */
858c2ecf20Sopenharmony_ci		/* allowed fence registers */
868c2ecf20Sopenharmony_ci		u32 fence_num;
878c2ecf20Sopenharmony_ci		u32 rsv2[3];
888c2ecf20Sopenharmony_ci	} avail_rs;		/* available/assigned resource */
898c2ecf20Sopenharmony_ci	u32 rsv3[0x200 - 24];	/* pad to half page */
908c2ecf20Sopenharmony_ci	/*
918c2ecf20Sopenharmony_ci	 * The bottom half page is for response from Gfx driver to hypervisor.
928c2ecf20Sopenharmony_ci	 */
938c2ecf20Sopenharmony_ci	u32 rsv4;
948c2ecf20Sopenharmony_ci	u32 display_ready;	/* ready for display owner switch */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	u32 rsv5[4];
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	u32 g2v_notify;
998c2ecf20Sopenharmony_ci	u32 rsv6[5];
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	u32 cursor_x_hot;
1028c2ecf20Sopenharmony_ci	u32 cursor_y_hot;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	struct {
1058c2ecf20Sopenharmony_ci		u32 lo;
1068c2ecf20Sopenharmony_ci		u32 hi;
1078c2ecf20Sopenharmony_ci	} pdp[4];
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	u32 execlist_context_descriptor_lo;
1108c2ecf20Sopenharmony_ci	u32 execlist_context_descriptor_hi;
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	u32  rsv7[0x200 - 24];    /* pad to one page */
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define vgtif_offset(x) (offsetof(struct vgt_if, x))
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define vgtif_reg(x) _MMIO(VGT_PVINFO_PAGE + vgtif_offset(x))
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/* vGPU display status to be used by the host side */
1208c2ecf20Sopenharmony_ci#define VGT_DRV_DISPLAY_NOT_READY 0
1218c2ecf20Sopenharmony_ci#define VGT_DRV_DISPLAY_READY     1  /* ready for display switch */
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#endif /* _I915_PVINFO_H_ */
124