SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

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