mali_kbase_mmu_hw.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. *
  3. * (C) COPYRIGHT 2014-2015 ARM Limited. All rights reserved.
  4. *
  5. * This program is free software and is provided to you under the terms of the
  6. * GNU General Public License version 2 as published by the Free Software
  7. * Foundation, and any use by you of this program is subject to the terms
  8. * of such GNU licence.
  9. *
  10. * A copy of the licence is included with the program, and can also be obtained
  11. * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  12. * Boston, MA 02110-1301, USA.
  13. *
  14. */
  15. /**
  16. * @file
  17. * Interface file for accessing MMU hardware functionality
  18. */
  19. /**
  20. * @page mali_kbase_mmu_hw_page MMU hardware interface
  21. *
  22. * @section mali_kbase_mmu_hw_intro_sec Introduction
  23. * This module provides an abstraction for accessing the functionality provided
  24. * by the midgard MMU and thus allows all MMU HW access to be contained within
  25. * one common place and allows for different backends (implementations) to
  26. * be provided.
  27. */
  28. #ifndef _MALI_KBASE_MMU_HW_H_
  29. #define _MALI_KBASE_MMU_HW_H_
  30. /* Forward declarations */
  31. struct kbase_device;
  32. struct kbase_as;
  33. struct kbase_context;
  34. /**
  35. * @addtogroup base_kbase_api
  36. * @{
  37. */
  38. /**
  39. * @addtogroup mali_kbase_mmu_hw MMU access APIs
  40. * @{
  41. */
  42. /** @brief MMU fault type descriptor.
  43. */
  44. enum kbase_mmu_fault_type {
  45. KBASE_MMU_FAULT_TYPE_UNKNOWN = 0,
  46. KBASE_MMU_FAULT_TYPE_PAGE,
  47. KBASE_MMU_FAULT_TYPE_BUS,
  48. KBASE_MMU_FAULT_TYPE_PAGE_UNEXPECTED,
  49. KBASE_MMU_FAULT_TYPE_BUS_UNEXPECTED
  50. };
  51. /** @brief Configure an address space for use.
  52. *
  53. * Configure the MMU using the address space details setup in the
  54. * @ref kbase_context structure.
  55. *
  56. * @param[in] kbdev kbase device to configure.
  57. * @param[in] as address space to configure.
  58. * @param[in] kctx kbase context to configure.
  59. */
  60. void kbase_mmu_hw_configure(struct kbase_device *kbdev,
  61. struct kbase_as *as, struct kbase_context *kctx);
  62. /** @brief Issue an operation to the MMU.
  63. *
  64. * Issue an operation (MMU invalidate, MMU flush, etc) on the address space that
  65. * is associated with the provided @ref kbase_context over the specified range
  66. *
  67. * @param[in] kbdev kbase device to issue the MMU operation on.
  68. * @param[in] as address space to issue the MMU operation on.
  69. * @param[in] kctx kbase context to issue the MMU operation on.
  70. * @param[in] vpfn MMU Virtual Page Frame Number to start the
  71. * operation on.
  72. * @param[in] nr Number of pages to work on.
  73. * @param[in] type Operation type (written to ASn_COMMAND).
  74. * @param[in] handling_irq Is this operation being called during the handling
  75. * of an interrupt?
  76. *
  77. * @return Zero if the operation was successful, non-zero otherwise.
  78. */
  79. int kbase_mmu_hw_do_operation(struct kbase_device *kbdev, struct kbase_as *as,
  80. struct kbase_context *kctx, u64 vpfn, u32 nr, u32 type,
  81. unsigned int handling_irq);
  82. /** @brief Clear a fault that has been previously reported by the MMU.
  83. *
  84. * Clear a bus error or page fault that has been reported by the MMU.
  85. *
  86. * @param[in] kbdev kbase device to clear the fault from.
  87. * @param[in] as address space to clear the fault from.
  88. * @param[in] kctx kbase context to clear the fault from or NULL.
  89. * @param[in] type The type of fault that needs to be cleared.
  90. */
  91. void kbase_mmu_hw_clear_fault(struct kbase_device *kbdev, struct kbase_as *as,
  92. struct kbase_context *kctx, enum kbase_mmu_fault_type type);
  93. /** @brief Enable fault that has been previously reported by the MMU.
  94. *
  95. * After a page fault or bus error has been reported by the MMU these
  96. * will be disabled. After these are handled this function needs to be
  97. * called to enable the page fault or bus error fault again.
  98. *
  99. * @param[in] kbdev kbase device to again enable the fault from.
  100. * @param[in] as address space to again enable the fault from.
  101. * @param[in] kctx kbase context to again enable the fault from.
  102. * @param[in] type The type of fault that needs to be enabled again.
  103. */
  104. void kbase_mmu_hw_enable_fault(struct kbase_device *kbdev, struct kbase_as *as,
  105. struct kbase_context *kctx, enum kbase_mmu_fault_type type);
  106. /** @} *//* end group mali_kbase_mmu_hw */
  107. /** @} *//* end group base_kbase_api */
  108. #endif // ifndef _MALI_KBASE_MMU_HW_H_