diff options
-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; +} |