Leroy P Leahy (leroy.p.leahy(a)intel.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10872
-gerrit
commit e59536eaebd038b9de307f11cca4461f26997844
Author: Lee Leahy <leroy.p.leahy(a)intel.com>
Date: Thu Jul 9 16:49:35 2015 -0700
Braswell: Use CBFS image type name
Use the simplified CBFS image type name in Makefile.inc.
BRANCH=none
BUG=None
TEST=Build and run on cyan
Change-Id: Idb62de7fce36fde38a6fbeeefdfc2dd0d75bd493
Signed-off-by: Lee Leahy <leroy.p.leahy(a)intel.com>
---
src/soc/intel/braswell/microcode/Makefile.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/soc/intel/braswell/microcode/Makefile.inc b/src/soc/intel/braswell/microcode/Makefile.inc
index 936dd85..da25b8b 100644
--- a/src/soc/intel/braswell/microcode/Makefile.inc
+++ b/src/soc/intel/braswell/microcode/Makefile.inc
@@ -9,5 +9,5 @@ fsp_ucode_cbfs_base = $(CONFIG_CPU_MICROCODE_CBFS_LOC)
# Override the location that was supplied by the core code.
add-cpu-microcode-to-cbfs = \
- $(CBFSTOOL) $(1) add -n $(cpu_ucode_cbfs_name) -f $(cpu_ucode_cbfs_file) -t 0x53 -b $(fsp_ucode_cbfs_base)
+ $(CBFSTOOL) $(1) add -n $(cpu_ucode_cbfs_name) -f $(cpu_ucode_cbfs_file) -t microcode -b $(fsp_ucode_cbfs_base)
Thaminda Edirisooriya (thaminda(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10870
-gerrit
commit 1c2c4ae971c587636a0108180d9896fa2691ed41
Author: Thaminda Edirisooriya <thaminda(a)google.com>
Date: Thu Jul 9 13:53:34 2015 -0700
riscv-emulation: Set stack size to 0 in Kconfig
Build now decides the stack size by correctly referencing the
value in /src/mainboard/emulation/qemu-riscv/memlayout.ld.
Note that while the size is correct, the placement is still
wrong, and causes the stack to be corrupted by the coreboot
tables. Still needs to be addressed
Change-Id: I86c08bd53eeb64e672fecba21e06220694a4c3dd
Signed-off-by: Thaminda Edirisooriya <thaminda(a)google.com>
---
src/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Kconfig b/src/Kconfig
index 9c0d1cf..8078a76 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -425,7 +425,7 @@ config HEAP_SIZE
config STACK_SIZE
hex
- default 0x0 if (ARCH_RAMSTAGE_ARM || ARCH_RAMSTAGE_MIPS)
+ default 0x0 if (ARCH_RAMSTAGE_ARM || ARCH_RAMSTAGE_MIPS || ARCH_RAMSTAGE_RISCV)
default 0x1000
config MAX_CPUS
Thaminda Edirisooriya (thaminda(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10870
-gerrit
commit 99e3f867a70842af0191bd947d96251f60cc1390
Author: Thaminda Edirisooriya <thaminda(a)google.com>
Date: Thu Jul 9 13:53:34 2015 -0700
riscv-emulation: added Kconfig line to get correct stack size
Build now decides the stack size by correctly referencing the
value in /src/mainboard/emulation/qemu-riscv/memlayout.ld.
Note that while the size is correct, the placement is still
wrong, and causes the stack to be corrupted by the coreboot
tables. Still needs to be addressed
Change-Id: I86c08bd53eeb64e672fecba21e06220694a4c3dd
Signed-off-by: Thaminda Edirisooriya <thaminda(a)google.com>
---
src/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Kconfig b/src/Kconfig
index 9c0d1cf..8078a76 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -425,7 +425,7 @@ config HEAP_SIZE
config STACK_SIZE
hex
- default 0x0 if (ARCH_RAMSTAGE_ARM || ARCH_RAMSTAGE_MIPS)
+ default 0x0 if (ARCH_RAMSTAGE_ARM || ARCH_RAMSTAGE_MIPS || ARCH_RAMSTAGE_RISCV)
default 0x1000
config MAX_CPUS
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10868
-gerrit
commit 397a105358899b32f123ab06b4bcf8c2e90329c8
Author: Patrick Georgi <pgeorgi(a)chromium.org>
Date: Thu Jul 9 13:57:00 2015 +0200
libpayload: Add support for handling fmaps
They will become more common soon, so better support them now.
Change-Id: I2b16e1bb7707fe8410365877524ff359aeefc161
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
payloads/libpayload/include/fmap_serialized.h | 73 +++++++++++++++++++++++
payloads/libpayload/include/libpayload.h | 5 ++
payloads/libpayload/libc/Makefile.inc | 1 +
payloads/libpayload/libc/fmap.c | 84 +++++++++++++++++++++++++++
4 files changed, 163 insertions(+)
diff --git a/payloads/libpayload/include/fmap_serialized.h b/payloads/libpayload/include/fmap_serialized.h
new file mode 100644
index 0000000..3585f0b
--- /dev/null
+++ b/payloads/libpayload/include/fmap_serialized.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2010, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ */
+
+#ifndef FLASHMAP_SERIALIZED_H__
+#define FLASHMAP_SERIALIZED_H__
+
+#include <stdint.h>
+
+#define FMAP_SIGNATURE "__FMAP__"
+#define FMAP_VER_MAJOR 1 /* this header's FMAP minor version */
+#define FMAP_VER_MINOR 1 /* this header's FMAP minor version */
+#define FMAP_STRLEN 32 /* maximum length for strings, */
+ /* including null-terminator */
+
+enum fmap_flags {
+ FMAP_AREA_STATIC = 1 << 0,
+ FMAP_AREA_COMPRESSED = 1 << 1,
+ FMAP_AREA_RO = 1 << 2,
+};
+
+/* Mapping of volatile and static regions in firmware binary */
+struct fmap_area {
+ uint32_t offset; /* offset relative to base */
+ uint32_t size; /* size in bytes */
+ uint8_t name[FMAP_STRLEN]; /* descriptive name */
+ uint16_t flags; /* flags for this area */
+} __attribute__((packed));
+
+struct fmap {
+ uint8_t signature[8]; /* "__FMAP__" (0x5F5F464D41505F5F) */
+ uint8_t ver_major; /* major version */
+ uint8_t ver_minor; /* minor version */
+ uint64_t base; /* address of the firmware binary */
+ uint32_t size; /* size of firmware binary in bytes */
+ uint8_t name[FMAP_STRLEN]; /* name of this firmware binary */
+ uint16_t nareas; /* number of areas described by
+ fmap_areas[] below */
+ struct fmap_area areas[];
+} __attribute__((packed));
+
+#endif /* FLASHMAP_SERIALIZED_H__ */
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index c09fc17..b92567c 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -47,6 +47,7 @@
#include <ctype.h>
#include <die.h>
#include <endian.h>
+#include <fmap_serialized.h>
#include <ipchksum.h>
#include <kconfig.h>
#include <stddef.h>
@@ -405,4 +406,8 @@ void gdb_enter(void);
/* Disconnect existing GDB connection if one exists. */
void gdb_exit(s8 exit_status);
+/* look for area "name" in "fmap", setting offset and size to describe it.
+ Returns 0 on success, < 0 on error. */
+int fmap_region_by_name(const uint32_t fmap_offset, const char * const name,
+ uint32_t * const offset, uint32_t * const size);
#endif
diff --git a/payloads/libpayload/libc/Makefile.inc b/payloads/libpayload/libc/Makefile.inc
index b3c0f76..edef62c 100644
--- a/payloads/libpayload/libc/Makefile.inc
+++ b/payloads/libpayload/libc/Makefile.inc
@@ -38,6 +38,7 @@ libc-$(CONFIG_LP_LIBC) += qsort.c
libc-$(CONFIG_LP_LIBC) += hexdump.c
libc-$(CONFIG_LP_LIBC) += die.c
libc-$(CONFIG_LP_LIBC) += coreboot.c
+libc-$(CONFIG_LP_LIBC) += fmap.c
ifeq ($(CONFIG_LP_ARCH_MIPS),y)
libc-$(CONFIG_LP_LIBC) += 64bit_div.c
diff --git a/payloads/libpayload/libc/fmap.c b/payloads/libpayload/libc/fmap.c
new file mode 100644
index 0000000..af9902e
--- /dev/null
+++ b/payloads/libpayload/libc/fmap.c
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload-config.h>
+#include <libpayload.h>
+#include <coreboot_tables.h>
+#include <cbfs.h>
+#include <fmap_serialized.h>
+#include <stdint.h>
+
+int fmap_region_by_name(const uint32_t fmap_offset, const char * const name,
+ uint32_t * const offset, uint32_t * const size)
+{
+ int i;
+
+ struct fmap *fmap;
+ struct fmap fmap_head;
+ struct cbfs_media default_media;
+ struct cbfs_media *media = &default_media;
+
+ if (init_default_cbfs_media(media) != 0)
+ return -1;
+
+ media->open(media);
+
+ if (!media->read(media, &fmap_head, fmap_offset, sizeof(fmap_head)))
+ return -1;
+
+ if (memcmp(fmap_head.signature, FMAP_SIGNATURE, sizeof(fmap_head.signature))) {
+ return -1;
+ }
+
+ int fmap_size = sizeof(*fmap) +
+ fmap_head.nareas * sizeof(struct fmap_area);
+
+ fmap = malloc(fmap_size);
+ if (!fmap)
+ return -1;
+
+ if (!media->read(media, fmap, fmap_offset, fmap_size))
+ goto err;
+
+ media->close(media);
+
+ for (i = 0; i < fmap->nareas; i++) {
+ if (strcmp((const char *)fmap->areas[i].name, name) != 0)
+ continue;
+ if (offset)
+ *offset = fmap->areas[i].offset;
+ if (size)
+ *size = fmap->areas[i].size;
+ free(fmap);
+ return 0;
+ }
+err:
+ free(fmap);
+ return -1;
+}
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10866
-gerrit
commit 2cb1799e3377f4c69eefb64e1390face8f90db3d
Author: Patrick Georgi <pgeorgi(a)chromium.org>
Date: Thu Jul 9 13:34:40 2015 +0200
fmap: publish find_fmap_directory()
The fmap directory can be useful to pass to the payload. For that, we need to
be able to get it.
Change-Id: Ibe0be73bb4fe28afb16d4d215b979eb0be369645
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
src/include/fmap.h | 3 +++
src/lib/fmap.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/include/fmap.h b/src/include/fmap.h
index 671e802..6be6fee 100644
--- a/src/include/fmap.h
+++ b/src/include/fmap.h
@@ -23,6 +23,9 @@
#include <region.h>
#include <fmap_serialized.h>
+/* Locate the fmap directory. Return 0 on success, < 0 on error. */
+int find_fmap_directory(struct region_device *fmrd);
+
/* Locate the named area in the fmap and fill in a region device representing
* that area. The region is a sub-region of the readonly boot media. Return
* 0 on success, < 0 on error. */
diff --git a/src/lib/fmap.c b/src/lib/fmap.c
index f2087c3..dea34bc 100644
--- a/src/lib/fmap.c
+++ b/src/lib/fmap.c
@@ -28,7 +28,7 @@
* See http://code.google.com/p/flashmap/ for more information on FMAP.
*/
-static int find_fmap_directory(struct region_device *fmrd)
+int find_fmap_directory(struct region_device *fmrd)
{
const struct region_device *boot;
struct fmap *fmap;
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10867
-gerrit
commit e6b2ffdacd9f1b6e1932dba63952980acdd7ce27
Author: Daisuke Nojiri <dnojiri(a)chromium.org>
Date: Wed Jul 1 11:08:22 2015 -0700
fmap: store boot params to coreboot table
This allows payloads on ARM platforms to use cbfs on spi flash by passing
along information to look it up from fmap.
[pg: adapted to use fmap instead of CBFS_HEADER_OFFSET]
Change-Id: I4b00159610077761c501507e136407e9ae08c73e
Signed-off-by: Daisuke Nojiri <dnojiri(a)chromium.org>
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
src/include/boot/coreboot_tables.h | 12 +++++
src/lib/coreboot_table.c | 6 +++
src/vendorcode/google/chromeos/vboot2/Makefile.inc | 1 +
src/vendorcode/google/chromeos/vboot2/cbtable.c | 55 ++++++++++++++++++++++
4 files changed, 74 insertions(+)
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index c8d5251..99eb3c6 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -297,6 +297,15 @@ struct lb_spi_flash {
uint32_t erase_cmd;
};
+#define LB_TAG_BOOT_MEDIA_PARAMS 0x0030
+struct lb_boot_media_params {
+ uint32_t tag;
+ uint32_t size;
+ /* offset from the start of the media */
+ uint32_t fmap_offset;
+ char fmap_name[32];
+};
+
#define LB_TAG_SERIALNO 0x002a
#define MAX_SERIALNO_LENGTH 32
@@ -390,6 +399,9 @@ void lb_add_console(uint16_t consoletype, void *data);
/* Define this in mainboard.c to add board-specific table entries. */
void lb_board(struct lb_header *header);
+/* Define this to add information which sub-CBFS to use. */
+void lb_boot_media_params(struct lb_header *header);
+
/*
* Function to retrieve MAC address(es) from the VPD and store them in the
* coreboot table.
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index f7fb2bb..9fa5da6 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -228,6 +228,10 @@ static void lb_board_id(struct lb_header *header)
#endif
}
+
+void __attribute__((weak)) lb_boot_media_params(struct lb_header *header)
+{ /* NOOP */ }
+
static void lb_ram_code(struct lb_header *header)
{
#if IS_ENABLED(CONFIG_RAM_CODE_SUPPORT)
@@ -483,6 +487,8 @@ unsigned long write_coreboot_table(
lb_ramoops(head);
#endif
+ lb_boot_media_params(head);
+
/* Remember where my valid memory ranges are */
return lb_table_fini(head);
}
diff --git a/src/vendorcode/google/chromeos/vboot2/Makefile.inc b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
index 9026df6..08993cb 100644
--- a/src/vendorcode/google/chromeos/vboot2/Makefile.inc
+++ b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
@@ -41,6 +41,7 @@ endif
romstage-y += vboot_handoff.c common.c
ramstage-y += common.c
+ramstage-y += cbtable.c
verstage-y += verstage.ld
diff --git a/src/vendorcode/google/chromeos/vboot2/cbtable.c b/src/vendorcode/google/chromeos/vboot2/cbtable.c
new file mode 100644
index 0000000..988cb13
--- /dev/null
+++ b/src/vendorcode/google/chromeos/vboot2/cbtable.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <boot/coreboot_tables.h>
+#include <fmap.h>
+#include <fmap_serialized.h>
+#include <region.h>
+#include <string.h>
+
+#include "misc.h"
+
+void lb_boot_media_params(struct lb_header *header)
+{
+ struct lb_boot_media_params *bmp;
+ struct vb2_working_data *wd = vboot_get_working_data();
+ struct region_device boot_media, fmrd;
+ char name[FMAP_STRLEN];
+
+ if (!wd)
+ return; /* no vboot2 data to work with */
+
+ if (find_fmap_directory(&fmrd))
+ return; /* couldn't find fmap */
+
+ if (vb2_get_selected_region(wd, &boot_media))
+ return; /* no boot media defined */
+
+ if (fmap_find_region_name(&boot_media.region, name))
+ return; /* couldn't find region */
+
+ bmp = (struct lb_boot_media_params *)lb_new_record(header);
+
+ bmp->tag = LB_TAG_BOOT_MEDIA_PARAMS;
+ bmp->size = sizeof(*bmp);
+ bmp->fmap_offset = region_device_offset(&fmrd);
+ memcpy(bmp->fmap_name, name, FMAP_STRLEN);
+}
+
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10865
-gerrit
commit add3cdb044ab4433252ab98f3fdb36238b7df6fb
Author: Patrick Georgi <pgeorgi(a)chromium.org>
Date: Thu Jul 9 11:27:44 2015 +0200
fmap: Introduce new function to derive fmap name from offset/size
vboot passes around the offset and size of the region to use in later stages.
To assign more meaning to this pair, provide a function that returns the
fmap area name if there's a precise match (and an error otherwise).
Change-Id: I5724b860271025c8cb8b390ecbd33352ea779660
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
src/include/fmap.h | 5 +++++
src/lib/fmap.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/src/include/fmap.h b/src/include/fmap.h
index e575bbf..671e802 100644
--- a/src/include/fmap.h
+++ b/src/include/fmap.h
@@ -21,6 +21,7 @@
#define _FMAP_H_
#include <region.h>
+#include <fmap_serialized.h>
/* Locate the named area in the fmap and fill in a region device representing
* that area. The region is a sub-region of the readonly boot media. Return
@@ -32,4 +33,8 @@ int fmap_locate_area_as_rdev(const char *name, struct region_device *area);
* < 0 on error. */
int fmap_locate_area(const char *name, struct region *r);
+/* Find fmap area name by offset and size.
+ * Return 0 on success, < 0 on error. */
+int fmap_find_region_name(const struct region * const ar,
+ char name[FMAP_STRLEN]);
#endif
diff --git a/src/lib/fmap.c b/src/lib/fmap.c
index 0f48cdc..f2087c3 100644
--- a/src/lib/fmap.c
+++ b/src/lib/fmap.c
@@ -117,3 +117,46 @@ int fmap_locate_area(const char *name, struct region *ar)
return -1;
}
+
+int fmap_find_region_name(const struct region * const ar,
+ char name[FMAP_STRLEN])
+{
+ struct region_device fmrd;
+ size_t offset;
+
+ if (find_fmap_directory(&fmrd))
+ return -1;
+
+ /* Start reading the areas just after fmap header. */
+ offset = sizeof(struct fmap);
+
+ while (1) {
+ struct fmap_area *area;
+
+ area = rdev_mmap(&fmrd, offset, sizeof(*area));
+
+ if (area == NULL)
+ return -1;
+
+ if ((ar->offset != area->offset) ||
+ (ar->size != area->size)) {
+ rdev_munmap(&fmrd, area);
+ offset += sizeof(struct fmap_area);
+ continue;
+ }
+
+ printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) found, named %s\n",
+ ar->offset, ar->size, area->name);
+
+ memcpy(name, area->name, FMAP_STRLEN);
+
+ rdev_munmap(&fmrd, area);
+
+ return 0;
+ }
+
+ printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) not found\n",
+ ar->offset, ar->size);
+
+ return -1;
+}