blob: 761e742f5600775763ca7f257268d48e68e5f27a [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin0424c952015-03-28 23:56:22 -05002
3#ifndef _FMAP_H_
4#define _FMAP_H_
5
Julius Werner98eeb962019-12-11 15:47:42 -08006#include <commonlib/bsd/fmap_serialized.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -05007#include <commonlib/region.h>
Elyes HAOUAS5817c562020-07-12 09:03:22 +02008#include <stddef.h>
9#include <stdint.h>
Aaron Durbin0424c952015-03-28 23:56:22 -050010
11/* Locate the named area in the fmap and fill in a region device representing
12 * that area. The region is a sub-region of the readonly boot media. Return
13 * 0 on success, < 0 on error. */
14int fmap_locate_area_as_rdev(const char *name, struct region_device *area);
15
Aaron Durbinbccaab82016-08-12 12:42:04 -050016/* Just like fmap_locate_area_as_rdev(), however the region device is
17 * created from the RW boot device. */
18int fmap_locate_area_as_rdev_rw(const char *name, struct region_device *area);
19
Aaron Durbin0424c952015-03-28 23:56:22 -050020/* Locate the named area in the fmap and fill in a region with the
21 * offset and size of that area within the boot media. Return 0 on success,
22 * < 0 on error. */
23int fmap_locate_area(const char *name, struct region *r);
24
Patrick Georgi99526902015-07-09 11:27:44 +020025/* Find fmap area name by offset and size.
26 * Return 0 on success, < 0 on error. */
27int fmap_find_region_name(const struct region * const ar,
28 char name[FMAP_STRLEN]);
T Michael Turney19fcc892019-03-20 14:37:34 -070029
30/* Read fmap area into provided buffer.
31 * Return size read on success, < 0 on error. */
32ssize_t fmap_read_area(const char *name, void *buffer, size_t size);
33
34/* Write provided buffer into fmap area.
35 * Return size written on success, < 0 on error. */
36ssize_t fmap_overwrite_area(const char *name, const void *buffer, size_t size);
Furquan Shaikhb33a2b02019-09-26 23:51:46 -070037
38/* Get offset of FMAP in flash. */
39uint64_t get_fmap_flash_offset(void);
40
Aaron Durbin0424c952015-03-28 23:56:22 -050041#endif