lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 2 | * |
| 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> |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 40 | #include <smem.h> |
| 41 | #include <target.h> |
| 42 | #include <sys/types.h> |
| 43 | #include <../../../app/aboot/devinfo.h> |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 44 | #include <../../../app/aboot/recovery.h> |
tracychui | d19990d | 2020-06-12 13:22:29 +0800 | [diff] [blame] | 45 | /*[TracyChui]Show memory information on fastboot screen 20200612 start */ |
| 46 | #include <mmu.h> |
| 47 | /*[TracyChui]Show memory information on fastboot screen 20200612 end */ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 48 | #define TITLE_MSG "<!>\n\n" |
| 49 | |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 50 | //[Arima][8901][JialongJhan] Command mode update screen 20190516 Start |
| 51 | extern int msm_display_flush(); |
| 52 | //[Arima][8901][JialongJhan] Command mode update screen 20190516 End |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 53 | static const char *unlock_menu_common_msg = "By unlocking the bootloader, you will be able to install "\ |
| 54 | "custom operating system on this phone. "\ |
| 55 | "A custom OS is not subject to the same level of testing "\ |
| 56 | "as the original OS, and can cause your phone "\ |
| 57 | "and installed applications to stop working properly.\n\n"\ |
| 58 | "Software integrity cannot be guaranteed with a custom OS, "\ |
| 59 | "so any data stored on the phone while the bootloader "\ |
| 60 | "is unlocked may be at risk.\n\n"\ |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 61 | "To prevent unauthorized access to your personal data, "\ |
| 62 | "unlocking the bootloader will also delete all personal "\ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 63 | "data on your phone.\n\n"\ |
| 64 | "Press the Volume keys to select whether to unlock the bootloader, "\ |
| 65 | "then the Power Button to continue.\n\n"; |
| 66 | |
| 67 | static const char *lock_menu_common_msg = "If you lock the bootloader, "\ |
| 68 | "you will not be able to install "\ |
| 69 | "custom operating system on this phone.\n\n"\ |
| 70 | "To prevent unauthorized access to your personal data, "\ |
| 71 | "locking the bootloader will also delete all personal "\ |
| 72 | "data on your phone.\n\n"\ |
| 73 | "Press the Volume keys to select whether to "\ |
| 74 | "lock the bootloader, then the power button to continue.\n\n"; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 75 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 76 | #define YELLOW_WARNING_MSG "Your device has loaded a different operating system\n\n "\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 77 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 78 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 79 | #define ORANGE_WARNING_MSG "The boot loader is unlocked and software integrity cannot "\ |
| 80 | "be guaranteed. Any data stored on the device may be available to attackers. "\ |
| 81 | "Do not store any sensitive data on the device.\n\n"\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 82 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 83 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 84 | #define RED_WARNING_MSG "Your device is corrupt. It can't be\ntrusted and will not boot\n\n" \ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 85 | "Visit this link on another device:\n" |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 86 | |
lijuang | bdd9bb4 | 2016-03-01 18:22:17 +0800 | [diff] [blame] | 87 | #define LOGGING_WARNING_MSG "The dm-verity is not started in enforcing mode and may "\ |
| 88 | "not work properly\n\nTo learn more, visit:\n" |
| 89 | |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 90 | #define EIO_WARNING_MSG "Your device is corrupt. It can't be\n trusted and may not work properly.\n\n"\ |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 91 | "Visit this link on another device:\n" |
| 92 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 93 | #define PAUSE_BOOT_MSG "PRESS POWER KEY TO PAUSE BOOT\n\n" |
| 94 | |
| 95 | #define CONTINUE_BOOT_MSG "PRESS POWER KEY TO CONTINUE\n\n" |
| 96 | |
| 97 | #define URL_MSG "g.co/ABH\n\n" |
Channagoud Kadabi | 86b0c11 | 2016-03-16 19:23:16 -0700 | [diff] [blame] | 98 | |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 99 | #define DELAY_5SEC 5000 |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 100 | #define DELAY_10SEC 10000 |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 101 | #define DELAY_30SEC 30000 |
| 102 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 103 | static bool is_thread_start = false; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 104 | static struct select_msg_info msg_info; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 105 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 106 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 107 | struct boot_verify_info { |
| 108 | int msg_type; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 109 | const char *title_msg; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 110 | const char *warning_msg; |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 111 | const char *url_msg; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 112 | const char *notice_msg; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | struct boot_verify_info boot_verify_info[] = { |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 116 | [DISPLAY_MENU_RED] = {FBCON_RED_MSG, TITLE_MSG, RED_WARNING_MSG, URL_MSG, NULL}, |
| 117 | [DISPLAY_MENU_YELLOW] = {FBCON_YELLOW_MSG, TITLE_MSG, YELLOW_WARNING_MSG, URL_MSG, PAUSE_BOOT_MSG}, |
| 118 | [DISPLAY_MENU_ORANGE] = {FBCON_ORANGE_MSG, TITLE_MSG, ORANGE_WARNING_MSG, URL_MSG, PAUSE_BOOT_MSG}, |
| 119 | [DISPLAY_MENU_LOGGING] = {FBCON_RED_MSG, TITLE_MSG, LOGGING_WARNING_MSG, NULL, NULL}, |
| 120 | [DISPLAY_MENU_EIO] = {FBCON_RED_MSG, TITLE_MSG, EIO_WARNING_MSG, URL_MSG, CONTINUE_BOOT_MSG}}; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 121 | #endif |
| 122 | |
| 123 | static char *verify_option_menu[] = { |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 124 | [POWEROFF] = "Power off\n", |
| 125 | [RESTART] = "Restart\n", |
| 126 | [RECOVER] = "Recovery\n", |
| 127 | [FASTBOOT] = "Fastboot\n", |
| 128 | [BACK] = "Back to previous page\n"}; |
| 129 | |
tracychui | f6dd8d7 | 2020-01-20 16:53:15 +0800 | [diff] [blame] | 130 | /*[20200120][TracyChui]Remove FFBM item in fastboot mode start */ |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 131 | static char *fastboot_option_menu[] = { |
| 132 | [0] = "START\n", |
| 133 | [1] = "Restart bootloader\n", |
| 134 | [2] = "Recovery mode\n", |
tracychui | f6dd8d7 | 2020-01-20 16:53:15 +0800 | [diff] [blame] | 135 | [3] = "Power off\n"}; |
| 136 | /*[20200120][TracyChui]Remove FFBM item in fastboot mode end */ |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 137 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 138 | static struct unlock_info munlock_info[] = { |
| 139 | [DISPLAY_MENU_LOCK] = {UNLOCK, FALSE}, |
| 140 | [DISPLAY_MENU_UNLOCK] = {UNLOCK, TRUE}, |
| 141 | [DISPLAY_MENU_LOCK_CRITICAL] = {UNLOCK_CRITICAL, FALSE}, |
| 142 | [DISPLAY_MENU_UNLOCK_CRITICAL] = {UNLOCK_CRITICAL, TRUE}, |
| 143 | }; |
| 144 | |
| 145 | struct unlock_option_msg munlock_option_msg[] = { |
| 146 | [TRUE] = {"DO NOT UNLOCK THE BOOTLOADER \n", "UNLOCK THE BOOTLOADER \n"}, |
| 147 | [FALSE] = {"DO NOT LOCK THE BOOTLOADER \n", "LOCK THE BOOTLOADER \n"}, |
| 148 | }; |
| 149 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 150 | static int big_factor = 2; |
| 151 | static int common_factor = 1; |
| 152 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 153 | static void wait_for_exit() |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 154 | { |
| 155 | struct select_msg_info *select_msg; |
| 156 | select_msg = &msg_info; |
| 157 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 158 | mutex_acquire(&select_msg->msg_lock); |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 159 | while(!select_msg->info.rel_exit == true) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 160 | mutex_release(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 161 | thread_sleep(10); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 162 | mutex_acquire(&select_msg->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 163 | } |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 164 | mutex_release(&select_msg->msg_lock); |
| 165 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 166 | is_thread_start = false; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 167 | fbcon_clear(); |
| 168 | display_image_on_screen(); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 169 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 170 | msm_display_flush(); |
| 171 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 172 | } |
| 173 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 174 | void wait_for_users_action() |
| 175 | { |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 176 | if (is_display_disabled()) |
| 177 | return; |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 178 | /* Waiting for exit menu keys detection if there is no any usr action |
| 179 | * otherwise it will do the action base on the keys detection thread |
| 180 | */ |
| 181 | wait_for_exit(); |
| 182 | } |
| 183 | |
| 184 | void exit_menu_keys_detection() |
| 185 | { |
| 186 | struct select_msg_info *select_msg; |
| 187 | select_msg = &msg_info; |
| 188 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 189 | if (is_display_disabled()) |
| 190 | return; |
| 191 | |
lijuang | de34d50 | 2016-02-26 16:04:50 +0800 | [diff] [blame] | 192 | mutex_acquire(&select_msg->msg_lock); |
| 193 | select_msg->info.is_exit = true; |
| 194 | mutex_release(&select_msg->msg_lock); |
| 195 | |
| 196 | wait_for_exit(); |
| 197 | } |
| 198 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 199 | static void set_message_factor() |
| 200 | { |
| 201 | uint32_t tmp_factor = 0; |
lijuang | 9e73e5a | 2018-04-23 17:00:16 +0800 | [diff] [blame] | 202 | uint32_t max_x_count = 0; |
| 203 | uint32_t max_x = 0; |
| 204 | |
| 205 | if (fbcon_get_width() < fbcon_get_height()) |
| 206 | max_x_count = CHAR_NUM_PERROW_POR; |
| 207 | else |
| 208 | max_x_count = CHAR_NUM_PERROW_HOR; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 209 | |
| 210 | max_x = fbcon_get_max_x(); |
| 211 | tmp_factor = max_x/max_x_count; |
| 212 | |
| 213 | if(tmp_factor <= 1) { |
| 214 | big_factor = 2; |
| 215 | common_factor = 1; |
| 216 | } else { |
| 217 | big_factor = tmp_factor*2; |
| 218 | common_factor = tmp_factor; |
| 219 | } |
| 220 | } |
| 221 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 222 | /* If y_start == 0, it will draw message from the current Y axis location, |
| 223 | otherwise it will start from the the value of y_start. */ |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 224 | static void display_fbcon_menu_message(char *str, unsigned type, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 225 | unsigned scale_factor, int y_start) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 226 | { |
| 227 | while(*str != 0) { |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 228 | fbcon_putc_factor(*str++, type, scale_factor, y_start); |
| 229 | y_start = 0; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | static char *str_align_right(char *str, int factor) |
| 234 | { |
| 235 | uint32_t max_x = 0; |
| 236 | int diff = 0; |
| 237 | int i = 0; |
| 238 | char *str_target = NULL; |
| 239 | |
| 240 | max_x = fbcon_get_max_x(); |
| 241 | if (!str_target && max_x) { |
| 242 | str_target = malloc(max_x); |
| 243 | } |
| 244 | |
| 245 | if (str_target) { |
| 246 | memset(str_target, 0, max_x); |
| 247 | if ( max_x/factor > strlen(str)) { |
| 248 | if (factor == 1) |
| 249 | diff = max_x/factor - strlen(str) - 1; |
| 250 | else |
| 251 | diff = max_x/factor - strlen(str); |
| 252 | for (i = 0; i < diff; i++) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 253 | strlcat(str_target, " ", max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 254 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 255 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 256 | strlcat(str_target, str, max_x); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 257 | } |
lijuang | bdb18ea | 2018-02-06 17:21:18 +0800 | [diff] [blame] | 258 | return str_target; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 259 | } |
| 260 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 261 | /** |
| 262 | Reset device unlock status |
| 263 | @param[in] Type The type of the unlock. |
| 264 | [DISPLAY_MENU_UNLOCK]: unlock the device |
| 265 | [DISPLAY_MENU_UNLOCK_CRITICAL]: critical unlock the device |
| 266 | [DISPLAY_MENU_LOCK]: lock the device |
| 267 | [DISPLAY_MENU_LOCK_CRITICAL]: critical lock the device |
| 268 | **/ |
| 269 | void reset_device_unlock_status (int type) |
| 270 | { |
| 271 | struct recovery_message msg; |
| 272 | |
| 273 | if (type == DISPLAY_MENU_LOCK || |
| 274 | type == DISPLAY_MENU_UNLOCK || |
| 275 | type == DISPLAY_MENU_LOCK_CRITICAL || |
| 276 | type == DISPLAY_MENU_UNLOCK_CRITICAL) { |
| 277 | set_device_unlock_value (munlock_info[type].unlock_type, |
| 278 | munlock_info[type].unlock_value); |
| 279 | memset(&msg, 0, sizeof(msg)); |
| 280 | snprintf(msg.recovery, sizeof(msg.recovery), "recovery\n--wipe_data"); |
| 281 | write_misc(0, &msg, sizeof(msg)); |
| 282 | } |
| 283 | } |
| 284 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 285 | /* msg_lock need to be holded when call this function. */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 286 | static void display_unlock_menu_renew(struct select_msg_info *unlock_msg_info, |
| 287 | int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 288 | { |
| 289 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 290 | memset(&unlock_msg_info->info, 0, sizeof(struct menu_info)); |
| 291 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 292 | display_fbcon_menu_message("<!>\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 293 | FBCON_UNLOCK_TITLE_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 294 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 295 | if (status) { |
| 296 | display_fbcon_menu_message((char*)unlock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 297 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 298 | } else { |
| 299 | display_fbcon_menu_message((char*)lock_menu_common_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 300 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 301 | } |
| 302 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 303 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 304 | unlock_msg_info->info.option_start[0] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 305 | display_fbcon_menu_message((char *)munlock_option_msg[status].ignore_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 306 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 307 | unlock_msg_info->info.option_bg[0] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 308 | unlock_msg_info->info.option_end[0] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 309 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 310 | unlock_msg_info->info.option_start[1] = fbcon_get_current_line(); |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 311 | display_fbcon_menu_message((char *)munlock_option_msg[status].comfirm_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 312 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 313 | unlock_msg_info->info.option_bg[1] = fbcon_get_current_bg(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 314 | unlock_msg_info->info.option_end[1] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 315 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 316 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 317 | if (type == UNLOCK) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 318 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 319 | if (!status) |
| 320 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK; |
| 321 | } else if (type == UNLOCK_CRITICAL) { |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 322 | unlock_msg_info->info.msg_type = DISPLAY_MENU_UNLOCK_CRITICAL; |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 323 | if (!status) |
| 324 | unlock_msg_info->info.msg_type = DISPLAY_MENU_LOCK_CRITICAL; |
| 325 | } |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 326 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 327 | unlock_msg_info->info.option_num = 2; |
| 328 | |
| 329 | /* Initialize the option index */ |
| 330 | unlock_msg_info->info.option_index= 2; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 331 | } |
| 332 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 333 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 334 | /* msg_lock need to be holded when call this function. */ |
| 335 | void display_bootverify_menu_renew(struct select_msg_info *msg_info, int type) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 336 | { |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 337 | unsigned char* fp_buf = NULL; |
| 338 | char fp_str_temp[EVP_MAX_MD_SIZE] = {'\0'}; |
| 339 | char fp_str[EVP_MAX_MD_SIZE*2] = {'\0'}; |
| 340 | char str_temp[8]; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 341 | uint32 fp_size = 0; |
| 342 | unsigned int i = 0; |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 343 | uint32_t timeout = DELAY_10SEC; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 344 | |
| 345 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 346 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 347 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 348 | if(boot_verify_info[type].title_msg != NULL) |
| 349 | display_fbcon_menu_message((char*)boot_verify_info[type].title_msg, |
| 350 | boot_verify_info[type].msg_type, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 351 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 352 | if(boot_verify_info[type].warning_msg != NULL) |
| 353 | display_fbcon_menu_message((char*)boot_verify_info[type].warning_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 354 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 355 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 356 | if(boot_verify_info[type].url_msg != NULL) { |
| 357 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", fbcon_get_current_line()); |
Brahmaji K | 0c2d598 | 2017-09-07 18:44:21 +0530 | [diff] [blame] | 358 | display_fbcon_menu_message((char*)boot_verify_info[type].url_msg, |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 359 | boot_verify_info[type].msg_type, common_factor, 0); |
| 360 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", fbcon_get_current_line()); |
| 361 | } |
| 362 | |
| 363 | if(boot_verify_info[type].notice_msg != NULL) { |
| 364 | msg_info->info.option_start[0] = fbcon_get_current_line(); |
| 365 | dprintf(INFO, "display_fbcon_menu_message: Location=%d\n", msg_info->info.option_start[0]); |
| 366 | display_fbcon_menu_message((char*)boot_verify_info[type].notice_msg, |
| 367 | FBCON_COMMON_MSG, common_factor, 0); |
| 368 | msg_info->info.option_end[0] = fbcon_get_current_line(); |
| 369 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 370 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 371 | if (type == DISPLAY_MENU_YELLOW) { |
| 372 | fp_buf = get_boot_fingerprint(&fp_size); |
| 373 | if (fp_buf != NULL) { |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 374 | strlcpy(fp_str_temp, (char const *)fp_buf, fp_size); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 375 | for (i = 0; i < fp_size; i++) { |
| 376 | if(i == fp_size - 1) |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 377 | snprintf(str_temp, sizeof(str_temp), "%02x", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 378 | else |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 379 | snprintf(str_temp, sizeof(str_temp), "%02x-", fp_str_temp[i]); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 380 | |
Parth Dixit | 73d3bd0 | 2016-01-07 14:29:41 +0530 | [diff] [blame] | 381 | strlcat(fp_str, str_temp, sizeof(fp_str)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 382 | } |
| 383 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 384 | display_fbcon_menu_message("ID:", FBCON_COMMON_MSG, common_factor, 0); |
| 385 | display_fbcon_menu_message(fp_str, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 386 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 387 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 388 | switch (type) { |
| 389 | case DISPLAY_MENU_RED: |
| 390 | timeout = DELAY_30SEC; |
| 391 | break; |
| 392 | case DISPLAY_MENU_EIO: |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 393 | #if ENABLE_VB_ATTEST |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 394 | timeout = DELAY_30SEC; |
Parth Dixit | 54ac3bb | 2017-03-07 15:52:48 +0530 | [diff] [blame] | 395 | #endif |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 396 | break; |
| 397 | default: |
| 398 | timeout = DELAY_10SEC; |
| 399 | break; |
| 400 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 401 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 402 | msg_info->info.msg_type = type; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 403 | |
| 404 | /* Initialize the time out time */ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 405 | msg_info->info.timeout_time = timeout; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 406 | } |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 407 | |
| 408 | void display_bootverify_menu_update (struct select_msg_info *msg_info) |
| 409 | { |
| 410 | int location = msg_info->info.option_start[0]; |
| 411 | |
| 412 | /* clean the old msg */ |
| 413 | fbcon_clear_msg (location, msg_info->info.option_end[0]); |
| 414 | display_fbcon_menu_message(CONTINUE_BOOT_MSG, FBCON_COMMON_MSG, common_factor, location); |
| 415 | msg_info->info.timeout_time = DELAY_30SEC; |
| 416 | } |
| 417 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 418 | #endif |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 419 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 420 | /* msg_lock need to be holded when call this function. */ |
| 421 | void display_bootverify_option_menu_renew(struct select_msg_info *msg_info) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 422 | { |
| 423 | int i = 0; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 424 | int len = 0; |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 425 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 426 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 427 | memset(&msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 428 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 429 | len = ARRAY_SIZE(verify_option_menu); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 430 | display_fbcon_menu_message("Options menu:\n\n", |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 431 | FBCON_COMMON_MSG, big_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 432 | display_fbcon_menu_message("Press volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 433 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 434 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 435 | for (i = 0; i < len; i++) { |
| 436 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 437 | msg_info->info.option_start[i] = fbcon_get_current_line(); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 438 | display_fbcon_menu_message(verify_option_menu[i], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 439 | FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 440 | msg_info->info.option_bg[i]= fbcon_get_current_bg(); |
| 441 | msg_info->info.option_end[i]= fbcon_get_current_line(); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 442 | } |
| 443 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 444 | fbcon_draw_line(FBCON_COMMON_MSG); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 445 | msg_info->info.msg_type = DISPLAY_MENU_MORE_OPTION; |
| 446 | msg_info->info.option_num = len; |
| 447 | |
| 448 | /* Initialize the option index */ |
| 449 | msg_info->info.option_index= len; |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 450 | } |
| 451 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 452 | /* msg_lock need to be holded when call this function. */ |
| 453 | void display_fastboot_menu_renew(struct select_msg_info *fastboot_msg_info) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 454 | { |
| 455 | int len; |
| 456 | int msg_type = FBCON_COMMON_MSG; |
| 457 | char msg_buf[64]; |
| 458 | char msg[128]; |
| 459 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 460 | /* The fastboot menu is switched base on the option index |
| 461 | * So it's need to store the index for the menu switching |
| 462 | */ |
| 463 | uint32_t option_index = fastboot_msg_info->info.option_index; |
| 464 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 465 | fbcon_clear(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 466 | memset(&fastboot_msg_info->info, 0, sizeof(struct menu_info)); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 467 | |
| 468 | len = ARRAY_SIZE(fastboot_option_menu); |
| 469 | switch(option_index) { |
| 470 | case 0: |
| 471 | msg_type = FBCON_GREEN_MSG; |
| 472 | break; |
| 473 | case 1: |
| 474 | case 2: |
| 475 | msg_type = FBCON_RED_MSG; |
| 476 | break; |
| 477 | case 3: |
lijuang | 42aefaa | 2016-04-14 15:55:17 +0800 | [diff] [blame] | 478 | case 4: |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 479 | msg_type = FBCON_COMMON_MSG; |
| 480 | break; |
| 481 | } |
| 482 | fbcon_draw_line(msg_type); |
| 483 | display_fbcon_menu_message(fastboot_option_menu[option_index], |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 484 | msg_type, big_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 485 | fbcon_draw_line(msg_type); |
| 486 | display_fbcon_menu_message("\n\nPress volume key to select, and "\ |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 487 | "press power key to select\n\n", FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 488 | |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 489 | display_fbcon_menu_message("FASTBOOT MODE\n", FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 490 | |
| 491 | get_product_name((unsigned char *) msg_buf); |
| 492 | snprintf(msg, sizeof(msg), "PRODUCT_NAME - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 493 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 494 | |
| 495 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 496 | smem_get_hw_platform_name((unsigned char *) msg_buf, sizeof(msg_buf)); |
| 497 | snprintf(msg, sizeof(msg), "VARIANT - %s %s\n", |
| 498 | msg_buf, target_is_emmc_boot()? "eMMC":"UFS"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 499 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 500 | |
| 501 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 502 | get_bootloader_version((unsigned char *) msg_buf); |
| 503 | snprintf(msg, sizeof(msg), "BOOTLOADER VERSION - %s\n", |
| 504 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 505 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 506 | |
| 507 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 508 | get_baseband_version((unsigned char *) msg_buf); |
| 509 | snprintf(msg, sizeof(msg), "BASEBAND VERSION - %s\n", |
| 510 | msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 511 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 512 | |
| 513 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 514 | target_serialno((unsigned char *) msg_buf); |
| 515 | snprintf(msg, sizeof(msg), "SERIAL NUMBER - %s\n", msg_buf); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 516 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 517 | |
tracychui | d19990d | 2020-06-12 13:22:29 +0800 | [diff] [blame] | 518 | /*[TracyChui]Show memory information on fastboot screen 20200612 start */ |
| 519 | dprintf(CRITICAL,"smem_get_ddr_size=%llu\n", smem_get_ddr_size()); |
| 520 | if (smem_get_ddr_size() == MEM_3GB) { |
| 521 | snprintf(msg, sizeof(msg), "INTERNAL STORAGE SIZE - 32G\n"); |
| 522 | } else if (smem_get_ddr_size() > MEM_3GB) { |
| 523 | if (smem_get_ddr_size() < MEM_4GB) |
| 524 | { |
| 525 | snprintf(msg, sizeof(msg), "INTERNAL STORAGE SIZE - 64G\n"); |
| 526 | } |
| 527 | else |
| 528 | { |
| 529 | snprintf(msg, sizeof(msg), "INTERNAL STORAGE SIZE - \n"); |
| 530 | } |
| 531 | } else { |
| 532 | snprintf(msg, sizeof(msg), "INTERNAL STORAGE SIZE - UNKNOWN\n"); |
| 533 | } |
| 534 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
| 535 | |
| 536 | memset(msg_buf, 0, sizeof(msg_buf)); |
| 537 | smem_get_ddr_manufacturer_id((unsigned char *) msg_buf); |
| 538 | dprintf(CRITICAL,"smem_get_ddr_size=%llu\n", smem_get_ddr_size()); |
| 539 | if (smem_get_ddr_size() == MEM_3GB) { |
| 540 | snprintf(msg, sizeof(msg), "MAIN MEMORY SIZE AND VENDOR - 3G\n"); |
| 541 | } else if (smem_get_ddr_size() > MEM_3GB) { |
| 542 | if (smem_get_ddr_size() < MEM_4GB) |
| 543 | { |
| 544 | snprintf(msg, sizeof(msg), "MAIN MEMORY SIZE AND VENDOR - 4G %s\n", msg_buf); |
| 545 | } |
| 546 | else |
| 547 | { |
| 548 | snprintf(msg, sizeof(msg), "MAIN MEMORY SIZE AND VENDOR - %s\n", msg_buf); |
| 549 | } |
| 550 | } else { |
| 551 | snprintf(msg, sizeof(msg), "MAIN MEMORY SIZE AND VENDOR - %s\n", msg_buf); |
| 552 | } |
| 553 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
| 554 | |
| 555 | /*[TracyChui]Show memory information on fastboot screen 20200612 end */ |
| 556 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 557 | snprintf(msg, sizeof(msg), "SECURE BOOT - %s\n", |
| 558 | is_secure_boot_enable()? "enabled":"disabled"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 559 | display_fbcon_menu_message(msg, FBCON_COMMON_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 560 | |
| 561 | snprintf(msg, sizeof(msg), "DEVICE STATE - %s\n", |
| 562 | is_device_locked()? "locked":"unlocked"); |
Monika Singh | 05fff3b | 2019-09-16 16:00:33 +0530 | [diff] [blame] | 563 | display_fbcon_menu_message(msg, FBCON_RED_MSG, common_factor, 0); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 564 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 565 | fastboot_msg_info->info.msg_type = DISPLAY_MENU_FASTBOOT; |
| 566 | fastboot_msg_info->info.option_num = len; |
| 567 | fastboot_msg_info->info.option_index = option_index; |
| 568 | } |
| 569 | |
| 570 | void msg_lock_init() |
| 571 | { |
| 572 | static bool is_msg_lock_init = false; |
| 573 | struct select_msg_info *msg_lock_info; |
| 574 | msg_lock_info = &msg_info; |
| 575 | |
| 576 | if (!is_msg_lock_init) { |
| 577 | mutex_init(&msg_lock_info->msg_lock); |
| 578 | is_msg_lock_init = true; |
| 579 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | static void display_menu_thread_start(struct select_msg_info *msg_info) |
| 583 | { |
| 584 | thread_t *thr; |
| 585 | |
| 586 | if (!is_thread_start) { |
| 587 | thr = thread_create("selectkeydetect", &select_msg_keys_detect, |
| 588 | (void*)msg_info, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE); |
| 589 | if (!thr) { |
| 590 | dprintf(CRITICAL, "ERROR: creat device status detect thread failed!!\n"); |
| 591 | return; |
| 592 | } |
| 593 | thread_resume(thr); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 594 | is_thread_start = true; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 595 | } |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 596 | } |
| 597 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 598 | /* The fuction be called after device in fastboot mode, |
| 599 | * so it's no need to initialize the msg_lock again |
| 600 | */ |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 601 | void display_unlock_menu(int type, bool status) |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 602 | { |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 603 | struct select_msg_info *unlock_menu_msg_info; |
| 604 | unlock_menu_msg_info = &msg_info; |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 605 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 606 | if (is_display_disabled()) |
| 607 | return; |
| 608 | |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 609 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 610 | |
| 611 | msg_lock_init(); |
| 612 | mutex_acquire(&unlock_menu_msg_info->msg_lock); |
| 613 | |
| 614 | /* Initialize the last_msg_type */ |
| 615 | unlock_menu_msg_info->last_msg_type = |
| 616 | unlock_menu_msg_info->info.msg_type; |
| 617 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 618 | display_unlock_menu_renew(unlock_menu_msg_info, type, status); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 619 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 620 | msm_display_flush(); |
| 621 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 622 | mutex_release(&unlock_menu_msg_info->msg_lock); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 623 | |
lijuang | f55ad05 | 2018-04-23 18:30:50 +0800 | [diff] [blame] | 624 | dprintf(INFO, "creating %s keys detect thread\n", |
| 625 | status ? "unlock":"lock"); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 626 | display_menu_thread_start(unlock_menu_msg_info); |
lijuang | 7d235f4 | 2015-07-16 20:19:45 +0800 | [diff] [blame] | 627 | } |
| 628 | |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 629 | void display_fastboot_menu() |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 630 | { |
| 631 | struct select_msg_info *fastboot_menu_msg_info; |
| 632 | fastboot_menu_msg_info = &msg_info; |
| 633 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 634 | if (is_display_disabled()) |
| 635 | return; |
| 636 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 637 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 638 | |
| 639 | msg_lock_init(); |
| 640 | mutex_acquire(&fastboot_menu_msg_info->msg_lock); |
| 641 | |
| 642 | /* There are 4 pages for fastboot menu: |
| 643 | * Page: Start/Fastboot/Recovery/Poweroff |
| 644 | * The menu is switched base on the option index |
| 645 | * Initialize the option index and last_msg_type |
| 646 | */ |
| 647 | fastboot_menu_msg_info->info.option_index = 0; |
| 648 | fastboot_menu_msg_info->last_msg_type = |
| 649 | fastboot_menu_msg_info->info.msg_type; |
| 650 | |
| 651 | display_fastboot_menu_renew(fastboot_menu_msg_info); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 652 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 Start |
| 653 | msm_display_flush(); |
| 654 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 655 | mutex_release(&fastboot_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 656 | |
| 657 | dprintf(INFO, "creating fastboot menu keys detect thread\n"); |
| 658 | display_menu_thread_start(fastboot_menu_msg_info); |
| 659 | } |
| 660 | |
Monika Singh | 5e17036 | 2018-03-14 00:48:36 +0530 | [diff] [blame] | 661 | #if VERIFIED_BOOT || VERIFIED_BOOT_2 |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 662 | void display_bootverify_menu(int type) |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 663 | { |
| 664 | struct select_msg_info *bootverify_menu_msg_info; |
| 665 | bootverify_menu_msg_info = &msg_info; |
| 666 | |
Krishna Manikandan | f2c8be9 | 2017-12-05 18:07:56 +0530 | [diff] [blame] | 667 | if (is_display_disabled()) |
| 668 | return; |
| 669 | |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 670 | set_message_factor(); |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 671 | |
| 672 | msg_lock_init(); |
| 673 | mutex_acquire(&bootverify_menu_msg_info->msg_lock); |
| 674 | |
| 675 | /* Initialize the last_msg_type */ |
| 676 | bootverify_menu_msg_info->last_msg_type = |
| 677 | bootverify_menu_msg_info->info.msg_type; |
| 678 | |
| 679 | display_bootverify_menu_renew(bootverify_menu_msg_info, type); |
jialongjhan | b2dda0b | 2020-04-21 20:20:51 +0800 | [diff] [blame] | 680 | //[Arima][8901][JialongJhan] Command mode update screen 201906118 Start |
| 681 | msm_display_flush(); |
| 682 | //[Arima][8901][JialongJhan] Command mode update screen 20190618 End |
lijuang | 9a7d3b9 | 2015-11-30 14:41:24 +0800 | [diff] [blame] | 683 | mutex_release(&bootverify_menu_msg_info->msg_lock); |
lijuang | 4ece1e7 | 2015-08-14 21:02:36 +0800 | [diff] [blame] | 684 | |
| 685 | dprintf(INFO, "creating boot verify keys detect thread\n"); |
| 686 | display_menu_thread_start(bootverify_menu_msg_info); |
| 687 | } |
| 688 | #endif |