summaryrefslogtreecommitdiff
path: root/QcomModulePkg
diff options
context:
space:
mode:
authorJeevan Shriram <jshriram@codeaurora.org>2018-03-12 16:45:59 -0700
committerMukesh Ojha <mojha@codeaurora.org>2018-03-29 23:46:11 +0530
commit9f8489e12383a3b867a64764990284c800abe782 (patch)
tree5b1ff33291fb67a261b31ff8292422042daf3cfa /QcomModulePkg
parentd35e99fcab4c60d264cae8a087d5f52501880b15 (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')
-rw-r--r--QcomModulePkg/Include/Library/Board.h4
-rw-r--r--QcomModulePkg/Include/Library/LinuxLoaderLib.h6
-rw-r--r--QcomModulePkg/Library/BootLib/Board.c3
-rw-r--r--QcomModulePkg/Library/BootLib/BootLib.inf3
-rw-r--r--QcomModulePkg/Library/BootLib/DeviceInfo.c12
-rw-r--r--QcomModulePkg/Library/BootLib/LinuxLoaderLib.c24
-rw-r--r--QcomModulePkg/Library/BootLib/MenuKeysDetection.c24
-rw-r--r--QcomModulePkg/Library/BootLib/Recovery.c26
-rw-r--r--QcomModulePkg/QcomModulePkg.dec4
9 files changed, 92 insertions, 14 deletions
diff --git a/QcomModulePkg/Include/Library/Board.h b/QcomModulePkg/Include/Library/Board.h
index 3c1d764d20..ad99a33af0 100644
--- a/QcomModulePkg/Include/Library/Board.h
+++ b/QcomModulePkg/Include/Library/Board.h
@@ -1,4 +1,4 @@
-/* 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
@@ -81,6 +81,8 @@ UINT32 BoardPlatformSubType (VOID);
UINT32 BoardTargetId (VOID);
VOID
GetRootDeviceType (CHAR8 *StrDeviceType, UINT32 Len);
+MemCardType
+CheckRootDeviceType (VOID);
VOID
BoardHwPlatformName (CHAR8 *StrHwPlatform, UINT32 Len);
EFI_STATUS
diff --git a/QcomModulePkg/Include/Library/LinuxLoaderLib.h b/QcomModulePkg/Include/Library/LinuxLoaderLib.h
index baf7d85fb4..a159a2c860 100644
--- a/QcomModulePkg/Include/Library/LinuxLoaderLib.h
+++ b/QcomModulePkg/Include/Library/LinuxLoaderLib.h
@@ -1,4 +1,4 @@
-/* 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
@@ -55,6 +55,7 @@
#include <Protocol/EFIEraseBlock.h>
#include <Protocol/EFIMdtp.h>
#include <Protocol/EFIVerifiedBoot.h>
+#include <Protocol/EFINandPartiGuid.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/SerialIo.h>
@@ -138,6 +139,9 @@ LoadImageFromPartition (VOID *ImageBuffer, UINT32 *ImageSize, CHAR16 *Pname);
EFI_STATUS
ReadWriteDeviceInfo (vb_device_state_op_t Mode, void *DevInfo, UINT32 Sz);
+
+EFI_STATUS
+GetNandMiscPartiGuid (EFI_GUID *Ptype);
/**
Returns a list of BlkIo handles based on required criteria
SelectionAttrib : Bitmask representing the conditions that need
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;
diff --git a/QcomModulePkg/QcomModulePkg.dec b/QcomModulePkg/QcomModulePkg.dec
index e8fddfa9b0..8b59d085bd 100644
--- a/QcomModulePkg/QcomModulePkg.dec
+++ b/QcomModulePkg/QcomModulePkg.dec
@@ -127,7 +127,9 @@
gEfiPartitionTypeGuid = { 0x6848de61, 0xeb61, 0x4def, { 0x9a, 0x8e, 0x38, 0x17, 0xcb, 0xeb, 0x8f, 0x1c } }
# Sha256 Protocol
gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }
-
+ #Nand Partition GUID Protocol
+ gEfiNandPartiGuidProtocolGuid = { 0xd68edce2, 0xa314, 0x457b, { 0x96, 0x2a, 0x1d, 0x99, 0xbb, 0xfc, 0xbb, 0xfb } }
+ # Rng Protocol guid
gQcomRngProtocolGuid = { 0x3152bca5, 0xeade, 0x433d, { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } }
#UBI flasher protocol Guid
gEfiUbiFlasherProtocolGuid = { 0xe3eef434, 0x22c9, 0xe33b, { 0x8f, 0x5d, 0x0e, 0x81, 0x68, 0x6a, 0x68, 0xcb } }