0007-firmware-Pass-VbDisplayInfo-information-structure-to.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. From aecef39cda6a70c99bf0caff0452e47ad43a68d8 Mon Sep 17 00:00:00 2001
  2. From: Paul Kocialkowski <contact@paulk.fr>
  3. Date: Sun, 10 Jul 2016 23:43:16 +0200
  4. Subject: [PATCH 7/7] firmware: Pass VbDisplayInfo information structure to
  5. VbExDisplayScreen
  6. This provides VbExDisplayScreen with an information structure
  7. (VbDisplayInfo) that contains various context information for display.
  8. Change-Id: Id9e07bb418f64e9286f07da11314cd63f925e301
  9. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
  10. ---
  11. firmware/include/vboot_api.h | 12 +++++++++-
  12. firmware/lib/include/vboot_display.h | 2 +-
  13. firmware/lib/vboot_api_kernel.c | 44 ++++++++++++++++++++++++------------
  14. firmware/lib/vboot_display.c | 15 ++++++------
  15. firmware/stub/vboot_api_stub.c | 3 ++-
  16. tests/vboot_api_devmode_tests.c | 3 ++-
  17. tests/vboot_api_kernel2_tests.c | 2 +-
  18. tests/vboot_api_kernel3_tests.c | 2 +-
  19. 8 files changed, 55 insertions(+), 28 deletions(-)
  20. diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
  21. index 950c1e2..ba53101 100644
  22. --- a/firmware/include/vboot_api.h
  23. +++ b/firmware/include/vboot_api.h
  24. @@ -697,6 +697,15 @@ enum VbScreenType_t {
  25. VB_SCREEN_OS_BROKEN = 0x208,
  26. };
  27. +/* Information on display context */
  28. +typedef struct VbDisplayInfo {
  29. + uint32_t allow_usb;
  30. + uint32_t allow_legacy;
  31. + uint32_t use_usb;
  32. + uint32_t use_legacy;
  33. + uint32_t signed_only;
  34. +} VbDisplayInfo;
  35. +
  36. /**
  37. * Initialize and clear the display. Set width and height to the screen
  38. * dimensions in pixels.
  39. @@ -725,7 +734,8 @@ VbError_t VbExDisplaySetDimension(uint32_t width, uint32_t height);
  40. * to be simple ASCII text such as "NO GOOD" or "INSERT"; these screens should
  41. * only be seen during development.
  42. */
  43. -VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale);
  44. +VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale,
  45. + VbDisplayInfo *info);
  46. /**
  47. * Write an image to the display, with the upper left corner at the specified
  48. diff --git a/firmware/lib/include/vboot_display.h b/firmware/lib/include/vboot_display.h
  49. index 0ab93f0..0574580 100644
  50. --- a/firmware/lib/include/vboot_display.h
  51. +++ b/firmware/lib/include/vboot_display.h
  52. @@ -15,7 +15,7 @@
  53. VbError_t VbDisplayScreenFromGBB(VbCommonParams *cparams, uint32_t screen,
  54. VbNvContext *vncptr, uint32_t locale);
  55. VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen, int force,
  56. - VbNvContext *vncptr);
  57. + VbNvContext *vncptr, VbDisplayInfo *info);
  58. VbError_t VbDisplayDebugInfo(VbCommonParams *cparams, VbNvContext *vncptr);
  59. VbError_t VbCheckDisplayKey(VbCommonParams *cparams, uint32_t key,
  60. VbNvContext *vncptr);
  61. diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
  62. index e03e042..7dcc754 100644
  63. --- a/firmware/lib/vboot_api_kernel.c
  64. +++ b/firmware/lib/vboot_api_kernel.c
  65. @@ -300,11 +300,13 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
  66. VbSharedDataHeader *shared =
  67. (VbSharedDataHeader *)cparams->shared_data_blob;
  68. + VbDisplayInfo info;
  69. uint32_t allow_usb = 0;
  70. uint32_t allow_legacy = 0;
  71. uint32_t disable_dev_boot = 0;
  72. uint32_t use_usb = 0;
  73. uint32_t use_legacy = 0;
  74. + uint32_t signed_only = 0;
  75. uint32_t default_boot = 0;
  76. uint32_t ctrl_d_pressed = 0;
  77. uint32_t hold = 0;
  78. @@ -350,10 +352,22 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
  79. }
  80. }
  81. + VbNvGet(&vnc, VBNV_DEV_BOOT_SIGNED_ONLY, &signed_only);
  82. +
  83. + if (fwmp.flags & FWMP_DEV_ENABLE_OFFICIAL_ONLY)
  84. + signed_only = 1;
  85. +
  86. + info.allow_usb = allow_usb;
  87. + info.allow_legacy = allow_legacy;
  88. + info.use_usb = use_usb;
  89. + info.use_legacy = use_legacy;
  90. + info.signed_only = signed_only;
  91. +
  92. /* If dev mode is disabled, only allow TONORM */
  93. while (disable_dev_boot) {
  94. VBDEBUG(("%s() - dev_disable_boot is set.\n", __func__));
  95. - VbDisplayScreen(cparams, VB_SCREEN_DEVELOPER_TO_NORM, 0, &vnc);
  96. + VbDisplayScreen(cparams, VB_SCREEN_DEVELOPER_TO_NORM, 0, &vnc,
  97. + NULL);
  98. VbExDisplayDebugInfo(dev_disable_msg);
  99. /* Ignore space in VbUserConfirms()... */
  100. @@ -363,7 +377,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
  101. VbNvSet(&vnc, VBNV_DISABLE_DEV_REQUEST, 1);
  102. VbDisplayScreen(cparams,
  103. VB_SCREEN_TO_NORM_CONFIRMED,
  104. - 0, &vnc);
  105. + 0, &vnc, NULL);
  106. VbExSleepMs(5000);
  107. return VBERROR_REBOOT_REQUIRED;
  108. case -1:
  109. @@ -377,7 +391,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
  110. developer_mode_screen:
  111. /* Show the dev mode warning screen */
  112. - VbDisplayScreen(cparams, VB_SCREEN_DEVELOPER_WARNING, 0, &vnc);
  113. + VbDisplayScreen(cparams, VB_SCREEN_DEVELOPER_WARNING, 0, &vnc, &info);
  114. /* Get audio/delay context */
  115. audio = VbAudioOpen(cparams);
  116. @@ -425,7 +439,7 @@ developer_mode_screen:
  117. }
  118. VbDisplayScreen(cparams,
  119. VB_SCREEN_DEVELOPER_TO_NORM,
  120. - 0, &vnc);
  121. + 0, &vnc, NULL);
  122. /* Ignore space in VbUserConfirms()... */
  123. switch (VbUserConfirms(cparams, 0)) {
  124. case 1:
  125. @@ -436,7 +450,7 @@ developer_mode_screen:
  126. VbDisplayScreen(
  127. cparams,
  128. VB_SCREEN_TO_NORM_CONFIRMED,
  129. - 0, &vnc);
  130. + 0, &vnc, NULL);
  131. VbExSleepMs(5000);
  132. return VBERROR_REBOOT_REQUIRED;
  133. case -1:
  134. @@ -450,7 +464,7 @@ developer_mode_screen:
  135. VbDisplayScreen(
  136. cparams,
  137. VB_SCREEN_DEVELOPER_WARNING,
  138. - 0, &vnc);
  139. + 0, &vnc, &info);
  140. /* Start new countdown */
  141. audio = VbAudioOpen(cparams);
  142. }
  143. @@ -512,7 +526,7 @@ developer_mode_screen:
  144. "USB booting is disabled\n"));
  145. VbDisplayScreen(cparams, VB_SCREEN_BLANK, 1,
  146. - &vnc);
  147. + &vnc, NULL);
  148. VbExDisplayDebugInfo(
  149. "WARNING: Booting from external media "
  150. @@ -533,7 +547,7 @@ developer_mode_screen:
  151. * key press.
  152. */
  153. VbDisplayScreen(cparams, VB_SCREEN_BLANK, 0,
  154. - &vnc);
  155. + &vnc, NULL);
  156. if (VBERROR_SUCCESS == VbTryUsb(cparams, p)) {
  157. VbAudioClose(audio);
  158. return VBERROR_SUCCESS;
  159. @@ -542,7 +556,7 @@ developer_mode_screen:
  160. VbDisplayScreen(
  161. cparams,
  162. VB_SCREEN_DEVELOPER_WARNING,
  163. - 0, &vnc);
  164. + 0, &vnc, &info);
  165. }
  166. }
  167. break;
  168. @@ -608,7 +622,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p)
  169. shared->recovery_reason));
  170. VbSetRecoverySubcode(shared->recovery_reason);
  171. VbNvCommit();
  172. - VbDisplayScreen(cparams, VB_SCREEN_OS_BROKEN, 0, &vnc);
  173. + VbDisplayScreen(cparams, VB_SCREEN_OS_BROKEN, 0, &vnc, NULL);
  174. VBDEBUG(("VbBootRecovery() waiting for manual recovery\n"));
  175. while (1) {
  176. if (VbWantShutdown(cparams->gbb->flags))
  177. @@ -637,7 +651,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p)
  178. VbDisplayScreen(cparams, VBERROR_NO_DISK_FOUND == retval ?
  179. VB_SCREEN_RECOVERY_INSERT :
  180. VB_SCREEN_RECOVERY_NO_GOOD,
  181. - 0, &vnc);
  182. + 0, &vnc, NULL);
  183. /*
  184. * Scan keyboard more frequently than media, since x86
  185. @@ -677,7 +691,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p)
  186. /* Ask the user to confirm entering dev-mode */
  187. VbDisplayScreen(cparams,
  188. VB_SCREEN_RECOVERY_TO_DEV,
  189. - 0, &vnc);
  190. + 0, &vnc, NULL);
  191. /* SPACE means no... */
  192. uint32_t vbc_flags =
  193. VB_CONFIRM_SPACE_MEANS_NO |
  194. @@ -839,7 +853,7 @@ static VbError_t EcUpdateImage(int devidx, VbCommonParams *cparams,
  195. return VBERROR_VGA_OPROM_MISMATCH;
  196. }
  197. - VbDisplayScreen(cparams, VB_SCREEN_WAIT, 0, &vnc);
  198. + VbDisplayScreen(cparams, VB_SCREEN_WAIT, 0, &vnc, NULL);
  199. }
  200. rv = VbExEcUpdateImage(devidx, select, expected, expected_size);
  201. @@ -1250,13 +1264,13 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
  202. p.boot_flags |= BOOT_FLAG_RECOVERY;
  203. retval = VbBootRecovery(cparams, &p);
  204. VbExEcEnteringMode(0, VB_EC_RECOVERY);
  205. - VbDisplayScreen(cparams, VB_SCREEN_BLANK, 0, &vnc);
  206. + VbDisplayScreen(cparams, VB_SCREEN_BLANK, 0, &vnc, NULL);
  207. } else if (p.boot_flags & BOOT_FLAG_DEVELOPER) {
  208. /* Developer boot */
  209. retval = VbBootDeveloper(cparams, &p);
  210. VbExEcEnteringMode(0, VB_EC_DEVELOPER);
  211. - VbDisplayScreen(cparams, VB_SCREEN_BLANK, 0, &vnc);
  212. + VbDisplayScreen(cparams, VB_SCREEN_BLANK, 0, &vnc, NULL);
  213. } else {
  214. /* Normal boot */
  215. diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
  216. index 6d8ed92..84b7961 100644
  217. --- a/firmware/lib/vboot_display.c
  218. +++ b/firmware/lib/vboot_display.c
  219. @@ -321,7 +321,7 @@ VbError_t VbDisplayScreenFromGBB(VbCommonParams *cparams, uint32_t screen,
  220. */
  221. static VbError_t VbDisplayScreenLegacy(VbCommonParams *cparams, uint32_t screen,
  222. int force, VbNvContext *vncptr,
  223. - uint32_t locale)
  224. + uint32_t locale, VbDisplayInfo *info)
  225. {
  226. VbError_t retval;
  227. @@ -336,7 +336,7 @@ static VbError_t VbDisplayScreenLegacy(VbCommonParams *cparams, uint32_t screen,
  228. VbExDisplayBacklight(VB_SCREEN_BLANK == screen ? 0 : 1);
  229. /* Display default first */
  230. - if (VBERROR_SUCCESS == VbExDisplayScreen(screen, locale))
  231. + if (VBERROR_SUCCESS == VbExDisplayScreen(screen, locale, info))
  232. return VBERROR_SUCCESS;
  233. /* If default doesn't have anything to show, fall back to GBB bitmaps */
  234. @@ -344,7 +344,7 @@ static VbError_t VbDisplayScreenLegacy(VbCommonParams *cparams, uint32_t screen,
  235. }
  236. VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen,
  237. - int force, VbNvContext *vncptr)
  238. + int force, VbNvContext *vncptr, VbDisplayInfo *info)
  239. {
  240. uint32_t locale;
  241. VbError_t rv;
  242. @@ -357,7 +357,7 @@ VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen,
  243. VbNvGet(vncptr, VBNV_LOCALIZATION_INDEX, &locale);
  244. rv = VbDisplayScreenLegacy(cparams, screen, force, vncptr,
  245. - locale);
  246. + locale, info);
  247. if (rv == VBERROR_SUCCESS)
  248. /* Keep track of the currently displayed screen */
  249. @@ -560,7 +560,7 @@ VbError_t VbDisplayDebugInfo(VbCommonParams *cparams, VbNvContext *vncptr)
  250. uint32_t i;
  251. /* Blank screen */
  252. - VbDisplayScreen(cparams, VB_SCREEN_BLANK, 1, vncptr);
  253. + VbDisplayScreen(cparams, VB_SCREEN_BLANK, 1, vncptr, NULL);
  254. /* Add hardware ID */
  255. VbRegionReadHWID(cparams, hwid, sizeof(hwid));
  256. @@ -725,13 +725,14 @@ VbError_t VbCheckDisplayKey(VbCommonParams *cparams, uint32_t key,
  257. #endif
  258. /* Force redraw of current screen */
  259. - return VbDisplayScreen(cparams, disp_current_screen, 1, vncptr);
  260. + return VbDisplayScreen(cparams, disp_current_screen, 1, vncptr,
  261. + NULL);
  262. }
  263. if (0 == memcmp(MagicBuffer, MAGIC_WORD, MAGIC_WORD_LEN)) {
  264. if (VBEASTEREGG)
  265. (void)VbDisplayScreen(cparams, disp_current_screen,
  266. - 1, vncptr);
  267. + 1, vncptr, NULL);
  268. }
  269. return VBERROR_SUCCESS;
  270. diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
  271. index 717c0f8..c086195 100644
  272. --- a/firmware/stub/vboot_api_stub.c
  273. +++ b/firmware/stub/vboot_api_stub.c
  274. @@ -41,7 +41,8 @@ VbError_t VbExDisplaySetDimension(uint32_t width, uint32_t height)
  275. return VBERROR_SUCCESS;
  276. }
  277. -VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale)
  278. +VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale,
  279. + VbDisplayInfo *info)
  280. {
  281. return VBERROR_SUCCESS;
  282. }
  283. diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
  284. index abd8e85..6e8afbd 100644
  285. --- a/tests/vboot_api_devmode_tests.c
  286. +++ b/tests/vboot_api_devmode_tests.c
  287. @@ -265,7 +265,8 @@ VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
  288. return beep_return;
  289. }
  290. -VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale) {
  291. +VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale,
  292. + VbDisplayInfo *info) {
  293. switch(screen_type) {
  294. case VB_SCREEN_BLANK:
  295. VBDEBUG(("VbExDisplayScreen(BLANK)\n"));
  296. diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
  297. index 433933b..d44fc1e 100644
  298. --- a/tests/vboot_api_kernel2_tests.c
  299. +++ b/tests/vboot_api_kernel2_tests.c
  300. @@ -185,7 +185,7 @@ uint32_t VbTryLoadKernel(VbCommonParams *cparams, LoadKernelParams *p,
  301. }
  302. VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen, int force,
  303. - VbNvContext *vncptr)
  304. + VbNvContext *vncptr, VbDisplayInfo *info)
  305. {
  306. if (screens_count < ARRAY_SIZE(screens_displayed))
  307. screens_displayed[screens_count++] = screen;
  308. diff --git a/tests/vboot_api_kernel3_tests.c b/tests/vboot_api_kernel3_tests.c
  309. index 3eddb73..0403c71 100644
  310. --- a/tests/vboot_api_kernel3_tests.c
  311. +++ b/tests/vboot_api_kernel3_tests.c
  312. @@ -195,7 +195,7 @@ VbError_t VbExEcUpdateImage(int devidx, enum VbSelectFirmware_t select,
  313. }
  314. VbError_t VbDisplayScreen(VbCommonParams *cparams, uint32_t screen, int force,
  315. - VbNvContext *vncptr)
  316. + VbNvContext *vncptr, VbDisplayInfo *info)
  317. {
  318. if (screens_count < ARRAY_SIZE(screens_displayed))
  319. screens_displayed[screens_count++] = screen;
  320. --
  321. 2.10.2