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