PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Committer:
Pokitto
Date:
Wed Oct 11 20:35:27 2017 +0000
Revision:
5:ea7377f3d1af
Fixed PokittoLib. Includes a working custom mbed-src

Who changed what in which revision?

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