diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-03-28 22:13:29 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-04-22 08:52:35 +0200 |
commit | 65f08d50ae6b7e91aec58ef3d050a336386130dc (patch) | |
tree | d6eedc583352c60e78c49eaa64a3da29958b578b /src/vendorcode | |
parent | 11ecdb75374c09b5fea69e55ef53dd5e0f789d93 (diff) |
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@chromium.org>
Original-Commit-Id: c2ae38ded24394e0640b5d077e2231cf956397c5
Original-Change-Id: If8a7d0883ea8bb21a13bf203b25ee9f8a08903a9
Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/262842
Reviewed-on: http://review.coreboot.org/9895
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/vendorcode')
-rw-r--r-- | src/vendorcode/google/chromeos/vpd_calibration.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/vendorcode/google/chromeos/vpd_calibration.c b/src/vendorcode/google/chromeos/vpd_calibration.c index 3bfd843db0..2f14fd924e 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); |