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