coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
region_file.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef REGION_FILE_H
4 #define REGION_FILE_H
5 
6 #include <commonlib/region.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
10 /*
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.
18  */
19 
20 struct region_file;
21 
22 /*
23  * Initialize a region file associated with a provided region device.
24  * Returns < 0 on error, 0 on success.
25  */
26 int region_file_init(struct region_file *f, const struct region_device *p);
27 
28 /*
29  * Initialize region device object associated with latest update of file data.
30  * Returns < 0 on error, 0 on success.
31  */
32 int region_file_data(const struct region_file *f, struct region_device *rdev);
33 
34 /*
35  * Create region file entry struct to insert multiple data buffers
36  * into the same region_file.
37  */
39  /* size of this entry */
40  size_t size;
41  /* data pointer */
42  const void *data;
43 };
44 
45 /* Update region file with latest data. Returns < 0 on error, 0 on success. */
47  const struct update_region_file_entry *entries,
48  size_t num_entries);
49 int region_file_update_data(struct region_file *f, const void *buf, size_t size);
50 
51 /* Declared here for easy object allocation. */
52 struct region_file {
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. */
59  /* Current slot in metadata marking end of data. */
60  int slot;
61 };
62 
63 #endif /* REGION_FILE_H */
static struct region_device rdev
Definition: flashconsole.c:14
static uint8_t * buf
Definition: uart.c:7
int region_file_data(const struct region_file *f, struct region_device *rdev)
Definition: region_file.c:243
int region_file_update_data_arr(struct region_file *f, const struct update_region_file_entry *entries, size_t num_entries)
Definition: region_file.c:429
int region_file_update_data(struct region_file *f, const void *buf, size_t size)
Definition: region_file.c:473
int region_file_init(struct region_file *f, const struct region_device *p)
Definition: region_file.c:186
unsigned short uint16_t
Definition: stdint.h:11
struct region_device rdev
Definition: region_file.h:54
struct region_device metadata
Definition: region_file.h:56
uint16_t data_blocks[2]
Definition: region_file.h:58
Definition: region_file.h:38
const void * data
Definition: region_file.h:42
size_t size
Definition: region_file.h:40