blob: eb7c4c3b3f3a5314ae11f9b74ab7aea1ac1f5cbb [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
6
7#ifndef __SEMIHOSTING_H__
8#define __SEMIHOSTING_H__
9
Dan Handleya4cb68e2014-04-23 13:47:06 +010010#include <stdint.h>
Dan Handley2bd4ef22014-04-09 13:14:54 +010011#include <stdio.h> /* For ssize_t */
12
13
Achin Gupta4f6ad662013-10-25 09:08:21 +010014#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
26
27#define FOPEN_MODE_R 0x0
28#define FOPEN_MODE_RB 0x1
29#define FOPEN_MODE_RPLUS 0x2
30#define FOPEN_MODE_RPLUSB 0x3
31#define FOPEN_MODE_W 0x4
32#define FOPEN_MODE_WB 0x5
33#define FOPEN_MODE_WPLUS 0x6
34#define FOPEN_MODE_WPLUSB 0x7
35#define FOPEN_MODE_A 0x8
36#define FOPEN_MODE_AB 0x9
37#define FOPEN_MODE_APLUS 0xa
38#define FOPEN_MODE_APLUSB 0xb
39
Ryan Harkincd529322014-02-10 17:17:04 +000040long semihosting_connection_supported(void);
41long semihosting_file_open(const char *file_name, size_t mode);
42long semihosting_file_seek(long file_handle, ssize_t offset);
Dan Handleya4cb68e2014-04-23 13:47:06 +010043long semihosting_file_read(long file_handle, size_t *length, uintptr_t buffer);
Ryan Harkincd529322014-02-10 17:17:04 +000044long semihosting_file_write(long file_handle,
45 size_t *length,
Dan Handleya4cb68e2014-04-23 13:47:06 +010046 const uintptr_t buffer);
Ryan Harkincd529322014-02-10 17:17:04 +000047long semihosting_file_close(long file_handle);
48long semihosting_file_length(long file_handle);
49long semihosting_system(char *command_line);
50long semihosting_get_flen(const char *file_name);
51long semihosting_download_file(const char *file_name,
52 size_t buf_size,
Dan Handleya4cb68e2014-04-23 13:47:06 +010053 uintptr_t buf);
Achin Gupta4f6ad662013-10-25 09:08:21 +010054void semihosting_write_char(char character);
55void semihosting_write_string(char *string);
56char semihosting_read_char(void);
57
58#endif /* __SEMIHOSTING_H__ */