Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 0672cf9

Browse files
kcxtamartinz
authored andcommitted
FastbootMenu: add ability to set active slot
Requires developer mode to be enabled. Change-Id: Iac972efac622bc4ed94645161ae2120ac5003533 Co-developed-by: Alexander Martinz <[email protected]> Signed-off-by: Alexander Martinz <[email protected]>
1 parent 97f9e08 commit 0672cf9

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

QcomModulePkg/Include/Library/DrawUI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ typedef enum {
115115
FFBM,
116116
QMMI,
117117
NOACTION,
118+
SET_ACTIVE_SLOT_A,
119+
SET_ACTIVE_SLOT_B,
118120
OPTION_ACTION_MAX,
119121
} OPTION_ITEM_ACTION;
120122

QcomModulePkg/Library/BootLib/FastbootMenu.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
STATIC OPTION_MENU_INFO gMenuInfo;
4444

45+
#define OPTIONS_COUNT_DEVELOPER_MODE 2
46+
4547
STATIC MENU_MSG_INFO mFastbootOptionTitle[] = {
4648
{{"START"},
4749
BIG_FACTOR,
@@ -87,6 +89,21 @@ STATIC MENU_MSG_INFO mFastbootOptionTitle[] = {
8789
0,
8890
QMMI},
8991
#endif
92+
/* Developer mode options */
93+
{{"Activate slot _a"},
94+
BIG_FACTOR,
95+
BGR_ORANGE,
96+
BGR_BLACK,
97+
OPTION_ITEM,
98+
0,
99+
SET_ACTIVE_SLOT_A},
100+
{{"Activate slot _b"},
101+
BIG_FACTOR,
102+
BGR_ORANGE,
103+
BGR_BLACK,
104+
OPTION_ITEM,
105+
0,
106+
SET_ACTIVE_SLOT_B},
90107
};
91108

92109
#define FASTBOOT_MSG_INDEX_HEADER 0
@@ -283,6 +300,7 @@ FastbootMenuShowScreen (OPTION_MENU_INFO *OptionMenuInfo)
283300
EFI_STATUS Status = EFI_SUCCESS;
284301
UINT32 Location = 0;
285302
UINT32 OptionItem = 0;
303+
UINT32 OptionItemCount = 0;
286304
UINT32 Height = 0;
287305
UINT32 i = 0;
288306
UINT32 j = 0;
@@ -417,7 +435,11 @@ FastbootMenuShowScreen (OPTION_MENU_INFO *OptionMenuInfo)
417435
}
418436

419437
OptionMenuInfo->Info.MenuType = DISPLAY_MENU_FASTBOOT;
420-
OptionMenuInfo->Info.OptionNum = ARRAY_SIZE (mFastbootOptionTitle);
438+
439+
OptionItemCount = ARRAY_SIZE (mFastbootOptionTitle);
440+
if (!IsDeveloperModeEnabled ())
441+
OptionItemCount -= OPTIONS_COUNT_DEVELOPER_MODE;
442+
OptionMenuInfo->Info.OptionNum = OptionItemCount;
421443

422444
return Status;
423445
}

QcomModulePkg/Library/BootLib/MenuKeysDetection.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ UpdateDeviceStatus (OPTION_MENU_INFO *MsgInfo, INTN Reason)
105105
EFI_STATUS Status = EFI_SUCCESS;
106106
EFI_GUID Ptype = gEfiMiscPartitionGuid;
107107
MemCardType CardType = UNKNOWN;
108+
CHAR16 SuffixUnicode[MAX_SLOT_SUFFIX_SZ] = u"";
109+
Slot BootSlot;
108110

109111
/* Clear the screen */
110112
gST->ConOut->ClearScreen (gST->ConOut);
@@ -158,6 +160,26 @@ UpdateDeviceStatus (OPTION_MENU_INFO *MsgInfo, INTN Reason)
158160
}
159161
RebootDevice (NORMAL_MODE);
160162
break;
163+
case SET_ACTIVE_SLOT_A:
164+
AsciiStrToUnicodeStr ("_a", SuffixUnicode);
165+
StrnCpyS (BootSlot.Suffix, ARRAY_SIZE (BootSlot.Suffix), SuffixUnicode,
166+
StrLen (SuffixUnicode));
167+
Status = SetActiveSlot (&BootSlot, TRUE);
168+
if (Status != EFI_SUCCESS) {
169+
DEBUG ((EFI_D_ERROR, "Failed to set the active slot to _a\n"));
170+
}
171+
RebootDevice (FASTBOOT_MODE);
172+
break;
173+
case SET_ACTIVE_SLOT_B:
174+
AsciiStrToUnicodeStr ("_b", SuffixUnicode);
175+
StrnCpyS (BootSlot.Suffix, ARRAY_SIZE (BootSlot.Suffix), SuffixUnicode,
176+
StrLen (SuffixUnicode));
177+
Status = SetActiveSlot (&BootSlot, TRUE);
178+
if (Status != EFI_SUCCESS) {
179+
DEBUG ((EFI_D_ERROR, "Failed to set the active slot to _b\n"));
180+
}
181+
RebootDevice (FASTBOOT_MODE);
182+
break;
161183
}
162184
}
163185

0 commit comments

Comments
 (0)