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