diff options
author | Bill Richardson <wfrichar@chromium.org> | 2011-08-22 16:03:59 -0700 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2011-08-24 09:27:12 -0700 |
commit | 0a9977e161ce6ad6b11935dfb05ae840bf758078 (patch) | |
tree | b3ec3bf4e7b17dad7b9c0a6ec9f8b2d1aec75fd7 /utility/image_types.c | |
parent | efea801390caff45c2ef6083fde5f253f03bc395 (diff) | |
download | vboot-0a9977e161ce6ad6b11935dfb05ae840bf758078.tar.gz |
bmpblock v1.2 - render HWID inside vboot_reference
The vboot_api.h doesn't require the BIOS display the ASCII HWID in
a graphical form (ARM U-Boot doesn't know how), so we have to do it
ourselves. This change makes that possible.
Summary of changes:
* bmpblk_font.h defines a structure to map ASCII chars to BMPs
* bmpblk_font utility generates that font structure
* bmpblock format is bumped to version 1.2
- YAML file specifies font to use for $HWID
- make_default_yaml updated to emit the new format
- README updated to describe the difference
BUG=chromium-os:18631
TEST=manual
I've tested this on ARM, like so:
Inside the chroot, build a U-Boot that uses it:
emerge-tegra2_kaen vboot_reference vboot_reference-firmware
emerge-tegra2_kaen tegra-bct tegra2-public-firmware-fdts \
chromeos-u-boot chromeos-bootimage
Outside chroot, but in src/platform/vboot_reference:
make
<copy ./build/utility/bmpblk_font and ./build/utility/bmpblk_utility to
somewhere in your $PATH>
make clean
cd scripts/newbitmaps/fonts
bmpblk_font --outfile ../images/hwid_fonts.bin outdir/*
cd scripts/newbitmaps/images
make arm
cd out_arm
<edit DEFAULT.yaml>
bmpblk_utility -z 2 -c DEFAULT.yaml arm_bmpblock.bin
<use gbb_utility to replace the bitmaps in the U-Boot image, boot it>
The HWID string is displayed.
Change-Id: I782004a0f30c57fa1f3bb246e8c59a02c5e9f561
Reviewed-on: http://gerrit.chromium.org/gerrit/6544
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'utility/image_types.c')
-rw-r--r-- | utility/image_types.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/utility/image_types.c b/utility/image_types.c new file mode 100644 index 00000000..2cc27b32 --- /dev/null +++ b/utility/image_types.c @@ -0,0 +1,71 @@ +// Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stdint.h> +#include <string.h> + +#include "bmpblk_header.h" +#include "bmpblk_font.h" +#include "image_types.h" + +/* BMP header, used to validate image requirements + * See http://en.wikipedia.org/wiki/BMP_file_format + */ +typedef struct { + uint8_t CharB; // must be 'B' + uint8_t CharM; // must be 'M' + uint32_t Size; + uint16_t Reserved[2]; + uint32_t ImageOffset; + uint32_t HeaderSize; + uint32_t PixelWidth; + uint32_t PixelHeight; + uint16_t Planes; // Must be 1 for x86 + uint16_t BitPerPixel; // 1, 4, 8, or 24 for x86 + uint32_t CompressionType; // 0 (none) for x86, 1 (RLE) for arm + uint32_t ImageSize; + uint32_t XPixelsPerMeter; + uint32_t YPixelsPerMeter; + uint32_t NumberOfColors; + uint32_t ImportantColors; +} __attribute__((packed)) BMP_IMAGE_HEADER; + + +ImageFormat identify_image_type(const void *buf, uint32_t bufsize, + ImageInfo *info) { + + if (info) + info->format = FORMAT_INVALID; + + if (bufsize < sizeof(BMP_IMAGE_HEADER) && + bufsize < sizeof(FontArrayHeader)) { + return FORMAT_INVALID; + } + + const BMP_IMAGE_HEADER *bhdr = buf; + if (bhdr->CharB == 'B' && bhdr->CharM == 'M' && + bhdr->Planes == 1 && + (bhdr->CompressionType == 0 || bhdr->CompressionType == 1) && + (bhdr->BitPerPixel == 1 || bhdr->BitPerPixel == 4 || + bhdr->BitPerPixel == 8 || bhdr->BitPerPixel == 24)) { + if (info) { + info->format = FORMAT_BMP; + info->width = bhdr->PixelWidth; + info->height = bhdr->PixelHeight; + } + return FORMAT_BMP; + } + + const FontArrayHeader *fhdr = buf; + if (0 == memcmp(&fhdr->signature, FONT_SIGNATURE, FONT_SIGNATURE_SIZE) && + fhdr->num_entries > 0) { + if (info) + info->format = FORMAT_FONT; + return FORMAT_FONT; + } + + return FORMAT_BMP; +} + + |