From e9b49a36e26a06cb1b9df9716f60a38407444398 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Mon, 19 Jun 2017 03:12:09 -0500 Subject: imx8qm/qxp: Modify the memory regions allocation to NS partition Change to search the ATF owned memory regions and assign them to non-secure OS partition. Not allocate new memory region for each one. Signed-off-by: Ye Li --- plat/imx/imx8qm/imx8qm_bl31_setup.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'plat/imx/imx8qm/imx8qm_bl31_setup.c') diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c index 8902d3e0..baae3802 100644 --- a/plat/imx/imx8qm/imx8qm_bl31_setup.c +++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c @@ -192,6 +192,8 @@ void mx8_partition_resources(void) sc_err_t err; sc_rm_pt_t secure_part, os_part; sc_rm_mr_t mr; + bool owned; + sc_faddr_t start, end; int i; err = sc_rm_get_partition(ipc_handle, &secure_part); @@ -225,14 +227,19 @@ void mx8_partition_resources(void) * */ - for (i = 0; i < (sizeof(ns_mem_region) / sizeof(struct mem_region)); i++) { - err = sc_rm_memreg_alloc(ipc_handle, &mr, ns_mem_region[i].start, ns_mem_region[i].end); - if (err) { - ERROR("Memreg alloc failed, 0x%lx -- 0x%lx\n", ns_mem_region[i].start, ns_mem_region[i].end); - } else { - err = sc_rm_assign_memreg(ipc_handle, os_part, mr); - if (err) - ERROR("Memreg assign failed, 0x%lx -- 0x%lx\n", ns_mem_region[i].start, ns_mem_region[i].end); + for (mr = 0; mr < 64; mr++) { + owned = sc_rm_is_memreg_owned(ipc_handle, mr); + if (owned) { + err = sc_rm_get_memreg_info(ipc_handle, mr, &start, &end); + if (err) { + ERROR("Memreg get info failed, %u\n", mr); + } else { + NOTICE("Memreg %u 0x%lx -- 0x%lx\n", mr, start, end); + + err = sc_rm_assign_memreg(ipc_handle, os_part, mr); + if (err) + ERROR("Memreg assign failed, 0x%lx -- 0x%lx\n", start, end); + } } } -- cgit v1.2.3