1 /* 2 * Copyright (c) 2022, Commonwealth Scientific and Industrial Research 3 * Organisation (CSIRO) ABN 41 687 119 230. 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <zephyr/sys/util_macro.h> 9 #include <zephyr/arch/common/semihost.h> 10 11 #if !(defined(CONFIG_ISA_ARM) || defined(CONFIG_ISA_THUMB2)) 12 #error Unsupported ISA 13 #endif 14 semihost_exec(enum semihost_instr instr,void * args)15long semihost_exec(enum semihost_instr instr, void *args) 16 { 17 register unsigned long r0 __asm__ ("r0") = instr; 18 register void *r1 __asm__ ("r1") = args; 19 register long ret __asm__ ("r0"); 20 21 if (IS_ENABLED(CONFIG_ISA_THUMB2)) { 22 __asm__ __volatile__ ("svc 0xab" 23 : "=r" (ret) : "r" (r0), "r" (r1) : "memory"); 24 } else { 25 __asm__ __volatile__ ("svc 0x123456" 26 : "=r" (ret) : "r" (r0), "r" (r1) : "memory"); 27 } 28 return ret; 29 } 30