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 17 18 /** 19 * @file 20 * Interface file for accessing MMU hardware functionality 21 */ 22 23 /** 24 * @page mali_kbase_mmu_hw_page MMU hardware interface 25 * 26 * @section mali_kbase_mmu_hw_intro_sec Introduction 27 * This module provides an abstraction for accessing the functionality provided 28 * by the midgard MMU and thus allows all MMU HW access to be contained within 29 * one common place and allows for different backends (implementations) to 30 * be provided. 31 */ 32 33 #ifndef _MALI_KBASE_MMU_HW_H_ 34 #define _MALI_KBASE_MMU_HW_H_ 35 36 /* Forward declarations */ 37 struct kbase_device; 38 struct kbase_as; 39 struct kbase_context; 40 41 /** 42 * @addtogroup base_kbase_api 43 * @{ 44 */ 45 46 /** 47 * @addtogroup mali_kbase_mmu_hw MMU access APIs 48 * @{ 49 */ 50 51 /** @brief MMU fault type descriptor. 52 */ 53 enum kbase_mmu_fault_type { 54 KBASE_MMU_FAULT_TYPE_UNKNOWN = 0, 55 KBASE_MMU_FAULT_TYPE_PAGE, 56 KBASE_MMU_FAULT_TYPE_BUS, 57 KBASE_MMU_FAULT_TYPE_PAGE_UNEXPECTED, 58 KBASE_MMU_FAULT_TYPE_BUS_UNEXPECTED 59 }; 60 61 /** @brief Configure an address space for use. 62 * 63 * Configure the MMU using the address space details setup in the 64 * @ref kbase_context structure. 65 * 66 * @param[in] kbdev kbase device to configure. 67 * @param[in] as address space to configure. 68 * @param[in] kctx kbase context to configure. 69 */ 70 void kbase_mmu_hw_configure(struct kbase_device *kbdev, 71 struct kbase_as *as, struct kbase_context *kctx); 72 73 /** @brief Issue an operation to the MMU. 74 * 75 * Issue an operation (MMU invalidate, MMU flush, etc) on the address space that 76 * is associated with the provided @ref kbase_context over the specified range 77 * 78 * @param[in] kbdev kbase device to issue the MMU operation on. 79 * @param[in] as address space to issue the MMU operation on. 80 * @param[in] kctx kbase context to issue the MMU operation on. 81 * @param[in] vpfn MMU Virtual Page Frame Number to start the 82 * operation on. 83 * @param[in] nr Number of pages to work on. 84 * @param[in] type Operation type (written to ASn_COMMAND). 85 * @param[in] handling_irq Is this operation being called during the handling 86 * of an interrupt? 87 * 88 * @return Zero if the operation was successful, non-zero otherwise. 89 */ 90 int kbase_mmu_hw_do_operation(struct kbase_device *kbdev, struct kbase_as *as, 91 struct kbase_context *kctx, u64 vpfn, u32 nr, u32 type, 92 unsigned int handling_irq); 93 94 /** @brief Clear a fault that has been previously reported by the MMU. 95 * 96 * Clear a bus error or page fault that has been reported by the MMU. 97 * 98 * @param[in] kbdev kbase device to clear the fault from. 99 * @param[in] as address space to clear the fault from. 100 * @param[in] kctx kbase context to clear the fault from or NULL. 101 * @param[in] type The type of fault that needs to be cleared. 102 */ 103 void kbase_mmu_hw_clear_fault(struct kbase_device *kbdev, struct kbase_as *as, 104 struct kbase_context *kctx, enum kbase_mmu_fault_type type); 105 106 /** @brief Enable fault that has been previously reported by the MMU. 107 * 108 * After a page fault or bus error has been reported by the MMU these 109 * will be disabled. After these are handled this function needs to be 110 * called to enable the page fault or bus error fault again. 111 * 112 * @param[in] kbdev kbase device to again enable the fault from. 113 * @param[in] as address space to again enable the fault from. 114 * @param[in] kctx kbase context to again enable the fault from. 115 * @param[in] type The type of fault that needs to be enabled again. 116 */ 117 void kbase_mmu_hw_enable_fault(struct kbase_device *kbdev, struct kbase_as *as, 118 struct kbase_context *kctx, enum kbase_mmu_fault_type type); 119 120 /** @} *//* end group mali_kbase_mmu_hw */ 121 /** @} *//* end group base_kbase_api */ 122 123 #endif /* _MALI_KBASE_MMU_HW_H_ */ 124