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