BOOLEAN mOpalEndOfDxe = FALSE;\r
OPAL_REQUEST_VARIABLE *mOpalRequestVariable = NULL;\r
UINTN mOpalRequestVariableSize = 0;\r
-CHAR16 mPopUpString[256];\r
+CHAR16 mPopUpString[100];\r
\r
typedef struct {\r
UINT32 Address;\r
}\r
\r
//\r
- // Psid revert is available for any device with media encryption support\r
- // Revert is allowed for any device with media encryption support, however it requires\r
+ // Psid revert is available for any device with media encryption support or pyrite 2.0 type support.\r
//\r
- if (SupportedAttributes->MediaEncryption) {\r
+ if (SupportedAttributes->PyriteSscV2 || SupportedAttributes->MediaEncryption) {\r
\r
//\r
- // Only allow psid revert if media encryption is enabled.\r
+ // Only allow psid revert if media encryption is enabled or pyrite 2.0 type support..\r
// Otherwise, someone who steals a disk can psid revert the disk and the user Data is still\r
// intact and accessible\r
//\r
mOpalRequestVariableSize = 0;\r
}\r
\r
+ //\r
+ // If no any device, return directly.\r
+ //\r
+ if (mOpalDriver.DeviceList == NULL) {\r
+ gBS->CloseEvent (Event);\r
+ return;\r
+ }\r
+\r
//\r
// Assume 64K size and alignment are enough.\r
//\r
@param[in] Dev The device which need Psid to process Psid Revert\r
OPAL request.\r
@param[in] PopUpString Pop up string.\r
+ @param[in] PopUpString2 Pop up string in line 2.\r
+\r
@param[out] PressEsc Whether user escape function through Press ESC.\r
\r
- @retval Password string if success. NULL if failed.\r
+ @retval Psid string if success. NULL if failed.\r
\r
**/\r
CHAR8 *\r
OpalDriverPopUpPsidInput (\r
IN OPAL_DRIVER_DEVICE *Dev,\r
IN CHAR16 *PopUpString,\r
+ IN CHAR16 *PopUpString2,\r
OUT BOOLEAN *PressEsc\r
)\r
{\r
InputLength = 0;\r
while (TRUE) {\r
Mask[InputLength] = L'_';\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &InputKey,\r
- PopUpString,\r
- L"---------------------",\r
- Mask,\r
- NULL\r
- );\r
+ if (PopUpString2 == NULL) {\r
+ CreatePopUp (\r
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+ &InputKey,\r
+ PopUpString,\r
+ L"---------------------",\r
+ Mask,\r
+ NULL\r
+ );\r
+ } else {\r
+ CreatePopUp (\r
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+ &InputKey,\r
+ PopUpString,\r
+ PopUpString2,\r
+ L"---------------------",\r
+ Mask,\r
+ NULL\r
+ );\r
+ }\r
\r
//\r
// Check key.\r
}\r
\r
/**\r
- Check if disk is locked, show popup window and ask for password if it is.\r
+ Get pop up string.\r
\r
- @param[in] Dev The device which need to be unlocked.\r
+ @param[in] Dev The OPAL device.\r
@param[in] RequestString Request string.\r
\r
+ @return Pop up string.\r
+\r
**/\r
CHAR16 *\r
OpalGetPopUpString (\r
IN CHAR16 *RequestString\r
)\r
{\r
- UINTN StrLength;\r
-\r
- StrLength = StrLen (RequestString) + 1 + MAX (StrLen (Dev->Name16), StrLen (L"Disk"));\r
- ASSERT (StrLength < sizeof (mPopUpString) / sizeof (CHAR16));\r
-\r
if (Dev->Name16 == NULL) {\r
- UnicodeSPrint (mPopUpString, StrLength + 1, L"%s Disk", RequestString);\r
+ UnicodeSPrint (mPopUpString, sizeof (mPopUpString), L"%s Disk", RequestString);\r
} else {\r
- UnicodeSPrint (mPopUpString, StrLength + 1, L"%s %s", RequestString, Dev->Name16);\r
+ UnicodeSPrint (mPopUpString, sizeof (mPopUpString), L"%s %s", RequestString, Dev->Name16);\r
}\r
\r
return mPopUpString;\r
break;\r
}\r
\r
+ //\r
+ // Check whether opal device's Tries value has reach the TryLimit value, if yes, force a shutdown\r
+ // before accept new password.\r
+ //\r
+ if (Ret == TcgResultFailureInvalidType) {\r
+ Count = MAX_PASSWORD_TRY_COUNT;\r
+ break;\r
+ }\r
+\r
Count++;\r
\r
do {\r
EFI_INPUT_KEY Key;\r
TCG_RESULT Ret;\r
CHAR16 *PopUpString;\r
+ CHAR16 *PopUpString2;\r
+ UINTN BufferSize;\r
\r
if (Dev == NULL) {\r
return;\r
\r
PopUpString = OpalGetPopUpString (Dev, RequestString);\r
\r
+ if (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME) {\r
+ BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds, DO NOT power off system during the revert action!");\r
+ PopUpString2 = AllocateZeroPool (BufferSize);\r
+ ASSERT (PopUpString2 != NULL);\r
+ UnicodeSPrint (\r
+ PopUpString2,\r
+ BufferSize,\r
+ L"WARNING: Revert action will take about %d seconds, DO NOT power off system during the revert action!",\r
+ Dev->OpalDisk.EstimateTimeCost\r
+ );\r
+ } else {\r
+ PopUpString2 = NULL;\r
+ }\r
+\r
Count = 0;\r
\r
ZeroMem(&Session, sizeof(Session));\r
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;\r
\r
while (Count < MAX_PSID_TRY_COUNT) {\r
- Psid = OpalDriverPopUpPsidInput (Dev, PopUpString, &PressEsc);\r
+ Psid = OpalDriverPopUpPsidInput (Dev, PopUpString, PopUpString2, &PressEsc);\r
if (PressEsc) {\r
do {\r
CreatePopUp (\r
\r
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
gST->ConOut->ClearScreen(gST->ConOut);\r
- return;\r
+ goto Done;\r
} else {\r
//\r
// Let user input Psid again.\r
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
gST->ConOut->ClearScreen(gST->ConOut);\r
}\r
+\r
+Done:\r
+ if (PopUpString2 != NULL) {\r
+ FreePool (PopUpString2);\r
+ }\r
}\r
\r
/**\r
TCG_RESULT Ret;\r
BOOLEAN PasswordFailed;\r
CHAR16 *PopUpString;\r
+ CHAR16 *PopUpString2;\r
+ UINTN BufferSize;\r
\r
if (Dev == NULL) {\r
return;\r
\r
PopUpString = OpalGetPopUpString (Dev, RequestString);\r
\r
+ if (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME) {\r
+ BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds, DO NOT power off system during the revert action!");\r
+ PopUpString2 = AllocateZeroPool (BufferSize);\r
+ ASSERT (PopUpString2 != NULL);\r
+ UnicodeSPrint (\r
+ PopUpString2,\r
+ BufferSize,\r
+ L"WARNING: Revert action will take about %d seconds, DO NOT power off system during the revert action!",\r
+ Dev->OpalDisk.EstimateTimeCost\r
+ );\r
+ } else {\r
+ PopUpString2 = NULL;\r
+ }\r
+\r
Count = 0;\r
\r
ZeroMem(&Session, sizeof(Session));\r
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;\r
\r
while (Count < MAX_PASSWORD_TRY_COUNT) {\r
- Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, NULL, &PressEsc);\r
+ Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, PopUpString2, &PressEsc);\r
if (PressEsc) {\r
do {\r
CreatePopUp (\r
\r
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
gST->ConOut->ClearScreen(gST->ConOut);\r
- return;\r
+ goto Done;\r
} else {\r
//\r
// Let user input password again.\r
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
gST->ConOut->ClearScreen(gST->ConOut);\r
}\r
+\r
+Done:\r
+ if (PopUpString2 != NULL) {\r
+ FreePool (PopUpString2);\r
+ }\r
}\r
\r
/**\r
Session.MediaId = Itr->OpalDisk.MediaId;\r
Session.OpalBaseComId = Itr->OpalDisk.OpalBaseComId;\r
\r
+ DEBUG ((DEBUG_INFO, "OpalPassword: ReadyToBoot point, send BlockSid command to device!\n"));\r
Result = OpalBlockSid (&Session, TRUE); // HardwareReset must always be TRUE\r
if (Result != TcgResultSuccess) {\r
DEBUG ((DEBUG_ERROR, "OpalBlockSid fail\n"));\r