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