1 /* 2 * vpd_decode.h 3 * 4 * Google VPD decoding routines. 5 * 6 * Copyright 2017 Google Inc. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License v2.0 as published by 10 * the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 */ 17 18 #ifndef __VPD_DECODE_H 19 #define __VPD_DECODE_H 20 21 #include <linux/types.h> 22 23 enum { 24 VPD_OK = 0, 25 VPD_FAIL, 26 }; 27 28 enum { 29 VPD_TYPE_TERMINATOR = 0, 30 VPD_TYPE_STRING, 31 VPD_TYPE_INFO = 0xfe, 32 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff, 33 }; 34 35 /* Callback for vpd_decode_string to invoke. */ 36 typedef int vpd_decode_callback(const u8 *key, s32 key_len, 37 const u8 *value, s32 value_len, 38 void *arg); 39 40 /* 41 * vpd_decode_string 42 * 43 * Given the encoded string, this function invokes callback with extracted 44 * (key, value). The *consumed will be plused the number of bytes consumed in 45 * this function. 46 * 47 * The input_buf points to the first byte of the input buffer. 48 * 49 * The *consumed starts from 0, which is actually the next byte to be decoded. 50 * It can be non-zero to be used in multiple calls. 51 * 52 * If one entry is successfully decoded, sends it to callback and returns the 53 * result. 54 */ 55 int vpd_decode_string(const s32 max_len, const u8 *input_buf, s32 *consumed, 56 vpd_decode_callback callback, void *callback_arg); 57 58 #endif /* __VPD_DECODE_H */ 59