[coreboot-gerrit] Patch set updated for coreboot: e66f6d6 vpd: decode calibration data into binary

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Tue Apr 21 11:18:04 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9895

-gerrit

commit e66f6d67fcc3863c53467e75e20adb36c82bbdc7
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Sat Mar 28 22:13:29 2015 -0700

    vpd: decode calibration data into binary
    
    The preferred way of communicating WiFi calibration data to the kernel
    is binary blob. But this data is stored in the VPD, and must be in
    ASCII, so it is encoded using base64.
    
    With the recent addition of the bas64 decoder it is possible to
    convert the VPD representation to the form preferred by the kernel.
    
    BRANCH=none
    BUG=chromium:450169
    TEST=with the rest of the patches applied verified that on both storm
         and urara the device tree contains the required binary data.
    
    Change-Id: I89da94bb425767eedc5e2d576e507663afad65ed
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: c2ae38ded24394e0640b5d077e2231cf956397c5
    Original-Change-Id: If8a7d0883ea8bb21a13bf203b25ee9f8a08903a9
    Original-Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/262842
---
 src/vendorcode/google/chromeos/vpd_calibration.c | 28 +++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/vendorcode/google/chromeos/vpd_calibration.c b/src/vendorcode/google/chromeos/vpd_calibration.c
index 3bfd843..2f14fd9 100644
--- a/src/vendorcode/google/chromeos/vpd_calibration.c
+++ b/src/vendorcode/google/chromeos/vpd_calibration.c
@@ -17,6 +17,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <b64_decode.h>
 #include <cbmem.h>
 #include <console/console.h>
 #include <string.h>
@@ -71,7 +72,7 @@ struct calibration_entry {
 struct vpd_blob_cache_t {
 	/* The longest name template must fit with an extra character. */
 	char key_name[40];
-	const void  *value_pointer;
+	void  *value_pointer;
 	unsigned blob_size;
 	unsigned key_size;
 	unsigned value_size;
@@ -108,7 +109,9 @@ static size_t fill_up_entries_cache(struct vpd_blob_cache_t *cache,
 
 		for (j = 0; j < MAX_WIFI_INTERFACE_COUNT; j++) {
 			const void *payload;
+			void *decoded_payload;
 			int payload_size;
+			size_t decoded_size;
 
 			strcpy(cache->key_name, templates[i]);
 			cache->key_name[index_location] = j + '0';
@@ -117,9 +120,27 @@ static size_t fill_up_entries_cache(struct vpd_blob_cache_t *cache,
 			if (!payload)
 				continue;
 
-			cache->value_pointer = payload;
+			decoded_size = B64_DECODED_SIZE(payload_size);
+			decoded_payload = malloc(decoded_size);
+			if (!decoded_payload) {
+				printk(BIOS_ERR,
+				       "%s: failed allocating %zd bytes\n",
+				       __func__, decoded_size);
+				continue;
+			}
+
+			decoded_size = b64_decode(payload, payload_size,
+						  decoded_payload);
+			if (!decoded_size) {
+				free(decoded_payload);
+				printk(BIOS_ERR, "%s: failed decoding %s\n",
+				       __func__, cache->key_name);
+				continue;
+			}
+
+			cache->value_pointer = decoded_payload;
 			cache->key_size = key_length;
-			cache->value_size = payload_size;
+			cache->value_size = decoded_size;
 			cache->blob_size =
 				ALIGN(sizeof(struct calibration_blob) +
 				      cache->key_size +
@@ -187,6 +208,7 @@ void cbmem_add_vpd_calibration_data(void)
 		/* and the value */
 		pointer += cache->key_size;
 		memcpy(pointer, cache->value_pointer, cache->value_size);
+		free(cache->value_pointer);
 
 		printk(BIOS_INFO, "%s: added %s to CBMEM\n",
 		       __func__, cache->key_name);



More information about the coreboot-gerrit mailing list