emi_mpu.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <debug.h>
  2. #include <platform/mt_typedefs.h>
  3. #include <platform/emi_mpu.h>
  4. #include <kernel/thread.h>
  5. extern unsigned long mt_secure_call(unsigned long, unsigned long, unsigned long, unsigned long);
  6. #define DBG_EMI(x...) dprintf(CRITICAL, x)
  7. #define MTK_SIP_KERNEL_EMIMPU_SET 0x82000262
  8. #define emi_mpu_smc_set(start, end, region_apc) \
  9. mt_secure_call(MTK_SIP_KERNEL_EMIMPU_SET, start, end, region_apc)
  10. /*
  11. * emi_mpu_set_region_protection: protect a region.
  12. * @start: start address of the region
  13. * @end: end address of the region
  14. * @region: EMI MPU region id
  15. * @access_permission: EMI MPU access permission
  16. * Return 0 for success, otherwise negative status code.
  17. */
  18. int emi_mpu_set_region_protection(unsigned int start, unsigned int end, int region, unsigned int access_permission)
  19. {
  20. int ret = 0;
  21. unsigned int apc;
  22. start = start >> 16;
  23. end = end >> 16;
  24. apc = (access_permission & 0x04FFFFFF) | (((unsigned int)region & 0x1F) << 27);
  25. enter_critical_section();
  26. emi_mpu_smc_set(start, end, apc);
  27. exit_critical_section();
  28. DBG_EMI("LK set emi mpu region protection start:%x end=%x region=%d apc=%x\n", start, end, region, apc);
  29. return ret;
  30. }