aboutsummaryrefslogtreecommitdiff
path: root/lib/semihosting/semihosting.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/semihosting/semihosting.c')
-rw-r--r--lib/semihosting/semihosting.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c
index 1a7ac60..632c316 100644
--- a/lib/semihosting/semihosting.c
+++ b/lib/semihosting/semihosting.c
@@ -31,43 +31,44 @@
#include <assert.h>
#include <string.h>
#include <errno.h>
+#include <stdio.h>
#include <semihosting.h>
#ifndef SEMIHOSTING_SUPPORTED
#define SEMIHOSTING_SUPPORTED 1
#endif
-extern int semihosting_call(unsigned int operation,
+extern long semihosting_call(unsigned long operation,
void *system_block_address);
typedef struct {
const char *file_name;
- unsigned int mode;
- unsigned int name_length;
+ unsigned long mode;
+ size_t name_length;
} smh_file_open_block;
typedef struct {
- int handle;
+ long handle;
void *buffer;
- unsigned int length;
+ size_t length;
} smh_file_read_write_block;
typedef struct {
- int handle;
- unsigned int location;
+ long handle;
+ ssize_t location;
} smh_file_seek_block;
typedef struct {
char *command_line;
- unsigned int command_length;
+ size_t command_length;
} smh_system_block;
-int semihosting_connection_supported(void)
+long semihosting_connection_supported(void)
{
return SEMIHOSTING_SUPPORTED;
}
-int semihosting_file_open(const char *file_name, unsigned int mode)
+long semihosting_file_open(const char *file_name, size_t mode)
{
smh_file_open_block open_block;
@@ -79,10 +80,10 @@ int semihosting_file_open(const char *file_name, unsigned int mode)
(void *) &open_block);
}
-int semihosting_file_seek(int file_handle, unsigned int offset)
+long semihosting_file_seek(long file_handle, ssize_t offset)
{
smh_file_seek_block seek_block;
- int result;
+ long result;
seek_block.handle = file_handle;
seek_block.location = offset;
@@ -96,10 +97,10 @@ int semihosting_file_seek(int file_handle, unsigned int offset)
return result;
}
-int semihosting_file_read(int file_handle, int *length, void *buffer)
+long semihosting_file_read(long file_handle, size_t *length, void *buffer)
{
smh_file_read_write_block read_block;
- int result = -EINVAL;
+ long result = -EINVAL;
if ((length == NULL) || (buffer == NULL))
return result;
@@ -120,7 +121,7 @@ int semihosting_file_read(int file_handle, int *length, void *buffer)
return result;
}
-int semihosting_file_write(int file_handle, int *length, const void *buffer)
+long semihosting_file_write(long file_handle, size_t *length, const void *buffer)
{
smh_file_read_write_block write_block;
@@ -137,13 +138,13 @@ int semihosting_file_write(int file_handle, int *length, const void *buffer)
return *length;
}
-int semihosting_file_close(int file_handle)
+long semihosting_file_close(long file_handle)
{
return semihosting_call(SEMIHOSTING_SYS_CLOSE,
(void *) &file_handle);
}
-int semihosting_file_length(int file_handle)
+long semihosting_file_length(long file_handle)
{
return semihosting_call(SEMIHOSTING_SYS_FLEN,
(void *) &file_handle);
@@ -164,7 +165,7 @@ void semihosting_write_string(char *string)
semihosting_call(SEMIHOSTING_SYS_WRITE0, (void *) string);
}
-int semihosting_system(char *command_line)
+long semihosting_system(char *command_line)
{
smh_system_block system_block;
@@ -175,9 +176,10 @@ int semihosting_system(char *command_line)
(void *) &system_block);
}
-int semihosting_get_flen(const char *file_name)
+long semihosting_get_flen(const char *file_name)
{
- int file_handle, length;
+ long file_handle;
+ size_t length;
assert(semihosting_connection_supported());
@@ -191,11 +193,13 @@ int semihosting_get_flen(const char *file_name)
return semihosting_file_close(file_handle) ? -1 : length;
}
-int semihosting_download_file(const char *file_name,
- int buf_size,
+long semihosting_download_file(const char *file_name,
+ size_t buf_size,
void *buf)
{
- int ret = -EINVAL, file_handle, length;
+ long ret = -EINVAL;
+ size_t length;
+ long file_handle;
/* Null pointer check */
if (!buf)