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