mbed library sources(for async_print)

Dependents:   AsyncPrint

Fork of mbed-src by mbed official

Committer:
emilmont
Date:
Fri Jun 14 17:49:17 2013 +0100
Revision:
10:3bc89ef62ce7
Parent:
9:0ce32e54c9a7
Child:
13:0645d8841f51
Unify mbed library sources

Who changed what in which revision?

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