Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * vpd_decode.h
0004  *
0005  * Google VPD decoding routines.
0006  *
0007  * Copyright 2017 Google Inc.
0008  */
0009 
0010 #ifndef __VPD_DECODE_H
0011 #define __VPD_DECODE_H
0012 
0013 #include <linux/types.h>
0014 
0015 enum {
0016     VPD_OK = 0,
0017     VPD_FAIL,
0018 };
0019 
0020 enum {
0021     VPD_TYPE_TERMINATOR = 0,
0022     VPD_TYPE_STRING,
0023     VPD_TYPE_INFO                = 0xfe,
0024     VPD_TYPE_IMPLICIT_TERMINATOR = 0xff,
0025 };
0026 
0027 /* Callback for vpd_decode_string to invoke. */
0028 typedef int vpd_decode_callback(const u8 *key, u32 key_len,
0029                 const u8 *value, u32 value_len,
0030                 void *arg);
0031 
0032 /*
0033  * vpd_decode_string
0034  *
0035  * Given the encoded string, this function invokes callback with extracted
0036  * (key, value). The *consumed will be plused the number of bytes consumed in
0037  * this function.
0038  *
0039  * The input_buf points to the first byte of the input buffer.
0040  *
0041  * The *consumed starts from 0, which is actually the next byte to be decoded.
0042  * It can be non-zero to be used in multiple calls.
0043  *
0044  * If one entry is successfully decoded, sends it to callback and returns the
0045  * result.
0046  */
0047 int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
0048               vpd_decode_callback callback, void *callback_arg);
0049 
0050 #endif  /* __VPD_DECODE_H */