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