Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __SEMIHOSTING_H__ |
| 32 | #define __SEMIHOSTING_H__ |
| 33 | |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 34 | #include <stdint.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 35 | #include <stdio.h> /* For ssize_t */ |
| 36 | |
| 37 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 38 | #define SEMIHOSTING_SYS_OPEN 0x01 |
| 39 | #define SEMIHOSTING_SYS_CLOSE 0x02 |
| 40 | #define SEMIHOSTING_SYS_WRITE0 0x04 |
| 41 | #define SEMIHOSTING_SYS_WRITEC 0x03 |
| 42 | #define SEMIHOSTING_SYS_WRITE 0x05 |
| 43 | #define SEMIHOSTING_SYS_READ 0x06 |
| 44 | #define SEMIHOSTING_SYS_READC 0x07 |
| 45 | #define SEMIHOSTING_SYS_SEEK 0x0A |
| 46 | #define SEMIHOSTING_SYS_FLEN 0x0C |
| 47 | #define SEMIHOSTING_SYS_REMOVE 0x0E |
| 48 | #define SEMIHOSTING_SYS_SYSTEM 0x12 |
| 49 | #define SEMIHOSTING_SYS_ERRNO 0x13 |
| 50 | |
| 51 | #define FOPEN_MODE_R 0x0 |
| 52 | #define FOPEN_MODE_RB 0x1 |
| 53 | #define FOPEN_MODE_RPLUS 0x2 |
| 54 | #define FOPEN_MODE_RPLUSB 0x3 |
| 55 | #define FOPEN_MODE_W 0x4 |
| 56 | #define FOPEN_MODE_WB 0x5 |
| 57 | #define FOPEN_MODE_WPLUS 0x6 |
| 58 | #define FOPEN_MODE_WPLUSB 0x7 |
| 59 | #define FOPEN_MODE_A 0x8 |
| 60 | #define FOPEN_MODE_AB 0x9 |
| 61 | #define FOPEN_MODE_APLUS 0xa |
| 62 | #define FOPEN_MODE_APLUSB 0xb |
| 63 | |
Ryan Harkin | cd52932 | 2014-02-10 17:17:04 +0000 | [diff] [blame] | 64 | long semihosting_connection_supported(void); |
| 65 | long semihosting_file_open(const char *file_name, size_t mode); |
| 66 | long semihosting_file_seek(long file_handle, ssize_t offset); |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 67 | long semihosting_file_read(long file_handle, size_t *length, uintptr_t buffer); |
Ryan Harkin | cd52932 | 2014-02-10 17:17:04 +0000 | [diff] [blame] | 68 | long semihosting_file_write(long file_handle, |
| 69 | size_t *length, |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 70 | const uintptr_t buffer); |
Ryan Harkin | cd52932 | 2014-02-10 17:17:04 +0000 | [diff] [blame] | 71 | long semihosting_file_close(long file_handle); |
| 72 | long semihosting_file_length(long file_handle); |
| 73 | long semihosting_system(char *command_line); |
| 74 | long semihosting_get_flen(const char *file_name); |
| 75 | long semihosting_download_file(const char *file_name, |
| 76 | size_t buf_size, |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 77 | uintptr_t buf); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 78 | void semihosting_write_char(char character); |
| 79 | void semihosting_write_string(char *string); |
| 80 | char semihosting_read_char(void); |
| 81 | |
| 82 | #endif /* __SEMIHOSTING_H__ */ |