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 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef SEMIHOSTING_H |
| 8 | #define SEMIHOSTING_H |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 9 | |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 10 | #include <stdint.h> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 11 | #include <stdio.h> /* For ssize_t */ |
| 12 | |
| 13 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 14 | #define SEMIHOSTING_SYS_OPEN 0x01 |
| 15 | #define SEMIHOSTING_SYS_CLOSE 0x02 |
| 16 | #define SEMIHOSTING_SYS_WRITE0 0x04 |
| 17 | #define SEMIHOSTING_SYS_WRITEC 0x03 |
| 18 | #define SEMIHOSTING_SYS_WRITE 0x05 |
| 19 | #define SEMIHOSTING_SYS_READ 0x06 |
| 20 | #define SEMIHOSTING_SYS_READC 0x07 |
| 21 | #define SEMIHOSTING_SYS_SEEK 0x0A |
| 22 | #define SEMIHOSTING_SYS_FLEN 0x0C |
| 23 | #define SEMIHOSTING_SYS_REMOVE 0x0E |
| 24 | #define SEMIHOSTING_SYS_SYSTEM 0x12 |
| 25 | #define SEMIHOSTING_SYS_ERRNO 0x13 |
Andrew Walbran | f3a6839 | 2020-01-15 14:18:04 +0000 | [diff] [blame] | 26 | #define SEMIHOSTING_SYS_EXIT 0x18 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 27 | |
| 28 | #define FOPEN_MODE_R 0x0 |
| 29 | #define FOPEN_MODE_RB 0x1 |
| 30 | #define FOPEN_MODE_RPLUS 0x2 |
| 31 | #define FOPEN_MODE_RPLUSB 0x3 |
| 32 | #define FOPEN_MODE_W 0x4 |
| 33 | #define FOPEN_MODE_WB 0x5 |
| 34 | #define FOPEN_MODE_WPLUS 0x6 |
| 35 | #define FOPEN_MODE_WPLUSB 0x7 |
| 36 | #define FOPEN_MODE_A 0x8 |
| 37 | #define FOPEN_MODE_AB 0x9 |
| 38 | #define FOPEN_MODE_APLUS 0xa |
| 39 | #define FOPEN_MODE_APLUSB 0xb |
| 40 | |
Ryan Harkin | cd52932 | 2014-02-10 17:17:04 +0000 | [diff] [blame] | 41 | long semihosting_connection_supported(void); |
| 42 | long semihosting_file_open(const char *file_name, size_t mode); |
| 43 | long semihosting_file_seek(long file_handle, ssize_t offset); |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 44 | 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] | 45 | long semihosting_file_write(long file_handle, |
| 46 | size_t *length, |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 47 | const uintptr_t buffer); |
Ryan Harkin | cd52932 | 2014-02-10 17:17:04 +0000 | [diff] [blame] | 48 | long semihosting_file_close(long file_handle); |
| 49 | long semihosting_file_length(long file_handle); |
| 50 | long semihosting_system(char *command_line); |
| 51 | long semihosting_get_flen(const char *file_name); |
| 52 | long semihosting_download_file(const char *file_name, |
| 53 | size_t buf_size, |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 54 | uintptr_t buf); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 55 | void semihosting_write_char(char character); |
| 56 | void semihosting_write_string(char *string); |
| 57 | char semihosting_read_char(void); |
Andrew Walbran | f3a6839 | 2020-01-15 14:18:04 +0000 | [diff] [blame] | 58 | void semihosting_exit(uint32_t reason, uint32_t subcode); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 59 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 60 | #endif /* SEMIHOSTING_H */ |