diff options
author | Jeevan Shriram <jshriram@codeaurora.org> | 2018-03-12 16:45:59 -0700 |
---|---|---|
committer | Mukesh Ojha <mojha@codeaurora.org> | 2018-03-29 23:46:11 +0530 |
commit | 9f8489e12383a3b867a64764990284c800abe782 (patch) | |
tree | 5b1ff33291fb67a261b31ff8292422042daf3cfa /QcomModulePkg/Library | |
parent | d35e99fcab4c60d264cae8a087d5f52501880b15 (diff) |
QcomModulePkg: Add support for read/write in NAND partitions
Add support to read and write from NAND partitions by generating NAND
GUID through protocol.
Change-Id: Ib2769e9cf313efafb84786e554337810cd24a140
Diffstat (limited to 'QcomModulePkg/Library')
-rw-r--r-- | QcomModulePkg/Library/BootLib/Board.c | 3 | ||||
-rw-r--r-- | QcomModulePkg/Library/BootLib/BootLib.inf | 3 | ||||
-rw-r--r-- | QcomModulePkg/Library/BootLib/DeviceInfo.c | 12 | ||||
-rw-r--r-- | QcomModulePkg/Library/BootLib/LinuxLoaderLib.c | 24 | ||||
-rw-r--r-- | QcomModulePkg/Library/BootLib/MenuKeysDetection.c | 24 | ||||
-rw-r--r-- | QcomModulePkg/Library/BootLib/Recovery.c | 26 |
6 files changed, 81 insertions, 11 deletions
diff --git a/QcomModulePkg/Library/BootLib/Board.c b/QcomModulePkg/Library/BootLib/Board.c index 57e1c8f97f..cee779cc6a 100644 --- a/QcomModulePkg/Library/BootLib/Board.c +++ b/QcomModulePkg/Library/BootLib/Board.c @@ -305,7 +305,8 @@ GetCompatibleRootDeviceType (VOID) @retval Device type : UNKNOWN | UFS | EMMC | NAND, default is UNKNOWN **/ -STATIC MemCardType CheckRootDeviceType (VOID) +MemCardType +CheckRootDeviceType (VOID) { EFI_STATUS Status = EFI_INVALID_PARAMETER; STATIC MemCardType Type = UNKNOWN; diff --git a/QcomModulePkg/Library/BootLib/BootLib.inf b/QcomModulePkg/Library/BootLib/BootLib.inf index 906400e13e..4910db2b11 100644 --- a/QcomModulePkg/Library/BootLib/BootLib.inf +++ b/QcomModulePkg/Library/BootLib/BootLib.inf @@ -1,5 +1,5 @@ #/* -# * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. +# * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. # * # * Redistribution and use in source and binary forms, with or without # * modification, are permitted provided that the following conditions are @@ -141,6 +141,7 @@ gQcomRngProtocolGuid gQcomMdtpProtocolGuid gQcomScmProtocolGuid + gEfiNandPartiGuidProtocolGuid [FixedPcd] gArmTokenSpaceGuid.PcdSystemMemoryBase diff --git a/QcomModulePkg/Library/BootLib/DeviceInfo.c b/QcomModulePkg/Library/BootLib/DeviceInfo.c index 4e013840cf..40606f5bc1 100644 --- a/QcomModulePkg/Library/BootLib/DeviceInfo.c +++ b/QcomModulePkg/Library/BootLib/DeviceInfo.c @@ -149,6 +149,8 @@ SetDeviceUnlockValue (UINT32 Type, BOOLEAN State) { EFI_STATUS Status = EFI_SUCCESS; struct RecoveryMessage Msg; + EFI_GUID Ptype = gEfiMiscPartitionGuid; + MemCardType CardType = UNKNOWN; switch (Type) { case UNLOCK: @@ -179,7 +181,15 @@ SetDeviceUnlockValue (UINT32 Type, BOOLEAN State) Status = AsciiStrnCpyS (Msg.recovery, sizeof (Msg.recovery), RECOVERY_WIPE_DATA, AsciiStrLen (RECOVERY_WIPE_DATA)); if (Status == EFI_SUCCESS) { - Status = WriteToPartition (&gEfiMiscPartitionGuid, &Msg, sizeof (Msg)); + CardType = CheckRootDeviceType (); + if (CardType == NAND) { + Status = GetNandMiscPartiGuid (&Ptype); + if (Status != EFI_SUCCESS) { + return Status; + } + } + + Status = WriteToPartition (&Ptype, &Msg, sizeof (Msg)); } return Status; diff --git a/QcomModulePkg/Library/BootLib/LinuxLoaderLib.c b/QcomModulePkg/Library/BootLib/LinuxLoaderLib.c index 6432ba8f79..5f5d67b93f 100644 --- a/QcomModulePkg/Library/BootLib/LinuxLoaderLib.c +++ b/QcomModulePkg/Library/BootLib/LinuxLoaderLib.c @@ -462,6 +462,30 @@ ReadWriteDeviceInfo (vb_device_state_op_t Mode, void *DevInfo, UINT32 Sz) } EFI_STATUS +GetNandMiscPartiGuid (EFI_GUID *Ptype) +{ + EFI_STATUS Status = EFI_INVALID_PARAMETER; + EFI_NAND_PARTI_GUID_PROTOCOL *NandPartiGuid; + + Status = gBS->LocateProtocol (&gEfiNandPartiGuidProtocolGuid, NULL, + (VOID **)&NandPartiGuid); + if (Status != EFI_SUCCESS) { + DEBUG ((EFI_D_ERROR, "Unable to locate NandPartiGuid protocol: %r\n", + Status)); + return Status; + } + + Status = NandPartiGuid->GenGuid (NandPartiGuid, (CONST CHAR16 *)L"misc", + StrLen ((CONST CHAR16 *)L"misc"), Ptype); + if (Status != EFI_SUCCESS) { + DEBUG ((EFI_D_ERROR, "NandPartiGuid GenGuid failed with: %r\n", Status)); + return Status; + } + + return Status; +} + +EFI_STATUS WriteToPartition (EFI_GUID *Ptype, VOID *Msg, UINT32 MsgSize) { EFI_STATUS Status; diff --git a/QcomModulePkg/Library/BootLib/MenuKeysDetection.c b/QcomModulePkg/Library/BootLib/MenuKeysDetection.c index 38b8a1cb23..42e79eb6f5 100644 --- a/QcomModulePkg/Library/BootLib/MenuKeysDetection.c +++ b/QcomModulePkg/Library/BootLib/MenuKeysDetection.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +39,7 @@ #include <Library/UefiBootServicesTableLib.h> #include <Library/UnlockMenu.h> #include <Library/VerifiedBootMenu.h> +#include <Library/Board.h> #include <Uefi.h> #include <Protocol/EFIVerifiedBoot.h> @@ -100,10 +101,15 @@ STATIC VOID UpdateDeviceStatus (OPTION_MENU_INFO *MsgInfo, INTN Reason) { CHAR8 FfbmPageBuffer[FFBM_MODE_BUF_SIZE] = ""; + EFI_STATUS Status = EFI_SUCCESS; + EFI_GUID Ptype = gEfiMiscPartitionGuid; + MemCardType CardType = UNKNOWN; /* Clear the screen */ gST->ConOut->ClearScreen (gST->ConOut); + CardType = CheckRootDeviceType (); + switch (Reason) { case RECOVER: if (MsgInfo->Info.MenuType == DISPLAY_MENU_UNLOCK || @@ -133,14 +139,22 @@ UpdateDeviceStatus (OPTION_MENU_INFO *MsgInfo, INTN Reason) break; case FFBM: AsciiSPrint (FfbmPageBuffer, sizeof (FfbmPageBuffer), "ffbm-00"); - WriteToPartition (&gEfiMiscPartitionGuid, FfbmPageBuffer, - sizeof (FfbmPageBuffer)); + if (CardType == NAND) { + Status = GetNandMiscPartiGuid (&Ptype); + } + if (Status == EFI_SUCCESS) { + WriteToPartition (&Ptype, FfbmPageBuffer, sizeof (FfbmPageBuffer)); + } RebootDevice (NORMAL_MODE); break; case QMMI: AsciiSPrint (FfbmPageBuffer, sizeof (FfbmPageBuffer), "ffbm-02"); - WriteToPartition (&gEfiMiscPartitionGuid, FfbmPageBuffer, - sizeof (FfbmPageBuffer)); + if (CardType == NAND) { + Status = GetNandMiscPartiGuid (&Ptype); + } + if (Status == EFI_SUCCESS) { + WriteToPartition (&Ptype, FfbmPageBuffer, sizeof (FfbmPageBuffer)); + } RebootDevice (NORMAL_MODE); break; } diff --git a/QcomModulePkg/Library/BootLib/Recovery.c b/QcomModulePkg/Library/BootLib/Recovery.c index c7c5da4ea4..7beb5c58bc 100644 --- a/QcomModulePkg/Library/BootLib/Recovery.c +++ b/QcomModulePkg/Library/BootLib/Recovery.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -96,8 +96,18 @@ RecoveryInit (BOOLEAN *BootIntoRecovery) { EFI_STATUS Status; struct RecoveryMessage *Msg = NULL; + EFI_GUID Ptype = gEfiMiscPartitionGuid; + MemCardType CardType = UNKNOWN; + + CardType = CheckRootDeviceType (); + if (CardType == NAND) { + Status = GetNandMiscPartiGuid (&Ptype); + if (Status != EFI_SUCCESS) { + return Status; + } + } - Status = ReadFromPartition (&gEfiMiscPartitionGuid, (VOID **)&Msg, + Status = ReadFromPartition (&Ptype, (VOID **)&Msg, sizeof (struct RecoveryMessage)); if (Status != EFI_SUCCESS) { DEBUG ((EFI_D_ERROR, "Error Reading from misc partition: %r\n", Status)); @@ -130,8 +140,18 @@ GetFfbmCommand (CHAR8 *FfbmString, UINT32 Sz) CONST CHAR8 *FfbmCmd = "ffbm-"; CHAR8 *FfbmData = NULL; EFI_STATUS Status; + EFI_GUID Ptype = gEfiMiscPartitionGuid; + MemCardType CardType = UNKNOWN; + + CardType = CheckRootDeviceType (); + if (CardType == NAND) { + Status = GetNandMiscPartiGuid (&Ptype); + if (Status != EFI_SUCCESS) { + return Status; + } + } - Status = ReadFromPartition (&gEfiMiscPartitionGuid, (VOID **)&FfbmData, Sz); + Status = ReadFromPartition (&Ptype, (VOID **)&FfbmData, Sz); if (Status != EFI_SUCCESS) { DEBUG ((EFI_D_ERROR, "Error Reading FFBM info from misc: %r\n", Status)); return Status; |