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