1 /* SPDX-License-Identifier: GPL-2.0-only */
6 #include <commonlib/region.h>
11 * A region file is an abstraction to allow appending updates in a
12 * region_device where the data returned is the most recently written
13 * data. It is block based with a 16 byte granularity. So if you write
14 * 2 bytes into the file the data returned in the region_device would
15 * have 16 bytes allocated for the latest update. Additionally, the
16 * current maximum file size allowed is 1MiB - 48 bytes. See comments
17 * in C implementation file for further details.
23 * Initialize a region file associated with a provided region device.
24 * Returns < 0 on error, 0 on success.
26 int region_file_init(struct region_file
*f
, const struct region_device
*p
);
29 * Initialize region device object associated with latest update of file data.
30 * Returns < 0 on error, 0 on success.
32 int region_file_data(const struct region_file
*f
, struct region_device
*rdev
);
35 * Create region file entry struct to insert multiple data buffers
36 * into the same region_file.
38 struct update_region_file_entry
{
39 /* size of this entry */
45 /* Update region file with latest data. Returns < 0 on error, 0 on success. */
46 int region_file_update_data_arr(struct region_file
*f
,
47 const struct update_region_file_entry
*entries
,
49 int region_file_update_data(struct region_file
*f
, const void *buf
, size_t size
);
51 /* Declared here for easy object allocation. */
53 /* Region device covering file */
54 struct region_device rdev
;
55 /* Metadata containing blocks of the data stream. */
56 struct region_device metadata
;
57 /* Blocks forming data. */
58 uint16_t data_blocks
[2];
59 /* Current slot in metadata marking end of data. */
63 #endif /* REGION_FILE_H */