Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_semihost_api.h Source File

mbed_semihost_api.h

00001 
00002 /* mbed Microcontroller Library
00003  * Copyright (c) 2006-2019 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 
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 {
00034     return __semihosting(reason, (void *)arg);
00035 }
00036 #else
00037 
00038 #ifdef __thumb__
00039 #   define AngelSWI            0xAB
00040 #   define AngelSWIInsn        "bkpt"
00041 #   define AngelSWIAsm          bkpt
00042 #else
00043 #   define AngelSWI            0x123456
00044 #   define AngelSWIInsn        "swi"
00045 #   define AngelSWIAsm          swi
00046 #endif
00047 
00048 static inline int __semihost(int reason, const void *arg)
00049 {
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