1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * vpd_decode.h
4 *
5 * Google VPD decoding routines.
6 *
7 * Copyright 2017 Google Inc.
8 */
9
10#ifndef __VPD_DECODE_H
11#define __VPD_DECODE_H
12
13#include <linux/types.h>
14
15enum {
16 VPD_OK = 0,
17 VPD_FAIL,
18};
19
20enum {
21 VPD_TYPE_TERMINATOR = 0,
22 VPD_TYPE_STRING,
23 VPD_TYPE_INFO = 0xfe,
24 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff,
25};
26
27/* Callback for vpd_decode_string to invoke. */
28typedef int vpd_decode_callback(const u8 *key, u32 key_len,
29 const u8 *value, u32 value_len,
30 void *arg);
31
32/*
33 * vpd_decode_string
34 *
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.
38 *
39 * The input_buf points to the first byte of the input buffer.
40 *
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.
43 *
44 * If one entry is successfully decoded, sends it to callback and returns the
45 * result.
46 */
47int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
48 vpd_decode_callback callback, void *callback_arg);
49
50#endif /* __VPD_DECODE_H */
51

source code of linux/drivers/firmware/google/vpd_decode.h