OLD | NEW |
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 yaml_event_t event; | 132 yaml_event_t event; |
133 string keyword; | 133 string keyword; |
134 expect_event(parser, YAML_MAPPING_START_EVENT); | 134 expect_event(parser, YAML_MAPPING_START_EVENT); |
135 for (;;) { | 135 for (;;) { |
136 yaml_parser_parse(parser, &event); | 136 yaml_parser_parse(parser, &event); |
137 switch (event.type) { | 137 switch (event.type) { |
138 case YAML_SCALAR_EVENT: | 138 case YAML_SCALAR_EVENT: |
139 keyword = (char*)event.data.scalar.value; | 139 keyword = (char*)event.data.scalar.value; |
140 if (keyword == "bmpblock") { | 140 if (keyword == "bmpblock") { |
141 parse_bmpblock(parser); | 141 parse_bmpblock(parser); |
| 142 } else if (keyword == "compression") { |
| 143 parse_compression(parser); |
142 } else if (keyword == "images") { | 144 } else if (keyword == "images") { |
143 parse_images(parser); | 145 parse_images(parser); |
144 } else if (keyword == "screens") { | 146 } else if (keyword == "screens") { |
145 parse_screens(parser); | 147 parse_screens(parser); |
146 } else if (keyword == "localizations") { | 148 } else if (keyword == "localizations") { |
147 parse_localizations(parser); | 149 parse_localizations(parser); |
148 } | 150 } |
149 break; | 151 break; |
150 case YAML_MAPPING_END_EVENT: | 152 case YAML_MAPPING_END_EVENT: |
151 yaml_event_delete(&event); | 153 yaml_event_delete(&event); |
(...skipping 15 matching lines...) Expand all Loading... |
167 sprintf(wantversion, "%d.%d", | 169 sprintf(wantversion, "%d.%d", |
168 BMPBLOCK_MAJOR_VERSION, | 170 BMPBLOCK_MAJOR_VERSION, |
169 BMPBLOCK_MINOR_VERSION); | 171 BMPBLOCK_MINOR_VERSION); |
170 string gotversion = (char*)event.data.scalar.value; | 172 string gotversion = (char*)event.data.scalar.value; |
171 if (gotversion != wantversion) { | 173 if (gotversion != wantversion) { |
172 error("Invalid version specified in config file\n"); | 174 error("Invalid version specified in config file\n"); |
173 } | 175 } |
174 yaml_event_delete(&event); | 176 yaml_event_delete(&event); |
175 } | 177 } |
176 | 178 |
| 179 void BmpBlockUtil::parse_compression(yaml_parser_t *parser) { |
| 180 yaml_event_t event; |
| 181 yaml_parser_parse(parser, &event); |
| 182 if (event.type != YAML_SCALAR_EVENT) { |
| 183 error("Syntax error in parsing bmpblock.\n"); |
| 184 } |
| 185 char *comp_str = (char *)event.data.scalar.value; |
| 186 char *e = 0; |
| 187 uint32_t comp = (uint32_t)strtoul(comp_str, &e, 0); |
| 188 if (!*comp_str || (e && *e) || comp >= MAX_COMPRESS) { |
| 189 error("Invalid compression specified in config file\n"); |
| 190 } |
| 191 if (!set_compression_) { |
| 192 compression_ = comp; |
| 193 } |
| 194 yaml_event_delete(&event); |
| 195 } |
| 196 |
177 void BmpBlockUtil::parse_images(yaml_parser_t *parser) { | 197 void BmpBlockUtil::parse_images(yaml_parser_t *parser) { |
178 yaml_event_t event; | 198 yaml_event_t event; |
179 string image_name, image_filename; | 199 string image_name, image_filename; |
180 expect_event(parser, YAML_MAPPING_START_EVENT); | 200 expect_event(parser, YAML_MAPPING_START_EVENT); |
181 for (;;) { | 201 for (;;) { |
182 yaml_parser_parse(parser, &event); | 202 yaml_parser_parse(parser, &event); |
183 switch (event.type) { | 203 switch (event.type) { |
184 case YAML_SCALAR_EVENT: | 204 case YAML_SCALAR_EVENT: |
185 image_name = (char*)event.data.scalar.value; | 205 image_name = (char*)event.data.scalar.value; |
186 yaml_event_delete(&event); | 206 yaml_event_delete(&event); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 else if (extract_mode) { | 701 else if (extract_mode) { |
682 return dump_bmpblock(bmpblock_fn, 1, extract_dir, overwrite); | 702 return dump_bmpblock(bmpblock_fn, 1, extract_dir, overwrite); |
683 } else { | 703 } else { |
684 return dump_bmpblock(bmpblock_fn, show_as_yaml, 0, 0); | 704 return dump_bmpblock(bmpblock_fn, show_as_yaml, 0, 0); |
685 } | 705 } |
686 | 706 |
687 return 0; | 707 return 0; |
688 } | 708 } |
689 | 709 |
690 #endif // WITH_UTIL_MAIN | 710 #endif // WITH_UTIL_MAIN |
OLD | NEW |