vboot_api_stub.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* Copyright (c) 2013 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. * Stub implementations of firmware-provided API functions.
  6. */
  7. #include <stdint.h>
  8. #include <stdarg.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <sys/time.h>
  13. #include "vboot_api.h"
  14. static enum VbEcBootMode_t vboot_mode;
  15. void VbExSleepMs(uint32_t msec)
  16. {
  17. }
  18. VbError_t VbExBeep(uint32_t msec, uint32_t frequency)
  19. {
  20. return VBERROR_SUCCESS;
  21. }
  22. VbError_t VbExDisplayInit(uint32_t *width, uint32_t *height)
  23. {
  24. return VBERROR_SUCCESS;
  25. }
  26. VbError_t VbExDisplayBacklight(uint8_t enable)
  27. {
  28. return VBERROR_SUCCESS;
  29. }
  30. VbError_t VbExDisplaySetDimension(uint32_t width, uint32_t height)
  31. {
  32. return VBERROR_SUCCESS;
  33. }
  34. VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale)
  35. {
  36. return VBERROR_SUCCESS;
  37. }
  38. VbError_t VbExDisplayImage(uint32_t x, uint32_t y,
  39. void *buffer, uint32_t buffersize)
  40. {
  41. return VBERROR_SUCCESS;
  42. }
  43. VbError_t VbExDisplayText(uint32_t x, uint32_t y,
  44. const char *info_str)
  45. {
  46. return VBERROR_SUCCESS;
  47. }
  48. VbError_t VbExDisplayDebugInfo(const char *info_str)
  49. {
  50. return VBERROR_SUCCESS;
  51. }
  52. uint32_t VbExKeyboardRead(void)
  53. {
  54. return 0;
  55. }
  56. uint32_t VbExKeyboardReadWithFlags(uint32_t *flags_ptr)
  57. {
  58. return 0;
  59. }
  60. uint32_t VbExGetSwitches(uint32_t mask)
  61. {
  62. return 0;
  63. }
  64. uint32_t VbExIsShutdownRequested(void)
  65. {
  66. return 0;
  67. }
  68. VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
  69. uint32_t compression_type,
  70. void *outbuf, uint32_t *out_size)
  71. {
  72. return VBERROR_SUCCESS;
  73. }
  74. int VbExTrustEC(int devidx)
  75. {
  76. return 1;
  77. }
  78. VbError_t VbExEcRunningRW(int devidx, int *in_rw)
  79. {
  80. *in_rw = 0;
  81. return VBERROR_SUCCESS;
  82. }
  83. VbError_t VbExEcJumpToRW(int devidx)
  84. {
  85. return VBERROR_SUCCESS;
  86. }
  87. VbError_t VbExEcRebootToRO(int devidx)
  88. {
  89. /* Nothing to reboot, so all we can do is return failure. */
  90. return VBERROR_UNKNOWN;
  91. }
  92. VbError_t VbExEcDisableJump(int devidx)
  93. {
  94. return VBERROR_SUCCESS;
  95. }
  96. #define SHA256_HASH_SIZE 32
  97. VbError_t VbExEcHashImage(int devidx, enum VbSelectFirmware_t select,
  98. const uint8_t **hash, int *hash_size)
  99. {
  100. static const uint8_t fake_hash[32] = {1, 2, 3, 4};
  101. *hash = fake_hash;
  102. *hash_size = sizeof(fake_hash);
  103. return VBERROR_SUCCESS;
  104. }
  105. VbError_t VbExEcGetExpectedImage(int devidx, enum VbSelectFirmware_t select,
  106. const uint8_t **image, int *image_size)
  107. {
  108. static uint8_t fake_image[64] = {5, 6, 7, 8};
  109. *image = fake_image;
  110. *image_size = sizeof(fake_image);
  111. return VBERROR_SUCCESS;
  112. }
  113. VbError_t VbExEcGetExpectedImageHash(int devidx, enum VbSelectFirmware_t select,
  114. const uint8_t **hash, int *hash_size)
  115. {
  116. static const uint8_t fake_hash[32] = {1, 2, 3, 4};
  117. *hash = fake_hash;
  118. *hash_size = sizeof(fake_hash);
  119. return VBERROR_SUCCESS;
  120. }
  121. VbError_t VbExEcUpdateImage(int devidx, enum VbSelectFirmware_t select,
  122. const uint8_t *image, int image_size)
  123. {
  124. return VBERROR_SUCCESS;
  125. }
  126. VbError_t VbExEcProtect(int devidx, enum VbSelectFirmware_t select)
  127. {
  128. return VBERROR_SUCCESS;
  129. }
  130. VbError_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode)
  131. {
  132. vboot_mode = mode;
  133. return VBERROR_SUCCESS;
  134. }
  135. VbError_t VbExEcVbootDone(int in_recovery)
  136. {
  137. return VBERROR_SUCCESS;
  138. }
  139. VbError_t VbExEcBatteryCutOff(void)
  140. {
  141. return VBERROR_SUCCESS;
  142. }
  143. enum VbEcBootMode_t VbGetMode(void)
  144. {
  145. return vboot_mode;
  146. }
  147. int VbExLegacy(void)
  148. {
  149. return 1;
  150. }
  151. uint8_t VbExOverrideGptEntryPriority(const GptEntry *e)
  152. {
  153. return 0;
  154. }