mmio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Ke Yu
  25. * Kevin Tian <kevin.tian@intel.com>
  26. * Dexuan Cui
  27. *
  28. * Contributors:
  29. * Tina Zhang <tina.zhang@intel.com>
  30. * Min He <min.he@intel.com>
  31. * Niu Bing <bing.niu@intel.com>
  32. * Zhi Wang <zhi.a.wang@intel.com>
  33. *
  34. */
  35. #ifndef _GVT_MMIO_H_
  36. #define _GVT_MMIO_H_
  37. struct intel_gvt;
  38. struct intel_vgpu;
  39. #define D_SNB (1 << 0)
  40. #define D_IVB (1 << 1)
  41. #define D_HSW (1 << 2)
  42. #define D_BDW (1 << 3)
  43. #define D_SKL (1 << 4)
  44. #define D_GEN9PLUS (D_SKL)
  45. #define D_GEN8PLUS (D_BDW | D_SKL)
  46. #define D_GEN75PLUS (D_HSW | D_BDW | D_SKL)
  47. #define D_GEN7PLUS (D_IVB | D_HSW | D_BDW | D_SKL)
  48. #define D_SKL_PLUS (D_SKL)
  49. #define D_BDW_PLUS (D_BDW | D_SKL)
  50. #define D_HSW_PLUS (D_HSW | D_BDW | D_SKL)
  51. #define D_IVB_PLUS (D_IVB | D_HSW | D_BDW | D_SKL)
  52. #define D_PRE_BDW (D_SNB | D_IVB | D_HSW)
  53. #define D_PRE_SKL (D_SNB | D_IVB | D_HSW | D_BDW)
  54. #define D_ALL (D_SNB | D_IVB | D_HSW | D_BDW | D_SKL)
  55. struct intel_gvt_mmio_info {
  56. u32 offset;
  57. u32 size;
  58. u32 length;
  59. u32 addr_mask;
  60. u64 ro_mask;
  61. u32 device;
  62. int (*read)(struct intel_vgpu *, unsigned int, void *, unsigned int);
  63. int (*write)(struct intel_vgpu *, unsigned int, void *, unsigned int);
  64. u32 addr_range;
  65. struct hlist_node node;
  66. };
  67. unsigned long intel_gvt_get_device_type(struct intel_gvt *gvt);
  68. bool intel_gvt_match_device(struct intel_gvt *gvt, unsigned long device);
  69. int intel_gvt_setup_mmio_info(struct intel_gvt *gvt);
  70. void intel_gvt_clean_mmio_info(struct intel_gvt *gvt);
  71. struct intel_gvt_mmio_info *intel_gvt_find_mmio_info(struct intel_gvt *gvt,
  72. unsigned int offset);
  73. #define INTEL_GVT_MMIO_OFFSET(reg) ({ \
  74. typeof(reg) __reg = reg; \
  75. u32 *offset = (u32 *)&__reg; \
  76. *offset; \
  77. })
  78. int intel_vgpu_init_mmio(struct intel_vgpu *vgpu);
  79. void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu);
  80. void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu);
  81. int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa);
  82. int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa,
  83. void *p_data, unsigned int bytes);
  84. int intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, u64 pa,
  85. void *p_data, unsigned int bytes);
  86. bool intel_gvt_mmio_is_cmd_access(struct intel_gvt *gvt,
  87. unsigned int offset);
  88. bool intel_gvt_mmio_is_unalign(struct intel_gvt *gvt, unsigned int offset);
  89. void intel_gvt_mmio_set_accessed(struct intel_gvt *gvt, unsigned int offset);
  90. void intel_gvt_mmio_set_cmd_accessed(struct intel_gvt *gvt,
  91. unsigned int offset);
  92. bool intel_gvt_mmio_has_mode_mask(struct intel_gvt *gvt, unsigned int offset);
  93. int intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
  94. void *p_data, unsigned int bytes);
  95. int intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
  96. void *p_data, unsigned int bytes);
  97. #endif