Commit 6d16ce0b authored by Dan Handley's avatar Dan Handley
Browse files

Remove redundant io_init() function

The intent of io_init() was to allow platform ports to provide
a data object (io_plat_data_t) to the IO storage framework to
allocate into. The abstraction was incomplete because io_plat_data_t
uses a platform defined constant and the IO storage framework
internally allocates other arrays using platform defined constants.

This change simplifies the implementation by instantiating the
supporting objects in the IO storage framework itself. There is now
no need for the platform to call io_init().

The FVP port has been updated accordingly.

THIS CHANGE REQUIRES ALL PLATFORM PORTS THAT USE THE IO STORAGE
FRAMEWORK TO BE UDPATED.

Change-Id: Ib48ac334de9e538064734334c773f8b43df3a7dc
parent cae3ef99
...@@ -218,6 +218,21 @@ be defined as well: ...@@ -218,6 +218,21 @@ be defined as well:
the secure memory identified by `TSP_SEC_MEM_BASE` and `TSP_SEC_MEM_SIZE` the secure memory identified by `TSP_SEC_MEM_BASE` and `TSP_SEC_MEM_SIZE`
constants. constants.
If the platform port uses the IO storage framework, the following constants
must also be defined:
* **#define : MAX_IO_DEVICES**
Defines the maximum number of registered IO devices. Attempting to register
more devices than this value using `io_register_device()` will fail with
IO_RESOURCES_EXHAUSTED.
* **#define : MAX_IO_HANDLES**
Defines the maximum number of open IO handles. Attempting to open more IO
entities than this value using `io_open()` will fail with
IO_RESOURCES_EXHAUSTED.
The following constants are optional. They should be defined when the platform The following constants are optional. They should be defined when the platform
memory layout implies some image overlaying like on FVP. memory layout implies some image overlaying like on FVP.
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#define __IO_DRIVER_H__ #define __IO_DRIVER_H__
#include <io_storage.h> #include <io_storage.h>
#include <platform_def.h> /* For MAX_IO_DEVICES */
#include <stdint.h> #include <stdint.h>
...@@ -76,20 +75,9 @@ typedef struct io_dev_funcs { ...@@ -76,20 +75,9 @@ typedef struct io_dev_funcs {
} io_dev_funcs_t; } io_dev_funcs_t;
/* IO platform data - used to track devices registered for a specific
* platform */
typedef struct io_plat_data {
const io_dev_info_t *devices[MAX_IO_DEVICES];
unsigned int dev_count;
} io_plat_data_t;
/* Operations intended to be performed during platform initialisation */ /* Operations intended to be performed during platform initialisation */
/* Initialise the IO layer */ /* Register an IO device */
void io_init(io_plat_data_t *data);
/* Register a device driver */
int io_register_device(const io_dev_info_t *dev_info); int io_register_device(const io_dev_info_t *dev_info);
#endif /* __IO_DRIVER_H__ */ #endif /* __IO_DRIVER_H__ */
...@@ -31,13 +31,10 @@ ...@@ -31,13 +31,10 @@
#include <assert.h> #include <assert.h>
#include <io_driver.h> #include <io_driver.h>
#include <io_storage.h> #include <io_storage.h>
#include <platform_def.h>
#include <stddef.h> #include <stddef.h>
#define MAX_DEVICES(plat_data) \
(sizeof((plat_data)->devices)/sizeof((plat_data)->devices[0]))
/* Storage for a fixed maximum number of IO entities, definable by platform */ /* Storage for a fixed maximum number of IO entities, definable by platform */
static io_entity_t entity_pool[MAX_IO_HANDLES]; static io_entity_t entity_pool[MAX_IO_HANDLES];
...@@ -48,9 +45,11 @@ static io_entity_t *entity_map[MAX_IO_HANDLES]; ...@@ -48,9 +45,11 @@ static io_entity_t *entity_map[MAX_IO_HANDLES];
/* Track number of allocated entities */ /* Track number of allocated entities */
static unsigned int entity_count; static unsigned int entity_count;
/* Array of fixed maximum of registered devices, definable by platform */
static const io_dev_info_t *devices[MAX_IO_DEVICES];
/* Used to keep a reference to platform-specific data */ /* Number of currently registered devices */
static io_plat_data_t *platform_data; static unsigned int dev_count;
#if DEBUG /* Extra validation functions only used in debug builds */ #if DEBUG /* Extra validation functions only used in debug builds */
...@@ -167,27 +166,15 @@ static int free_entity(const io_entity_t *entity) ...@@ -167,27 +166,15 @@ static int free_entity(const io_entity_t *entity)
/* Exported API */ /* Exported API */
/* Initialise the IO layer */
void io_init(io_plat_data_t *data)
{
assert(data != NULL);
platform_data = data;
}
/* Register a device driver */ /* Register a device driver */
int io_register_device(const io_dev_info_t *dev_info) int io_register_device(const io_dev_info_t *dev_info)
{ {
int result = IO_FAIL; int result = IO_FAIL;
assert(dev_info != NULL); assert(dev_info != NULL);
assert(platform_data != NULL);
unsigned int dev_count = platform_data->dev_count;
if (dev_count < MAX_DEVICES(platform_data)) { if (dev_count < MAX_IO_DEVICES) {
platform_data->devices[dev_count] = dev_info; devices[dev_count] = dev_info;
platform_data->dev_count++; dev_count++;
result = IO_SUCCESS; result = IO_SUCCESS;
} else { } else {
result = IO_RESOURCES_EXHAUSTED; result = IO_RESOURCES_EXHAUSTED;
......
...@@ -35,12 +35,11 @@ ...@@ -35,12 +35,11 @@
#include <io_memmap.h> #include <io_memmap.h>
#include <io_storage.h> #include <io_storage.h>
#include <io_semihosting.h> #include <io_semihosting.h>
#include <platform_def.h>
#include <semihosting.h> /* For FOPEN_MODE_... */ #include <semihosting.h> /* For FOPEN_MODE_... */
#include <string.h> #include <string.h>
#include "fvp_def.h"
/* IO devices */ /* IO devices */
static io_plat_data_t io_data;
static const io_dev_connector_t *sh_dev_con; static const io_dev_connector_t *sh_dev_con;
static uintptr_t sh_dev_spec; static uintptr_t sh_dev_spec;
static uintptr_t sh_init_params; static uintptr_t sh_init_params;
...@@ -172,9 +171,6 @@ void fvp_io_setup (void) ...@@ -172,9 +171,6 @@ void fvp_io_setup (void)
{ {
int io_result = IO_FAIL; int io_result = IO_FAIL;
/* Initialise the IO layer */
io_init(&io_data);
/* Register the IO devices on this platform */ /* Register the IO devices on this platform */
io_result = register_io_dev_sh(&sh_dev_con); io_result = register_io_dev_sh(&sh_dev_con);
assert(io_result == IO_SUCCESS); assert(io_result == IO_SUCCESS);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment