@ -14,11 +14,33 @@ void set_emi_mpu_regions(void)
{
struct emi_region_info_t region_info ;
/* BL31 address */
region_info . start = TZRAM_BASE ;
region_info . end = TZRAM_BASE + TZRAM_SIZE - 1 ;
region_info . region = BL31_EMI_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , SEC_RW ) ;
emi_mpu_set_protection ( & region_info ) ;
/* BL32 address */
region_info . start = BL32_REGION_BASE ;
region_info . end = BL32_REGION_BASE + BL32_REGION_SIZE - 1 ;
region_info . region = BL32_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , SEC_RW , SEC_RW ) ;
emi_mpu_set_protection ( & region_info ) ;
/* SCP core0 DRAM */
region_info . start = 0x50000000ULL ;
region_info . end = 0x507FFFFFULL ;
region_info . region = 2 ;
SET_ACCESS_PERMISSION ( region_info . apc , 1 ,
region_info . start = SCP_CORE0_REGION_BASE ;
region_info . end = SCP_CORE0_REGION_BASE + SCP_CORE0_REGION_SIZE - 1 ;
region_info . region = SCP_CORE0_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , NO_PROTECTION ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
@ -26,10 +48,10 @@ void set_emi_mpu_regions(void)
emi_mpu_set_protection ( & region_info ) ;
/* SCP core1 DRAM */
region_info . start = 0x70000000ULL ;
region_info . end = 0x79FFFFFFULL ;
region_info . region = 3 ;
SET_ACCESS_PERMISSION ( region_info . apc , 1 ,
region_info . start = SCP_CORE1_REGION_BASE ;
region_info . end = SCP_CORE1_REGION_BASE + SCP_CORE1_REGION_SIZE - 1 ;
region_info . region = SCP_CORE1_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , NO_PROTECTION ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
@ -37,10 +59,10 @@ void set_emi_mpu_regions(void)
emi_mpu_set_protection ( & region_info ) ;
/* DSP protect address */
region_info . start = 0x60000000ULL ;
region_info . end = 0x610FFFFFULL ;
region_info . region = 4 ;
SET_ACCESS_PERMISSION ( region_info . apc , 1 ,
region_info . start = DSP_PROTECT_REGION_BASE ;
region_info . end = DSP_PROTECT_REGION_BASE + DSP_PROTECT_REGION_SIZE - 1 ;
region_info . region = DSP_PROTECT_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , NO_PROTECTION ,
@ -48,10 +70,10 @@ void set_emi_mpu_regions(void)
emi_mpu_set_protection ( & region_info ) ;
/* All default settings */
region_info . start = 0x40000000ULL ;
region_info . end = 0x1FFFF0000ULL ;
region_info . region = 31 ;
SET_ACCESS_PERMISSION ( region_info . apc , 1 ,
region_info . start = DRAM_START_ADDR ;
region_info . end = DRAM_START_ADDR + DRAM_MAX_SIZE - 1 ;
region_info . region = ALL_DEFAULT_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , LOCK ,
FORBIDDEN , FORBIDDEN , NO_PROTECTION , NO_PROTECTION ,
NO_PROTECTION , FORBIDDEN , NO_PROTECTION , NO_PROTECTION ,
NO_PROTECTION , SEC_R_NSEC_RW , NO_PROTECTION , FORBIDDEN ,
@ -65,7 +87,7 @@ int set_apu_emi_mpu_region(void)
region_info . start = ( unsigned long long ) APUSYS_SEC_BUF_PA ;
region_info . end = ( unsigned long long ) ( APUSYS_SEC_BUF_PA + APUSYS_SEC_BUF_SZ ) - 1 ;
region_info . region = APUSYS_SEC_BUF_EMI_REGION ;
region_info . region = APUSYS_SEC_BUF_EMI_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , UNLOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
@ -86,12 +108,18 @@ static inline uint32_t get_decoded_zone_id(uint32_t info)
return ( ( info & 0xFFFF0000 ) > > MPU_PHYSICAL_ADDR_SHIFT_BITS ) ;
}
static inline uint32_t get_decoded_set_clear_info ( uint32_t info )
{
return ( info & 0x0000FFFF ) ;
}
int emi_mpu_optee_handler ( uint64_t encoded_addr , uint64_t zone_size ,
uint64_t zone_info )
{
uint64_t phys_addr = get_decoded_phys_addr ( encoded_addr ) ;
struct emi_region_info_t region_info ;
enum MPU_REQ_ORIGIN_ZONE_ID zone_id = get_decoded_zone_id ( zone_info ) ;
uint32_t is_set = get_decoded_set_clear_info ( zone_info ) ;
INFO ( " encoded_addr = 0x%lx, zone_size = 0x%lx, zone_info = 0x%lx \n " ,
encoded_addr , zone_size , zone_info ) ;
@ -101,17 +129,21 @@ int emi_mpu_optee_handler(uint64_t encoded_addr, uint64_t zone_size,
return MTK_SIP_E_INVALID_PARAM ;
}
/* SVP DRAM */
region_info . start = phys_addr ;
region_info . end = phys_addr + zone_size ;
region_info . region = 4 ;
SET_ACCESS_PERMISSION ( region_info . apc , 1 ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , SEC_RW ) ;
emi_mpu_set_protection ( & region_info ) ;
if ( is_set > 0 ) {
/* SVP DRAM */
region_info . start = phys_addr ;
region_info . end = phys_addr + zone_size - 1 ;
region_info . region = SVP_DRAM_REGION_ID ;
SET_ACCESS_PERMISSION ( region_info . apc , UNLOCK ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , SEC_RW , FORBIDDEN , FORBIDDEN ,
FORBIDDEN , FORBIDDEN , SEC_RW , SEC_RW ) ;
emi_mpu_set_protection ( & region_info ) ;
} else { /* clear region protection */
emi_mpu_clear_protection ( SVP_DRAM_REGION_ID ) ;
}
return 0 ;
}