From ba5c1bea44025d906b5d402dbeebcc27ea3ebc44 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sat, 1 Sep 2018 11:00:42 +0800 Subject: [dlmodule] Add cache ops in dlmodule. --- components/libc/libdl/dlelf.c | 1 + components/libc/libdl/dlmodule.c | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'components/libc') diff --git a/components/libc/libdl/dlelf.c b/components/libc/libdl/dlelf.c index 8075af1374..6d83424b80 100644 --- a/components/libc/libdl/dlelf.c +++ b/components/libc/libdl/dlelf.c @@ -277,6 +277,7 @@ rt_err_t dlmodule_load_relocated_object(struct rt_dlmodule* module, void *module rt_kprintf("Module: allocate space failed.\n"); return -RT_ERROR; } + module->mem_size = module_size; /* zero all space */ ptr = module->mem_space; diff --git a/components/libc/libdl/dlmodule.c b/components/libc/libdl/dlmodule.c index 844ad897cf..61ffbfc772 100644 --- a/components/libc/libdl/dlmodule.c +++ b/components/libc/libdl/dlmodule.c @@ -491,6 +491,12 @@ struct rt_dlmodule* dlmodule_load(const char* filename) /* increase module reference count */ module->nref ++; + /* deal with cache */ +#ifdef RT_USING_CACHE + rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, module->mem_space, module->mem_size); + rt_hw_cpu_icache_ops(RT_HW_CACHE_INVALIDATE, module->mem_space, module->mem_size); +#endif + /* set module initialization and cleanup function */ module->init_func = dlsym(module, "module_init"); module->cleanup_func = dlsym(module, "module_cleanup"); -- cgit v1.3.1