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