diff options
author | danh-arm <dan.handley@arm.com> | 2014-05-06 17:54:03 +0100 |
---|---|---|
committer | danh-arm <dan.handley@arm.com> | 2014-05-06 17:54:03 +0100 |
commit | 408c37682a0233c8c4fa88700b603f0b09d6361f (patch) | |
tree | 18133148dea88d9a2313113111b24b56e8130505 /drivers/io | |
parent | b495bdef190acf166c713e138b61c5bb25402fc0 (diff) | |
parent | 97043ac98e13a726dbf8b3b41654dca759e3da2c (diff) |
Merge pull request #48 from danh-arm/dh/major-refactoring
dh/major refactoring
Diffstat (limited to 'drivers/io')
-rw-r--r-- | drivers/io/io_driver.h | 93 | ||||
-rw-r--r-- | drivers/io/io_fip.c | 78 | ||||
-rw-r--r-- | drivers/io/io_fip.h | 36 | ||||
-rw-r--r-- | drivers/io/io_memmap.c | 58 | ||||
-rw-r--r-- | drivers/io/io_memmap.h | 36 | ||||
-rw-r--r-- | drivers/io/io_semihosting.c | 44 | ||||
-rw-r--r-- | drivers/io/io_semihosting.h | 36 |
7 files changed, 90 insertions, 291 deletions
diff --git a/drivers/io/io_driver.h b/drivers/io/io_driver.h deleted file mode 100644 index 82dbbf12..00000000 --- a/drivers/io/io_driver.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_DRIVER_H__ -#define __IO_DRIVER_H__ - -#include "platform.h" /* For MAX_IO_DEVICES */ - - -/* Generic IO entity structure,representing an accessible IO construct on the - * device, such as a file */ -struct io_entity { - io_dev_handle dev_handle; - uintptr_t info; -}; - - -/* Device info structure, providing device-specific functions and a means of - * adding driver-specific state */ -struct io_dev_info { - struct io_dev_funcs *funcs; - uintptr_t info; -}; - - -/* Structure used to create a connection to a type of device */ -struct io_dev_connector { - /* dev_open opens a connection to a particular device driver */ - int (*dev_open)(void *spec, struct io_dev_info **dev_info); -}; - - -/* Structure to hold device driver function pointers */ -struct io_dev_funcs { - io_type (*type)(void); - int (*open)(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); - int (*seek)(struct io_entity *entity, int mode, ssize_t offset); - int (*size)(struct io_entity *entity, size_t *length); - int (*read)(struct io_entity *entity, void *buffer, size_t length, - size_t *length_read); - int (*write)(struct io_entity *entity, const void *buffer, - size_t length, size_t *length_written); - int (*close)(struct io_entity *entity); - int (*dev_init)(struct io_dev_info *dev_info, const void *init_params); - int (*dev_close)(struct io_dev_info *dev_info); -}; - - -/* IO platform data - used to track devices registered for a specific - * platform */ -struct io_plat_data { - struct io_dev_info *devices[MAX_IO_DEVICES]; - unsigned int dev_count; -}; - - -/* Operations intended to be performed during platform initialisation */ - -/* Initialise the IO layer */ -void io_init(struct io_plat_data *data); - -/* Register a device driver */ -int io_register_device(struct io_dev_info *dev_info); - -#endif /* __IO_DRIVER_H__ */ diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c index 1eb76faa..b2dcfccf 100644 --- a/drivers/io/io_fip.c +++ b/drivers/io/io_fip.c @@ -28,17 +28,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <stdint.h> -#include <uuid.h> +#include <assert.h> +#include <debug.h> #include <errno.h> +#include <firmware_image_package.h> +#include <io_driver.h> +#include <io_fip.h> +#include <io_storage.h> +#include <platform.h> +#include <stdint.h> #include <string.h> -#include <assert.h> -#include "platform.h" -#include "firmware_image_package.h" -#include "io_storage.h" -#include "io_driver.h" -#include "io_fip.h" -#include "debug.h" +#include <uuid.h> /* Useful for printing UUIDs when debugging.*/ #define PRINT_UUID2(x) \ @@ -51,7 +51,7 @@ typedef struct { const char *name; const uuid_t uuid; -} plat_fip_name_uuid; +} plat_fip_name_uuid_t; typedef struct { /* Put file_pos above the struct to allow {0} on static init. @@ -59,10 +59,10 @@ typedef struct { * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 */ unsigned int file_pos; - fip_toc_entry entry; -} file_state; + fip_toc_entry_t entry; +} file_state_t; -static plat_fip_name_uuid name_uuid[] = { +static plat_fip_name_uuid_t name_uuid[] = { {BL2_IMAGE_NAME, UUID_TRUSTED_BOOT_FIRMWARE_BL2}, {BL31_IMAGE_NAME, UUID_EL3_RUNTIME_FIRMWARE_BL31}, {BL32_IMAGE_NAME, UUID_SECURE_PAYLOAD_BL32}, @@ -70,21 +70,21 @@ static plat_fip_name_uuid name_uuid[] = { }; static const uuid_t uuid_null = {0}; -static file_state current_file = {0}; +static file_state_t current_file = {0}; static io_dev_handle backend_dev_handle; static void *backend_image_spec; /* Firmware Image Package driver functions */ -static int fip_dev_open(void *spec, struct io_dev_info **dev_info); -static int fip_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int fip_file_len(struct io_entity *entity, size_t *length); -static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, +static int fip_dev_open(void *spec, io_dev_info_t **dev_info); +static int fip_file_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int fip_file_len(io_entity_t *entity, size_t *length); +static int fip_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int fip_file_close(struct io_entity *entity); -static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params); -static int fip_dev_close(struct io_dev_info *dev_info); +static int fip_file_close(io_entity_t *entity); +static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params); +static int fip_dev_close(io_dev_info_t *dev_info); static inline int copy_uuid(uuid_t *dst, const uuid_t *src) @@ -102,7 +102,7 @@ static inline int compare_uuids(const uuid_t *uuid1, const uuid_t *uuid2) /* TODO: We could check version numbers or do a package checksum? */ -static inline int is_valid_header(fip_toc_header *header) +static inline int is_valid_header(fip_toc_header_t *header) { if ((header->name == TOC_HEADER_NAME) && (header->serial_number != 0)) { return 1; @@ -129,7 +129,7 @@ static int file_to_uuid(const char *filename, uuid_t *uuid) /* Identify the device type as a virtual driver */ -io_type device_type_fip(void) +io_type_t device_type_fip(void) { return IO_TYPE_FIRMWARE_IMAGE_PACKAGE; } @@ -161,7 +161,7 @@ static struct io_dev_info fip_dev_info = { /* Open a connection to the FIP device */ static int fip_dev_open(void *spec __attribute__((unused)), - struct io_dev_info **dev_info) + io_dev_info_t **dev_info) { assert(dev_info != NULL); *dev_info = &fip_dev_info; @@ -171,12 +171,12 @@ static int fip_dev_open(void *spec __attribute__((unused)), /* Do some basic package checks. */ -static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params) +static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params) { int result = IO_FAIL; char *image_name = (char *)init_params; io_handle backend_handle; - fip_toc_header header; + fip_toc_header_t header; size_t bytes_read; /* Obtain a reference to the image by querying the platform layer */ @@ -215,7 +215,7 @@ static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params) } /* Close a connection to the FIP device */ -static int fip_dev_close(struct io_dev_info *dev_info) +static int fip_dev_close(io_dev_info_t *dev_info) { /* TODO: Consider tracking open files and cleaning them up here */ @@ -228,13 +228,13 @@ static int fip_dev_close(struct io_dev_info *dev_info) /* Open a file for access from package. */ -static int fip_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity) +static int fip_file_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity) { int result = IO_FAIL; io_handle backend_handle; uuid_t file_uuid; - const io_file_spec *file_spec = (io_file_spec *)spec; + const io_file_spec_t *file_spec = (io_file_spec_t *)spec; size_t bytes_read; int found_file = 0; @@ -262,7 +262,7 @@ static int fip_file_open(struct io_dev_info *dev_info, const void *spec, } /* Seek past the FIP header into the Table of Contents */ - result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header)); + result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header_t)); if (result != IO_SUCCESS) { WARN("fip_file_open: failed to seek\n"); result = IO_FAIL; @@ -310,23 +310,23 @@ static int fip_file_open(struct io_dev_info *dev_info, const void *spec, /* Return the size of a file in package */ -static int fip_file_len(struct io_entity *entity, size_t *length) +static int fip_file_len(io_entity_t *entity, size_t *length) { assert(entity != NULL); assert(length != NULL); - *length = ((file_state *)entity->info)->entry.size; + *length = ((file_state_t *)entity->info)->entry.size; return IO_SUCCESS; } /* Read data from a file in package */ -static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, +static int fip_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { int result = IO_FAIL; - file_state *fp; + file_state_t *fp; size_t file_offset; size_t bytes_read; io_handle backend_handle; @@ -345,7 +345,7 @@ static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, goto fip_file_read_exit; } - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; /* Seek to the position in the FIP where the payload lives */ file_offset = fp->entry.offset_address + fp->file_pos; @@ -378,7 +378,7 @@ static int fip_file_read(struct io_entity *entity, void *buffer, size_t length, /* Close a file in package */ -static int fip_file_close(struct io_entity *entity) +static int fip_file_close(io_entity_t *entity) { /* Clear our current file pointer. * If we had malloc() we would free() here. @@ -396,7 +396,7 @@ static int fip_file_close(struct io_entity *entity) /* Exported functions */ /* Register the Firmware Image Package driver with the IO abstraction */ -int register_io_dev_fip(struct io_dev_connector **dev_con) +int register_io_dev_fip(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_fip.h b/drivers/io/io_fip.h deleted file mode 100644 index 56dd1e0f..00000000 --- a/drivers/io/io_fip.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_FIP_H__ -#define __IO_FIP_H__ - -int register_io_dev_fip(struct io_dev_connector **dev_con); - -#endif /* __IO_FIP_H__ */ diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index 40b8e9ab..a40e6120 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -29,10 +29,10 @@ */ #include <assert.h> +#include <debug.h> +#include <io_driver.h> +#include <io_storage.h> #include <string.h> -#include "io_storage.h" -#include "io_driver.h" -#include "debug.h" /* As we need to be able to keep state for seek, only one file can be open * at a time. Make this a structure and point to the entity->info. When we @@ -45,28 +45,28 @@ typedef struct { int in_use; size_t base; size_t file_pos; -} file_state; +} file_state_t; -static file_state current_file = {0}; +static file_state_t current_file = {0}; /* Identify the device type as memmap */ -io_type device_type_memmap(void) +io_type_t device_type_memmap(void) { return IO_TYPE_MEMMAP; } /* Memmap device functions */ -static int memmap_dev_open(void *spec, struct io_dev_info **dev_info); -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int memmap_block_seek(struct io_entity *entity, int mode, +static int memmap_dev_open(void *spec, io_dev_info_t **dev_info); +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset); -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written); -static int memmap_block_close(struct io_entity *entity); -static int memmap_dev_close(struct io_dev_info *dev_info); +static int memmap_block_close(io_entity_t *entity); +static int memmap_dev_close(io_dev_info_t *dev_info); static struct io_dev_connector memmap_dev_connector = { @@ -95,7 +95,7 @@ static struct io_dev_info memmap_dev_info = { /* Open a connection to the memmap device */ static int memmap_dev_open(void *spec __attribute__((unused)), - struct io_dev_info **dev_info) + io_dev_info_t **dev_info) { assert(dev_info != NULL); *dev_info = &memmap_dev_info; @@ -106,7 +106,7 @@ static int memmap_dev_open(void *spec __attribute__((unused)), /* Close a connection to the memmap device */ -static int memmap_dev_close(struct io_dev_info *dev_info) +static int memmap_dev_close(io_dev_info_t *dev_info) { /* NOP */ /* TODO: Consider tracking open files and cleaning them up here */ @@ -116,11 +116,11 @@ static int memmap_dev_close(struct io_dev_info *dev_info) /* Open a file on the memmap device */ /* TODO: Can we do any sensible limit checks on requested memory */ -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity) +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity) { int result = IO_FAIL; - const io_block_spec *block_spec = (io_block_spec *)spec; + const io_block_spec_t *block_spec = (io_block_spec_t *)spec; /* Since we need to track open state for seek() we only allow one open * spec at a time. When we have dynamic memory we can malloc and set @@ -146,7 +146,7 @@ static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, /* Seek to a particular file offset on the memmap device */ -static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset) { int result = IO_FAIL; @@ -155,7 +155,7 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) assert(entity != NULL); /* TODO: can we do some basic limit checks on seek? */ - ((file_state *)entity->info)->file_pos = offset; + ((file_state_t *)entity->info)->file_pos = offset; result = IO_SUCCESS; } else { result = IO_FAIL; @@ -166,16 +166,16 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) /* Read data from a file on the memmap device */ -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_read != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy(buffer, (void *)(fp->base + fp->file_pos), length); @@ -188,16 +188,16 @@ static int memmap_block_read(struct io_entity *entity, void *buffer, /* Write data to a file on the memmap device */ -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_written != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy((void *)(fp->base + fp->file_pos), buffer, length); @@ -211,7 +211,7 @@ static int memmap_block_write(struct io_entity *entity, const void *buffer, /* Close a file on the memmap device */ -static int memmap_block_close(struct io_entity *entity) +static int memmap_block_close(io_entity_t *entity) { assert(entity != NULL); @@ -227,7 +227,7 @@ static int memmap_block_close(struct io_entity *entity) /* Exported functions */ /* Register the memmap driver with the IO abstraction */ -int register_io_dev_memmap(struct io_dev_connector **dev_con) +int register_io_dev_memmap(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_memmap.h b/drivers/io/io_memmap.h deleted file mode 100644 index 5fa7bc98..00000000 --- a/drivers/io/io_memmap.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_MEMMAP_H__ -#define __IO_MEMMAP_H__ - -int register_io_dev_memmap(struct io_dev_connector **dev_con); - -#endif /* __IO_MEMMAP_H__ */ diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c index 14ec687c..a37693df 100644 --- a/drivers/io/io_semihosting.c +++ b/drivers/io/io_semihosting.c @@ -29,14 +29,14 @@ */ #include <assert.h> -#include "io_storage.h" -#include "io_driver.h" -#include "semihosting.h" +#include <io_driver.h> +#include <io_storage.h> +#include <semihosting.h> /* Identify the device type as semihosting */ -static io_type device_type_sh(void) +static io_type_t device_type_sh(void) { return IO_TYPE_SEMIHOSTING; } @@ -44,16 +44,16 @@ static io_type device_type_sh(void) /* Semi-hosting functions, device info and handle */ -static int sh_dev_open(void *spec, struct io_dev_info **dev_info); -static int sh_file_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset); -static int sh_file_len(struct io_entity *entity, size_t *length); -static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, +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, + 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, size_t *length_read); -static int sh_file_write(struct io_entity *entity, const void *buffer, +static int sh_file_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written); -static int sh_file_close(struct io_entity *entity); +static int sh_file_close(io_entity_t *entity); static struct io_dev_connector sh_dev_connector = { .dev_open = sh_dev_open @@ -80,7 +80,7 @@ static struct io_dev_info sh_dev_info = { /* Open a connection to the semi-hosting device */ -static int sh_dev_open(void *spec __unused, struct io_dev_info **dev_info) +static int sh_dev_open(void *spec __unused, io_dev_info_t **dev_info) { int result = IO_SUCCESS; assert(dev_info != NULL); @@ -90,12 +90,12 @@ static int sh_dev_open(void *spec __unused, struct io_dev_info **dev_info) /* Open a file on the semi-hosting device */ -static int sh_file_open(struct io_dev_info *dev_info __attribute__((unused)), - const void *spec, struct io_entity *entity) +static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)), + const void *spec, io_entity_t *entity) { int result = IO_FAIL; long sh_result = -1; - const io_file_spec *file_spec = (io_file_spec *)spec; + const io_file_spec_t *file_spec = (io_file_spec_t *)spec; assert(file_spec != NULL); assert(entity != NULL); @@ -113,7 +113,7 @@ static int sh_file_open(struct io_dev_info *dev_info __attribute__((unused)), /* Seek to a particular file offset on the semi-hosting device */ -static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset) +static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset) { int result = IO_FAIL; long file_handle, sh_result; @@ -131,7 +131,7 @@ static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset) /* Return the size of a file on the semi-hosting device */ -static int sh_file_len(struct io_entity *entity, size_t *length) +static int sh_file_len(io_entity_t *entity, size_t *length) { int result = IO_FAIL; @@ -151,7 +151,7 @@ static int sh_file_len(struct io_entity *entity, size_t *length) /* Read data from a file on the semi-hosting device */ -static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, +static int sh_file_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { int result = IO_FAIL; @@ -178,7 +178,7 @@ static int sh_file_read(struct io_entity *entity, void *buffer, size_t length, /* Write data to a file on the semi-hosting device */ -static int sh_file_write(struct io_entity *entity, const void *buffer, +static int sh_file_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written) { int result = IO_FAIL; @@ -205,7 +205,7 @@ static int sh_file_write(struct io_entity *entity, const void *buffer, /* Close a file on the semi-hosting device */ -static int sh_file_close(struct io_entity *entity) +static int sh_file_close(io_entity_t *entity) { int result = IO_FAIL; long sh_result = -1; @@ -226,7 +226,7 @@ static int sh_file_close(struct io_entity *entity) /* Exported functions */ /* Register the semi-hosting driver with the IO abstraction */ -int register_io_dev_sh(struct io_dev_connector **dev_con) +int register_io_dev_sh(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); diff --git a/drivers/io/io_semihosting.h b/drivers/io/io_semihosting.h deleted file mode 100644 index 7dc632dd..00000000 --- a/drivers/io/io_semihosting.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of ARM nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __IO_SH_H__ -#define __IO_SH_H__ - -int register_io_dev_sh(struct io_dev_connector **dev_con); - -#endif /* __IO_SH_H__ */ |