blob: 0fda310c336eb0cb94489a4514c615622fa611e2 [file] [log] [blame]
lijuang9a7d3b92015-11-30 14:41:24 +08001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
lijuang7d235f42015-07-16 20:19:45 +08002*
3* Redistribution and use in source and binary forms, with or without
4* modification, are permitted provided that the following conditions are
5* met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above
9* copyright notice, this list of conditions and the following
10* disclaimer in the documentation and/or other materials provided
11* with the distribution.
12* * Neither the name of The Linux Foundation nor the names of its
13* contributors may be used to endorse or promote products derived
14* from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#include <debug.h>
30#include <reg.h>
31#include <stdlib.h>
32#include <openssl/evp.h>
33#include <dev/fbcon.h>
34#include <kernel/thread.h>
35#include <display_menu.h>
36#include <menu_keys_detect.h>
37#include <boot_verifier.h>
38#include <string.h>
39#include <platform.h>
lijuang4ece1e72015-08-14 21:02:36 +080040#include <smem.h>
41#include <target.h>
42#include <sys/types.h>
43#include <../../../app/aboot/devinfo.h>
lijuang7d235f42015-07-16 20:19:45 +080044
lijuang4ece1e72015-08-14 21:02:36 +080045static const char *unlock_menu_common_msg = "If you unlock the bootloader, "\
lijuang7d235f42015-07-16 20:19:45 +080046 "you will be able to install "\
47 "custom operating system on this phone.\n\n"\
48 "A custom OS is not subject to the same testing "\
49 "as the original OS, "\
50 "and can cause your phone and installed "\
51 "applications to stop working properly.\n\n"\
52 "To prevent unauthorized access to your personal data, "\
53 "unlocking the bootloader will also delete all personal "\
54 "data from your phone(a \"fatory data reset\").\n\n"\
55 "Press the Volume Up/Down buttons to select Yes "\
56 "or No. Then press the Power button to continue.\n";
57
lijuang4ece1e72015-08-14 21:02:36 +080058#define YELLOW_WARNING_MSG "Your device has loaded a diffrent operating "\
59 "system\n\nTo learn more, visit:\n"
lijuang7d235f42015-07-16 20:19:45 +080060
lijuang4ece1e72015-08-14 21:02:36 +080061#define ORANGE_WARNING_MSG "Your device has been unlocker and cann't "\
62 "be trusted\n\nTo learn more, visit:\n"
lijuang7d235f42015-07-16 20:19:45 +080063
lijuang4ece1e72015-08-14 21:02:36 +080064#define RED_WARNING_MSG "Your device has failed verification and may "\
65 "not work properly\n\nTo learn more, visit:\n"
lijuang7d235f42015-07-16 20:19:45 +080066
67static bool is_thread_start = false;
lijuang9a7d3b92015-11-30 14:41:24 +080068static struct select_msg_info msg_info;
lijuang7d235f42015-07-16 20:19:45 +080069
lijuang4ece1e72015-08-14 21:02:36 +080070#if VERIFIED_BOOT
71struct boot_verify_info {
72 int msg_type;
73 const char *warning_msg;
74};
75
76struct boot_verify_info boot_verify_info[] = {
77 [DISPLAY_MENU_RED] = {FBCON_RED_MSG, RED_WARNING_MSG},
78 [DISPLAY_MENU_YELLOW] = {FBCON_YELLOW_MSG, YELLOW_WARNING_MSG},
79 [DISPLAY_MENU_ORANGE] = {FBCON_ORANGE_MSG, ORANGE_WARNING_MSG}};
80#endif
81
82static char *verify_option_menu[] = {
lijuang7d235f42015-07-16 20:19:45 +080083 [POWEROFF] = "Power off\n",
84 [RESTART] = "Restart\n",
85 [RECOVER] = "Recovery\n",
86 [FASTBOOT] = "Fastboot\n",
87 [BACK] = "Back to previous page\n"};
88
lijuang4ece1e72015-08-14 21:02:36 +080089static char *fastboot_option_menu[] = {
90 [0] = "START\n",
91 [1] = "Restart bootloader\n",
92 [2] = "Recovery mode\n",
93 [3] = "Power off\n"};
94
lijuang7d235f42015-07-16 20:19:45 +080095static int big_factor = 2;
96static int common_factor = 1;
97
98void wait_for_users_action()
99{
100 struct select_msg_info *select_msg;
101 select_msg = &msg_info;
102
lijuang9a7d3b92015-11-30 14:41:24 +0800103 mutex_acquire(&select_msg->msg_lock);
104 while(!select_msg->info.is_timeout == true) {
105 mutex_release(&select_msg->msg_lock);
lijuang7d235f42015-07-16 20:19:45 +0800106 thread_sleep(10);
lijuang9a7d3b92015-11-30 14:41:24 +0800107 mutex_acquire(&select_msg->msg_lock);
lijuang7d235f42015-07-16 20:19:45 +0800108 }
lijuang9a7d3b92015-11-30 14:41:24 +0800109 mutex_release(&select_msg->msg_lock);
110
lijuang7d235f42015-07-16 20:19:45 +0800111 fbcon_clear();
112 display_image_on_screen();
113}
114
115static void set_message_factor()
116{
117 uint32_t tmp_factor = 0;
118 uint32_t max_x_count = 40;
119 uint32_t max_x = fbcon_get_max_x();
120
121 max_x = fbcon_get_max_x();
122 tmp_factor = max_x/max_x_count;
123
124 if(tmp_factor <= 1) {
125 big_factor = 2;
126 common_factor = 1;
127 } else {
128 big_factor = tmp_factor*2;
129 common_factor = tmp_factor;
130 }
131}
132
133static void display_fbcon_menu_message(char *str, unsigned type,
134 unsigned scale_factor)
135{
136 while(*str != 0) {
137 fbcon_putc_factor(*str++, type, scale_factor);
138 }
139}
140
141static char *str_align_right(char *str, int factor)
142{
143 uint32_t max_x = 0;
144 int diff = 0;
145 int i = 0;
146 char *str_target = NULL;
147
148 max_x = fbcon_get_max_x();
149 if (!str_target && max_x) {
150 str_target = malloc(max_x);
151 }
152
153 if (str_target) {
154 memset(str_target, 0, max_x);
155 if ( max_x/factor > strlen(str)) {
156 if (factor == 1)
157 diff = max_x/factor - strlen(str) - 1;
158 else
159 diff = max_x/factor - strlen(str);
160 for (i = 0; i < diff; i++) {
Parth Dixit73d3bd02016-01-07 14:29:41 +0530161 strlcat(str_target, " ", max_x);
lijuang7d235f42015-07-16 20:19:45 +0800162 }
Parth Dixit73d3bd02016-01-07 14:29:41 +0530163 strlcat(str_target, str, max_x);
lijuang7d235f42015-07-16 20:19:45 +0800164 return str_target;
165 } else {
166 free(str_target);
167 return str;
168 }
169 }
170 return str;
171}
172
lijuang9a7d3b92015-11-30 14:41:24 +0800173/* msg_lock need to be holded when call this function. */
174void display_unlock_menu_renew(struct select_msg_info *unlock_msg_info, int type)
lijuang7d235f42015-07-16 20:19:45 +0800175{
176 fbcon_clear();
lijuang9a7d3b92015-11-30 14:41:24 +0800177 memset(&unlock_msg_info->info, 0, sizeof(struct menu_info));
178
lijuang7d235f42015-07-16 20:19:45 +0800179 display_fbcon_menu_message("Unlock bootloader?\n",
180 FBCON_UNLOCK_TITLE_MSG, big_factor);
lijuang4ece1e72015-08-14 21:02:36 +0800181 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang7d235f42015-07-16 20:19:45 +0800182
lijuang4ece1e72015-08-14 21:02:36 +0800183 display_fbcon_menu_message((char*)unlock_menu_common_msg,
lijuang7d235f42015-07-16 20:19:45 +0800184 FBCON_COMMON_MSG, common_factor);
lijuang4ece1e72015-08-14 21:02:36 +0800185 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang9a7d3b92015-11-30 14:41:24 +0800186 unlock_msg_info->info.option_start[0] = fbcon_get_current_line();
lijuang7d235f42015-07-16 20:19:45 +0800187 display_fbcon_menu_message("Yes\n",
188 FBCON_COMMON_MSG, big_factor);
lijuang9a7d3b92015-11-30 14:41:24 +0800189 unlock_msg_info->info.option_bg[0] = fbcon_get_current_bg();
lijuang7d235f42015-07-16 20:19:45 +0800190 display_fbcon_menu_message("Unlock bootloader(may void warranty)\n",
191 FBCON_COMMON_MSG, common_factor);
lijuang9a7d3b92015-11-30 14:41:24 +0800192 unlock_msg_info->info.option_end[0] = fbcon_get_current_line();
lijuang4ece1e72015-08-14 21:02:36 +0800193 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang9a7d3b92015-11-30 14:41:24 +0800194 unlock_msg_info->info.option_start[1] = fbcon_get_current_line();
lijuang7d235f42015-07-16 20:19:45 +0800195 display_fbcon_menu_message("No\n",
196 FBCON_COMMON_MSG, big_factor);
lijuang9a7d3b92015-11-30 14:41:24 +0800197 unlock_msg_info->info.option_bg[1] = fbcon_get_current_bg();
lijuang7d235f42015-07-16 20:19:45 +0800198 display_fbcon_menu_message("Do not unlock bootloader and restart phone\n",
199 FBCON_COMMON_MSG, common_factor);
lijuang9a7d3b92015-11-30 14:41:24 +0800200 unlock_msg_info->info.option_end[1] = fbcon_get_current_line();
lijuang4ece1e72015-08-14 21:02:36 +0800201 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang7d235f42015-07-16 20:19:45 +0800202
lijuang4ece1e72015-08-14 21:02:36 +0800203 if (type == UNLOCK)
lijuang9a7d3b92015-11-30 14:41:24 +0800204 unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK;
lijuang4ece1e72015-08-14 21:02:36 +0800205 else if (type == UNLOCK_CRITICAL)
lijuang9a7d3b92015-11-30 14:41:24 +0800206 unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK_CRITICAL;
lijuang4ece1e72015-08-14 21:02:36 +0800207
lijuang9a7d3b92015-11-30 14:41:24 +0800208 unlock_msg_info->info.option_num = 2;
209
210 /* Initialize the option index */
211 unlock_msg_info->info.option_index= 2;
lijuang7d235f42015-07-16 20:19:45 +0800212}
213
lijuang4ece1e72015-08-14 21:02:36 +0800214#if VERIFIED_BOOT
lijuang9a7d3b92015-11-30 14:41:24 +0800215/* msg_lock need to be holded when call this function. */
216void display_bootverify_menu_renew(struct select_msg_info *msg_info, int type)
lijuang7d235f42015-07-16 20:19:45 +0800217{
lijuang7d235f42015-07-16 20:19:45 +0800218 unsigned char* fp_buf = NULL;
219 char fp_str_temp[EVP_MAX_MD_SIZE] = {'\0'};
220 char fp_str[EVP_MAX_MD_SIZE*2] = {'\0'};
221 char str_temp[8];
222
223 char str1[]= "Start >";
224 char str2[] = "Continue boot";
225 char *str_target = NULL;
226 uint32 fp_size = 0;
227 unsigned int i = 0;
228
229 fbcon_clear();
lijuang9a7d3b92015-11-30 14:41:24 +0800230 memset(&msg_info->info, 0, sizeof(struct menu_info));
lijuang7d235f42015-07-16 20:19:45 +0800231
lijuang7d235f42015-07-16 20:19:45 +0800232 /* Align Right */
233 str_target = str_align_right(str1, big_factor);
Sridhar Parasuram995a3552015-08-22 08:46:10 -0700234 if(str_target != NULL)
235 display_fbcon_menu_message(str_target, FBCON_TITLE_MSG, big_factor);
lijuang7d235f42015-07-16 20:19:45 +0800236
237 str_target = str_align_right(str2, common_factor);
Sridhar Parasuram995a3552015-08-22 08:46:10 -0700238 if(str_target != NULL)
239 display_fbcon_menu_message(str_target, FBCON_TITLE_MSG, common_factor);
lijuang7d235f42015-07-16 20:19:45 +0800240
241 display_fbcon_menu_message("\n< More options\n",
242 FBCON_COMMON_MSG, common_factor);
243 display_fbcon_menu_message("press VOLUME keys\n\n",
244 FBCON_SUBTITLE_MSG, common_factor);
lijuang4ece1e72015-08-14 21:02:36 +0800245 if(boot_verify_info[type].warning_msg != NULL)
246 display_fbcon_menu_message((char*)boot_verify_info[type].warning_msg,
247 FBCON_COMMON_MSG, common_factor);
lijuang7d235f42015-07-16 20:19:45 +0800248
249 display_fbcon_menu_message("g.co/placeholder\n",
lijuang4ece1e72015-08-14 21:02:36 +0800250 boot_verify_info[type].msg_type, common_factor);
lijuang7d235f42015-07-16 20:19:45 +0800251
lijuang7d235f42015-07-16 20:19:45 +0800252 if (type == DISPLAY_MENU_YELLOW) {
253 fp_buf = get_boot_fingerprint(&fp_size);
254 if (fp_buf != NULL) {
Parth Dixit73d3bd02016-01-07 14:29:41 +0530255 strlcpy(fp_str_temp, (char const *)fp_buf, fp_size);
lijuang7d235f42015-07-16 20:19:45 +0800256 for (i = 0; i < fp_size; i++) {
257 if(i == fp_size - 1)
Parth Dixit73d3bd02016-01-07 14:29:41 +0530258 snprintf(str_temp, sizeof(str_temp), "%02x", fp_str_temp[i]);
lijuang7d235f42015-07-16 20:19:45 +0800259 else
Parth Dixit73d3bd02016-01-07 14:29:41 +0530260 snprintf(str_temp, sizeof(str_temp), "%02x-", fp_str_temp[i]);
lijuang7d235f42015-07-16 20:19:45 +0800261
Parth Dixit73d3bd02016-01-07 14:29:41 +0530262 strlcat(fp_str, str_temp, sizeof(fp_str));
lijuang7d235f42015-07-16 20:19:45 +0800263 }
264 }
265 display_fbcon_menu_message("ID:", FBCON_COMMON_MSG, common_factor);
266 display_fbcon_menu_message(fp_str, FBCON_COMMON_MSG, common_factor);
267 }
lijuang7d235f42015-07-16 20:19:45 +0800268
269 display_fbcon_menu_message("\n\nIf no key pressed:\n"\
270 "Your device will boot in 5 seconds\n\n", FBCON_COMMON_MSG, common_factor);
271
lijuang9a7d3b92015-11-30 14:41:24 +0800272 msg_info->info.msg_type = type;
lijuang7d235f42015-07-16 20:19:45 +0800273 if(str_target) {
274 free(str_target);
275 }
lijuang9a7d3b92015-11-30 14:41:24 +0800276
277 /* Initialize the time out time */
278 msg_info->info.timeout_time = 5000; //5s
lijuang7d235f42015-07-16 20:19:45 +0800279}
lijuang4ece1e72015-08-14 21:02:36 +0800280#endif
lijuang7d235f42015-07-16 20:19:45 +0800281
lijuang9a7d3b92015-11-30 14:41:24 +0800282/* msg_lock need to be holded when call this function. */
283void display_bootverify_option_menu_renew(struct select_msg_info *msg_info)
lijuang7d235f42015-07-16 20:19:45 +0800284{
285 int i = 0;
lijuang4ece1e72015-08-14 21:02:36 +0800286 int len = 0;
lijuang9a7d3b92015-11-30 14:41:24 +0800287
lijuang7d235f42015-07-16 20:19:45 +0800288 fbcon_clear();
lijuang9a7d3b92015-11-30 14:41:24 +0800289 memset(&msg_info->info, 0, sizeof(struct menu_info));
lijuang7d235f42015-07-16 20:19:45 +0800290
lijuang4ece1e72015-08-14 21:02:36 +0800291 len = ARRAY_SIZE(verify_option_menu);
lijuang7d235f42015-07-16 20:19:45 +0800292 display_fbcon_menu_message("Options menu:\n\n",
293 FBCON_COMMON_MSG, big_factor);
294 display_fbcon_menu_message("Press volume key to select, and "\
295 "press power key to select\n\n", FBCON_COMMON_MSG, common_factor);
296
lijuang4ece1e72015-08-14 21:02:36 +0800297 for (i = 0; i < len; i++) {
298 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang9a7d3b92015-11-30 14:41:24 +0800299 msg_info->info.option_start[i] = fbcon_get_current_line();
lijuang4ece1e72015-08-14 21:02:36 +0800300 display_fbcon_menu_message(verify_option_menu[i],
lijuang7d235f42015-07-16 20:19:45 +0800301 FBCON_COMMON_MSG, common_factor);
lijuang9a7d3b92015-11-30 14:41:24 +0800302 msg_info->info.option_bg[i]= fbcon_get_current_bg();
303 msg_info->info.option_end[i]= fbcon_get_current_line();
lijuang7d235f42015-07-16 20:19:45 +0800304 }
305
lijuang4ece1e72015-08-14 21:02:36 +0800306 fbcon_draw_line(FBCON_COMMON_MSG);
lijuang9a7d3b92015-11-30 14:41:24 +0800307 msg_info->info.msg_type = DISPLAY_MENU_MORE_OPTION;
308 msg_info->info.option_num = len;
309
310 /* Initialize the option index */
311 msg_info->info.option_index= len;
lijuang4ece1e72015-08-14 21:02:36 +0800312}
313
lijuang9a7d3b92015-11-30 14:41:24 +0800314/* msg_lock need to be holded when call this function. */
315void display_fastboot_menu_renew(struct select_msg_info *fastboot_msg_info)
lijuang4ece1e72015-08-14 21:02:36 +0800316{
317 int len;
318 int msg_type = FBCON_COMMON_MSG;
319 char msg_buf[64];
320 char msg[128];
321
lijuang9a7d3b92015-11-30 14:41:24 +0800322 /* The fastboot menu is switched base on the option index
323 * So it's need to store the index for the menu switching
324 */
325 uint32_t option_index = fastboot_msg_info->info.option_index;
326
lijuang4ece1e72015-08-14 21:02:36 +0800327 fbcon_clear();
lijuang9a7d3b92015-11-30 14:41:24 +0800328 memset(&fastboot_msg_info->info, 0, sizeof(struct menu_info));
lijuang4ece1e72015-08-14 21:02:36 +0800329
330 len = ARRAY_SIZE(fastboot_option_menu);
331 switch(option_index) {
332 case 0:
333 msg_type = FBCON_GREEN_MSG;
334 break;
335 case 1:
336 case 2:
337 msg_type = FBCON_RED_MSG;
338 break;
339 case 3:
340 msg_type = FBCON_COMMON_MSG;
341 break;
342 }
343 fbcon_draw_line(msg_type);
344 display_fbcon_menu_message(fastboot_option_menu[option_index],
345 msg_type, big_factor);
346 fbcon_draw_line(msg_type);
347 display_fbcon_menu_message("\n\nPress volume key to select, and "\
348 "press power key to select\n\n", FBCON_COMMON_MSG, common_factor);
349
350 display_fbcon_menu_message("FASTBOOT MODE\n", FBCON_RED_MSG, common_factor);
351
352 get_product_name((unsigned char *) msg_buf);
353 snprintf(msg, sizeof(msg), "PRODUCT_NAME - %s\n", msg_buf);
354 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
355
356 memset(msg_buf, 0, sizeof(msg_buf));
357 smem_get_hw_platform_name((unsigned char *) msg_buf, sizeof(msg_buf));
358 snprintf(msg, sizeof(msg), "VARIANT - %s %s\n",
359 msg_buf, target_is_emmc_boot()? "eMMC":"UFS");
360 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
361
362 memset(msg_buf, 0, sizeof(msg_buf));
363 get_bootloader_version((unsigned char *) msg_buf);
364 snprintf(msg, sizeof(msg), "BOOTLOADER VERSION - %s\n",
365 msg_buf);
366 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
367
368 memset(msg_buf, 0, sizeof(msg_buf));
369 get_baseband_version((unsigned char *) msg_buf);
370 snprintf(msg, sizeof(msg), "BASEBAND VERSION - %s\n",
371 msg_buf);
372 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
373
374 memset(msg_buf, 0, sizeof(msg_buf));
375 target_serialno((unsigned char *) msg_buf);
376 snprintf(msg, sizeof(msg), "SERIAL NUMBER - %s\n", msg_buf);
377 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
378
379 snprintf(msg, sizeof(msg), "SECURE BOOT - %s\n",
380 is_secure_boot_enable()? "enabled":"disabled");
381 display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor);
382
383 snprintf(msg, sizeof(msg), "DEVICE STATE - %s\n",
384 is_device_locked()? "locked":"unlocked");
385 display_fbcon_menu_message(msg, FBCON_RED_MSG, common_factor);
386
lijuang9a7d3b92015-11-30 14:41:24 +0800387 fastboot_msg_info->info.msg_type = DISPLAY_MENU_FASTBOOT;
388 fastboot_msg_info->info.option_num = len;
389 fastboot_msg_info->info.option_index = option_index;
390}
391
392void msg_lock_init()
393{
394 static bool is_msg_lock_init = false;
395 struct select_msg_info *msg_lock_info;
396 msg_lock_info = &msg_info;
397
398 if (!is_msg_lock_init) {
399 mutex_init(&msg_lock_info->msg_lock);
400 is_msg_lock_init = true;
401 }
lijuang7d235f42015-07-16 20:19:45 +0800402}
403
404static void display_menu_thread_start(struct select_msg_info *msg_info)
405{
406 thread_t *thr;
407
408 if (!is_thread_start) {
409 thr = thread_create("selectkeydetect", &select_msg_keys_detect,
410 (void*)msg_info, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
411 if (!thr) {
412 dprintf(CRITICAL, "ERROR: creat device status detect thread failed!!\n");
413 return;
414 }
415 thread_resume(thr);
lijuang9a7d3b92015-11-30 14:41:24 +0800416 is_thread_start = true;
lijuang7d235f42015-07-16 20:19:45 +0800417 }
lijuang7d235f42015-07-16 20:19:45 +0800418}
419
lijuang9a7d3b92015-11-30 14:41:24 +0800420/* The fuction be called after device in fastboot mode,
421 * so it's no need to initialize the msg_lock again
422 */
423void display_unlock_menu(int type)
lijuang7d235f42015-07-16 20:19:45 +0800424{
lijuang4ece1e72015-08-14 21:02:36 +0800425 struct select_msg_info *unlock_menu_msg_info;
426 unlock_menu_msg_info = &msg_info;
lijuang7d235f42015-07-16 20:19:45 +0800427
428 set_message_factor();
lijuang9a7d3b92015-11-30 14:41:24 +0800429
430 msg_lock_init();
431 mutex_acquire(&unlock_menu_msg_info->msg_lock);
432
433 /* Initialize the last_msg_type */
434 unlock_menu_msg_info->last_msg_type =
435 unlock_menu_msg_info->info.msg_type;
436
437 display_unlock_menu_renew(unlock_menu_msg_info, type);
438 mutex_release(&unlock_menu_msg_info->msg_lock);
lijuang7d235f42015-07-16 20:19:45 +0800439
lijuang4ece1e72015-08-14 21:02:36 +0800440 dprintf(INFO, "creating unlock keys detect thread\n");
441 display_menu_thread_start(unlock_menu_msg_info);
lijuang7d235f42015-07-16 20:19:45 +0800442}
443
lijuang9a7d3b92015-11-30 14:41:24 +0800444void display_fastboot_menu()
lijuang4ece1e72015-08-14 21:02:36 +0800445{
446 struct select_msg_info *fastboot_menu_msg_info;
447 fastboot_menu_msg_info = &msg_info;
448
449 set_message_factor();
lijuang9a7d3b92015-11-30 14:41:24 +0800450
451 msg_lock_init();
452 mutex_acquire(&fastboot_menu_msg_info->msg_lock);
453
454 /* There are 4 pages for fastboot menu:
455 * Page: Start/Fastboot/Recovery/Poweroff
456 * The menu is switched base on the option index
457 * Initialize the option index and last_msg_type
458 */
459 fastboot_menu_msg_info->info.option_index = 0;
460 fastboot_menu_msg_info->last_msg_type =
461 fastboot_menu_msg_info->info.msg_type;
462
463 display_fastboot_menu_renew(fastboot_menu_msg_info);
464 mutex_release(&fastboot_menu_msg_info->msg_lock);
lijuang4ece1e72015-08-14 21:02:36 +0800465
466 dprintf(INFO, "creating fastboot menu keys detect thread\n");
467 display_menu_thread_start(fastboot_menu_msg_info);
468}
469
470#if VERIFIED_BOOT
lijuang9a7d3b92015-11-30 14:41:24 +0800471void display_bootverify_menu(int type)
lijuang4ece1e72015-08-14 21:02:36 +0800472{
473 struct select_msg_info *bootverify_menu_msg_info;
474 bootverify_menu_msg_info = &msg_info;
475
476 set_message_factor();
lijuang9a7d3b92015-11-30 14:41:24 +0800477
478 msg_lock_init();
479 mutex_acquire(&bootverify_menu_msg_info->msg_lock);
480
481 /* Initialize the last_msg_type */
482 bootverify_menu_msg_info->last_msg_type =
483 bootverify_menu_msg_info->info.msg_type;
484
485 display_bootverify_menu_renew(bootverify_menu_msg_info, type);
486 mutex_release(&bootverify_menu_msg_info->msg_lock);
lijuang4ece1e72015-08-14 21:02:36 +0800487
488 dprintf(INFO, "creating boot verify keys detect thread\n");
489 display_menu_thread_start(bootverify_menu_msg_info);
490}
491#endif