Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/sys/arm/swi.h')
-rw-r--r--newlib/libc/sys/arm/swi.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/newlib/libc/sys/arm/swi.h b/newlib/libc/sys/arm/swi.h
index f5c910313..0f9313447 100644
--- a/newlib/libc/sys/arm/swi.h
+++ b/newlib/libc/sys/arm/swi.h
@@ -1,3 +1,5 @@
+#include "arm.h"
+
/* SWI numbers for RDP (Demon) monitor. */
#define SWI_WriteC 0x0
#define SWI_Write0 0x2
@@ -33,8 +35,8 @@
#else
#define AngelSWI AngelSWI_ARM
#endif
-/* For Thumb-2 code use the BKPT instruction instead of SWI. */
-#ifdef __thumb2__
+/* For thumb only architectures use the BKPT instruction instead of SWI. */
+#ifdef THUMB_V7M_V6M
#define AngelSWIInsn "bkpt"
#define AngelSWIAsm bkpt
#else
@@ -66,3 +68,24 @@
#define AngelSWI_Reason_ReportException 0x18
#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
+
+#if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__)
+
+static inline int
+do_AngelSWI (int reason, void * arg)
+{
+ int value;
+ asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0"
+ : "=r" (value) /* Outputs */
+ : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
+ : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
+ /* Clobbers r0 and r1, and lr if in supervisor mode */);
+ /* Accordingly to page 13-77 of ARM DUI 0040D other registers
+ can also be clobbered. Some memory positions may also be
+ changed by a system call, so they should not be kept in
+ registers. Note: we are assuming the manual is right and
+ Angel is respecting the APCS. */
+ return value;
+}
+
+#endif