diff options
Diffstat (limited to 'drivers/io/io_semihosting.c')
-rw-r--r-- | drivers/io/io_semihosting.c | 34 |
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); |