WIP FPC-III support
[linux/fpc-iii.git] / drivers / firmware / google / vpd_decode.h
blob8dbe41cac599b14b094a37d409a4a9c8d3660816
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * vpd_decode.h
5 * Google VPD decoding routines.
7 * Copyright 2017 Google Inc.
8 */
10 #ifndef __VPD_DECODE_H
11 #define __VPD_DECODE_H
13 #include <linux/types.h>
15 enum {
16 VPD_OK = 0,
17 VPD_FAIL,
20 enum {
21 VPD_TYPE_TERMINATOR = 0,
22 VPD_TYPE_STRING,
23 VPD_TYPE_INFO = 0xfe,
24 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff,
27 /* Callback for vpd_decode_string to invoke. */
28 typedef int vpd_decode_callback(const u8 *key, u32 key_len,
29 const u8 *value, u32 value_len,
30 void *arg);
33 * vpd_decode_string
35 * Given the encoded string, this function invokes callback with extracted
36 * (key, value). The *consumed will be plused the number of bytes consumed in
37 * this function.
39 * The input_buf points to the first byte of the input buffer.
41 * The *consumed starts from 0, which is actually the next byte to be decoded.
42 * It can be non-zero to be used in multiple calls.
44 * If one entry is successfully decoded, sends it to callback and returns the
45 * result.
47 int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
48 vpd_decode_callback callback, void *callback_arg);
50 #endif /* __VPD_DECODE_H */