µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
semihosting.h File Reference

Go to the source code of this file.

Macros

#define AngelSWI   AngelSWI_ARM
 
#define AngelSWI_ARM   0x123456
 
#define AngelSWIAsm   swi
 
#define AngelSWIInsn   "swi"
 

Enumerations

enum  OperationNumber {
  SEMIHOSTING_EnterSVC = 0x17 ,
  SEMIHOSTING_ReportException = 0x18 ,
  SEMIHOSTING_SYS_CLOSE = 0x02 ,
  SEMIHOSTING_SYS_CLOCK = 0x10 ,
  SEMIHOSTING_SYS_ELAPSED = 0x30 ,
  SEMIHOSTING_SYS_ERRNO = 0x13 ,
  SEMIHOSTING_SYS_FLEN = 0x0C ,
  SEMIHOSTING_SYS_GET_CMDLINE = 0x15 ,
  SEMIHOSTING_SYS_HEAPINFO = 0x16 ,
  SEMIHOSTING_SYS_ISERROR = 0x08 ,
  SEMIHOSTING_SYS_ISTTY = 0x09 ,
  SEMIHOSTING_SYS_OPEN = 0x01 ,
  SEMIHOSTING_SYS_READ = 0x06 ,
  SEMIHOSTING_SYS_READC = 0x07 ,
  SEMIHOSTING_SYS_REMOVE = 0x0E ,
  SEMIHOSTING_SYS_RENAME = 0x0F ,
  SEMIHOSTING_SYS_SEEK = 0x0A ,
  SEMIHOSTING_SYS_SYSTEM = 0x12 ,
  SEMIHOSTING_SYS_TICKFREQ = 0x31 ,
  SEMIHOSTING_SYS_TIME = 0x11 ,
  SEMIHOSTING_SYS_TMPNAM = 0x0D ,
  SEMIHOSTING_SYS_WRITE = 0x05 ,
  SEMIHOSTING_SYS_WRITEC = 0x03 ,
  SEMIHOSTING_SYS_WRITE0 = 0x04 ,
  ADP_Stopped_ApplicationExit = ((2 << 16) + 38) ,
  ADP_Stopped_RunTimeError = ((2 << 16) + 35)
}
 

Functions

static int call_host (int reason, void *arg)
 
static void report_exception (int reason)
 

Macro Definition Documentation

◆ AngelSWI

#define AngelSWI   AngelSWI_ARM

Definition at line 72 of file semihosting.h.

◆ AngelSWI_ARM

#define AngelSWI_ARM   0x123456

Definition at line 68 of file semihosting.h.

◆ AngelSWIAsm

#define AngelSWIAsm   swi

Definition at line 81 of file semihosting.h.

◆ AngelSWIInsn

#define AngelSWIInsn   "swi"

Definition at line 80 of file semihosting.h.

Enumeration Type Documentation

◆ OperationNumber

Enumerator
SEMIHOSTING_EnterSVC 
SEMIHOSTING_ReportException 
SEMIHOSTING_SYS_CLOSE 
SEMIHOSTING_SYS_CLOCK 
SEMIHOSTING_SYS_ELAPSED 
SEMIHOSTING_SYS_ERRNO 
SEMIHOSTING_SYS_FLEN 
SEMIHOSTING_SYS_GET_CMDLINE 
SEMIHOSTING_SYS_HEAPINFO 
SEMIHOSTING_SYS_ISERROR 
SEMIHOSTING_SYS_ISTTY 
SEMIHOSTING_SYS_OPEN 
SEMIHOSTING_SYS_READ 
SEMIHOSTING_SYS_READC 
SEMIHOSTING_SYS_REMOVE 
SEMIHOSTING_SYS_RENAME 
SEMIHOSTING_SYS_SEEK 
SEMIHOSTING_SYS_SYSTEM 
SEMIHOSTING_SYS_TICKFREQ 
SEMIHOSTING_SYS_TIME 
SEMIHOSTING_SYS_TMPNAM 
SEMIHOSTING_SYS_WRITE 
SEMIHOSTING_SYS_WRITEC 
SEMIHOSTING_SYS_WRITE0 
ADP_Stopped_ApplicationExit 
ADP_Stopped_RunTimeError 

Definition at line 31 of file semihosting.h.

32 {
33 // Regular operations
58
59 // Codes returned by SEMIHOSTING_ReportException
60 ADP_Stopped_ApplicationExit = ((2 << 16) + 38),
61 ADP_Stopped_RunTimeError = ((2 << 16) + 35),
62
63 };
@ SEMIHOSTING_SYS_TICKFREQ
Definition semihosting.h:52
@ ADP_Stopped_RunTimeError
Definition semihosting.h:61
@ SEMIHOSTING_ReportException
Definition semihosting.h:35
@ SEMIHOSTING_SYS_ISERROR
Definition semihosting.h:43
@ SEMIHOSTING_EnterSVC
Definition semihosting.h:34
@ SEMIHOSTING_SYS_WRITE
Definition semihosting.h:55
@ SEMIHOSTING_SYS_FLEN
Definition semihosting.h:40
@ SEMIHOSTING_SYS_GET_CMDLINE
Definition semihosting.h:41
@ SEMIHOSTING_SYS_REMOVE
Definition semihosting.h:48
@ SEMIHOSTING_SYS_SEEK
Definition semihosting.h:50
@ SEMIHOSTING_SYS_TMPNAM
Definition semihosting.h:54
@ ADP_Stopped_ApplicationExit
Definition semihosting.h:60
@ SEMIHOSTING_SYS_TIME
Definition semihosting.h:53
@ SEMIHOSTING_SYS_CLOCK
Definition semihosting.h:37
@ SEMIHOSTING_SYS_WRITEC
Definition semihosting.h:56
@ SEMIHOSTING_SYS_ERRNO
Definition semihosting.h:39
@ SEMIHOSTING_SYS_ISTTY
Definition semihosting.h:44
@ SEMIHOSTING_SYS_HEAPINFO
Definition semihosting.h:42
@ SEMIHOSTING_SYS_WRITE0
Definition semihosting.h:57
@ SEMIHOSTING_SYS_ELAPSED
Definition semihosting.h:38
@ SEMIHOSTING_SYS_READ
Definition semihosting.h:46
@ SEMIHOSTING_SYS_SYSTEM
Definition semihosting.h:51
@ SEMIHOSTING_SYS_CLOSE
Definition semihosting.h:36
@ SEMIHOSTING_SYS_READC
Definition semihosting.h:47
@ SEMIHOSTING_SYS_OPEN
Definition semihosting.h:45
@ SEMIHOSTING_SYS_RENAME
Definition semihosting.h:49

Function Documentation

◆ call_host()

static int call_host ( int  reason,
void *  arg 
)
inlinestatic

Definition at line 97 of file semihosting.h.

98 {
99 int value;
100 __asm__ volatile (
101
102 " mov r0, %[rsn] \n"
103 " mov r1, %[arg] \n"
104#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
105 " " AngelSWITestFault " \n"
106#else
107 " " AngelSWIInsn " %[swi] \n"
108#endif
109 " mov %[val], r0"
110
111 : [val] "=r"(value) /* Outputs */
112 : [rsn] "r"(reason), [arg] "r"(arg), [swi] "i"(AngelSWI) /* Inputs */
113 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
114 // Clobbers r0 and r1, and lr if in supervisor mode
115 );
116
117 // Accordingly to page 13-77 of ARM DUI 0040D other registers
118 // can also be clobbered. Some memory positions may also be
119 // changed by a system call, so they should not be kept in
120 // registers. Note: we are assuming the manual is right and
121 // Angel is respecting the APCS.
122 return value;
123 }
#define AngelSWIInsn
Definition semihosting.h:80
#define AngelSWI
Definition semihosting.h:72

References AngelSWI, and AngelSWIInsn.

Referenced by report_exception().

◆ report_exception()

static void report_exception ( int  reason)
inlinestatic

Definition at line 131 of file semihosting.h.

132 {
133 call_host (SEMIHOSTING_ReportException, (void*)reason);
134
135 for (;;)
136 ;
137 }
static int call_host(int reason, void *arg)
Definition semihosting.h:97

References call_host(), and SEMIHOSTING_ReportException.