0007-vboot-Display-callbacks-for-developer-and-recovery-m.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. From 541a3f09ecb062e3f0778eb9846732cfabcbfbba Mon Sep 17 00:00:00 2001
  2. From: Paul Kocialkowski <contact@paulk.fr>
  3. Date: Tue, 11 Aug 2015 11:22:54 +0200
  4. Subject: [PATCH 7/7] vboot: Display callbacks for developer and recovery mode
  5. screens
  6. We don't want to use bitmaps stored in GBB since they recommend the use of non-
  7. free software (Chrome OS), so this implements a text-based interface instead.
  8. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
  9. ---
  10. src/vboot/callbacks/display.c | 168 +++++++++++++++++++++++++++++++++++++++---
  11. 1 file changed, 156 insertions(+), 12 deletions(-)
  12. diff --git a/src/vboot/callbacks/display.c b/src/vboot/callbacks/display.c
  13. index efa0691..b659f7b 100644
  14. --- a/src/vboot/callbacks/display.c
  15. +++ b/src/vboot/callbacks/display.c
  16. @@ -84,9 +84,17 @@ void print_on_center(const char *msg)
  17. print_string(msg);
  18. }
  19. -VbError_t VbExDisplayScreen(uint32_t screen_type)
  20. +VbError_t VbExDisplayScreen(uint32_t screen_type, VbNvContext *vnc)
  21. {
  22. - const char *msg = NULL;
  23. + unsigned int rows, cols;
  24. + uint32_t boot_signed_only = 0;
  25. + uint32_t boot_usb = 0;
  26. + uint32_t boot_legacy = 0;
  27. + const char *fw_id;
  28. + int fw_index;
  29. + void *blob = NULL;
  30. + int size = 0;
  31. + char *msg;
  32. /*
  33. * Show the debug messages for development. It is a backup method
  34. @@ -98,31 +106,167 @@ VbError_t VbExDisplayScreen(uint32_t screen_type)
  35. video_console_clear();
  36. break;
  37. case VB_SCREEN_DEVELOPER_WARNING:
  38. - msg = "developer mode warning";
  39. + video_console_clear();
  40. + video_console_set_cursor(0, 0);
  41. +
  42. + if (vnc != NULL) {
  43. + VbNvGet(vnc, VBNV_DEV_BOOT_SIGNED_ONLY,
  44. + &boot_signed_only);
  45. +
  46. + VbNvGet(vnc, VBNV_DEV_BOOT_USB, &boot_usb);
  47. + VbNvGet(vnc, VBNV_DEV_BOOT_LEGACY, &boot_legacy);
  48. + }
  49. +
  50. + print_string(
  51. + "Welcome to developer mode!\n\n"
  52. + "Useful key combinations:\n"
  53. + "- Ctrl + H: Hold developer mode\n"
  54. + "- Ctrl + D: Boot from internal storage\n");
  55. +
  56. + if (boot_usb)
  57. + print_string("- Ctrl + U: Boot from external media\n");
  58. +
  59. + if (boot_legacy)
  60. + print_string("- Ctrl + L: Boot from legacy payload\n");
  61. +
  62. + print_string(
  63. + "- Ctrl + I: Show device information\n"
  64. + "- Space: Disable developer mode\n\n"
  65. + "This screen is shown for 3 seconds (if not held)."
  66. + "\n\n");
  67. +
  68. + if (vnc != NULL) {
  69. + if (!boot_signed_only)
  70. + print_string(
  71. + "Warning: this device will boot kernels"
  72. + " without verifying their signature!"
  73. + "\n");
  74. +
  75. + if (boot_usb)
  76. + print_string(
  77. + "Warning: this device will boot from "
  78. + "external media!\n");
  79. +
  80. + if (boot_legacy)
  81. + print_string(
  82. + "Warning: this device will boot legacy "
  83. + "payloads!\n");
  84. +
  85. + if (!boot_signed_only || boot_usb)
  86. + print_string("\n");
  87. + }
  88. +
  89. + find_common_params(&blob, &size);
  90. +
  91. + if (blob != NULL) {
  92. + VbSharedDataHeader *vdat = (VbSharedDataHeader *) blob;
  93. + fw_index = get_active_fw_index(vdat);
  94. + fw_id = get_fw_id(fw_index);
  95. +
  96. + if (fw_id == NULL)
  97. + fw_id = "NOT FOUND";
  98. +
  99. + print_string("Active firmware id: ");
  100. + print_string(fw_id);
  101. +
  102. + switch (fw_index) {
  103. + case VDAT_RW_A:
  104. + print_string(" (RW A)\n");
  105. + break;
  106. + case VDAT_RW_B:
  107. + print_string(" (RW A)\n");
  108. + break;
  109. + case VDAT_RO:
  110. + print_string(" (RO)\n");
  111. + break;
  112. + default:
  113. + print_string(" (UNKNOWN)\n");
  114. + break;
  115. + }
  116. + }
  117. break;
  118. case VB_SCREEN_DEVELOPER_EGG:
  119. - msg = "easter egg";
  120. + video_console_clear();
  121. + print_on_center("Free as in Freedom!");
  122. break;
  123. case VB_SCREEN_RECOVERY_REMOVE:
  124. - msg = "remove inserted devices";
  125. + video_console_clear();
  126. + print_on_center(
  127. + "Please remove any external media before accessing "
  128. + "recovery screen.");
  129. break;
  130. case VB_SCREEN_RECOVERY_INSERT:
  131. - msg = "insert recovery image";
  132. - break;
  133. case VB_SCREEN_RECOVERY_NO_GOOD:
  134. - msg = "insert image invalid";
  135. + video_console_clear();
  136. + print_string(
  137. + "Welcome to recovery mode!\n\n"
  138. + "Useful key combinations:\n"
  139. + "- Ctrl + D: Enable developer mode (if possible)\n\n");
  140. +
  141. + if (screen_type == VB_SCREEN_RECOVERY_NO_GOOD)
  142. + print_on_center(
  143. + "Invalid recovery media, please instert a "
  144. + "valid one.");
  145. + else
  146. + print_on_center(
  147. + "Please insert an external recovery media.");
  148. + break;
  149. + case VB_SCREEN_RECOVERY_TO_DEV:
  150. + video_console_clear();
  151. + video_get_rows_cols(&rows, &cols);
  152. +
  153. + video_console_set_cursor(0, 0);
  154. +
  155. + print_string(
  156. + "Enabling developer mode will allow booting unsigned "
  157. + "kernels and booting from external media (when enabled "
  158. + "with crossystem).\n\n"
  159. + "Developer mode can be disabled via the developer mode "
  160. + "screen.");
  161. +
  162. + msg = "Developer mode will be enabled.";
  163. + video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
  164. + print_string(msg);
  165. +
  166. + msg = "Press enter to confirm or escape to go back.";
  167. + video_console_set_cursor((cols - strlen(msg)) / 2,
  168. + rows / 2 + 2);
  169. + print_string(msg);
  170. + break;
  171. + case VB_SCREEN_DEVELOPER_TO_NORM:
  172. + video_console_clear();
  173. + video_get_rows_cols(&rows, &cols);
  174. +
  175. + video_console_set_cursor(0, 0);
  176. +
  177. + print_string(
  178. + "Disabling developer mode will restrict boot to signed "
  179. + "kernels stored on internal memory only.\n\n"
  180. + "Developer mode can be enabled again via the recovery "
  181. + "mode screen.");
  182. +
  183. + msg = "Developer mode will be disabled.";
  184. + video_console_set_cursor((cols - strlen(msg)) / 2, rows / 2);
  185. + print_string(msg);
  186. +
  187. + msg = "Press enter to confirm or escape to go back.";
  188. + video_console_set_cursor((cols - strlen(msg)) / 2,
  189. + rows / 2 + 2);
  190. + print_string(msg);
  191. break;
  192. case VB_SCREEN_WAIT:
  193. - msg = "wait for ec update";
  194. + video_console_clear();
  195. + print_on_center("Waiting for EC update...");
  196. + break;
  197. + case VB_SCREEN_TO_NORM_CONFIRMED:
  198. + video_console_clear();
  199. + print_on_center("Disabling developer mode.");
  200. break;
  201. default:
  202. printf("Not a valid screen type: %d.\n", screen_type);
  203. return VBERROR_INVALID_SCREEN_INDEX;
  204. }
  205. - if (msg)
  206. - print_on_center(msg);
  207. -
  208. return VBERROR_SUCCESS;
  209. }
  210. --
  211. 1.9.1