summaryrefslogtreecommitdiff
path: root/drivers/io/io_semihosting.c
diff options
context:
space:
mode:
authorDan Handley <dan.handley@arm.com>2014-04-23 13:47:06 +0100
committerDan Handley <dan.handley@arm.com>2014-05-06 17:55:38 +0100
commit625de1d4f04b30383354bee944d0a7ca3dba1e67 (patch)
tree3a9c8494e30f1d7475dbc69edef172a37f036594 /drivers/io/io_semihosting.c
parent408c37682a0233c8c4fa88700b603f0b09d6361f (diff)
Remove variables from .data section
Update code base to remove variables from the .data section, mainly by using const static data where possible and adding the const specifier as required. Most changes are to the IO subsystem, including the framework APIs. The FVP power management code is also affected. Delay initialization of the global static variable, next_image_type in bl31_main.c, until it is realy needed. Doing this moves the variable from the .data to the .bss section. Also review the IO interface for inconsistencies, using uintptr_t where possible instead of void *. Remove the io_handle and io_dev_handle typedefs, which were unnecessary, replacing instances with uintptr_t. Fixes ARM-software/tf-issues#107. Change-Id: I085a62197c82410b566e4698e5590063563ed304
Diffstat (limited to 'drivers/io/io_semihosting.c')
-rw-r--r--drivers/io/io_semihosting.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c
index a37693d..3c92c6d 100644
--- a/drivers/io/io_semihosting.c
+++ b/drivers/io/io_semihosting.c
@@ -44,23 +44,23 @@ static io_type_t device_type_sh(void)
/* Semi-hosting functions, device info and handle */
-static int sh_dev_open(void *spec, io_dev_info_t **dev_info);
-static int sh_file_open(io_dev_info_t *dev_info, const void *spec,
+static int sh_dev_open(const uintptr_t dev_spec, io_dev_info_t **dev_info);
+static int sh_file_open(io_dev_info_t *dev_info, const uintptr_t spec,
io_entity_t *entity);
static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset);
static int sh_file_len(io_entity_t *entity, size_t *length);
-static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
+static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length,
size_t *length_read);
-static int sh_file_write(io_entity_t *entity, const void *buffer,
+static int sh_file_write(io_entity_t *entity, const uintptr_t buffer,
size_t length, size_t *length_written);
static int sh_file_close(io_entity_t *entity);
-static struct io_dev_connector sh_dev_connector = {
+static const io_dev_connector_t sh_dev_connector = {
.dev_open = sh_dev_open
};
-static struct io_dev_funcs sh_dev_funcs = {
+static const io_dev_funcs_t sh_dev_funcs = {
.type = device_type_sh,
.open = sh_file_open,
.seek = sh_file_seek,
@@ -73,29 +73,31 @@ static struct io_dev_funcs sh_dev_funcs = {
};
-static struct io_dev_info sh_dev_info = {
+/* No state associated with this device so structure can be const */
+static const io_dev_info_t sh_dev_info = {
.funcs = &sh_dev_funcs,
.info = (uintptr_t)NULL
};
/* Open a connection to the semi-hosting device */
-static int sh_dev_open(void *spec __unused, io_dev_info_t **dev_info)
+static int sh_dev_open(const uintptr_t dev_spec __unused,
+ io_dev_info_t **dev_info)
{
int result = IO_SUCCESS;
assert(dev_info != NULL);
- *dev_info = &sh_dev_info;
+ *dev_info = (io_dev_info_t *)&sh_dev_info; /* cast away const */
return result;
}
/* Open a file on the semi-hosting device */
static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)),
- const void *spec, io_entity_t *entity)
+ const uintptr_t spec, io_entity_t *entity)
{
int result = IO_FAIL;
long sh_result = -1;
- const io_file_spec_t *file_spec = (io_file_spec_t *)spec;
+ const io_file_spec_t *file_spec = (const io_file_spec_t *)spec;
assert(file_spec != NULL);
assert(entity != NULL);
@@ -151,7 +153,7 @@ static int sh_file_len(io_entity_t *entity, size_t *length)
/* Read data from a file on the semi-hosting device */
-static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
+static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length,
size_t *length_read)
{
int result = IO_FAIL;
@@ -160,7 +162,7 @@ static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
long file_handle;
assert(entity != NULL);
- assert(buffer != NULL);
+ assert(buffer != (uintptr_t)NULL);
assert(length_read != NULL);
file_handle = (long)entity->info;
@@ -178,7 +180,7 @@ static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
/* Write data to a file on the semi-hosting device */
-static int sh_file_write(io_entity_t *entity, const void *buffer,
+static int sh_file_write(io_entity_t *entity, const uintptr_t buffer,
size_t length, size_t *length_written)
{
int result = IO_FAIL;
@@ -187,7 +189,7 @@ static int sh_file_write(io_entity_t *entity, const void *buffer,
size_t bytes = length;
assert(entity != NULL);
- assert(buffer != NULL);
+ assert(buffer != (uintptr_t)NULL);
assert(length_written != NULL);
file_handle = (long)entity->info;
@@ -226,7 +228,7 @@ static int sh_file_close(io_entity_t *entity)
/* Exported functions */
/* Register the semi-hosting driver with the IO abstraction */
-int register_io_dev_sh(io_dev_connector_t **dev_con)
+int register_io_dev_sh(const io_dev_connector_t **dev_con)
{
int result = IO_FAIL;
assert(dev_con != NULL);