mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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