/* * core_init_mmu_map - init tee core default memory mapping * * this routine sets the static default tee core mapping. * * If an error happend: core_init_mmu_map is expected to reset. */ void core_init_mmu_map(void) { struct tee_mmap_region *map; size_t n; for (n = 0; n < ARRAY_SIZE(secure_only); n++) { if (pbuf_intersects(nsec_shared, secure_only[n].paddr, secure_only[n].size)) panic("Invalid memory access config: sec/nsec"); } if (!mem_map_inited) init_mem_map(static_memory_map, ARRAY_SIZE(static_memory_map)); map = static_memory_map; while (map->type != MEM_AREA_NOTYPE) { switch (map->type) { case MEM_AREA_TEE_RAM: if (!pbuf_is_inside(secure_only, map->pa, map->size)) panic("TEE_RAM can't fit in secure_only"); map_tee_ram = map; break; case MEM_AREA_TA_RAM: if (!pbuf_is_inside(secure_only, map->pa, map->size)) panic("TA_RAM can't fit in secure_only"); map_ta_ram = map; break; case MEM_AREA_NSEC_SHM: if (!pbuf_is_inside(nsec_shared, map->pa, map->size)) panic("NS_SHM can't fit in nsec_shared"); map_nsec_shm = map; break; case MEM_AREA_IO_SEC: case MEM_AREA_IO_NSEC: case MEM_AREA_RAM_SEC: case MEM_AREA_RAM_NSEC: case MEM_AREA_RES_VASPACE: break; default: EMSG("Uhandled memtype %d", map->type); panic(); } map++; } /* Check that we have the mandatory memory areas defined */ if (!map_tee_ram || !map_ta_ram || !map_nsec_shm) panic("mandatory area(s) not found"); core_init_mmu_tables(static_memory_map); }
/* * core_init_mmu_map - init tee core default memory mapping * * this routine sets the static default tee core mapping. * * If an error happend: core_init_mmu_map is expected to reset. */ void core_init_mmu_map(void) { struct tee_mmap_region mm[MAX_MMAP_REGIONS + 1]; struct map_area *map, *in; /* get memory bootcfg from system */ in = bootcfg_get_memory(); if (!in) { EMSG("Invalid memory map"); TEE_ASSERT(0); } bootcfg_pbuf_is = (unsigned long)bootcfg_get_pbuf_is_handler(); if (bootcfg_pbuf_is == 0) { EMSG("invalid platform handler for pbuf_is"); TEE_ASSERT(0); } /* we must find at least a PUB_RAM area and a TEE_RAM area */ map_tee_ram = NULL; map_ta_ram = NULL; map_nsec_shm = NULL; /* map what needs to be mapped (non-null size and non INTRAM/EXTRAM) */ map = in; while (map->type != MEM_AREA_NOTYPE) { if (map->va) panic(); map->va = map->pa; /* 1-to-1 pa = va mapping */ if (map->type == MEM_AREA_TEE_RAM) map_tee_ram = map; else if (map->type == MEM_AREA_TA_RAM) map_ta_ram = map; else if (map->type == MEM_AREA_NSEC_SHM) map_nsec_shm = map; map++; } if ((map_tee_ram == NULL) || (map_ta_ram == NULL) || (map_nsec_shm == NULL)) { EMSG("mapping area missing"); TEE_ASSERT(0); } static_memory_map = in; core_mmu_mmap_init(mm, ARRAY_SIZE(mm), in); core_init_mmu_tables(mm); }