crossystem_arch.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. *
  5. * Architecture-specific APIs for crossystem
  6. */
  7. #ifndef VBOOT_REFERENCE_CROSSYSTEM_ARCH_H_
  8. #define VBOOT_REFERENCE_CROSSYSTEM_ARCH_H_
  9. #include <stddef.h>
  10. #include "vboot_nvstorage.h"
  11. #include "vboot_struct.h"
  12. /* Firmware types from BINF.3. Placed in the common file because both x86 and
  13. * arm use this. The constants are defined in "Chrome OS Main Processor
  14. * Firmware Spec"
  15. */
  16. #define BINF3_RECOVERY 0
  17. #define BINF3_NORMAL 1
  18. #define BINF3_DEVELOPER 2
  19. #define BINF3_NETBOOT 3
  20. /* INTERNAL APIS FOR CROSSYSTEM AVAILABLE TO ARCH-SPECIFIC FUNCTIONS */
  21. /* Read an integer property from VbNvStorage.
  22. *
  23. * Returns the parameter value, or -1 if error. */
  24. int VbGetNvStorage(VbNvParam param);
  25. /* Write an integer property to VbNvStorage.
  26. *
  27. * Returns 0 if success, -1 if error. */
  28. int VbSetNvStorage(VbNvParam param, int value);
  29. /* Return true if the FWID starts with the specified string. */
  30. int FwidStartsWith(const char *start);
  31. /* Return version of VbSharedData struct or -1 if not found. */
  32. int VbSharedDataVersion(void);
  33. /* Apis WITH ARCH-SPECIFIC IMPLEMENTATIONS */
  34. /* Read the non-volatile context from NVRAM.
  35. *
  36. * Returns 0 if success, -1 if error. */
  37. int VbReadNvStorage(VbNvContext* vnc);
  38. /* Write the non-volatile context to NVRAM.
  39. *
  40. * Returns 0 if success, -1 if error. */
  41. int VbWriteNvStorage(VbNvContext* vnc);
  42. /* Read the VbSharedData buffer.
  43. *
  44. * Verifies the buffer contains at least enough data for the
  45. * VbSharedDataHeader; if not, this is an error.
  46. *
  47. * If less data is read than expected, sets the returned structure's data_size
  48. * to the actual amount of data read. If this is less than data_used, then
  49. * some data was not returned; callers must handle this; this is not considered
  50. * an error.
  51. *
  52. * Returns the data buffer, which must be freed by the caller using
  53. * free(), or NULL if error. */
  54. VbSharedDataHeader* VbSharedDataRead(void);
  55. /* Read an architecture-specific system property integer.
  56. *
  57. * Returns the property value, or -1 if error. */
  58. int VbGetArchPropertyInt(const char* name);
  59. /* Read an architecture-specific system property string into a
  60. * destination buffer of the specified size. Returned string will be
  61. * null-terminated. If the buffer is too small, the returned string
  62. * will be truncated.
  63. *
  64. * Returns the passed buffer, or NULL if error. */
  65. const char* VbGetArchPropertyString(const char* name, char* dest, size_t size);
  66. /* Set an architecture-specific system property integer.
  67. *
  68. * Returns 0 if success, -1 if error. */
  69. int VbSetArchPropertyInt(const char* name, int value);
  70. /* Set an architecture-specific system property string.
  71. *
  72. * Returns 0 if success, -1 if error. */
  73. int VbSetArchPropertyString(const char* name, const char* value);
  74. #endif /* VBOOT_REFERENCE__CROSSYSTEM_ARCH_H_ */