[coreboot-gerrit] Patch set updated for coreboot: 4a8e63a Remove inessential mappings in cbfs_media

Naman Govil (namangov@gmail.com) gerrit at coreboot.org
Wed Aug 6 08:41:22 CEST 2014


Naman Govil (namangov at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6507

-gerrit

commit 4a8e63af3cf7bd70a851392f16b973c0e5841d46
Author: Naman Govil <namangov at gmail.com>
Date:   Wed Aug 6 11:46:17 2014 +0530

    Remove inessential mappings in cbfs_media
    
    Reducing sram usage while booting by removing unwanted map()s by creating
    a structure to replace it with appropriate read()s
    
    Change-Id: I6e49543f5bb30936162ebea11a3ca8cee8213dc2
    Signed-off-by: Naman Govil <namangov at gmail.com>
---
 src/arch/x86/boot/smbios.c            |  3 +--
 src/include/cbfs_core.h               | 10 +++++-----
 src/lib/cbfs.c                        |  2 +-
 src/lib/cbfs_core.c                   | 20 ++++++--------------
 src/lib/loaders/cbfs_payload_loader.c |  6 ++----
 5 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/src/arch/x86/boot/smbios.c b/src/arch/x86/boot/smbios.c
index ec3e5e8..37c4b80 100644
--- a/src/arch/x86/boot/smbios.c
+++ b/src/arch/x86/boot/smbios.c
@@ -153,9 +153,8 @@ static int smbios_write_type0(unsigned long *current, int handle)
 	{
 		struct cbfs_header header;
 		u32 romsize = CONFIG_ROM_SIZE;
-		if (!cbfs_get_header(CBFS_DEFAULT_MEDIA, &header)) {
+		if (!cbfs_get_header(CBFS_DEFAULT_MEDIA, &header))
 			romsize = header.romsize;
-			}
 		t->bios_rom_size = (romsize / 65535) - 1;
 	}
 
diff --git a/src/include/cbfs_core.h b/src/include/cbfs_core.h
index 11de0ee..ecfee36 100644
--- a/src/include/cbfs_core.h
+++ b/src/include/cbfs_core.h
@@ -232,18 +232,18 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);
 int cbfs_decompress(int algo, void *src, void *dst, int len);
 
 /* finds the CBFS master header and fills it in a cbfs_header structure,
-   return 0 on success and <0 if header not found */
+ *  return 0 on success and <0 if header not found */
 int cbfs_get_header(struct cbfs_media *media, struct cbfs_header *header);
 
 /* Returns success (0) on finding the file requested by verifying name;
-  -1 if file not found
- The absolute data_offset to the file is stored */
+ * -1 if file not found
+ * The absolute data_offset to the file is stored */
 int cbfs_find_file(struct cbfs_media *media, struct cbfs_file_handle *f,
 		const char *name);
 
 /* Returns success (0) on finding the file requested by verifying name and type;
-  -1 if file not found
- The absolute data_offset to the file is stored */
+ * -1 if file not found
+ *  The absolute data_offset to the file is stored */
 int cbfs_find_file_by_type(struct cbfs_media *media, struct cbfs_file_handle *f,
 		const char *name, int type);
 
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 5442ddc..41a871f 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -138,7 +138,7 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name)
 	c = cbfs_find_file_by_type(media, &f, name, CBFS_TYPE_STAGE);
 
 	if (c < 0) {
-		ERROR("Stage not loaded\n");
+		ERROR("Stage not loaded.\n");
 		return (void *)-1;
 	}
 
diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c
index 164473e..348ff77 100644
--- a/src/lib/cbfs_core.c
+++ b/src/lib/cbfs_core.c
@@ -191,15 +191,6 @@ int cbfs_find_file(struct cbfs_media *media, struct cbfs_file_handle *f,
 int cbfs_find_file_by_type(struct cbfs_media *media, struct cbfs_file_handle *f,
 		const char *name, int type)
 {
-	struct cbfs_media default_media;
-
-	if (media == CBFS_DEFAULT_MEDIA) {
-		media = &default_media;
-		if (init_default_cbfs_media(media) != 0) {
-			ERROR("Failed to initialize default media/\n");
-			return -1;
-		}
-	}
 
 	if (cbfs_find_file(media, f, name) < 0) {
 		ERROR("Failed to find file\n");
@@ -211,10 +202,7 @@ int cbfs_find_file_by_type(struct cbfs_media *media, struct cbfs_file_handle *f,
 		return 0;
 	}
 	else
-	{
-		ERROR("File of matching type not found\n");
 		return -1;
-	}
 }
 
 
@@ -277,8 +265,12 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
 		return NULL;
 	}
 
-	fileptr = media->map(media, f.data_offset, f.data_len);
-	return fileptr;
+	fileptr = media->map(media, f.data_offset - f.file.offset, f.data_len + f.file.offset);
+
+	if (fileptr == CBFS_MEDIA_INVALID_MAP_ADDRESS)
+		return NULL;
+	else
+		return fileptr;
 }
 
 int cbfs_decompress(int algo, void *src, void *dst, int len)
diff --git a/src/lib/loaders/cbfs_payload_loader.c b/src/lib/loaders/cbfs_payload_loader.c
index d1ebd84..2fa42c4 100644
--- a/src/lib/loaders/cbfs_payload_loader.c
+++ b/src/lib/loaders/cbfs_payload_loader.c
@@ -25,11 +25,9 @@
 static int cbfs_locate_payload(struct payload *payload)
 {
 	const int type = CBFS_TYPE_PAYLOAD;
-	struct cbfs_media default_media, *m;
+	struct cbfs_media *m;
 
-	m = &default_media;
-	if (init_default_cbfs_media(m) != 0)
-		return -1;
+	m = CBFS_DEFAULT_MEDIA;
 
 	if (cbfs_find_file_by_type(m, &payload->f, payload->name, type) < 0)
 		return -1;



More information about the coreboot-gerrit mailing list