vpd_decode.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef __VPD_DECODE_H
  10. #define __VPD_DECODE_H
  11. #include <linux/types.h>
  12. enum {
  13. VPD_OK = 0,
  14. VPD_FAIL,
  15. };
  16. enum {
  17. VPD_TYPE_TERMINATOR = 0,
  18. VPD_TYPE_STRING,
  19. VPD_TYPE_INFO = 0xfe,
  20. VPD_TYPE_IMPLICIT_TERMINATOR = 0xff,
  21. };
  22. /* Callback for vpd_decode_string to invoke. */
  23. typedef int vpd_decode_callback(const u8 *key, u32 key_len,
  24. const u8 *value, u32 value_len,
  25. void *arg);
  26. /*
  27. * vpd_decode_string
  28. *
  29. * Given the encoded string, this function invokes callback with extracted
  30. * (key, value). The *consumed will be plused the number of bytes consumed in
  31. * this function.
  32. *
  33. * The input_buf points to the first byte of the input buffer.
  34. *
  35. * The *consumed starts from 0, which is actually the next byte to be decoded.
  36. * It can be non-zero to be used in multiple calls.
  37. *
  38. * If one entry is successfully decoded, sends it to callback and returns the
  39. * result.
  40. */
  41. int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
  42. vpd_decode_callback callback, void *callback_arg);
  43. #endif /* __VPD_DECODE_H */