0003-vboot-Display-callbacks-for-all-screens.patch 6.5 KB

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