blob: beb79574720927417b549ede79e0b7b2955c26c3 [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin0424c952015-03-28 23:56:22 -05003
4#ifndef _FMAP_H_
5#define _FMAP_H_
6
Julius Werner98eeb962019-12-11 15:47:42 -08007#include <commonlib/bsd/fmap_serialized.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -05008#include <commonlib/region.h>
Aaron Durbin0424c952015-03-28 23:56:22 -05009
10/* Locate the named area in the fmap and fill in a region device representing
11 * that area. The region is a sub-region of the readonly boot media. Return
12 * 0 on success, < 0 on error. */
13int fmap_locate_area_as_rdev(const char *name, struct region_device *area);
14
Aaron Durbinbccaab82016-08-12 12:42:04 -050015/* Just like fmap_locate_area_as_rdev(), however the region device is
16 * created from the RW boot device. */
17int fmap_locate_area_as_rdev_rw(const char *name, struct region_device *area);
18
Aaron Durbin0424c952015-03-28 23:56:22 -050019/* Locate the named area in the fmap and fill in a region with the
20 * offset and size of that area within the boot media. Return 0 on success,
21 * < 0 on error. */
22int fmap_locate_area(const char *name, struct region *r);
23
Patrick Georgi99526902015-07-09 11:27:44 +020024/* Find fmap area name by offset and size.
25 * Return 0 on success, < 0 on error. */
26int fmap_find_region_name(const struct region * const ar,
27 char name[FMAP_STRLEN]);
T Michael Turney19fcc892019-03-20 14:37:34 -070028
29/* Read fmap area into provided buffer.
30 * Return size read on success, < 0 on error. */
31ssize_t fmap_read_area(const char *name, void *buffer, size_t size);
32
33/* Write provided buffer into fmap area.
34 * Return size written on success, < 0 on error. */
35ssize_t fmap_overwrite_area(const char *name, const void *buffer, size_t size);
Furquan Shaikhb33a2b02019-09-26 23:51:46 -070036
37/* Get offset of FMAP in flash. */
38uint64_t get_fmap_flash_offset(void);
39
Aaron Durbin0424c952015-03-28 23:56:22 -050040#endif