diff options
author | Damien George <damien@micropython.org> | 2024-08-12 11:17:00 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-08-28 11:52:08 +1000 |
commit | 9f9c283ef48950487bb566e9717819e8a2a29ac6 (patch) | |
tree | 04eacf3c36e6586821334316febc62402ccea722 /shared/runtime/semihosting_arm.c | |
parent | c8838b5004d32351ffea89b2f224c22c65f9e375 (diff) |
shared/runtime/semihosting_arm: Support semihosting on non-Thumb ARM.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'shared/runtime/semihosting_arm.c')
-rw-r--r-- | shared/runtime/semihosting_arm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/shared/runtime/semihosting_arm.c b/shared/runtime/semihosting_arm.c index 3ca29d5d7..5cfaaa3c6 100644 --- a/shared/runtime/semihosting_arm.c +++ b/shared/runtime/semihosting_arm.c @@ -40,10 +40,6 @@ #define OPEN_MODE_READ (0) // mode "r" #define OPEN_MODE_WRITE (4) // mode "w" -#ifndef __thumb__ -#error Semihosting is only implemented for ARM microcontrollers. -#endif - static int mp_semihosting_stdout; static uint32_t mp_semihosting_call(uint32_t num, const void *arg) { @@ -61,7 +57,13 @@ static uint32_t mp_semihosting_call(uint32_t num, const void *arg) { register uint32_t num_reg __asm__ ("r0") = num; register const void *args_reg __asm__ ("r1") = arg; __asm__ __volatile__ ( + #if defined(__ARM_ARCH_ISA_ARM) + "svc 0x00123456\n" // invoke semihosting call + #elif defined(__ARM_ARCH_ISA_THUMB) "bkpt 0xAB\n" // invoke semihosting call + #else + #error Unknown architecture + #endif : "+r" (num_reg) // call number and result : "r" (args_reg) // arguments : "memory"); // make sure args aren't optimized away |