Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
inc/semihost_api.h@0:afeca64a6543, 2018-10-17 (annotated)
- Committer:
- martwerl
- Date:
- Wed Oct 17 17:19:45 2018 +0000
- Revision:
- 0:afeca64a6543
Diplomarbeit_MW_CW
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martwerl | 0:afeca64a6543 | 1 | /* mbed Microcontroller Library |
| martwerl | 0:afeca64a6543 | 2 | * Copyright (c) 2006-2013 ARM Limited |
| martwerl | 0:afeca64a6543 | 3 | * |
| martwerl | 0:afeca64a6543 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| martwerl | 0:afeca64a6543 | 5 | * of this software and associated documentation files (the "Software"), to deal |
| martwerl | 0:afeca64a6543 | 6 | * in the Software without restriction, including without limitation the rights |
| martwerl | 0:afeca64a6543 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| martwerl | 0:afeca64a6543 | 8 | * copies of the Software, and to permit persons to whom the Software is |
| martwerl | 0:afeca64a6543 | 9 | * furnished to do so, subject to the following conditions: |
| martwerl | 0:afeca64a6543 | 10 | * |
| martwerl | 0:afeca64a6543 | 11 | * The above copyright notice and this permission notice shall be included in |
| martwerl | 0:afeca64a6543 | 12 | * all copies or substantial portions of the Software. |
| martwerl | 0:afeca64a6543 | 13 | * |
| martwerl | 0:afeca64a6543 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| martwerl | 0:afeca64a6543 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| martwerl | 0:afeca64a6543 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| martwerl | 0:afeca64a6543 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| martwerl | 0:afeca64a6543 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| martwerl | 0:afeca64a6543 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| martwerl | 0:afeca64a6543 | 20 | * SOFTWARE. |
| martwerl | 0:afeca64a6543 | 21 | */ |
| martwerl | 0:afeca64a6543 | 22 | #ifndef MBED_SEMIHOST_H |
| martwerl | 0:afeca64a6543 | 23 | #define MBED_SEMIHOST_H |
| martwerl | 0:afeca64a6543 | 24 | |
| martwerl | 0:afeca64a6543 | 25 | #include "device.h" |
| martwerl | 0:afeca64a6543 | 26 | #include "toolchain.h" |
| martwerl | 0:afeca64a6543 | 27 | |
| martwerl | 0:afeca64a6543 | 28 | #ifdef __cplusplus |
| martwerl | 0:afeca64a6543 | 29 | extern "C" { |
| martwerl | 0:afeca64a6543 | 30 | #endif |
| martwerl | 0:afeca64a6543 | 31 | |
| martwerl | 0:afeca64a6543 | 32 | #if DEVICE_SEMIHOST |
| martwerl | 0:afeca64a6543 | 33 | |
| martwerl | 0:afeca64a6543 | 34 | #ifndef __CC_ARM |
| martwerl | 0:afeca64a6543 | 35 | |
| martwerl | 0:afeca64a6543 | 36 | #if defined(__ICCARM__) |
| martwerl | 0:afeca64a6543 | 37 | inline int __semihost(int reason, const void *arg) { |
| martwerl | 0:afeca64a6543 | 38 | return __semihosting(reason, (void*)arg); |
| martwerl | 0:afeca64a6543 | 39 | } |
| martwerl | 0:afeca64a6543 | 40 | #else |
| martwerl | 0:afeca64a6543 | 41 | |
| martwerl | 0:afeca64a6543 | 42 | #ifdef __thumb__ |
| martwerl | 0:afeca64a6543 | 43 | # define AngelSWI 0xAB |
| martwerl | 0:afeca64a6543 | 44 | # define AngelSWIInsn "bkpt" |
| martwerl | 0:afeca64a6543 | 45 | # define AngelSWIAsm bkpt |
| martwerl | 0:afeca64a6543 | 46 | #else |
| martwerl | 0:afeca64a6543 | 47 | # define AngelSWI 0x123456 |
| martwerl | 0:afeca64a6543 | 48 | # define AngelSWIInsn "swi" |
| martwerl | 0:afeca64a6543 | 49 | # define AngelSWIAsm swi |
| martwerl | 0:afeca64a6543 | 50 | #endif |
| martwerl | 0:afeca64a6543 | 51 | |
| martwerl | 0:afeca64a6543 | 52 | inline int __semihost(int reason, const void *arg) { |
| martwerl | 0:afeca64a6543 | 53 | int value; |
| martwerl | 0:afeca64a6543 | 54 | |
| martwerl | 0:afeca64a6543 | 55 | asm volatile ( |
| martwerl | 0:afeca64a6543 | 56 | "mov r0, %1" "\n\t" |
| martwerl | 0:afeca64a6543 | 57 | "mov r1, %2" "\n\t" |
| martwerl | 0:afeca64a6543 | 58 | AngelSWIInsn " %a3" "\n\t" |
| martwerl | 0:afeca64a6543 | 59 | "mov %0, r0" |
| martwerl | 0:afeca64a6543 | 60 | : "=r" (value) /* output operands */ |
| martwerl | 0:afeca64a6543 | 61 | : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */ |
| martwerl | 0:afeca64a6543 | 62 | : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */ |
| martwerl | 0:afeca64a6543 | 63 | ); |
| martwerl | 0:afeca64a6543 | 64 | |
| martwerl | 0:afeca64a6543 | 65 | return value; |
| martwerl | 0:afeca64a6543 | 66 | } |
| martwerl | 0:afeca64a6543 | 67 | #endif |
| martwerl | 0:afeca64a6543 | 68 | #endif |
| martwerl | 0:afeca64a6543 | 69 | |
| martwerl | 0:afeca64a6543 | 70 | #if DEVICE_LOCALFILESYSTEM |
| martwerl | 0:afeca64a6543 | 71 | FILEHANDLE semihost_open(const char* name, int openmode); |
| martwerl | 0:afeca64a6543 | 72 | int semihost_close (FILEHANDLE fh); |
| martwerl | 0:afeca64a6543 | 73 | int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode); |
| martwerl | 0:afeca64a6543 | 74 | int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode); |
| martwerl | 0:afeca64a6543 | 75 | int semihost_ensure(FILEHANDLE fh); |
| martwerl | 0:afeca64a6543 | 76 | long semihost_flen (FILEHANDLE fh); |
| martwerl | 0:afeca64a6543 | 77 | int semihost_seek (FILEHANDLE fh, long position); |
| martwerl | 0:afeca64a6543 | 78 | int semihost_istty (FILEHANDLE fh); |
| martwerl | 0:afeca64a6543 | 79 | |
| martwerl | 0:afeca64a6543 | 80 | int semihost_remove(const char *name); |
| martwerl | 0:afeca64a6543 | 81 | int semihost_rename(const char *old_name, const char *new_name); |
| martwerl | 0:afeca64a6543 | 82 | #endif |
| martwerl | 0:afeca64a6543 | 83 | |
| martwerl | 0:afeca64a6543 | 84 | int semihost_uid(char *uid); |
| martwerl | 0:afeca64a6543 | 85 | int semihost_reset(void); |
| martwerl | 0:afeca64a6543 | 86 | int semihost_vbus(void); |
| martwerl | 0:afeca64a6543 | 87 | int semihost_powerdown(void); |
| martwerl | 0:afeca64a6543 | 88 | int semihost_exit(void); |
| martwerl | 0:afeca64a6543 | 89 | |
| martwerl | 0:afeca64a6543 | 90 | int semihost_connected(void); |
| martwerl | 0:afeca64a6543 | 91 | int semihost_disabledebug(void); |
| martwerl | 0:afeca64a6543 | 92 | |
| martwerl | 0:afeca64a6543 | 93 | #endif |
| martwerl | 0:afeca64a6543 | 94 | |
| martwerl | 0:afeca64a6543 | 95 | #ifdef __cplusplus |
| martwerl | 0:afeca64a6543 | 96 | } |
| martwerl | 0:afeca64a6543 | 97 | #endif |
| martwerl | 0:afeca64a6543 | 98 | |
| martwerl | 0:afeca64a6543 | 99 | #endif |
| martwerl | 0:afeca64a6543 | 100 |