* @brief Entry point for light-weight process threads * * @param[in] parameter Thread parameter (unused) * * @note This function is the main entry point for threads created within a light-weight process. * It handles thread initialization, debug mode setup, and transitions to user mode. */
| 293 | * It handles thread initialization, debug mode setup, and transitions to user mode. |
| 294 | */ |
| 295 | static void _lwp_thread_entry(void *parameter) |
| 296 | { |
| 297 | rt_thread_t tid; |
| 298 | struct rt_lwp *lwp; |
| 299 | |
| 300 | tid = rt_thread_self(); |
| 301 | lwp = (struct rt_lwp *)tid->lwp; |
| 302 | tid->cleanup = lwp_cleanup; |
| 303 | tid->user_stack = RT_NULL; |
| 304 | |
| 305 | if (lwp->debug) |
| 306 | { |
| 307 | lwp->bak_first_inst = *(uint32_t *)lwp->text_entry; |
| 308 | *(uint32_t *)lwp->text_entry = dbg_get_ins(); |
| 309 | rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, lwp->text_entry, sizeof(uint32_t)); |
| 310 | icache_invalid_all(); |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * without ASID support, it will be a special case when trying to run application |
| 315 | * and exit multiple times and a same page frame allocated to it bound to |
| 316 | * different text segment. Then we are in a situation where icache contains |
| 317 | * out-of-dated data and must be handle by the running core itself. |
| 318 | * with ASID support, this should be a rare case that ASID & page frame both |
| 319 | * identical to previous running application. |
| 320 | * |
| 321 | * For a new application loaded into memory, icache are seen as empty. And there |
| 322 | * should be nothing in the icache entry to match. So this icache invalidation |
| 323 | * operation should have barely influence. |
| 324 | */ |
| 325 | rt_hw_icache_invalidate_all(); |
| 326 | |
| 327 | #ifdef ARCH_MM_MMU |
| 328 | arch_start_umode(lwp->args, lwp->text_entry, (void *)USER_STACK_VEND, (char *)tid->stack_addr + tid->stack_size); |
| 329 | #else |
| 330 | arch_start_umode(lwp->args, lwp->text_entry, lwp->data_entry, (void *)((uint32_t)lwp->data_entry + lwp->data_size)); |
| 331 | #endif /* ARCH_MM_MMU */ |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * @brief Get the current light-weight process |
nothing calls this directly
no test coverage detected