2 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
12 #include <drivers/io/io_storage.h>
14 /* Generic IO entity structure,representing an accessible IO construct on the
15 * device, such as a file */
16 typedef struct io_entity
{
17 struct io_dev_info
*dev_handle
;
22 /* Device info structure, providing device-specific functions and a means of
23 * adding driver-specific state */
24 typedef struct io_dev_info
{
25 const struct io_dev_funcs
*funcs
;
30 /* Structure used to create a connection to a type of device */
31 typedef struct io_dev_connector
{
32 /* dev_open opens a connection to a particular device driver */
33 int (*dev_open
)(const uintptr_t dev_spec
, io_dev_info_t
**dev_info
);
37 /* Structure to hold device driver function pointers */
38 typedef struct io_dev_funcs
{
39 io_type_t (*type
)(void);
40 int (*open
)(io_dev_info_t
*dev_info
, const uintptr_t spec
,
42 int (*seek
)(io_entity_t
*entity
, int mode
, ssize_t offset
);
43 int (*size
)(io_entity_t
*entity
, size_t *length
);
44 int (*read
)(io_entity_t
*entity
, uintptr_t buffer
, size_t length
,
46 int (*write
)(io_entity_t
*entity
, const uintptr_t buffer
,
47 size_t length
, size_t *length_written
);
48 int (*close
)(io_entity_t
*entity
);
49 int (*dev_init
)(io_dev_info_t
*dev_info
, const uintptr_t init_params
);
50 int (*dev_close
)(io_dev_info_t
*dev_info
);
54 /* Operations intended to be performed during platform initialisation */
56 /* Register an IO device */
57 int io_register_device(const io_dev_info_t
*dev_info
);
59 #endif /* IO_DRIVER_H */