emi_mpu.c 1.1 KB

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