Fix RZ/A1H target issues

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Nov 20 17:24:08 2012 +0000
Revision:
0:fd0d7bdfcdc2
Child:
2:143cac498751
mbed sources

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:fd0d7bdfcdc2 1 /* mbed Microcontroller Library
mbed_official 0:fd0d7bdfcdc2 2 * Copyright (c) 2006-2012 ARM Limited
mbed_official 0:fd0d7bdfcdc2 3 *
mbed_official 0:fd0d7bdfcdc2 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
mbed_official 0:fd0d7bdfcdc2 5 * of this software and associated documentation files (the "Software"), to deal
mbed_official 0:fd0d7bdfcdc2 6 * in the Software without restriction, including without limitation the rights
mbed_official 0:fd0d7bdfcdc2 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbed_official 0:fd0d7bdfcdc2 8 * copies of the Software, and to permit persons to whom the Software is
mbed_official 0:fd0d7bdfcdc2 9 * furnished to do so, subject to the following conditions:
mbed_official 0:fd0d7bdfcdc2 10 *
mbed_official 0:fd0d7bdfcdc2 11 * The above copyright notice and this permission notice shall be included in
mbed_official 0:fd0d7bdfcdc2 12 * all copies or substantial portions of the Software.
mbed_official 0:fd0d7bdfcdc2 13 *
mbed_official 0:fd0d7bdfcdc2 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbed_official 0:fd0d7bdfcdc2 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbed_official 0:fd0d7bdfcdc2 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbed_official 0:fd0d7bdfcdc2 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbed_official 0:fd0d7bdfcdc2 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:fd0d7bdfcdc2 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
mbed_official 0:fd0d7bdfcdc2 20 * SOFTWARE.
mbed_official 0:fd0d7bdfcdc2 21 */
mbed_official 0:fd0d7bdfcdc2 22 #ifndef MBED_SEMIHOST_H
mbed_official 0:fd0d7bdfcdc2 23 #define MBED_SEMIHOST_H
mbed_official 0:fd0d7bdfcdc2 24
mbed_official 0:fd0d7bdfcdc2 25 #include "device.h"
mbed_official 0:fd0d7bdfcdc2 26 #include "toolchain.h"
mbed_official 0:fd0d7bdfcdc2 27
mbed_official 0:fd0d7bdfcdc2 28 #ifdef __cplusplus
mbed_official 0:fd0d7bdfcdc2 29 extern "C" {
mbed_official 0:fd0d7bdfcdc2 30 #endif
mbed_official 0:fd0d7bdfcdc2 31
mbed_official 0:fd0d7bdfcdc2 32 /* __semihost intrinsic
mbed_official 0:fd0d7bdfcdc2 33 This intrinsic inserts an SVC or BKPT instruction into the instruction stream
mbed_official 0:fd0d7bdfcdc2 34 generated by the compiler. It enables you to make semihosting calls from C or
mbed_official 0:fd0d7bdfcdc2 35 C++ that are independent of the target architecture.
mbed_official 0:fd0d7bdfcdc2 36 */
mbed_official 0:fd0d7bdfcdc2 37 #ifndef __CC_ARM
mbed_official 0:fd0d7bdfcdc2 38 /* Semihost implementation taken from eLua (MIT license):
mbed_official 0:fd0d7bdfcdc2 39 * git://github.com/elua/elua.git/src/semifs.c
mbed_official 0:fd0d7bdfcdc2 40 */
mbed_official 0:fd0d7bdfcdc2 41
mbed_official 0:fd0d7bdfcdc2 42 /* SWI numbers for RDI (Angel) monitors */
mbed_official 0:fd0d7bdfcdc2 43 #ifdef __thumb__
mbed_official 0:fd0d7bdfcdc2 44 #define AngelSWI 0xAB
mbed_official 0:fd0d7bdfcdc2 45 #else
mbed_official 0:fd0d7bdfcdc2 46 #define AngelSWI 0x123456
mbed_official 0:fd0d7bdfcdc2 47 #endif
mbed_official 0:fd0d7bdfcdc2 48 /* For Thumb-2 code use the BKPT instruction instead of SWI */
mbed_official 0:fd0d7bdfcdc2 49 #ifdef __thumb2__
mbed_official 0:fd0d7bdfcdc2 50 #define AngelSWIInsn "bkpt"
mbed_official 0:fd0d7bdfcdc2 51 #define AngelSWIAsm bkpt
mbed_official 0:fd0d7bdfcdc2 52 #else
mbed_official 0:fd0d7bdfcdc2 53 #define AngelSWIInsn "swi"
mbed_official 0:fd0d7bdfcdc2 54 #define AngelSWIAsm swi
mbed_official 0:fd0d7bdfcdc2 55 #endif
mbed_official 0:fd0d7bdfcdc2 56
mbed_official 0:fd0d7bdfcdc2 57 inline int __semihost(int reason, const void *arg) {
mbed_official 0:fd0d7bdfcdc2 58 int value;
mbed_official 0:fd0d7bdfcdc2 59 asm volatile ("mov r0, %1; mov r1, %2; " AngelSWIInsn " %a3; mov %0, r0"
mbed_official 0:fd0d7bdfcdc2 60 : "=r" (value) /* Outputs */
mbed_official 0:fd0d7bdfcdc2 61 : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
mbed_official 0:fd0d7bdfcdc2 62 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc"
mbed_official 0:fd0d7bdfcdc2 63 /* Clobbers r0 and r1, and lr if in supervisor mode */);
mbed_official 0:fd0d7bdfcdc2 64 /* Accordingly to page 13-77 of ARM DUI 0040D other registers
mbed_official 0:fd0d7bdfcdc2 65 can also be clobbered. Some memory positions may also be
mbed_official 0:fd0d7bdfcdc2 66 changed by a system call, so they should not be kept in
mbed_official 0:fd0d7bdfcdc2 67 registers. Note: we are assuming the manual is right and
mbed_official 0:fd0d7bdfcdc2 68 Angel is respecting the APCS. */
mbed_official 0:fd0d7bdfcdc2 69
mbed_official 0:fd0d7bdfcdc2 70 return value;
mbed_official 0:fd0d7bdfcdc2 71 }
mbed_official 0:fd0d7bdfcdc2 72
mbed_official 0:fd0d7bdfcdc2 73 #endif
mbed_official 0:fd0d7bdfcdc2 74
mbed_official 0:fd0d7bdfcdc2 75 #if DEVICE_LOCALFILESYSTEM
mbed_official 0:fd0d7bdfcdc2 76 FILEHANDLE semihost_open(const char* name, int openmode);
mbed_official 0:fd0d7bdfcdc2 77 int semihost_close (FILEHANDLE fh);
mbed_official 0:fd0d7bdfcdc2 78 int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
mbed_official 0:fd0d7bdfcdc2 79 int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
mbed_official 0:fd0d7bdfcdc2 80 int semihost_ensure(FILEHANDLE fh);
mbed_official 0:fd0d7bdfcdc2 81 long semihost_flen (FILEHANDLE fh);
mbed_official 0:fd0d7bdfcdc2 82 int semihost_seek (FILEHANDLE fh, long position);
mbed_official 0:fd0d7bdfcdc2 83 int semihost_istty (FILEHANDLE fh);
mbed_official 0:fd0d7bdfcdc2 84
mbed_official 0:fd0d7bdfcdc2 85 int semihost_remove(const char *name);
mbed_official 0:fd0d7bdfcdc2 86 int semihost_rename(const char *old_name, const char *new_name);
mbed_official 0:fd0d7bdfcdc2 87 #endif
mbed_official 0:fd0d7bdfcdc2 88
mbed_official 0:fd0d7bdfcdc2 89 int semihost_uid(char *uid);
mbed_official 0:fd0d7bdfcdc2 90 int semihost_reset(void);
mbed_official 0:fd0d7bdfcdc2 91 int semihost_vbus(void);
mbed_official 0:fd0d7bdfcdc2 92 int semihost_powerdown(void);
mbed_official 0:fd0d7bdfcdc2 93 int semihost_exit(void);
mbed_official 0:fd0d7bdfcdc2 94
mbed_official 0:fd0d7bdfcdc2 95 int semihost_connected(void);
mbed_official 0:fd0d7bdfcdc2 96 int semihost_disabledebug(void);
mbed_official 0:fd0d7bdfcdc2 97
mbed_official 0:fd0d7bdfcdc2 98 #ifdef __cplusplus
mbed_official 0:fd0d7bdfcdc2 99 }
mbed_official 0:fd0d7bdfcdc2 100 #endif
mbed_official 0:fd0d7bdfcdc2 101
mbed_official 0:fd0d7bdfcdc2 102 #endif