mbed library sources

Dependents:   RPC_Serial_V_mac

Committer:
mbed_official
Date:
Wed Sep 30 17:00:09 2015 +0100
Revision:
636:a11c0372f0ba
Parent:
13:0645d8841f51
Synchronized with git revision d29c98dae61be0946ddf3a3c641c7726056f9452

Full URL: https://github.com/mbedmicro/mbed/commit/d29c98dae61be0946ddf3a3c641c7726056f9452/

Added support for SAMW25

Who changed what in which revision?

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