Decompress images in vboot wrapper, not in BIOS.

The vboot library needs to decompress the images so that it can handle those
that are special cases (like rendering the HWID). This means that 1) it
needs access to the BIOS' native decompression routine, and 2) that
VbExDisplayImage() only needs to handle the uncompressed native-format image
and doesn't need to know about how the image is packed in the GBB.

BUG=chromium-os:19134
TEST=manual

This requires a change to vboot_api.h, which requires a (simultaneous)
matching change to the BIOS, at least for U-Boot, which builds separately.
I've made that change and run the "vbexport_test display" command from the
modified U-Boot, but that also requires a change to the way U-Boot is built
so that I can get at the U-Boot commandline.

Change-Id: I449fb467cd3a68e742f27ec41b95d52685459d89
Reviewed-on: http://gerrit.chromium.org/gerrit/6129
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Bill Richardson
2011-08-16 17:38:58 -07:00
parent 49446d8489
commit b1c85a8442
3 changed files with 49 additions and 16 deletions

View File

@@ -506,14 +506,14 @@ VbError_t VbExDisplayBacklight(uint8_t enable);
VbError_t VbExDisplayScreen(uint32_t screen_type); VbError_t VbExDisplayScreen(uint32_t screen_type);
/* Write an image to the display, with the upper left corner at the /* Write an image to the display, with the upper left corner at the specified
* specified pixel coordinates. The bitmap buffer is a * pixel coordinates. The bitmap buffer is a pointer to the platform-dependent
* platform-dependent binary blob with size specified by * uncompressed binary blob with dimensions and format specified internally
* info->compressed_size. */ * (for example, a raw BMP, GIF, PNG, whatever). We pass the size just for
// TODO: I don't like passing an ImageInfo directly to the underlying firmware; * convenience.
// should pass a struct defined in THIS header file, or individual params. */
VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo* info, VbError_t VbExDisplayImage(uint32_t x, uint32_t y,
const void* buffer); void* buffer, uint32_t buffersize);
/* Display a string containing debug information on the screen, /* Display a string containing debug information on the screen,
* rendered in a platform-dependent font. Should be able to handle * rendered in a platform-dependent font. Should be able to handle
@@ -527,7 +527,7 @@ VbError_t VbExDisplayDebugInfo(const char* info_str);
* (CMOS breadcrumbs) is platform-specific. If we decide to * (CMOS breadcrumbs) is platform-specific. If we decide to
* soft-render the HWID string (chrome-os-partner:3693), we'll need to * soft-render the HWID string (chrome-os-partner:3693), we'll need to
* maintain our own fonts, so we'll likely display it via * maintain our own fonts, so we'll likely display it via
* VbExDisplayBitmap() above. */ * VbExDisplayImage() above. */
/*****************************************************************************/ /*****************************************************************************/
@@ -580,4 +580,14 @@ uint32_t VbExKeyboardRead(void);
* control loop so this can occur cleanly. */ * control loop so this can occur cleanly. */
uint32_t VbExIsShutdownRequested(void); uint32_t VbExIsShutdownRequested(void);
/* Expose the BIOS' built-in decompression routine to the vboot wrapper. The
* caller must know how large the uncompressed data will be and must manage
* that memory. The decompression routine just puts the uncompressed data into
* the specified buffer. We pass in the size of the outbuf, and get back the
* actual size used.
*/
VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
uint32_t compression_type,
void *outbuf, uint32_t *out_size);
#endif /* VBOOT_REFERENCE_VBOOT_API_H_ */ #endif /* VBOOT_REFERENCE_VBOOT_API_H_ */

View File

@@ -71,13 +71,14 @@ static VbError_t VbDisplayScreenFromGBB(VbCommonParams* cparams,
uint32_t screen) { uint32_t screen) {
GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)cparams->gbb_data; GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)cparams->gbb_data;
uint8_t* bmpfv = NULL; uint8_t* bmpfv = NULL;
uint8_t* fullimage = NULL;
BmpBlockHeader* hdr; BmpBlockHeader* hdr;
ScreenLayout* layout; ScreenLayout* layout;
ImageInfo* image_info; ImageInfo* image_info;
uint32_t screen_index; uint32_t screen_index;
uint32_t localization = 0; uint32_t localization = 0;
VbError_t retval = VBERROR_UNKNOWN; /* Assume error until proven VbError_t retval = VBERROR_UNKNOWN; /* Assume error until proven ok */
* successful */ uint32_t inoutsize;
uint32_t offset; uint32_t offset;
uint32_t i; uint32_t i;
@@ -165,9 +166,25 @@ static VbError_t VbDisplayScreenFromGBB(VbCommonParams* cparams,
layout->images[i].x, layout->images[i].y, layout->images[i].x, layout->images[i].y,
image_info->compressed_size, image_info->original_size, image_info->compressed_size, image_info->original_size,
image_info->tag, offset)); image_info->tag, offset));
if (COMPRESS_NONE != image_info->compression) {
retval = VbExDisplayImage(layout->images[i].x, layout->images[i].y, inoutsize = image_info->original_size;
image_info, bmpfv + offset + sizeof(ImageInfo)); fullimage = (uint8_t*)VbExMalloc(inoutsize);
retval = VbExDecompress(bmpfv + offset + sizeof(ImageInfo),
image_info->compressed_size,
image_info->compression,
fullimage, &inoutsize);
if (VBERROR_SUCCESS != retval) {
VbExFree(fullimage);
goto VbDisplayScreenFromGBB_exit;
}
retval = VbExDisplayImage(layout->images[i].x, layout->images[i].y,
fullimage, inoutsize);
VbExFree(fullimage);
} else {
retval = VbExDisplayImage(layout->images[i].x, layout->images[i].y,
bmpfv + offset + sizeof(ImageInfo),
image_info->original_size);
}
if (VBERROR_SUCCESS != retval) if (VBERROR_SUCCESS != retval)
goto VbDisplayScreenFromGBB_exit; goto VbDisplayScreenFromGBB_exit;
} }

View File

@@ -99,8 +99,8 @@ VbError_t VbExDisplayScreen(uint32_t screen_type) {
} }
VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo* info, VbError_t VbExDisplayImage(uint32_t x, uint32_t y,
const void* buffer) { void* buffer, uint32_t buffersize) {
return VBERROR_SUCCESS; return VBERROR_SUCCESS;
} }
@@ -118,3 +118,9 @@ uint32_t VbExKeyboardRead(void) {
uint32_t VbExIsShutdownRequested(void) { uint32_t VbExIsShutdownRequested(void) {
return 0; return 0;
} }
VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
uint32_t compression_type,
void *outbuf, uint32_t *out_size) {
return VBERROR_SUCCESS;
}