,,

Fork of Application by Daniel Sygut

Committer:
Zaitsev
Date:
Thu Feb 15 14:29:23 2018 +0000
Revision:
15:2a20c3d2616e
Parent:
10:41552d038a69
j

Who changed what in which revision?

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