This fork captures the mbed lib v125 for ease of integration into older projects.

Fork of mbed-dev by mbed official

Committer:
apluscw
Date:
Fri Jul 20 21:24:42 2018 +0000
Revision:
187:92cbb9eec47b
Mbed library with source code from mbed lib v125. Posted to ease integration with some older projects.

Who changed what in which revision?

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