mali_mmu.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2007-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. #ifndef __MALI_MMU_H__
  11. #define __MALI_MMU_H__
  12. #include "mali_osk.h"
  13. #include "mali_mmu_page_directory.h"
  14. #include "mali_hw_core.h"
  15. /* Forward declaration from mali_group.h */
  16. struct mali_group;
  17. /**
  18. * MMU register numbers
  19. * Used in the register read/write routines.
  20. * See the hardware documentation for more information about each register
  21. */
  22. typedef enum mali_mmu_register {
  23. MALI_MMU_REGISTER_DTE_ADDR = 0x0000, /**< Current Page Directory Pointer */
  24. MALI_MMU_REGISTER_STATUS = 0x0004, /**< Status of the MMU */
  25. MALI_MMU_REGISTER_COMMAND = 0x0008, /**< Command register, used to control the MMU */
  26. MALI_MMU_REGISTER_PAGE_FAULT_ADDR = 0x000C, /**< Logical address of the last page fault */
  27. MALI_MMU_REGISTER_ZAP_ONE_LINE = 0x010, /**< Used to invalidate the mapping of a single page from the MMU */
  28. MALI_MMU_REGISTER_INT_RAWSTAT = 0x0014, /**< Raw interrupt status, all interrupts visible */
  29. MALI_MMU_REGISTER_INT_CLEAR = 0x0018, /**< Indicate to the MMU that the interrupt has been received */
  30. MALI_MMU_REGISTER_INT_MASK = 0x001C, /**< Enable/disable types of interrupts */
  31. MALI_MMU_REGISTER_INT_STATUS = 0x0020 /**< Interrupt status based on the mask */
  32. } mali_mmu_register;
  33. /**
  34. * MMU interrupt register bits
  35. * Each cause of the interrupt is reported
  36. * through the (raw) interrupt status registers.
  37. * Multiple interrupts can be pending, so multiple bits
  38. * can be set at once.
  39. */
  40. typedef enum mali_mmu_interrupt {
  41. MALI_MMU_INTERRUPT_PAGE_FAULT = 0x01, /**< A page fault occured */
  42. MALI_MMU_INTERRUPT_READ_BUS_ERROR = 0x02 /**< A bus read error occured */
  43. } mali_mmu_interrupt;
  44. typedef enum mali_mmu_status_bits {
  45. MALI_MMU_STATUS_BIT_PAGING_ENABLED = 1 << 0,
  46. MALI_MMU_STATUS_BIT_PAGE_FAULT_ACTIVE = 1 << 1,
  47. MALI_MMU_STATUS_BIT_STALL_ACTIVE = 1 << 2,
  48. MALI_MMU_STATUS_BIT_IDLE = 1 << 3,
  49. MALI_MMU_STATUS_BIT_REPLAY_BUFFER_EMPTY = 1 << 4,
  50. MALI_MMU_STATUS_BIT_PAGE_FAULT_IS_WRITE = 1 << 5,
  51. MALI_MMU_STATUS_BIT_STALL_NOT_ACTIVE = 1 << 31,
  52. } mali_mmu_status_bits;
  53. /**
  54. * Definition of the MMU struct
  55. * Used to track a MMU unit in the system.
  56. * Contains information about the mapping of the registers
  57. */
  58. struct mali_mmu_core {
  59. struct mali_hw_core hw_core; /**< Common for all HW cores */
  60. _mali_osk_irq_t *irq; /**< IRQ handler */
  61. };
  62. _mali_osk_errcode_t mali_mmu_initialize(void);
  63. void mali_mmu_terminate(void);
  64. struct mali_mmu_core *mali_mmu_create(_mali_osk_resource_t *resource, struct mali_group *group, mali_bool is_virtual);
  65. void mali_mmu_delete(struct mali_mmu_core *mmu);
  66. _mali_osk_errcode_t mali_mmu_reset(struct mali_mmu_core *mmu);
  67. mali_bool mali_mmu_zap_tlb(struct mali_mmu_core *mmu);
  68. void mali_mmu_zap_tlb_without_stall(struct mali_mmu_core *mmu);
  69. void mali_mmu_invalidate_page(struct mali_mmu_core *mmu, u32 mali_address);
  70. void mali_mmu_activate_page_directory(struct mali_mmu_core* mmu, struct mali_page_directory *pagedir);
  71. void mali_mmu_activate_empty_page_directory(struct mali_mmu_core* mmu);
  72. void mali_mmu_activate_fault_flush_page_directory(struct mali_mmu_core* mmu);
  73. void mali_mmu_page_fault_done(struct mali_mmu_core *mmu);
  74. /*** Register reading/writing functions ***/
  75. MALI_STATIC_INLINE u32 mali_mmu_get_int_status(struct mali_mmu_core *mmu)
  76. {
  77. return mali_hw_core_register_read(&mmu->hw_core, MALI_MMU_REGISTER_INT_STATUS);
  78. }
  79. MALI_STATIC_INLINE u32 mali_mmu_get_rawstat(struct mali_mmu_core *mmu)
  80. {
  81. return mali_hw_core_register_read(&mmu->hw_core, MALI_MMU_REGISTER_INT_RAWSTAT);
  82. }
  83. MALI_STATIC_INLINE void mali_mmu_mask_all_interrupts(struct mali_mmu_core *mmu)
  84. {
  85. mali_hw_core_register_write(&mmu->hw_core, MALI_MMU_REGISTER_INT_MASK, 0);
  86. }
  87. MALI_STATIC_INLINE u32 mali_mmu_get_status(struct mali_mmu_core *mmu)
  88. {
  89. return mali_hw_core_register_read(&mmu->hw_core, MALI_MMU_REGISTER_STATUS);
  90. }
  91. MALI_STATIC_INLINE u32 mali_mmu_get_page_fault_addr(struct mali_mmu_core *mmu)
  92. {
  93. return mali_hw_core_register_read(&mmu->hw_core, MALI_MMU_REGISTER_PAGE_FAULT_ADDR);
  94. }
  95. #endif /* __MALI_MMU_H__ */