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.
semihost_api.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 #ifndef MBED_SEMIHOST_H 00023 #define MBED_SEMIHOST_H 00024 00025 #include "device.h" 00026 #include "toolchain.h" 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #if DEVICE_SEMIHOST 00033 00034 #ifndef __CC_ARM 00035 00036 #if defined(__ICCARM__) 00037 inline int __semihost(int reason, const void *arg) { 00038 return __semihosting(reason, (void*)arg); 00039 } 00040 #else 00041 00042 #ifdef __thumb__ 00043 # define AngelSWI 0xAB 00044 # define AngelSWIInsn "bkpt" 00045 # define AngelSWIAsm bkpt 00046 #else 00047 # define AngelSWI 0x123456 00048 # define AngelSWIInsn "swi" 00049 # define AngelSWIAsm swi 00050 #endif 00051 00052 inline int __semihost(int reason, const void *arg) { 00053 int value; 00054 00055 asm volatile ( 00056 "mov r0, %1" "\n\t" 00057 "mov r1, %2" "\n\t" 00058 AngelSWIInsn " %a3" "\n\t" 00059 "mov %0, r0" 00060 : "=r" (value) /* output operands */ 00061 : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */ 00062 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */ 00063 ); 00064 00065 return value; 00066 } 00067 #endif 00068 #endif 00069 00070 #if DEVICE_LOCALFILESYSTEM 00071 FILEHANDLE semihost_open(const char* name, int openmode); 00072 int semihost_close (FILEHANDLE fh); 00073 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode); 00074 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode); 00075 int semihost_ensure(FILEHANDLE fh); 00076 long semihost_flen (FILEHANDLE fh); 00077 int semihost_seek (FILEHANDLE fh, long position); 00078 int semihost_istty (FILEHANDLE fh); 00079 00080 int semihost_remove(const char *name); 00081 int semihost_rename(const char *old_name, const char *new_name); 00082 #endif 00083 00084 int semihost_uid(char *uid); 00085 int semihost_reset(void); 00086 int semihost_vbus(void); 00087 int semihost_powerdown(void); 00088 int semihost_exit(void); 00089 00090 int semihost_connected(void); 00091 int semihost_disabledebug(void); 00092 00093 #endif 00094 00095 #ifdef __cplusplus 00096 } 00097 #endif 00098 00099 #endif 00100
Generated on Wed Jul 13 2022 02:59:12 by
