Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
semihost_api.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_SEMIHOST_H 00017 #define MBED_SEMIHOST_H 00018 00019 #include "device.h" 00020 #include "toolchain.h" 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 #if DEVICE_SEMIHOST 00027 00028 #ifndef __CC_ARM 00029 00030 #if defined(__ICCARM__) 00031 inline int __semihost(int reason, const void *arg) { 00032 return __semihosting(reason, (void*)arg); 00033 } 00034 #else 00035 00036 #ifdef __thumb__ 00037 # define AngelSWI 0xAB 00038 # define AngelSWIInsn "bkpt" 00039 # define AngelSWIAsm bkpt 00040 #else 00041 # define AngelSWI 0x123456 00042 # define AngelSWIInsn "swi" 00043 # define AngelSWIAsm swi 00044 #endif 00045 00046 static inline int __semihost(int reason, const void *arg) { 00047 int value; 00048 00049 asm volatile ( 00050 "mov r0, %1" "\n\t" 00051 "mov r1, %2" "\n\t" 00052 AngelSWIInsn " %a3" "\n\t" 00053 "mov %0, r0" 00054 : "=r" (value) /* output operands */ 00055 : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */ 00056 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */ 00057 ); 00058 00059 return value; 00060 } 00061 #endif 00062 #endif 00063 00064 #if DEVICE_LOCALFILESYSTEM 00065 FILEHANDLE semihost_open(const char* name, int openmode); 00066 int semihost_close (FILEHANDLE fh); 00067 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode); 00068 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode); 00069 int semihost_ensure(FILEHANDLE fh); 00070 long semihost_flen (FILEHANDLE fh); 00071 int semihost_seek (FILEHANDLE fh, long position); 00072 int semihost_istty (FILEHANDLE fh); 00073 00074 int semihost_remove(const char *name); 00075 int semihost_rename(const char *old_name, const char *new_name); 00076 #endif 00077 00078 int semihost_uid(char *uid); 00079 int semihost_reset(void); 00080 int semihost_vbus(void); 00081 int semihost_powerdown(void); 00082 int semihost_exit(void); 00083 00084 int semihost_connected(void); 00085 int semihost_disabledebug(void); 00086 00087 #endif 00088 00089 #ifdef __cplusplus 00090 } 00091 #endif 00092 00093 #endif
Generated on Tue Jul 12 2022 21:21:33 by
