summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2011-05-18 18:25:31 -0700
committerBill Richardson <wfrichar@chromium.org>2011-05-19 08:37:14 -0700
commit8ba3d790e16c6e0759686b1bd8b25db778c3fc9f (patch)
tree3891482c5205a8093659965011775b4b18b39706
parentc3fb9a26903458c4f10c7470f2b98a5ddd7e133e (diff)
downloadvboot-8ba3d790e16c6e0759686b1bd8b25db778c3fc9f.tar.gz
Add locale_string decoder into BmpBlock.
This change adds an additional (optional) section to the .yaml file which can enumerate the names of the locales. If present, these names will be appended to the end of the bmpblock and the (new) locale_string_offset field in the BmpBlockHeader will point to it. The names are encoded as a series of null-terminated ASCII strings. The end of the series is indicated by an extra null (for example, "en_US\0fr\0\0" names two locales). The BIOS does not use this information. Factory or OOBE could use it to select the initiale locale for the BIOS screens from the list of locales included in the BmpBlock. BUG=chrome-os-partner:3868 TEST=none Change-Id: I34fd9ece27343d56ec43772de975ac6f2ad7c9a6 Reviewed-on: http://gerrit.chromium.org/gerrit/1156 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--firmware/include/bmpblk_header.h3
-rw-r--r--scripts/newbitmaps/images/1280x800/DEFAULT.yaml50
-rw-r--r--scripts/newbitmaps/images/1366x768/DEFAULT.yaml50
-rw-r--r--scripts/newbitmaps/images/1366x768/ZGB.binbin0 -> 195339 bytes
-rw-r--r--scripts/newbitmaps/images/1366x768/ZGB.yaml225
-rw-r--r--utility/bmpblk_util.c15
-rw-r--r--utility/bmpblk_utility.cc44
-rw-r--r--utility/include/bmpblk_utility.h2
8 files changed, 388 insertions, 1 deletions
diff --git a/firmware/include/bmpblk_header.h b/firmware/include/bmpblk_header.h
index 09474d76..ea918cab 100644
--- a/firmware/include/bmpblk_header.h
+++ b/firmware/include/bmpblk_header.h
@@ -65,7 +65,8 @@ typedef struct BmpBlockHeader {
uint32_t number_of_screenlayouts; /* Number of screen layouts in each
* localization */
uint32_t number_of_imageinfos; /* Number of image infos */
- uint32_t reserved[3];
+ uint32_t locale_string_offset; /* Offset of locale-translation string */
+ uint32_t reserved[2];
} __attribute__((packed)) BmpBlockHeader;
/* Screen layout, describing how to stack multiple images on screen */
diff --git a/scripts/newbitmaps/images/1280x800/DEFAULT.yaml b/scripts/newbitmaps/images/1280x800/DEFAULT.yaml
index 3dd3c676..053e4f6e 100644
--- a/scripts/newbitmaps/images/1280x800/DEFAULT.yaml
+++ b/scripts/newbitmaps/images/1280x800/DEFAULT.yaml
@@ -1396,3 +1396,53 @@ localizations:
- [ zh_TW_devel, zh_TW_remove, zh_TW_yuck, zh_TW_insert ]
- [ ko_devel, ko_remove, ko_yuck, ko_insert ]
- [ ja_devel, ja_remove, ja_yuck, ja_insert ]
+
+locale_index:
+
+ # This list MUST match the order and number of the localizations above.
+ # These entries are used to match the locale name index (for example,
+ # "en_US" is index 0, "es_41" is index 1, etc).
+
+ - en
+ - es_419
+ - pt_BR
+ - en_GB
+ - fr
+ - es
+ - pt_PT
+ - ca
+ - it
+ - de
+ - el
+ - nl
+ - da
+ - no
+ - sv
+ - fi
+ - et
+ - lv
+ - lt
+ - ru
+ - pl
+ - cs
+ - sk
+ - hu
+ - sl
+ - sr
+ - hr
+ - bg
+ - ro
+ - uk
+ - tr
+ - iw
+ - ar
+ - fa
+ - hi
+ - th
+ - vi
+ - id
+ - fil
+ - zh_CN
+ - zh_TW
+ - ko
+ - ja
diff --git a/scripts/newbitmaps/images/1366x768/DEFAULT.yaml b/scripts/newbitmaps/images/1366x768/DEFAULT.yaml
index ce19e745..bd7cadc6 100644
--- a/scripts/newbitmaps/images/1366x768/DEFAULT.yaml
+++ b/scripts/newbitmaps/images/1366x768/DEFAULT.yaml
@@ -1396,3 +1396,53 @@ localizations:
- [ zh_TW_devel, zh_TW_remove, zh_TW_yuck, zh_TW_insert ]
- [ ko_devel, ko_remove, ko_yuck, ko_insert ]
- [ ja_devel, ja_remove, ja_yuck, ja_insert ]
+
+locale_index:
+
+ # This list MUST match the order and number of the localizations above.
+ # These entries are used to match the locale name index (for example,
+ # "en_US" is index 0, "es_41" is index 1, etc).
+
+ - en
+ - es_419
+ - pt_BR
+ - en_GB
+ - fr
+ - es
+ - pt_PT
+ - ca
+ - it
+ - de
+ - el
+ - nl
+ - da
+ - no
+ - sv
+ - fi
+ - et
+ - lv
+ - lt
+ - ru
+ - pl
+ - cs
+ - sk
+ - hu
+ - sl
+ - sr
+ - hr
+ - bg
+ - ro
+ - uk
+ - tr
+ - iw
+ - ar
+ - fa
+ - hi
+ - th
+ - vi
+ - id
+ - fil
+ - zh_CN
+ - zh_TW
+ - ko
+ - ja
diff --git a/scripts/newbitmaps/images/1366x768/ZGB.bin b/scripts/newbitmaps/images/1366x768/ZGB.bin
new file mode 100644
index 00000000..9d84e252
--- /dev/null
+++ b/scripts/newbitmaps/images/1366x768/ZGB.bin
Binary files differ
diff --git a/scripts/newbitmaps/images/1366x768/ZGB.yaml b/scripts/newbitmaps/images/1366x768/ZGB.yaml
new file mode 100644
index 00000000..73b7788d
--- /dev/null
+++ b/scripts/newbitmaps/images/1366x768/ZGB.yaml
@@ -0,0 +1,225 @@
+bmpblock: 1.1
+
+compression: 1
+
+images:
+
+ # This URL never changes
+ url: URL.bmp
+
+ # The background images are from the UI people
+ devmode_bg: Devmode.bmp
+ remove_bg: Remove.bmp
+ yuck_bg: Yuck.bmp
+ insert_bg: Insert.bmp
+
+ # The following strings must be approved by the localization people
+ en_model_text: ./localized_bitmaps/en/model.bmp
+ en_devmode_text: ./localized_bitmaps/en/devmode.bmp
+ en_remove_text: ./localized_bitmaps/en/remove.bmp
+ en_yuck_text: ./localized_bitmaps/en/yuck.bmp
+ en_insert_text: ./localized_bitmaps/en/insert.bmp
+
+ fr_model_text: ./localized_bitmaps/fr/model.bmp
+ fr_devmode_text: ./localized_bitmaps/fr/devmode.bmp
+ fr_remove_text: ./localized_bitmaps/fr/remove.bmp
+ fr_yuck_text: ./localized_bitmaps/fr/yuck.bmp
+ fr_insert_text: ./localized_bitmaps/fr/insert.bmp
+
+ es_model_text: ./localized_bitmaps/es/model.bmp
+ es_devmode_text: ./localized_bitmaps/es/devmode.bmp
+ es_remove_text: ./localized_bitmaps/es/remove.bmp
+ es_yuck_text: ./localized_bitmaps/es/yuck.bmp
+ es_insert_text: ./localized_bitmaps/es/insert.bmp
+
+ it_model_text: ./localized_bitmaps/it/model.bmp
+ it_devmode_text: ./localized_bitmaps/it/devmode.bmp
+ it_remove_text: ./localized_bitmaps/it/remove.bmp
+ it_yuck_text: ./localized_bitmaps/it/yuck.bmp
+ it_insert_text: ./localized_bitmaps/it/insert.bmp
+
+ de_model_text: ./localized_bitmaps/de/model.bmp
+ de_devmode_text: ./localized_bitmaps/de/devmode.bmp
+ de_remove_text: ./localized_bitmaps/de/remove.bmp
+ de_yuck_text: ./localized_bitmaps/de/yuck.bmp
+ de_insert_text: ./localized_bitmaps/de/insert.bmp
+
+ nl_model_text: ./localized_bitmaps/nl/model.bmp
+ nl_devmode_text: ./localized_bitmaps/nl/devmode.bmp
+ nl_remove_text: ./localized_bitmaps/nl/remove.bmp
+ nl_yuck_text: ./localized_bitmaps/nl/yuck.bmp
+ nl_insert_text: ./localized_bitmaps/nl/insert.bmp
+
+screens:
+ en_devel:
+ - [ 0, 0, devmode_bg]
+ - [272, 516, en_devmode_text]
+
+ en_remove:
+ - [ 0, 0, remove_bg]
+ - [256, 534, en_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [195, 453, en_remove_text]
+
+ en_yuck:
+ - [ 0, 0, yuck_bg]
+ - [256, 534, en_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [160, 453, en_yuck_text]
+
+ en_insert:
+ - [ 0, 0, insert_bg]
+ - [256, 534, en_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [273, 435, en_insert_text]
+
+ fr_devel:
+ - [ 0, 0, devmode_bg]
+ - [141, 516, fr_devmode_text]
+
+ fr_remove:
+ - [ 0, 0, remove_bg]
+ - [249, 534, fr_model_text]
+ - [321, 534, $HWID]
+ - [192, 479, url]
+ - [68, 453, fr_remove_text]
+
+ fr_yuck:
+ - [ 0, 0, yuck_bg]
+ - [249, 534, fr_model_text]
+ - [321, 534, $HWID]
+ - [192, 479, url]
+ - [66, 453, fr_yuck_text]
+
+ fr_insert:
+ - [ 0, 0, insert_bg]
+ - [249, 534, fr_model_text]
+ - [321, 534, $HWID]
+ - [192, 479, url]
+ - [215, 435, fr_insert_text]
+
+ es_devel:
+ - [ 0, 0, devmode_bg]
+ - [212, 516, es_devmode_text]
+
+ es_remove:
+ - [ 0, 0, remove_bg]
+ - [252, 534, es_model_text]
+ - [319, 534, $HWID]
+ - [192, 479, url]
+ - [166, 453, es_remove_text]
+
+ es_yuck:
+ - [ 0, 0, yuck_bg]
+ - [252, 534, es_model_text]
+ - [319, 534, $HWID]
+ - [192, 479, url]
+ - [147, 453, es_yuck_text]
+
+ es_insert:
+ - [ 0, 0, insert_bg]
+ - [252, 534, es_model_text]
+ - [319, 534, $HWID]
+ - [192, 479, url]
+ - [239, 435, es_insert_text]
+
+ it_devel:
+ - [ 0, 0, devmode_bg]
+ - [229, 516, it_devmode_text]
+
+ it_remove:
+ - [ 0, 0, remove_bg]
+ - [250, 534, it_model_text]
+ - [320, 534, $HWID]
+ - [192, 479, url]
+ - [200, 453, it_remove_text]
+
+ it_yuck:
+ - [ 0, 0, yuck_bg]
+ - [250, 534, it_model_text]
+ - [320, 534, $HWID]
+ - [192, 479, url]
+ - [168, 453, it_yuck_text]
+
+ it_insert:
+ - [ 0, 0, insert_bg]
+ - [250, 534, it_model_text]
+ - [320, 534, $HWID]
+ - [192, 479, url]
+ - [241, 435, it_insert_text]
+
+ de_devel:
+ - [ 0, 0, devmode_bg]
+ - [181, 516, de_devmode_text]
+
+ de_remove:
+ - [ 0, 0, remove_bg]
+ - [255, 534, de_model_text]
+ - [316, 534, $HWID]
+ - [192, 479, url]
+ - [140, 453, de_remove_text]
+
+ de_yuck:
+ - [ 0, 0, yuck_bg]
+ - [255, 534, de_model_text]
+ - [316, 534, $HWID]
+ - [192, 479, url]
+ - [134, 453, de_yuck_text]
+
+ de_insert:
+ - [ 0, 0, insert_bg]
+ - [255, 534, de_model_text]
+ - [316, 534, $HWID]
+ - [192, 479, url]
+ - [212, 435, de_insert_text]
+
+ nl_devel:
+ - [ 0, 0, devmode_bg]
+ - [222, 516, nl_devmode_text]
+
+ nl_remove:
+ - [ 0, 0, remove_bg]
+ - [256, 534, nl_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [170, 453, nl_remove_text]
+
+ nl_yuck:
+ - [ 0, 0, yuck_bg]
+ - [256, 534, nl_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [58, 453, nl_yuck_text]
+
+ nl_insert:
+ - [ 0, 0, insert_bg]
+ - [256, 534, nl_model_text]
+ - [314, 534, $HWID]
+ - [192, 479, url]
+ - [259, 435, nl_insert_text]
+
+localizations:
+
+ # This determines the order in which the localizations appear. The first
+ # one is the default.
+
+ - [ en_devel, en_remove, en_yuck, en_insert ]
+ - [ fr_devel, fr_remove, fr_yuck, fr_insert ]
+ - [ es_devel, es_remove, es_yuck, es_insert ]
+ - [ it_devel, it_remove, it_yuck, it_insert ]
+ - [ de_devel, de_remove, de_yuck, de_insert ]
+ - [ nl_devel, nl_remove, nl_yuck, nl_insert ]
+
+locale_index:
+
+ # This list MUST match the order and number of the localizations above.
+
+ - en
+ - fr
+ - es
+ - it
+ - de
+ - nl
diff --git a/utility/bmpblk_util.c b/utility/bmpblk_util.c
index 2dd63e8c..84a48fb1 100644
--- a/utility/bmpblk_util.c
+++ b/utility/bmpblk_util.c
@@ -419,6 +419,21 @@ int dump_bmpblock(const char *infile, int show_as_yaml,
fprintf(yfp, " ]\n");
}
+ if (hdr->locale_string_offset) {
+ char *loc_ptr = (char *)ptr + hdr->locale_string_offset;
+ char c;
+ fprintf(yfp, "locale_index:\n");
+ while ((c = *loc_ptr) != '\0') {
+ fprintf(yfp, " - ");
+ do {
+ fputc(c, yfp);
+ loc_ptr++;
+ } while((c = *loc_ptr) != '\0');
+ loc_ptr++;
+ fputc('\n', yfp);
+ }
+ }
+
if (todir)
fclose(yfp);
diff --git a/utility/bmpblk_utility.cc b/utility/bmpblk_utility.cc
index 3cc31ad2..ba3f04fb 100644
--- a/utility/bmpblk_utility.cc
+++ b/utility/bmpblk_utility.cc
@@ -94,6 +94,7 @@ namespace vboot_reference {
config_.images_map.clear();
config_.screens_map.clear();
config_.localizations.clear();
+ config_.locale_names.clear();
FILE *fp = fopen(filename, "rb");
if (!fp) {
@@ -113,6 +114,7 @@ namespace vboot_reference {
// All images referenced in the screens should be defined.
// All screens should be used somewhere in the localizations.
// All screens referenced in the localizations should be defined.
+ // The number of localizations should match the number of locale_index
if (debug_) {
printf("%ld image_names\n", config_.image_names.size());
@@ -143,6 +145,7 @@ namespace vboot_reference {
it->second.data.images[k].image_info_offset);
}
}
+ // TODO(wfrichar): print debugging info about locale_names
}
}
@@ -183,6 +186,8 @@ namespace vboot_reference {
parse_screens(parser);
} else if (keyword == "localizations") {
parse_localizations(parser);
+ } else if (keyword == "locale_index") {
+ parse_locale_index(parser);
}
break;
case YAML_MAPPING_END_EVENT:
@@ -370,6 +375,26 @@ namespace vboot_reference {
}
}
+ void BmpBlockUtil::parse_locale_index(yaml_parser_t *parser) {
+ yaml_event_t event;
+ expect_event(parser, YAML_SEQUENCE_START_EVENT);
+ for (;;) {
+ yaml_parser_parse(parser, &event);
+ switch (event.type) {
+ case YAML_SCALAR_EVENT:
+ config_.locale_names.append((char*)event.data.scalar.value);
+ config_.locale_names.append(1, (char)'\0'); // '\0' to delimit
+ break;
+ case YAML_SEQUENCE_END_EVENT:
+ yaml_event_delete(&event);
+ config_.locale_names.append(1, (char)'\0'); // double '\0' to terminate
+ return;
+ default:
+ error("Syntax error in parsing localizations.\n");
+ }
+ }
+ }
+
void BmpBlockUtil::load_all_image_files() {
for (unsigned int i = 0; i < config_.image_names.size(); i++) {
StrImageConfigMap::iterator it =
@@ -518,6 +543,7 @@ namespace vboot_reference {
config_.localizations[i].size());
}
config_.header.number_of_imageinfos = config_.images_map.size();
+ config_.header.locale_string_offset = 0; // Filled by pack_bmpblock()
}
void BmpBlockUtil::pack_bmpblock() {
@@ -544,6 +570,12 @@ namespace vboot_reference {
current_offset = (current_offset & ~3) + 4;
}
}
+ /* And leave room for the locale_index string */
+ if (config_.locale_names.size()) {
+ config_.header.locale_string_offset = current_offset;
+ current_offset += config_.locale_names.size();
+ }
+
bmpblock_.resize(current_offset);
/* Fill BmpBlockHeader struct. */
@@ -604,6 +636,18 @@ namespace vboot_reference {
it->second.compressed_content.end(),
current_filled);
}
+
+ /* Fill in locale_names. */
+ if (config_.header.locale_string_offset) {
+ current_offset = config_.header.locale_string_offset;
+ current_filled = bmpblock_.begin() + current_offset;
+ if (debug_)
+ printf("locale_names: offset 0x%08x (len %ld)\n",
+ current_offset, config_.locale_names.size());
+ std::copy(config_.locale_names.begin(),
+ config_.locale_names.end(),
+ current_filled);
+ }
}
void BmpBlockUtil::write_to_bmpblock(const char *filename) {
diff --git a/utility/include/bmpblk_utility.h b/utility/include/bmpblk_utility.h
index 95e8ce35..5b70ce2d 100644
--- a/utility/include/bmpblk_utility.h
+++ b/utility/include/bmpblk_utility.h
@@ -46,6 +46,7 @@ typedef struct BmpBlockConfig {
StrImageConfigMap images_map;
StrScreenConfigMap screens_map;
vector<vector<string> > localizations;
+ string locale_names;
} BmpBlockConfig;
class BmpBlockUtil {
@@ -88,6 +89,7 @@ class BmpBlockUtil {
void parse_layout(yaml_parser_t *parser, ScreenConfig &screen);
void parse_screens(yaml_parser_t *parser);
void parse_localizations(yaml_parser_t *parser);
+ void parse_locale_index(yaml_parser_t *parser);
/* Useful functions */
const string read_image_file(const char *filename);