Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. |
lijuang | 463e3cb | 2016-07-27 19:26:38 +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 | */ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 28 | #include "AutoGen.h" |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 29 | #include <Library/BaseLib.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 30 | #include <Library/BaseMemoryLib.h> |
| 31 | #include <Library/DebugLib.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 32 | #include <Library/DeviceInfo.h> |
| 33 | #include <Library/DrawUI.h> |
| 34 | #include <Library/FastbootMenu.h> |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 35 | #include <Library/MemoryAllocationLib.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 36 | #include <Library/MenuKeysDetection.h> |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 37 | #include <Library/UefiBootServicesTableLib.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 38 | #include <Library/UpdateDeviceTree.h> |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 39 | #include <Library/BootLinux.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 40 | #include <Protocol/EFIVerifiedBoot.h> |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 41 | #include <Uefi.h> |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 42 | |
| 43 | STATIC OPTION_MENU_INFO gMenuInfo; |
| 44 | |
| 45 | STATIC MENU_MSG_INFO mFastbootOptionTitle[] = { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 46 | {{"START"}, |
| 47 | BIG_FACTOR, |
| 48 | BGR_GREEN, |
| 49 | BGR_BLACK, |
| 50 | OPTION_ITEM, |
| 51 | 0, |
| 52 | RESTART}, |
| 53 | {{"Restart bootloader"}, |
| 54 | BIG_FACTOR, |
| 55 | BGR_RED, |
| 56 | BGR_BLACK, |
| 57 | OPTION_ITEM, |
| 58 | 0, |
| 59 | FASTBOOT}, |
| 60 | {{"Recovery mode"}, |
| 61 | BIG_FACTOR, |
| 62 | BGR_RED, |
| 63 | BGR_BLACK, |
| 64 | OPTION_ITEM, |
| 65 | 0, |
| 66 | RECOVER}, |
| 67 | {{"Power off"}, |
| 68 | BIG_FACTOR, |
| 69 | BGR_WHITE, |
| 70 | BGR_BLACK, |
| 71 | OPTION_ITEM, |
| 72 | 0, |
| 73 | POWEROFF}, |
| 74 | {{"Boot to FFBM"}, |
| 75 | BIG_FACTOR, |
| 76 | BGR_YELLOW, |
| 77 | BGR_BLACK, |
| 78 | OPTION_ITEM, |
| 79 | 0, |
| 80 | FFBM}, |
| 81 | {{"Boot to QMMI"}, |
| 82 | BIG_FACTOR, |
| 83 | BGR_YELLOW, |
| 84 | BGR_BLACK, |
| 85 | OPTION_ITEM, |
| 86 | 0, |
| 87 | QMMI}, |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | STATIC MENU_MSG_INFO mFastbootCommonMsgInfo[] = { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 91 | {{"\nPress volume key to select, " |
| 92 | "and press power key to select\n\n"}, |
| 93 | COMMON_FACTOR, |
| 94 | BGR_WHITE, |
| 95 | BGR_BLACK, |
| 96 | COMMON, |
| 97 | 0, |
| 98 | NOACTION}, |
Alexander Martinz | 1bf6709 | 2021-02-17 17:43:53 +0100 | [diff] [blame^] | 99 | {{"Fastboot mode\n\n"}, |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 100 | COMMON_FACTOR, |
Alexander Martinz | 1bf6709 | 2021-02-17 17:43:53 +0100 | [diff] [blame^] | 101 | BGR_YELLOW, |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 102 | BGR_BLACK, |
| 103 | COMMON, |
| 104 | 0, |
| 105 | NOACTION}, |
| 106 | {{"PRODUCT_NAME - "}, |
| 107 | COMMON_FACTOR, |
| 108 | BGR_WHITE, |
| 109 | BGR_BLACK, |
| 110 | COMMON, |
| 111 | 0, |
| 112 | NOACTION}, |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 113 | {{"PRODUCT_MODEL - "}, |
| 114 | COMMON_FACTOR, |
| 115 | BGR_WHITE, |
| 116 | BGR_BLACK, |
| 117 | COMMON, |
| 118 | 0, |
| 119 | NOACTION}, |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 120 | {{"VARIANT - "}, |
| 121 | COMMON_FACTOR, |
| 122 | BGR_WHITE, |
| 123 | BGR_BLACK, |
| 124 | COMMON, |
| 125 | 0, |
| 126 | NOACTION}, |
| 127 | {{"BOOTLOADER VERSION - "}, |
| 128 | COMMON_FACTOR, |
| 129 | BGR_WHITE, |
| 130 | BGR_BLACK, |
| 131 | COMMON, |
| 132 | 0, |
| 133 | NOACTION}, |
| 134 | {{"BASEBAND VERSION - "}, |
| 135 | COMMON_FACTOR, |
| 136 | BGR_WHITE, |
| 137 | BGR_BLACK, |
| 138 | COMMON, |
| 139 | 0, |
| 140 | NOACTION}, |
| 141 | {{"SERIAL NUMBER - "}, |
| 142 | COMMON_FACTOR, |
| 143 | BGR_WHITE, |
| 144 | BGR_BLACK, |
| 145 | COMMON, |
| 146 | 0, |
| 147 | NOACTION}, |
Alexander Martinz | 44513b0 | 2020-06-02 12:18:31 +0200 | [diff] [blame] | 148 | {{"HARDWARE REVISION - "}, |
| 149 | COMMON_FACTOR, |
| 150 | BGR_WHITE, |
| 151 | BGR_BLACK, |
| 152 | COMMON, |
| 153 | 0, |
| 154 | NOACTION}, |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 155 | {{"SECURE BOOT - "}, |
| 156 | COMMON_FACTOR, |
| 157 | BGR_WHITE, |
| 158 | BGR_BLACK, |
| 159 | COMMON, |
| 160 | 0, |
| 161 | NOACTION}, |
Alexander Martinz | 1bf6709 | 2021-02-17 17:43:53 +0100 | [diff] [blame^] | 162 | {{"\nDEVICE STATE - unlocked"}, |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 163 | COMMON_FACTOR, |
| 164 | BGR_RED, |
| 165 | BGR_BLACK, |
| 166 | COMMON, |
| 167 | 0, |
| 168 | NOACTION}, |
Alexander Martinz | 1bf6709 | 2021-02-17 17:43:53 +0100 | [diff] [blame^] | 169 | {{"\nDEVICE STATE - locked"}, |
| 170 | COMMON_FACTOR, |
| 171 | BGR_GREEN, |
| 172 | BGR_BLACK, |
| 173 | COMMON, |
| 174 | 0, |
| 175 | NOACTION}, |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | /** |
| 179 | Update the fastboot option item |
| 180 | @param[in] OptionItem The new fastboot option item |
| 181 | @param[out] pLocation The pointer of the location |
| 182 | @retval EFI_SUCCESS The entry point is executed successfully. |
| 183 | @retval other Some error occurs when executing this entry point. |
| 184 | **/ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 185 | EFI_STATUS |
| 186 | UpdateFastbootOptionItem (UINT32 OptionItem, UINT32 *pLocation) |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 187 | { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 188 | EFI_STATUS Status = EFI_SUCCESS; |
| 189 | UINT32 Location = 0; |
| 190 | UINT32 Height = 0; |
| 191 | MENU_MSG_INFO *FastbootLineInfo = NULL; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 192 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 193 | FastbootLineInfo = AllocateZeroPool (sizeof (MENU_MSG_INFO)); |
| 194 | if (FastbootLineInfo == NULL) { |
| 195 | DEBUG ((EFI_D_ERROR, "Failed to allocate zero pool.\n")); |
| 196 | return EFI_OUT_OF_RESOURCES; |
| 197 | } |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 198 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 199 | SetMenuMsgInfo (FastbootLineInfo, "__________", COMMON_FACTOR, |
| 200 | mFastbootOptionTitle[OptionItem].FgColor, |
| 201 | mFastbootOptionTitle[OptionItem].BgColor, LINEATION, Location, |
| 202 | NOACTION); |
| 203 | Status = DrawMenu (FastbootLineInfo, &Height); |
| 204 | if (Status != EFI_SUCCESS) |
| 205 | goto Exit; |
| 206 | Location += Height; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 207 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 208 | mFastbootOptionTitle[OptionItem].Location = Location; |
| 209 | Status = DrawMenu (&mFastbootOptionTitle[OptionItem], &Height); |
| 210 | if (Status != EFI_SUCCESS) |
| 211 | goto Exit; |
| 212 | Location += Height; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 213 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 214 | FastbootLineInfo->Location = Location; |
| 215 | Status = DrawMenu (FastbootLineInfo, &Height); |
| 216 | if (Status != EFI_SUCCESS) |
| 217 | goto Exit; |
| 218 | Location += Height; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 219 | |
lijuang | c336a29 | 2017-08-22 19:48:49 +0800 | [diff] [blame] | 220 | Exit: |
| 221 | FreePool (FastbootLineInfo); |
| 222 | FastbootLineInfo = NULL; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 223 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 224 | if (pLocation != NULL) |
| 225 | *pLocation = Location; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 226 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 227 | return Status; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /** |
| 231 | Draw the fastboot menu |
| 232 | @param[out] OptionMenuInfo Fastboot option info |
| 233 | @retval EFI_SUCCESS The entry point is executed successfully. |
| 234 | @retval other Some error occurs when executing this entry point. |
| 235 | **/ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 236 | STATIC EFI_STATUS |
| 237 | FastbootMenuShowScreen (OPTION_MENU_INFO *OptionMenuInfo) |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 238 | { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 239 | EFI_STATUS Status = EFI_SUCCESS; |
| 240 | UINT32 Location = 0; |
| 241 | UINT32 OptionItem = 0; |
| 242 | UINT32 Height = 0; |
| 243 | UINT32 i = 0; |
| 244 | CHAR8 StrTemp[MAX_RSP_SIZE] = ""; |
| 245 | CHAR8 StrTemp1[MAX_RSP_SIZE] = ""; |
| 246 | CHAR8 VersionTemp[MAX_VERSION_LEN] = ""; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 247 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 248 | ZeroMem (&OptionMenuInfo->Info, sizeof (MENU_OPTION_ITEM_INFO)); |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 249 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 250 | /* Update fastboot option title */ |
| 251 | OptionMenuInfo->Info.MsgInfo = mFastbootOptionTitle; |
| 252 | for (i = 0; i < ARRAY_SIZE (mFastbootOptionTitle); i++) { |
| 253 | OptionMenuInfo->Info.OptionItems[i] = i; |
| 254 | } |
| 255 | OptionItem = |
| 256 | OptionMenuInfo->Info.OptionItems[OptionMenuInfo->Info.OptionIndex]; |
| 257 | Status = UpdateFastbootOptionItem (OptionItem, &Location); |
| 258 | if (Status != EFI_SUCCESS) |
| 259 | return Status; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 260 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 261 | /* Update fastboot common message */ |
| 262 | for (i = 0; i < ARRAY_SIZE (mFastbootCommonMsgInfo); i++) { |
| 263 | switch (i) { |
| 264 | case 0: |
| 265 | case 1: |
| 266 | break; |
| 267 | case 2: |
| 268 | /* Get product name */ |
| 269 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
Jeevan Shriram | d5d169f | 2018-04-20 16:09:10 -0700 | [diff] [blame] | 270 | sizeof (mFastbootCommonMsgInfo[i].Msg), PRODUCT_NAME, |
| 271 | AsciiStrLen (PRODUCT_NAME)); |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 272 | break; |
| 273 | case 3: |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 274 | /* Get product model */ |
| 275 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 276 | sizeof (mFastbootCommonMsgInfo[i].Msg), PRODUCT_MODEL, |
| 277 | AsciiStrLen (PRODUCT_MODEL)); |
| 278 | break; |
| 279 | case 4: |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 280 | /* Get variant value */ |
| 281 | BoardHwPlatformName (StrTemp, sizeof (StrTemp)); |
| 282 | GetRootDeviceType (StrTemp1, sizeof (StrTemp1)); |
lijuang | 77421c0 | 2016-11-02 16:16:43 +0800 | [diff] [blame] | 283 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 284 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 285 | sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp, |
| 286 | sizeof (StrTemp)); |
| 287 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 288 | sizeof (mFastbootCommonMsgInfo[i].Msg), " ", |
| 289 | AsciiStrLen (" ")); |
| 290 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 291 | sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp1, |
| 292 | sizeof (StrTemp1)); |
| 293 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 294 | case 5: |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 295 | /* Get bootloader version */ |
| 296 | GetBootloaderVersion (VersionTemp, sizeof (VersionTemp)); |
| 297 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 298 | sizeof (mFastbootCommonMsgInfo[i].Msg), VersionTemp, |
| 299 | sizeof (VersionTemp)); |
| 300 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 301 | case 6: |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 302 | /* Get baseband version */ |
| 303 | ZeroMem (VersionTemp, sizeof (VersionTemp)); |
| 304 | GetRadioVersion (VersionTemp, sizeof (VersionTemp)); |
| 305 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 306 | sizeof (mFastbootCommonMsgInfo[i].Msg), VersionTemp, |
| 307 | sizeof (VersionTemp)); |
| 308 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 309 | case 7: |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 310 | /* Get serial number */ |
| 311 | ZeroMem (StrTemp, sizeof (StrTemp)); |
| 312 | BoardSerialNum (StrTemp, MAX_RSP_SIZE); |
| 313 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 314 | sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp, |
| 315 | sizeof (StrTemp)); |
| 316 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 317 | case 8: |
Alexander Martinz | 44513b0 | 2020-06-02 12:18:31 +0200 | [diff] [blame] | 318 | /* Get hardware revision */ |
| 319 | ZeroMem (StrTemp, sizeof (StrTemp)); |
| 320 | BoardHardwareRevision (StrTemp, MAX_RSP_SIZE); |
| 321 | AsciiStrnCatS (mFastbootCommonMsgInfo[i].Msg, |
| 322 | sizeof (mFastbootCommonMsgInfo[i].Msg), StrTemp, |
| 323 | sizeof (StrTemp)); |
| 324 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 325 | case 9: |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 326 | /* Get secure boot value */ |
| 327 | AsciiStrnCatS ( |
| 328 | mFastbootCommonMsgInfo[i].Msg, sizeof (mFastbootCommonMsgInfo[i].Msg), |
| 329 | IsSecureBootEnabled () ? "yes" : "no", |
| 330 | IsSecureBootEnabled () ? AsciiStrLen ("yes") : AsciiStrLen ("no")); |
| 331 | break; |
Alexander Martinz | 968ec91 | 2020-06-02 14:06:24 +0200 | [diff] [blame] | 332 | case 10: |
Alexander Martinz | 1bf6709 | 2021-02-17 17:43:53 +0100 | [diff] [blame^] | 333 | /* Get device status, only show when unlocked */ |
| 334 | if (!IsUnlocked ()) |
| 335 | continue; |
| 336 | break; |
| 337 | case 11: |
| 338 | /* Get device status, only show when locked */ |
| 339 | if (IsUnlocked ()) |
| 340 | continue; |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 341 | break; |
| 342 | } |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 343 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 344 | mFastbootCommonMsgInfo[i].Location = Location; |
| 345 | Status = DrawMenu (&mFastbootCommonMsgInfo[i], &Height); |
| 346 | if (Status != EFI_SUCCESS) |
| 347 | return Status; |
| 348 | Location += Height; |
| 349 | } |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 350 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 351 | OptionMenuInfo->Info.MenuType = DISPLAY_MENU_FASTBOOT; |
| 352 | OptionMenuInfo->Info.OptionNum = ARRAY_SIZE (mFastbootOptionTitle); |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 353 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 354 | return Status; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | /* Draw the fastboot menu and start to detect the key's status */ |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 358 | VOID DisplayFastbootMenu (VOID) |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 359 | { |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 360 | EFI_STATUS Status; |
| 361 | OPTION_MENU_INFO *OptionMenuInfo; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 362 | |
Anuj Garg | ae40955 | 2020-06-03 19:21:55 +0530 | [diff] [blame] | 363 | if (IsEnableDisplayMenuFlagSupported ()) { |
| 364 | OptionMenuInfo = &gMenuInfo; |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 365 | DrawMenuInit (); |
| 366 | OptionMenuInfo->LastMenuType = OptionMenuInfo->Info.MenuType; |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 367 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 368 | Status = FastbootMenuShowScreen (OptionMenuInfo); |
| 369 | if (Status != EFI_SUCCESS) { |
| 370 | DEBUG ((EFI_D_ERROR, "Unable to show fastboot menu on screen: %r\n", |
| 371 | Status)); |
| 372 | return; |
| 373 | } |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 374 | |
Jeevan Shriram | 17f173d | 2017-10-24 22:11:07 -0700 | [diff] [blame] | 375 | MenuKeysDetectionInit (OptionMenuInfo); |
| 376 | DEBUG ((EFI_D_VERBOSE, "Creating fastboot menu keys detect event\n")); |
| 377 | } else { |
| 378 | DEBUG ((EFI_D_INFO, "Display menu is not enabled!\n")); |
| 379 | } |
lijuang | 463e3cb | 2016-07-27 19:26:38 +0800 | [diff] [blame] | 380 | } |