Skip to content

Commit

Permalink
Improve Mass Storage again
Browse files Browse the repository at this point in the history
Co-authored-by: Robotix <[email protected]>
  • Loading branch information
AistopGit and Robotix22 authored Aug 6, 2024
1 parent 314d895 commit ea95d2a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
62 changes: 26 additions & 36 deletions Silicon/Qualcomm/QcomPkg/Applications/MassStorage/MassStorage.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ STATIC EFI_USB_MSD_PROTOCOL *mUsbMsdProtocol;
STATIC EFI_CHARGER_EX_PROTOCOL *mChargerExProtocol;
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL *mConsoleOutHandle;

EFI_STATUS
StartMassStorage ()
VOID
PrintGUI (CHAR16 *Message)
{
EFI_STATUS Status = EFI_SUCCESS;
BOOLEAN DisplayedNotice = FALSE;
BOOLEAN Connected = FALSE;
UINTN CurrentSplash = 0;

// Black & White Color
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
Expand All @@ -32,6 +27,22 @@ StartMassStorage ()
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0x00;
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;

// Set Position of Message
UINTN XPos = (mConsoleOutHandle->Mode->Info->HorizontalResolution - StrLen(Message) * EFI_GLYPH_WIDTH) / 2;
UINTN YPos = (mConsoleOutHandle->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Print New Message
PrintXY (XPos, YPos, &White, &Black, Message);
}

EFI_STATUS
StartMassStorage ()
{
EFI_STATUS Status = EFI_SUCCESS;
BOOLEAN DisplayedNotice = FALSE;
BOOLEAN Connected = FALSE;
UINTN CurrentSplash = 0;

// Start Mass Storage
Status = mUsbMsdProtocol->StartDevice (mUsbMsdProtocol);
if (EFI_ERROR (Status)) {
Expand All @@ -56,14 +67,7 @@ StartMassStorage ()
CurrentSplash = BG_MSD_CONNECTED;

// New Message
CHAR16 *HintMessage = L"Disconnect your Device to Enable Exit Function.";

// Set Position of Message
UINTN XPos = (mConsoleOutHandle->Mode->Info->HorizontalResolution - StrLen(HintMessage) * EFI_GLYPH_WIDTH) / 2;
UINTN YPos = (mConsoleOutHandle->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Print New Message
PrintXY (XPos, YPos, &White, &Black, HintMessage);
PrintGUI (L"Disconnect your Device to Enable Exit Function.");

// Reset Notice Message
DisplayedNotice = FALSE;
Expand All @@ -75,14 +79,7 @@ StartMassStorage ()
CurrentSplash = BG_MSD_DISCONNECTED;

// New Message
CHAR16 *ExitMessage = L"Press Volume Up Button to Exit Mass Storage.";

// Set Position of Message
UINTN XPos = (mConsoleOutHandle->Mode->Info->HorizontalResolution - StrLen(ExitMessage) * EFI_GLYPH_WIDTH) / 2;
UINTN YPos = (mConsoleOutHandle->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Print New Message
PrintXY (XPos, YPos, &White, &Black, ExitMessage);
PrintGUI (L"Press Volume Up Button to Exit Mass Storage.");
}

// Get current Key
Expand All @@ -91,14 +88,7 @@ StartMassStorage ()
// Display Confirm Message
if (!Connected) {
if (Key.ScanCode == SCAN_UP && DisplayedNotice == FALSE) {
CHAR16 *ConfirmMessage = L"Press Power Button to Confirm Exiting Mass Storage.";

// Set Position of Message
UINTN XPos = (mConsoleOutHandle->Mode->Info->HorizontalResolution - StrLen(ConfirmMessage) * EFI_GLYPH_WIDTH) / 2;
UINTN YPos = (mConsoleOutHandle->Mode->Info->VerticalResolution - EFI_GLYPH_HEIGHT) * 48 / 50;

// Print New Message
PrintXY (XPos, YPos, &White, &Black, ConfirmMessage);
PrintGUI (L"Press Power Button to Confirm Exiting Mass Storage.");

DisplayedNotice = TRUE;
}
Expand All @@ -109,7 +99,7 @@ StartMassStorage ()
mUsbMsdProtocol->StopDevice (mUsbMsdProtocol);

// Remove Assigned BLK IO Protocol
mUsbMsdProtocol->AssingBlkIoHandle (mUsbMsdProtocol, NULL, 0);
mUsbMsdProtocol->AssignBlkIoHandle (mUsbMsdProtocol, NULL, 0);

// Exit Application
break;
Expand Down Expand Up @@ -171,9 +161,9 @@ PrepareMassStorage ()
}

// Assign Protocol
Status = mUsbMsdProtocol->AssingBlkIoHandle (mUsbMsdProtocol, UFSBlkIoProtocol, 0);
Status = mUsbMsdProtocol->AssignBlkIoHandle (mUsbMsdProtocol, UFSBlkIoProtocol, 0);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Failed to Assing UFS BLK IO Protocol! Status = %r\n", Status));
DEBUG ((EFI_D_ERROR, "Failed to Assign UFS BLK IO Protocol! Status = %r\n", Status));
goto exit;
}
}
Expand All @@ -188,9 +178,9 @@ PrepareMassStorage ()
}

// Assign Protocol
Status = mUsbMsdProtocol->AssingBlkIoHandle (mUsbMsdProtocol, eMMCBlkIoProtocol, 0);
Status = mUsbMsdProtocol->AssignBlkIoHandle (mUsbMsdProtocol, eMMCBlkIoProtocol, 0);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Failed to Assing eMMC BLK IO Protocol! Status = %r\n", Status));
DEBUG ((EFI_D_ERROR, "Failed to Assign eMMC BLK IO Protocol! Status = %r\n", Status));
goto exit;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Silicon/Qualcomm/QcomPkg/Include/Protocol/EFIUsbMsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
typedef struct _EFI_USB_MSD_PROTOCOL EFI_USB_MSD_PROTOCOL;

/**
This Function Assings a New BLK IO Protocol.
This Function Assigns a New BLK IO Protocol.
@param[in] This - The USB Mass Storage Device Protocol.
@param[in] BlkIo - The BLK IO Protocol.
Expand All @@ -24,7 +24,7 @@ typedef struct _EFI_USB_MSD_PROTOCOL EFI_USB_MSD_PROTOCOL;
**/
typedef
EFI_STATUS
(EFIAPI *EFI_ASSING_BLK_IO_HANDLE) (
(EFIAPI *EFI_ASSIGN_BLK_IO_HANDLE) (
IN EFI_USB_MSD_PROTOCOL *This,
IN EFI_BLOCK_IO_PROTOCOL *BlkIo,
IN UINT32 Lun
Expand Down Expand Up @@ -85,7 +85,7 @@ EFI_STATUS
//
struct _EFI_USB_MSD_PROTOCOL {
UINT32 Revision;
EFI_ASSING_BLK_IO_HANDLE AssingBlkIoHandle;
EFI_ASSIGN_BLK_IO_HANDLE AssignBlkIoHandle;
EFI_QUERY_MAX_LUN QueryMaxLun;
EFI_EVENT_HANDLER EventHandler;
EFI_START_DEVICE StartDevice;
Expand Down

0 comments on commit ea95d2a

Please sign in to comment.