// Semi-hosting I/O services // Copyright (C)2013-2015, Philip Munts, President, Munts AM Corp. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // These services ONLY work in debug mode. If your program calls any of these, // it will NOT work unless you are debugging. // Be sure to issue "monitor arm semihosting enable" in gdb before starting // your program. // Semi-hosting operations -- From "ARM Compiler toolchain Developing // Software for ARM Processors,Version 5.03" #ifndef INCLUDE_DI_FW_SEMIHOSTING_H_ #define INCLUDE_DI_FW_SEMIHOSTING_H_ #include #define SYS_OPEN 0x01 #define SYS_CLOSE 0x02 #define SYS_WRITEC 0x03 #define SYS_WRITE0 0x04 #define SYS_WRITE 0x05 #define SYS_READ 0x06 #define SYS_READC 0x07 #define SYS_ISERROR 0x08 #define SYS_ISTTY 0x09 #define SYS_SEEK 0x0A #define SYS_FLEN 0x0C #define SYS_TMPNAM 0x0D #define SYS_REMOVE 0x0E #define SYS_CLOCK 0x10 #define SYS_TIME 0x11 #define SYS_SYSTEM 0x12 #define SYS_ERRNO 0x13 #define SYS_GET_CMDLINE 0x15 #define SYS_HEAPINFO 0x16 #define SYS_ELAPSED 0x30 #define SYS_TICKFREQ 0x31 #define FD_LINUX 0 #define FD_WINDOWS 1 #if !defined(DEBUG_BUILD) && !defined(UNITY_OUTPUT_CHAR) #define semihosting_register(n) (void)n #define semihosting_stdio(n) (void)n #define semihosting_open(n) (void)n #define semihosting_close(n) (void)n #define semihosting_putc(f, c) (void)c #define semihosting_read(n, b, c) (void)n #define semihosting_write(n, b, c) (void)n static inline int semihosting_fdprintf(unsigned int fd, const char *fmt, ...) { (void)fd; (void)fmt; return 0; } #define semihosting_read_ready(n) (void)n #define semihosting_write_ready(n) (void)n #else int semihosting_register(char *name); int semihosting_stdio(char *name); int semihosting_open(void *name); int semihosting_close(unsigned int fd); /* Buffered putc, will flush on '\n' or full buffer */ int semihosting_putc(unsigned int fd, int c); int semihosting_read(unsigned int fd, void *buf, unsigned int count); int semihosting_write(unsigned int fd, const void *buf, unsigned int count); int semihosting_fdprintf(unsigned int fd, const char *fmt, ...); int semihosting_read_ready(unsigned int fd); int semihosting_write_ready(unsigned int fd); void semihosting_log_writer(const struct di_log_msg *msg, void *private_data); #endif #endif /* INCLUDE_DI_FW_SEMIHOSTING_H_ */