test

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Committer:
ommpy
Date:
Mon Jul 06 17:18:59 2020 +0530
Revision:
0:d383e2dee0f7
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ommpy 0:d383e2dee0f7 1
ommpy 0:d383e2dee0f7 2 /* mbed Microcontroller Library
ommpy 0:d383e2dee0f7 3 * Copyright (c) 2006-2013 ARM Limited
ommpy 0:d383e2dee0f7 4 * SPDX-License-Identifier: Apache-2.0
ommpy 0:d383e2dee0f7 5 *
ommpy 0:d383e2dee0f7 6 * Licensed under the Apache License, Version 2.0 (the "License");
ommpy 0:d383e2dee0f7 7 * you may not use this file except in compliance with the License.
ommpy 0:d383e2dee0f7 8 * You may obtain a copy of the License at
ommpy 0:d383e2dee0f7 9 *
ommpy 0:d383e2dee0f7 10 * http://www.apache.org/licenses/LICENSE-2.0
ommpy 0:d383e2dee0f7 11 *
ommpy 0:d383e2dee0f7 12 * Unless required by applicable law or agreed to in writing, software
ommpy 0:d383e2dee0f7 13 * distributed under the License is distributed on an "AS IS" BASIS,
ommpy 0:d383e2dee0f7 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ommpy 0:d383e2dee0f7 15 * See the License for the specific language governing permissions and
ommpy 0:d383e2dee0f7 16 * limitations under the License.
ommpy 0:d383e2dee0f7 17 */
ommpy 0:d383e2dee0f7 18 #ifndef MBED_SEMIHOST_H
ommpy 0:d383e2dee0f7 19 #define MBED_SEMIHOST_H
ommpy 0:d383e2dee0f7 20
ommpy 0:d383e2dee0f7 21 #include "device.h"
ommpy 0:d383e2dee0f7 22 #include "platform/mbed_toolchain.h"
ommpy 0:d383e2dee0f7 23
ommpy 0:d383e2dee0f7 24 #ifdef __cplusplus
ommpy 0:d383e2dee0f7 25 extern "C" {
ommpy 0:d383e2dee0f7 26 #endif
ommpy 0:d383e2dee0f7 27
ommpy 0:d383e2dee0f7 28 #if DEVICE_SEMIHOST
ommpy 0:d383e2dee0f7 29
ommpy 0:d383e2dee0f7 30 #if !defined(__CC_ARM) && !defined(__ARMCC_VERSION)
ommpy 0:d383e2dee0f7 31
ommpy 0:d383e2dee0f7 32 #if defined(__ICCARM__)
ommpy 0:d383e2dee0f7 33 static inline int __semihost(int reason, const void *arg)
ommpy 0:d383e2dee0f7 34 {
ommpy 0:d383e2dee0f7 35 return __semihosting(reason, (void *)arg);
ommpy 0:d383e2dee0f7 36 }
ommpy 0:d383e2dee0f7 37 #else
ommpy 0:d383e2dee0f7 38
ommpy 0:d383e2dee0f7 39 #ifdef __thumb__
ommpy 0:d383e2dee0f7 40 # define AngelSWI 0xAB
ommpy 0:d383e2dee0f7 41 # define AngelSWIInsn "bkpt"
ommpy 0:d383e2dee0f7 42 # define AngelSWIAsm bkpt
ommpy 0:d383e2dee0f7 43 #else
ommpy 0:d383e2dee0f7 44 # define AngelSWI 0x123456
ommpy 0:d383e2dee0f7 45 # define AngelSWIInsn "swi"
ommpy 0:d383e2dee0f7 46 # define AngelSWIAsm swi
ommpy 0:d383e2dee0f7 47 #endif
ommpy 0:d383e2dee0f7 48
ommpy 0:d383e2dee0f7 49 static inline int __semihost(int reason, const void *arg)
ommpy 0:d383e2dee0f7 50 {
ommpy 0:d383e2dee0f7 51 int value;
ommpy 0:d383e2dee0f7 52
ommpy 0:d383e2dee0f7 53 asm volatile(
ommpy 0:d383e2dee0f7 54 "mov r0, %1" "\n\t"
ommpy 0:d383e2dee0f7 55 "mov r1, %2" "\n\t"
ommpy 0:d383e2dee0f7 56 AngelSWIInsn " %a3" "\n\t"
ommpy 0:d383e2dee0f7 57 "mov %0, r0"
ommpy 0:d383e2dee0f7 58 : "=r"(value) /* output operands */
ommpy 0:d383e2dee0f7 59 : "r"(reason), "r"(arg), "i"(AngelSWI) /* input operands */
ommpy 0:d383e2dee0f7 60 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
ommpy 0:d383e2dee0f7 61 );
ommpy 0:d383e2dee0f7 62
ommpy 0:d383e2dee0f7 63 return value;
ommpy 0:d383e2dee0f7 64 }
ommpy 0:d383e2dee0f7 65 #endif
ommpy 0:d383e2dee0f7 66 #endif
ommpy 0:d383e2dee0f7 67
ommpy 0:d383e2dee0f7 68 #if DEVICE_LOCALFILESYSTEM
ommpy 0:d383e2dee0f7 69 FILEHANDLE semihost_open(const char *name, int openmode);
ommpy 0:d383e2dee0f7 70 int semihost_close(FILEHANDLE fh);
ommpy 0:d383e2dee0f7 71 int semihost_read(FILEHANDLE fh, unsigned char *buffer, unsigned int length, int mode);
ommpy 0:d383e2dee0f7 72 int semihost_write(FILEHANDLE fh, const unsigned char *buffer, unsigned int length, int mode);
ommpy 0:d383e2dee0f7 73 int semihost_ensure(FILEHANDLE fh);
ommpy 0:d383e2dee0f7 74 long semihost_flen(FILEHANDLE fh);
ommpy 0:d383e2dee0f7 75 int semihost_seek(FILEHANDLE fh, long position);
ommpy 0:d383e2dee0f7 76 int semihost_istty(FILEHANDLE fh);
ommpy 0:d383e2dee0f7 77
ommpy 0:d383e2dee0f7 78 int semihost_remove(const char *name);
ommpy 0:d383e2dee0f7 79 int semihost_rename(const char *old_name, const char *new_name);
ommpy 0:d383e2dee0f7 80 #endif
ommpy 0:d383e2dee0f7 81
ommpy 0:d383e2dee0f7 82 int semihost_uid(char *uid);
ommpy 0:d383e2dee0f7 83 int semihost_reset(void);
ommpy 0:d383e2dee0f7 84 int semihost_vbus(void);
ommpy 0:d383e2dee0f7 85 int semihost_powerdown(void);
ommpy 0:d383e2dee0f7 86 int semihost_exit(void);
ommpy 0:d383e2dee0f7 87
ommpy 0:d383e2dee0f7 88 int semihost_connected(void);
ommpy 0:d383e2dee0f7 89 int semihost_disabledebug(void);
ommpy 0:d383e2dee0f7 90
ommpy 0:d383e2dee0f7 91 #endif
ommpy 0:d383e2dee0f7 92
ommpy 0:d383e2dee0f7 93 #ifdef __cplusplus
ommpy 0:d383e2dee0f7 94 }
ommpy 0:d383e2dee0f7 95 #endif
ommpy 0:d383e2dee0f7 96
ommpy 0:d383e2dee0f7 97 #endif
ommpy 0:d383e2dee0f7 98
ommpy 0:d383e2dee0f7 99