summaryrefslogtreecommitdiff
path: root/lib/semihosting
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2014-02-10 17:17:04 +0000
committerDan Handley <dan.handley@arm.com>2014-02-20 19:06:34 +0000
commitcd529320988a559c3408292f09e443233d2157c3 (patch)
tree269f79bb314e15220227cda09ca8f56d7cae7ca3 /lib/semihosting
parent2f2cef46573cc55204e7873795b2c31fcc9f6216 (diff)
Fix semihosting with latest toolchain
Fixes issues #10: https://github.com/ARM-software/tf-issues/issues/10 This patch changes all/most variables of type int to be size_t or long to fix the sizing and alignment problems found when building with the newer toolchains such as Linaro GCC 13.12 or later. Change-Id: Idc9d48eb2ff9b8c5bbd5b227e6907263d1ea188b Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
Diffstat (limited to 'lib/semihosting')
-rw-r--r--lib/semihosting/semihosting.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c
index 1a7ac60b..d5b8524b 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,9 @@ 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 +140,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 +167,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 +178,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 +195,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)