[coreboot-gerrit] New patch to review for coreboot: cbfstool: Add compression attribute to ramstage

Werner Zeh (werner.zeh@siemens.com) gerrit at coreboot.org
Wed Jan 27 08:25:29 CET 2016


Werner Zeh (werner.zeh at siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13489

-gerrit

commit 9e788837a042580f8c206f457bc9a44cafbc97e5
Author: Werner Zeh <werner.zeh at siemens.com>
Date:   Wed Jan 27 08:19:47 2016 +0100

    cbfstool: Add compression attribute to ramstage
    
    Currently, compression attribute is added to every cbfs file but
    ramstage. This patch adds compression attribute for ramstage, too.
    
    Change-Id: If66a9d3129740fcd5e703b9f3035a31431afb851
    Signed-off-by: Werner Zeh <werner.zeh at siemens.com>
---
 util/cbfstool/cbfs-mkstage.c |  3 +++
 util/cbfstool/cbfstool.c     | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index 9d88658..2a2d062 100644
--- a/util/cbfstool/cbfs-mkstage.c
+++ b/util/cbfstool/cbfs-mkstage.c
@@ -5,6 +5,7 @@
  *               2009 coresystems GmbH
  *                 written by Patrick Georgi <patrick.georgi at coresystems.de>
  * Copyright (C) 2012 Google, Inc.
+ * Copyright (C) 2016 Siemens AG. All rights reserved.
  *
  * 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
@@ -285,6 +286,8 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
 		*location -= sizeof(struct cbfs_stage);
 	output->size = sizeof(struct cbfs_stage) + outlen;
 	ret = 0;
+	if (algo == CBFS_COMPRESS_NONE)
+		ret = 1;
 
 err:
 	parsed_elf_destroy(&pelf);
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 23787d8..c0a4b32 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -504,12 +504,30 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset,
 
 		ret = parse_elf_to_xip_stage(buffer, &output, offset,
 						param.ignore_section);
-	} else
+	} else {
 		ret = parse_elf_to_stage(buffer, &output, param.compression,
 					 offset, param.ignore_section);
+		/* Add compression header. Compression was disabled in */
+		/* parse_elf_to_stage() when ret == 1, take it into account */
+		if (ret == 1)
+			param.compression = CBFS_COMPRESS_NONE;
+		struct cbfs_file_attr_compression *attrs =
+			(struct cbfs_file_attr_compression *)
+			cbfs_add_file_attr(header,
+				CBFS_FILE_ATTR_TAG_COMPRESSION,
+				sizeof(struct cbfs_file_attr_compression));
+		if (attrs == NULL)
+			ret = -1;
+		else {
+			attrs->compression = htonl(param.compression);
+			attrs->decompressed_size = htonl(buffer->size);
+			ret = 0;
+		}
+	}
 
 	if (ret != 0)
 		return -1;
+
 	buffer_delete(buffer);
 	// direct assign, no dupe.
 	memcpy(buffer, &output, sizeof(*buffer));



More information about the coreboot-gerrit mailing list