stoneyridge: Enable legacy IO
[coreboot.git] / src / include / region_file.h
blob0b79be36877bcb315cb69b87fe9b46133ac16e2e
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2016 Google Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef REGION_FILE_H
17 #define REGION_FILE_H
19 #include <commonlib/region.h>
20 #include <stdint.h>
23 * A region file is an abstraction to allow appending updates in a
24 * region_device where the data returned is the most recently written
25 * data. It is block based with a 16 byte granularity. So if you write
26 * 2 bytes into the file the data returned in the region_device would
27 * have 16 bytes allocated for the latest update. Additionally, the
28 * current maximum file size allowed is 1MiB - 48 bytes. See comments
29 * in C implementation file for further details.
32 struct region_file;
35 * Initialize a region file associated with a provided region device.
36 * Returns < 0 on error, 0 on success.
38 int region_file_init(struct region_file *f, const struct region_device *p);
41 * Initialize region device object associated with latest update of file data.
42 * Returns < 0 on error, 0 on success.
44 int region_file_data(const struct region_file *f, struct region_device *rdev);
46 /* Update region file with latest data. Returns < 0 on error, 0 on success. */
47 int region_file_update_data(struct region_file *f, const void *buf,
48 size_t size);
50 /* Declared here for easy object allocation. */
51 struct region_file {
52 /* Region device covering file */
53 struct region_device rdev;
54 /* Metadata containing blocks of the data stream. */
55 struct region_device metadata;
56 /* Blocks forming data. */
57 uint16_t data_blocks[2];
58 /* Current slot in metadata marking end of data. */
59 int slot;
62 #endif /* REGION_FILE_H */