diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2018-03-08 15:43:12 +0100 |
---|---|---|
committer | Philipp Deppenwiese <zaolin.daisuki@gmail.com> | 2018-09-09 17:51:37 +0000 |
commit | 28cee59ca294422056d983fc06d5d8d5800a4390 (patch) | |
tree | 2dab3f2423f474a9075dc9c9d56ad997d6c4ed77 /src/vendorcode/google/chromeos/vpd_decode.c | |
parent | c4b0fd0a86db280ad1a8d8572218dc42fd5bb7e4 (diff) | |
download | coreboot-28cee59ca294422056d983fc06d5d8d5800a4390.tar.xz |
drivers/vpd: Add VPD support
VPD reference: https://chromium.googlesource.com/chromiumos/platform/vpd/+/master/README.md
Copy ChromeOS VPD driver to add support for VPD without CROMEOS.
Possible use case:
* Storing calibration data
* Storing MAC address
* Storing serial
* Storing boot options
+ Now it's possible to define the VPD space by choosing
one of the following enums: VPD_ANY, VPD_RW, VPD_RO.
+ CHROMEOS selects now VPD as part of it.
+ VPD is implemented as driver.
Change-Id: Id9263bd39bf25d024e93daa57053fefcb1adc53a
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25046
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/vendorcode/google/chromeos/vpd_decode.c')
-rw-r--r-- | src/vendorcode/google/chromeos/vpd_decode.c | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/vendorcode/google/chromeos/vpd_decode.c b/src/vendorcode/google/chromeos/vpd_decode.c deleted file mode 100644 index 545fd8106f..0000000000 --- a/src/vendorcode/google/chromeos/vpd_decode.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - */ -#include <assert.h> -#include "lib_vpd.h" - -int decodeLen( - const int32_t max_len, - const uint8_t *in, - int32_t *length, - int32_t *decoded_len) { - uint8_t more; - int i = 0; - - assert(length); - assert(decoded_len); - - *length = 0; - do { - if (i >= max_len) return VPD_FAIL; - more = in[i] & 0x80; - *length <<= 7; - *length |= in[i] & 0x7f; - ++i; - } while (more); - - *decoded_len = i; - - return VPD_OK; -} - -/* Sequentially decodes type, key, and value. - */ -int decodeVpdString( - const int32_t max_len, - const uint8_t *input_buf, - int32_t *consumed, - VpdDecodeCallback callback, - void *callback_arg) { - int type; - int32_t key_len, value_len; - int32_t decoded_len; - const uint8_t *key, *value; - - /* type */ - if (*consumed >= max_len) - return VPD_FAIL; - - type = input_buf[*consumed]; - switch (type) { - case VPD_TYPE_INFO: - case VPD_TYPE_STRING: - (*consumed)++; - - /* key */ - if (VPD_OK != decodeLen(max_len - *consumed, &input_buf[*consumed], - &key_len, &decoded_len) || - *consumed + decoded_len >= max_len) { - return VPD_FAIL; - } - - *consumed += decoded_len; - key = &input_buf[*consumed]; - *consumed += key_len; - - /* value */ - if (VPD_OK != decodeLen(max_len - *consumed, &input_buf[*consumed], - &value_len, &decoded_len) || - *consumed + decoded_len > max_len) { - return VPD_FAIL; - } - *consumed += decoded_len; - value = &input_buf[*consumed]; - *consumed += value_len; - - if (type == VPD_TYPE_STRING) - return callback(key, key_len, value, value_len, callback_arg); - - return VPD_OK; - - default: - return VPD_FAIL; - break; - } - return VPD_OK; -} |