RTEMS  5.0.0
swi.h
Go to the documentation of this file.
1 
17 /*
18  * Copied from libgloss 1 Oct 2009.
19  * Minor modifications to work with RTEMS.
20  */
21 
22 /* SWI numbers for RDP (Demon) monitor. */
23 #define SWI_WriteC 0x0
24 #define SWI_Write0 0x2
25 #define SWI_ReadC 0x4
26 #define SWI_CLI 0x5
27 #define SWI_GetEnv 0x10
28 #define SWI_Exit 0x11
29 #define SWI_EnterOS 0x16
30 
31 #define SWI_GetErrno 0x60
32 #define SWI_Clock 0x61
33 #define SWI_Time 0x63
34 #define SWI_Remove 0x64
35 #define SWI_Rename 0x65
36 #define SWI_Open 0x66
37 
38 #define SWI_Close 0x68
39 #define SWI_Write 0x69
40 #define SWI_Read 0x6a
41 #define SWI_Seek 0x6b
42 #define SWI_Flen 0x6c
43 
44 #define SWI_IsTTY 0x6e
45 #define SWI_TmpNam 0x6f
46 #define SWI_InstallHandler 0x70
47 #define SWI_GenerateError 0x71
48 
49 
50 /* Now the SWI numbers and reason codes for RDI (Angel) monitors. */
51 #define AngelSWI_ARM 0x123456
52 #ifdef __thumb__
53 #define AngelSWI 0xAB
54 #else
55 #define AngelSWI AngelSWI_ARM
56 #endif
57 /* For Thumb-2 code use the BKPT instruction instead of SWI. */
58 #ifdef __thumb2__
59 #define AngelSWIInsn "bkpt"
60 #define AngelSWIAsm bkpt
61 #else
62 #define AngelSWIInsn "swi"
63 #define AngelSWIAsm swi
64 #endif
65 
66 /* The reason codes: */
67 #define AngelSWI_Reason_Open 0x01
68 #define AngelSWI_Reason_Close 0x02
69 #define AngelSWI_Reason_WriteC 0x03
70 #define AngelSWI_Reason_Write0 0x04
71 #define AngelSWI_Reason_Write 0x05
72 #define AngelSWI_Reason_Read 0x06
73 #define AngelSWI_Reason_ReadC 0x07
74 #define AngelSWI_Reason_IsTTY 0x09
75 #define AngelSWI_Reason_Seek 0x0A
76 #define AngelSWI_Reason_FLen 0x0C
77 #define AngelSWI_Reason_TmpNam 0x0D
78 #define AngelSWI_Reason_Remove 0x0E
79 #define AngelSWI_Reason_Rename 0x0F
80 #define AngelSWI_Reason_Clock 0x10
81 #define AngelSWI_Reason_Time 0x11
82 #define AngelSWI_Reason_System 0x12
83 #define AngelSWI_Reason_Errno 0x13
84 #define AngelSWI_Reason_GetCmdLine 0x15
85 #define AngelSWI_Reason_HeapInfo 0x16
86 #define AngelSWI_Reason_EnterSVC 0x17
87 #define AngelSWI_Reason_ReportException 0x18
88 #define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
89 #define ADP_Stopped_RunTimeError ((2 << 16) + 35)
90 
91 #if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__)
92 
93 static inline int
94 do_AngelSWI (int reason, void * arg)
95 {
96  int value;
97  __asm__ volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0"
98  : "=r" (value) /* Outputs */
99  : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
100  : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
101  /* Clobbers r0 and r1, and lr if in supervisor mode */);
102  /* Accordingly to page 13-77 of ARM DUI 0040D other registers
103  can also be clobbered. Some memory positions may also be
104  changed by a system call, so they should not be kept in
105  registers. Note: we are assuming the manual is right and
106  Angel is respecting the APCS. */
107  return value;
108 }
109 
110 #endif
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.