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