nvram.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2019-2020 Alibaba Group Holding Limited
  3. */
  4. #ifndef YOC_NVRAM_H
  5. #define YOC_NVRAM_H
  6. #include <stdint.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /**
  11. * This function will init nvram.
  12. *
  13. * @param[in] pathname the data pair of the key, less than 64 bytes
  14. * @return 0 on success, negative error on failure.
  15. */
  16. int nvram_init(const char *pathname);
  17. /**
  18. * This function will reset nvram, clear all data.
  19. *
  20. * @return 0 on success, negative error on failure.
  21. */
  22. int nvram_reset();
  23. /**
  24. * This function will get data from the factory setting area.
  25. *
  26. * @param[in] key the data pair of the key, less than 64 bytes
  27. * @param[in] len the length of the buffer
  28. * @param[out] value the buffer that will store the data
  29. * @return the length of the data value, error code otherwise
  30. */
  31. int nvram_get_val(const char *key, char *value, int len);
  32. /**
  33. * This function will set data to the factory setting area.
  34. *
  35. * @param[in] key the data pair of the key, less than 64 bytes
  36. * @param[in] value the data pair of the value, delete the pair if value == NULL
  37. * @return 0 on success, negative error on failure.
  38. */
  39. int nvram_set_val(const char *key, char *value);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif