diff options
author | Bill Richardson <wfrichar@chromium.org> | 2011-08-16 17:38:58 -0700 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2011-08-17 13:37:08 -0700 |
commit | b1c85a8442fd2d8e05705cdcadfa40865e952975 (patch) | |
tree | bd7ff9c5ff0017b793857eaaacb18ffa57d03af1 | |
parent | 49446d8489acfd01c642568d5af6e4b36f5a0fef (diff) | |
download | vboot-b1c85a8442fd2d8e05705cdcadfa40865e952975.tar.gz |
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>
-rw-r--r-- | firmware/include/vboot_api.h | 28 | ||||
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 27 | ||||
-rw-r--r-- | firmware/stub/vboot_api_stub.c | 10 |
3 files changed, 49 insertions, 16 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 79a461bf..c468868f 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -506,14 +506,14 @@ VbError_t VbExDisplayBacklight(uint8_t enable); VbError_t VbExDisplayScreen(uint32_t screen_type); -/* Write an image to the display, with the upper left corner at the - * specified pixel coordinates. The bitmap buffer is a - * platform-dependent binary blob with size specified by - * info->compressed_size. */ -// TODO: I don't like passing an ImageInfo directly to the underlying firmware; -// should pass a struct defined in THIS header file, or individual params. -VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo* info, - const void* buffer); +/* Write an image to the display, with the upper left corner at the specified + * pixel coordinates. The bitmap buffer is a pointer to the platform-dependent + * uncompressed binary blob with dimensions and format specified internally + * (for example, a raw BMP, GIF, PNG, whatever). We pass the size just for + * convenience. + */ +VbError_t VbExDisplayImage(uint32_t x, uint32_t y, + void* buffer, uint32_t buffersize); /* Display a string containing debug information on the screen, * 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 * soft-render the HWID string (chrome-os-partner:3693), we'll need to * 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. */ 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_ */ diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 61cbb910..e1fce4fd 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -71,13 +71,14 @@ static VbError_t VbDisplayScreenFromGBB(VbCommonParams* cparams, uint32_t screen) { GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)cparams->gbb_data; uint8_t* bmpfv = NULL; + uint8_t* fullimage = NULL; BmpBlockHeader* hdr; ScreenLayout* layout; ImageInfo* image_info; uint32_t screen_index; uint32_t localization = 0; - VbError_t retval = VBERROR_UNKNOWN; /* Assume error until proven - * successful */ + VbError_t retval = VBERROR_UNKNOWN; /* Assume error until proven ok */ + uint32_t inoutsize; uint32_t offset; uint32_t i; @@ -165,9 +166,25 @@ static VbError_t VbDisplayScreenFromGBB(VbCommonParams* cparams, layout->images[i].x, layout->images[i].y, image_info->compressed_size, image_info->original_size, image_info->tag, offset)); - - retval = VbExDisplayImage(layout->images[i].x, layout->images[i].y, - image_info, bmpfv + offset + sizeof(ImageInfo)); + if (COMPRESS_NONE != image_info->compression) { + inoutsize = image_info->original_size; + 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) goto VbDisplayScreenFromGBB_exit; } diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c index 5cd0ad3c..80368300 100644 --- a/firmware/stub/vboot_api_stub.c +++ b/firmware/stub/vboot_api_stub.c @@ -99,8 +99,8 @@ VbError_t VbExDisplayScreen(uint32_t screen_type) { } -VbError_t VbExDisplayImage(uint32_t x, uint32_t y, const ImageInfo* info, - const void* buffer) { +VbError_t VbExDisplayImage(uint32_t x, uint32_t y, + void* buffer, uint32_t buffersize) { return VBERROR_SUCCESS; } @@ -118,3 +118,9 @@ uint32_t VbExKeyboardRead(void) { uint32_t VbExIsShutdownRequested(void) { return 0; } + +VbError_t VbExDecompress(void *inbuf, uint32_t in_size, + uint32_t compression_type, + void *outbuf, uint32_t *out_size) { + return VBERROR_SUCCESS; +} |