2 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
12 #include <stdio.h> /* For ssize_t */
16 /* Device type which can be used to enable policy decisions about which device
23 IO_TYPE_FIRMWARE_IMAGE_PACKAGE
,
31 /* Modes used when seeking data on a supported device */
41 /* Connector type, providing a means of identifying a device to open */
42 struct io_dev_connector
;
45 /* File specification - used to refer to data on a device supporting file-like
47 typedef struct io_file_spec
{
52 /* UUID specification - used to refer to data accessed using UUIDs (i.e. FIP
54 typedef struct io_uuid_spec
{
58 /* Block specification - used to refer to data on a device supporting
59 * block-like entities */
60 typedef struct io_block_spec
{
66 /* Access modes used when accessing data on a device */
67 #define IO_MODE_INVALID (0)
68 #define IO_MODE_RO (1 << 0)
69 #define IO_MODE_RW (1 << 1)
72 /* Open a connection to a device */
73 int io_dev_open(const struct io_dev_connector
*dev_con
,
74 const uintptr_t dev_spec
,
78 /* Initialise a device explicitly - to permit lazy initialisation or
79 * re-initialisation */
80 int io_dev_init(uintptr_t dev_handle
, const uintptr_t init_params
);
82 /* TODO: Consider whether an explicit "shutdown" API should be included */
84 /* Close a connection to a device */
85 int io_dev_close(uintptr_t dev_handle
);
88 /* Synchronous operations */
89 int io_open(uintptr_t dev_handle
, const uintptr_t spec
, uintptr_t *handle
);
91 int io_seek(uintptr_t handle
, io_seek_mode_t mode
, ssize_t offset
);
93 int io_size(uintptr_t handle
, size_t *length
);
95 int io_read(uintptr_t handle
, uintptr_t buffer
, size_t length
,
98 int io_write(uintptr_t handle
, const uintptr_t buffer
, size_t length
,
99 size_t *length_written
);
101 int io_close(uintptr_t handle
);
104 #endif /* IO_STORAGE_H */