[ATfE] Provide nohost init and exit in llvmlibc startup code#683
[ATfE] Provide nohost init and exit in llvmlibc startup code#683voltur01 merged 2 commits intoarm:arm-softwarefrom
Conversation
Provide init and exit handlers for not hosted environments in llvm libc crt0. Update the documentation accordingly. Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting.
smithp35
left a comment
There was a problem hiding this comment.
While I think disabling interrupts and going into low-power mode is sensible for a lot of applications. It won't be universally applicable. For example what if there's a timer on an interrupt that resets the system? Or if the program is running without the privilege.
For a universal default I think we'd better off following picolibc's lead and doing an infinite loop.
| #error "Unsupported architecture" | ||
| #endif | ||
|
|
||
| static inline void idle_once(void) { __asm__ volatile("wfi" ::: "memory"); } |
There was a problem hiding this comment.
There is an intrinsic in the ACLE for this https://arm-software.github.io/acle/main/acle.html#hints
I think wfi is also not supported in v4t, I think it needs 5te.
| // Go into low power infinite loop on exit | ||
| [[gnu::weak, noreturn]] void __llvm_libc_exit(int status) { | ||
| (void)status; | ||
| mask_irqs(); |
There was a problem hiding this comment.
This will need a privileged instruction and we may (likely) be running at user-mode or EL0 so this will generate an abort.
…embly instructions
smithp35
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the update.
Provide init and exit handlers for not hosted environments in llvm libc crt0. Update the documentation accordingly. Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting. (cherry picked from commit ab657ec)
This applies the following changes to 22.x release branch: #667 [ATfE] Use semihosting SYS_READC for stdin with llvm libc #676 [ATfE] Remove __LLVM_LIBC__ define workaround for libcxx #678 [ATfE] Replace call to abort with __llvm_libc_exit in libc startup code #679 [ATfE] Update comment about handling cleanup for exit() #683 [ATfE] Provide nohost init and exit in llvmlibc startup code
Provide init and exit handlers for not hosted environments in llvm libc crt0.
Update the documentation accordingly.
Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting.