mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-18 18:44:22 +00:00
feat(mt8188): add support for SMC from OP-TEE
- Add MTK_SIP_SMC_FROM_S_EL1_TABLE to handle the SMC call from OP-TEE. - Register optee for EMI MPU. Change-Id: Ie94542f0e3966c4c25f2b7233b9355d41f8f36a5 Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> Signed-off-by: Jason Chen <Jason-ch.Chen@mediatek.com>
This commit is contained in:
parent
39bcbeac9c
commit
34d9d619f1
3 changed files with 59 additions and 2 deletions
|
@ -57,9 +57,18 @@ struct emi_region_info_t {
|
|||
unsigned int apc[EMI_MPU_DGROUP_NUM];
|
||||
};
|
||||
|
||||
enum MPU_REQ_ORIGIN_ZONE_ID {
|
||||
MPU_REQ_ORIGIN_TEE_ZONE_SVP = 0,
|
||||
MPU_REQ_ORIGIN_TEE_ZONE_TUI = 1,
|
||||
MPU_REQ_ORIGIN_TEE_ZONE_WFD = 2,
|
||||
MPU_REQ_ORIGIN_TEE_ZONE_MAX = 3,
|
||||
MPU_REQ_ORIGIN_ZONE_INVALID = 0x7FFFFFFF,
|
||||
};
|
||||
|
||||
int emi_mpu_init(void);
|
||||
int emi_mpu_optee_handler(uint64_t encoded_addr, uint64_t zone_size,
|
||||
uint64_t zone_info);
|
||||
int emi_mpu_set_protection(struct emi_region_info_t *region_info);
|
||||
void set_emi_mpu_regions(void);
|
||||
int set_apu_emi_mpu_region(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <string.h>
|
||||
#include <common/debug.h>
|
||||
#include <lib/mmio.h>
|
||||
#include <smccc_helpers.h>
|
||||
|
||||
#include <emi_mpu.h>
|
||||
#include <lib/mtk_init/mtk_init.h>
|
||||
#include <mtk_sip_svc.h>
|
||||
|
@ -116,7 +118,10 @@ u_register_t mtk_emi_mpu_sip_handler(u_register_t x1, u_register_t x2,
|
|||
u_register_t x3, u_register_t x4,
|
||||
void *handle, struct smccc_res *smccc_ret)
|
||||
{
|
||||
/* TODO: implement emi mpu handler */
|
||||
int ret;
|
||||
|
||||
ret = emi_mpu_optee_handler(x1, x2, x3);
|
||||
SMC_RET2(handle, ret, 0U);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include <common/debug.h>
|
||||
#include <emi_mpu.h>
|
||||
#include <mtk_sip_svc.h>
|
||||
|
||||
#define MPU_PHYSICAL_ADDR_SHIFT_BITS (16)
|
||||
|
||||
void set_emi_mpu_regions(void)
|
||||
{
|
||||
|
@ -29,3 +32,43 @@ int set_apu_emi_mpu_region(void)
|
|||
|
||||
return emi_mpu_set_protection(®ion_info);
|
||||
}
|
||||
|
||||
static inline uint64_t get_decoded_phys_addr(uint64_t addr)
|
||||
{
|
||||
return (addr << MPU_PHYSICAL_ADDR_SHIFT_BITS);
|
||||
}
|
||||
|
||||
static inline uint32_t get_decoded_zone_id(uint32_t info)
|
||||
{
|
||||
return ((info & 0xFFFF0000) >> MPU_PHYSICAL_ADDR_SHIFT_BITS);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
INFO("encoded_addr = 0x%lx, zone_size = 0x%lx, zone_info = 0x%lx\n",
|
||||
encoded_addr, zone_size, zone_info);
|
||||
|
||||
if (zone_id != MPU_REQ_ORIGIN_TEE_ZONE_SVP) {
|
||||
ERROR("Invalid param %s, %d\n", __func__, __LINE__);
|
||||
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(®ion_info);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue