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