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