Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: utility/bmpblk_utility.cc

Issue 6533012: Write images to the bmpblock in the order they appear in the yaml. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/bitmaps/case_order2.yaml ('k') | utility/include/bmpblk_utility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Utility for manipulating firmware screen block (BMPBLOCK) in GBB. 5 // Utility for manipulating firmware screen block (BMPBLOCK) in GBB.
6 // 6 //
7 7
8 #include "bmpblk_utility.h" 8 #include "bmpblk_utility.h"
9 9
10 #include <assert.h> 10 #include <assert.h>
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 yaml_parser_parse(parser, &event); 181 yaml_parser_parse(parser, &event);
182 switch (event.type) { 182 switch (event.type) {
183 case YAML_SCALAR_EVENT: 183 case YAML_SCALAR_EVENT:
184 image_name = (char*)event.data.scalar.value; 184 image_name = (char*)event.data.scalar.value;
185 yaml_event_delete(&event); 185 yaml_event_delete(&event);
186 yaml_parser_parse(parser, &event); 186 yaml_parser_parse(parser, &event);
187 if (event.type != YAML_SCALAR_EVENT) { 187 if (event.type != YAML_SCALAR_EVENT) {
188 error("Syntax error in parsing images.\n"); 188 error("Syntax error in parsing images.\n");
189 } 189 }
190 image_filename = (char*)event.data.scalar.value; 190 image_filename = (char*)event.data.scalar.value;
191 config_.image_names.push_back(image_name);
191 config_.images_map[image_name] = ImageConfig(); 192 config_.images_map[image_name] = ImageConfig();
192 config_.images_map[image_name].filename = image_filename; 193 config_.images_map[image_name].filename = image_filename;
193 break; 194 break;
194 case YAML_MAPPING_END_EVENT: 195 case YAML_MAPPING_END_EVENT:
195 yaml_event_delete(&event); 196 yaml_event_delete(&event);
196 return; 197 return;
197 default: 198 default:
198 error("Syntax error in parsing images.\n"); 199 error("Syntax error in parsing images.\n");
199 } 200 }
200 yaml_event_delete(&event); 201 yaml_event_delete(&event);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 437 }
437 config_.header.number_of_imageinfos = config_.images_map.size(); 438 config_.header.number_of_imageinfos = config_.images_map.size();
438 } 439 }
439 440
440 void BmpBlockUtil::pack_bmpblock() { 441 void BmpBlockUtil::pack_bmpblock() {
441 bmpblock_.clear(); 442 bmpblock_.clear();
442 443
443 /* Compute the ImageInfo offsets from start of BMPBLOCK. */ 444 /* Compute the ImageInfo offsets from start of BMPBLOCK. */
444 uint32_t current_offset = sizeof(BmpBlockHeader) + 445 uint32_t current_offset = sizeof(BmpBlockHeader) +
445 sizeof(ScreenLayout) * config_.screens_map.size(); 446 sizeof(ScreenLayout) * config_.screens_map.size();
446 for (StrImageConfigMap::iterator it = config_.images_map.begin(); 447 for (unsigned int i = 0; i < config_.image_names.size(); ++i) {
447 it != config_.images_map.end(); 448 string image_name = config_.image_names[i];
448 ++it) { 449 ImageConfig &img = config_.images_map[image_name];
449 it->second.offset = current_offset; 450 img.offset = current_offset;
450 current_offset += sizeof(ImageInfo) + it->second.data.compressed_size; 451 current_offset += sizeof(ImageInfo) +
452 config_.images_map[image_name].data.compressed_size;
451 /* Make it 4-byte aligned. */ 453 /* Make it 4-byte aligned. */
452 if ((current_offset & 3) > 0) { 454 if ((current_offset & 3) > 0) {
453 current_offset = (current_offset & ~3) + 4; 455 current_offset = (current_offset & ~3) + 4;
454 } 456 }
455 } 457 }
456 bmpblock_.resize(current_offset); 458 bmpblock_.resize(current_offset);
457 459
458 /* Fill BmpBlockHeader struct. */ 460 /* Fill BmpBlockHeader struct. */
459 string::iterator current_filled = bmpblock_.begin(); 461 string::iterator current_filled = bmpblock_.begin();
460 std::copy(reinterpret_cast<char*>(&config_.header), 462 std::copy(reinterpret_cast<char*>(&config_.header),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 else if (extract_mode) { 647 else if (extract_mode) {
646 return dump_bmpblock(bmpblock_fn, 1, extract_dir, overwrite); 648 return dump_bmpblock(bmpblock_fn, 1, extract_dir, overwrite);
647 } else { 649 } else {
648 return dump_bmpblock(bmpblock_fn, show_as_yaml, 0, 0); 650 return dump_bmpblock(bmpblock_fn, show_as_yaml, 0, 0);
649 } 651 }
650 652
651 return 0; 653 return 0;
652 } 654 }
653 655
654 #endif // WITH_UTIL_MAIN 656 #endif // WITH_UTIL_MAIN
OLDNEW
« no previous file with comments | « tests/bitmaps/case_order2.yaml ('k') | utility/include/bmpblk_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698