1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef MBED_SEMIHOST_H
17 #define MBED_SEMIHOST_H
20 #include "toolchain.h"
30 #if defined(__ICCARM__)
31 inline int __semihost(int reason, const void *arg) {
32 return __semihosting(reason, (void*)arg);
37 # define AngelSWI 0xAB
38 # define AngelSWIInsn "bkpt"
39 # define AngelSWIAsm bkpt
41 # define AngelSWI 0x123456
42 # define AngelSWIInsn "swi"
43 # define AngelSWIAsm swi
46 static inline int __semihost(int reason, const void *arg) {
52 AngelSWIInsn " %a3" "\n\t"
54 : "=r" (value) /* output operands */
55 : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */
56 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
64 #if DEVICE_LOCALFILESYSTEM
65 FILEHANDLE semihost_open(const char* name, int openmode);
66 int semihost_close (FILEHANDLE fh);
67 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
68 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
69 int semihost_ensure(FILEHANDLE fh);
70 long semihost_flen (FILEHANDLE fh);
71 int semihost_seek (FILEHANDLE fh, long position);
72 int semihost_istty (FILEHANDLE fh);
74 int semihost_remove(const char *name);
75 int semihost_rename(const char *old_name, const char *new_name);
78 int semihost_uid(char *uid);
79 int semihost_reset(void);
80 int semihost_vbus(void);
81 int semihost_powerdown(void);
82 int semihost_exit(void);
84 int semihost_connected(void);
85 int semihost_disabledebug(void);