[coreboot-gerrit] New patch to review for coreboot: cbfs: New API to locate a file from specific region
Pratikkumar V Prajapati (pratikkumar.v.prajapati@intel.com)
gerrit at coreboot.org
Thu Dec 1 02:40:51 CET 2016
Pratikkumar V Prajapati (pratikkumar.v.prajapati at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17664
-gerrit
commit e129e8421a8f6a6318a70f18919ece2563bdbc75
Author: Pratik Prajapati <pratikkumar.v.prajapati at intel.com>
Date: Wed Nov 30 17:29:10 2016 -0800
cbfs: New API to locate a file from specific region
method to find file by name from any specific
region of fmap.
Change-Id: Iabe785a6434937be6a57c7009882a0d68f6c8ad4
Signed-off-by: Pratik Prajapati <pratikkumar.v.prajapati at intel.com>
---
src/include/cbfs.h | 3 +++
src/lib/cbfs.c | 27 ++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index 8538b3d..b063f0e 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -34,6 +34,9 @@ int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type);
* leaking mappings are a no-op. Returns NULL on error, else returns
* the mapping and sets the size of the file. */
void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size);
+/* Locate file in a specific region of fmap.*/
+void *cbfs_locate_file_in_region(const char *region_name,
+ const char *file_name, uint32_t file_type, size_t *file_size);
/* Load a struct file from CBFS into a buffer. Returns amount of loaded
* bytes on success or 0 on error. File will get decompressed as necessary.
* Same decompression requirements as cbfs_load_and_decompress(). */
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 19737a4..9b5c7fa 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -24,7 +24,7 @@
#include <lib.h>
#include <symbols.h>
#include <timestamp.h>
-
+#include <fmap.h>
#include "fmap_config.h"
#define ERROR(x...) printk(BIOS_ERR, "CBFS: " x)
@@ -72,6 +72,31 @@ void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size)
return rdev_mmap(&fh.data, 0, fsize);
}
+void *cbfs_locate_file_in_region(const char *region_name, const char *file_name,
+ uint32_t file_type, size_t *file_size)
+{
+ struct region_device rdev;
+ struct cbfsf fh;
+
+ if (file_size != NULL)
+ *file_size = 0;
+
+ if (fmap_locate_area_as_rdev(region_name, &rdev) == 0) {
+ if (cbfs_locate(&fh, &rdev, file_name, &file_type) == 0) {
+ if (file_size != NULL)
+ *file_size = region_device_sz(&fh.data);
+ return rdev_mmap_full(&fh.data);
+ } else {
+ LOG("%s file not found in %s region\n",
+ file_name, region_name);
+ }
+ } else {
+ LOG("%s region not found while looking for %s\n",
+ region_name, file_name);
+ }
+ return NULL;
+}
+
size_t cbfs_load_and_decompress(const struct region_device *rdev, size_t offset,
size_t in_size, void *buffer, size_t buffer_size, uint32_t compression)
{
More information about the coreboot-gerrit
mailing list