summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Tcg/Opal
diff options
context:
space:
mode:
Diffstat (limited to 'SecurityPkg/Tcg/Opal')
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/ComponentName.c92
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c1476
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h257
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c594
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h108
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c38
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h90
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h18
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.c148
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h6
10 files changed, 1446 insertions, 1381 deletions
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/ComponentName.c b/SecurityPkg/Tcg/Opal/OpalPassword/ComponentName.c
index 746916b65f..51786a5d25 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/ComponentName.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/ComponentName.c
@@ -20,18 +20,17 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName =
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2 = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2 = {
OpalEfiDriverComponentName2GetDriverName,
OpalEfiDriverComponentName2GetControllerName,
"en"
};
-
/// The name of the driver in all the languages we support.
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOpalDriverNameTable[] = {
- { LANGUAGE_RFC_3066_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },
- { LANGUAGE_ISO_639_2_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },
- { 0, 0 }
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOpalDriverNameTable[] = {
+ { LANGUAGE_RFC_3066_ENGLISH, (CHAR16 *)EFI_DRIVER_NAME_UNICODE },
+ { LANGUAGE_ISO_639_2_ENGLISH, (CHAR16 *)EFI_DRIVER_NAME_UNICODE },
+ { 0, 0 }
};
/**
@@ -75,19 +74,19 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOpalDriverNameTable[] =
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentNameGetDriverName(
- EFI_COMPONENT_NAME_PROTOCOL* This,
- CHAR8* Language,
- CHAR16** DriverName
+OpalEfiDriverComponentNameGetDriverName (
+ EFI_COMPONENT_NAME_PROTOCOL *This,
+ CHAR8 *Language,
+ CHAR16 **DriverName
)
{
- return LookupUnicodeString2(
- Language,
- This->SupportedLanguages,
- mOpalDriverNameTable,
- DriverName,
- TRUE
- );
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mOpalDriverNameTable,
+ DriverName,
+ TRUE
+ );
}
/**
@@ -131,19 +130,19 @@ OpalEfiDriverComponentNameGetDriverName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentName2GetDriverName(
- EFI_COMPONENT_NAME2_PROTOCOL* This,
- CHAR8* Language,
- CHAR16** DriverName
+OpalEfiDriverComponentName2GetDriverName (
+ EFI_COMPONENT_NAME2_PROTOCOL *This,
+ CHAR8 *Language,
+ CHAR16 **DriverName
)
{
- return LookupUnicodeString2(
- Language,
- This->SupportedLanguages,
- mOpalDriverNameTable,
- DriverName,
- FALSE
- );
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mOpalDriverNameTable,
+ DriverName,
+ FALSE
+ );
}
/**
@@ -213,14 +212,14 @@ OpalEfiDriverComponentName2GetDriverName(
**/
EFI_STATUS
-GetControllerName(
+GetControllerName (
EFI_HANDLE ControllerHandle,
EFI_HANDLE ChildHandle,
- CHAR8* Language,
- CHAR16** ControllerName
+ CHAR8 *Language,
+ CHAR16 **ControllerName
)
{
- if (Language == NULL || ControllerName == NULL || ControllerHandle == NULL) {
+ if ((Language == NULL) || (ControllerName == NULL) || (ControllerHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -298,15 +297,15 @@ GetControllerName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentNameGetControllerName(
- EFI_COMPONENT_NAME_PROTOCOL* This,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- CHAR8* Language,
- CHAR16** ControllerName
+OpalEfiDriverComponentNameGetControllerName (
+ EFI_COMPONENT_NAME_PROTOCOL *This,
+ EFI_HANDLE ControllerHandle,
+ EFI_HANDLE ChildHandle,
+ CHAR8 *Language,
+ CHAR16 **ControllerName
)
{
- return (GetControllerName( ControllerHandle, ChildHandle, Language, ControllerName));
+ return (GetControllerName (ControllerHandle, ChildHandle, Language, ControllerName));
}
/**
@@ -379,14 +378,13 @@ OpalEfiDriverComponentNameGetControllerName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentName2GetControllerName(
- EFI_COMPONENT_NAME2_PROTOCOL* This,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- CHAR8* Language,
- CHAR16** ControllerName
+OpalEfiDriverComponentName2GetControllerName (
+ EFI_COMPONENT_NAME2_PROTOCOL *This,
+ EFI_HANDLE ControllerHandle,
+ EFI_HANDLE ChildHandle,
+ CHAR8 *Language,
+ CHAR16 **ControllerName
)
{
- return (GetControllerName(ControllerHandle, ChildHandle, Language, ControllerName));
+ return (GetControllerName (ControllerHandle, ChildHandle, Language, ControllerName));
}
-
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
index b5b6aec98c..f127757ad9 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
@@ -15,19 +15,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "OpalDriver.h"
#include "OpalHii.h"
-EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
+EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
-BOOLEAN mOpalEndOfDxe = FALSE;
-OPAL_REQUEST_VARIABLE *mOpalRequestVariable = NULL;
-UINTN mOpalRequestVariableSize = 0;
-CHAR16 mPopUpString[100];
+BOOLEAN mOpalEndOfDxe = FALSE;
+OPAL_REQUEST_VARIABLE *mOpalRequestVariable = NULL;
+UINTN mOpalRequestVariableSize = 0;
+CHAR16 mPopUpString[100];
-OPAL_DRIVER mOpalDriver;
+OPAL_DRIVER mOpalDriver;
//
// Globals
//
-EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding = {
OpalEfiDriverBindingSupported,
OpalEfiDriverBindingStart,
OpalEfiDriverBindingStop,
@@ -48,21 +48,21 @@ EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding = {
**/
TCG_RESULT
EFIAPI
-OpalSupportGetAvailableActions(
- IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes,
- IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature,
- IN UINT16 OwnerShip,
- OUT OPAL_DISK_ACTIONS *AvalDiskActions
+OpalSupportGetAvailableActions (
+ IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes,
+ IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature,
+ IN UINT16 OwnerShip,
+ OUT OPAL_DISK_ACTIONS *AvalDiskActions
)
{
- BOOLEAN ExistingPassword;
+ BOOLEAN ExistingPassword;
- NULL_CHECK(AvalDiskActions);
+ NULL_CHECK (AvalDiskActions);
- AvalDiskActions->AdminPass = 1;
- AvalDiskActions->UserPass = 0;
+ AvalDiskActions->AdminPass = 1;
+ AvalDiskActions->UserPass = 0;
AvalDiskActions->DisableUser = 0;
- AvalDiskActions->Unlock = 0;
+ AvalDiskActions->Unlock = 0;
//
// Revert is performed on locking sp, so only allow if locking sp is enabled
@@ -75,13 +75,12 @@ OpalSupportGetAvailableActions(
// Psid revert is available for any device with media encryption support or pyrite 2.0 type support.
//
if (SupportedAttributes->PyriteSscV2 || SupportedAttributes->MediaEncryption) {
-
//
// Only allow psid revert if media encryption is enabled or pyrite 2.0 type support..
// Otherwise, someone who steals a disk can psid revert the disk and the user Data is still
// intact and accessible
//
- AvalDiskActions->PsidRevert = 1;
+ AvalDiskActions->PsidRevert = 1;
AvalDiskActions->RevertKeepDataForced = 0;
//
@@ -90,7 +89,7 @@ OpalSupportGetAvailableActions(
//
AvalDiskActions->SecureErase = 1;
} else {
- AvalDiskActions->PsidRevert = 0;
+ AvalDiskActions->PsidRevert = 0;
AvalDiskActions->SecureErase = 0;
//
@@ -109,7 +108,7 @@ OpalSupportGetAvailableActions(
//
// Only allow user to set password if an admin password exists
//
- ExistingPassword = OpalUtilAdminPasswordExists(OwnerShip, LockingFeature);
+ ExistingPassword = OpalUtilAdminPasswordExists (OwnerShip, LockingFeature);
AvalDiskActions->UserPass = ExistingPassword;
//
@@ -133,42 +132,42 @@ OpalSupportGetAvailableActions(
TCG_RESULT
EFIAPI
OpalSupportEnableOpalFeature (
- IN OPAL_SESSION *Session,
- IN VOID *Msid,
- IN UINT32 MsidLength,
- IN VOID *Password,
- IN UINT32 PassLength
+ IN OPAL_SESSION *Session,
+ IN VOID *Msid,
+ IN UINT32 MsidLength,
+ IN VOID *Password,
+ IN UINT32 PassLength
)
{
- TCG_RESULT Ret;
-
- NULL_CHECK(Session);
- NULL_CHECK(Msid);
- NULL_CHECK(Password);
-
- Ret = OpalUtilSetAdminPasswordAsSid(
- Session,
- Msid,
- MsidLength,
- Password,
- PassLength
- );
+ TCG_RESULT Ret;
+
+ NULL_CHECK (Session);
+ NULL_CHECK (Msid);
+ NULL_CHECK (Password);
+
+ Ret = OpalUtilSetAdminPasswordAsSid (
+ Session,
+ Msid,
+ MsidLength,
+ Password,
+ PassLength
+ );
if (Ret == TcgResultSuccess) {
//
// Enable global locking range
//
- Ret = OpalUtilSetOpalLockingRange(
- Session,
- Password,
- PassLength,
- OPAL_LOCKING_SP_LOCKING_GLOBALRANGE,
- 0,
- 0,
- TRUE,
- TRUE,
- FALSE,
- FALSE
- );
+ Ret = OpalUtilSetOpalLockingRange (
+ Session,
+ Password,
+ PassLength,
+ OPAL_LOCKING_SP_LOCKING_GLOBALRANGE,
+ 0,
+ 0,
+ TRUE,
+ TRUE,
+ FALSE,
+ FALSE
+ );
}
return Ret;
@@ -184,13 +183,13 @@ OpalSupportEnableOpalFeature (
**/
VOID
OpalSupportUpdatePassword (
- IN OUT OPAL_DISK *OpalDisk,
- IN VOID *Password,
- IN UINT32 PasswordLength
+ IN OUT OPAL_DISK *OpalDisk,
+ IN VOID *Password,
+ IN UINT32 PasswordLength
)
{
CopyMem (OpalDisk->Password, Password, PasswordLength);
- OpalDisk->PasswordLength = (UINT8) PasswordLength;
+ OpalDisk->PasswordLength = (UINT8)PasswordLength;
}
/**
@@ -208,17 +207,17 @@ ExtractDeviceInfoFromDevicePath (
OUT OPAL_DEVICE_LOCKBOX_DATA *DevInfo OPTIONAL
)
{
- EFI_DEVICE_PATH_PROTOCOL *TmpDevPath;
- EFI_DEVICE_PATH_PROTOCOL *TmpDevPath2;
- PCI_DEVICE_PATH *PciDevPath;
- UINT8 DeviceType;
- UINT8 BusNum;
- OPAL_PCI_DEVICE *PciDevice;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevPath;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevPath2;
+ PCI_DEVICE_PATH *PciDevPath;
+ UINT8 DeviceType;
+ UINT8 BusNum;
+ OPAL_PCI_DEVICE *PciDevice;
ASSERT (DevicePath != NULL);
ASSERT (DevInfoLength != NULL);
- DeviceType = OPAL_DEVICE_TYPE_UNKNOWN;
+ DeviceType = OPAL_DEVICE_TYPE_UNKNOWN;
*DevInfoLength = 0;
TmpDevPath = DevicePath;
@@ -228,39 +227,42 @@ ExtractDeviceInfoFromDevicePath (
//
while (!IsDevicePathEnd (TmpDevPath)) {
if ((TmpDevPath->Type == MESSAGING_DEVICE_PATH) &&
- (TmpDevPath->SubType == MSG_SATA_DP || TmpDevPath->SubType == MSG_NVME_NAMESPACE_DP)) {
+ ((TmpDevPath->SubType == MSG_SATA_DP) || (TmpDevPath->SubType == MSG_NVME_NAMESPACE_DP)))
+ {
if (DevInfo != NULL) {
- DevInfo->DevicePathLength = (UINT32) GetDevicePathSize (DevicePath);
+ DevInfo->DevicePathLength = (UINT32)GetDevicePathSize (DevicePath);
CopyMem (DevInfo->DevicePath, DevicePath, DevInfo->DevicePathLength);
}
- DeviceType = (TmpDevPath->SubType == MSG_SATA_DP) ? OPAL_DEVICE_TYPE_ATA : OPAL_DEVICE_TYPE_NVME;
- *DevInfoLength = sizeof (OPAL_DEVICE_LOCKBOX_DATA) + (UINT32) GetDevicePathSize (DevicePath);
+ DeviceType = (TmpDevPath->SubType == MSG_SATA_DP) ? OPAL_DEVICE_TYPE_ATA : OPAL_DEVICE_TYPE_NVME;
+ *DevInfoLength = sizeof (OPAL_DEVICE_LOCKBOX_DATA) + (UINT32)GetDevicePathSize (DevicePath);
break;
}
+
TmpDevPath = NextDevicePathNode (TmpDevPath);
}
//
// Get device info.
//
- BusNum = 0;
- TmpDevPath = DevicePath;
+ BusNum = 0;
+ TmpDevPath = DevicePath;
TmpDevPath2 = NextDevicePathNode (DevicePath);
while (!IsDevicePathEnd (TmpDevPath2)) {
- if (TmpDevPath->Type == HARDWARE_DEVICE_PATH && TmpDevPath->SubType == HW_PCI_DP) {
- PciDevPath = (PCI_DEVICE_PATH *) TmpDevPath;
+ if ((TmpDevPath->Type == HARDWARE_DEVICE_PATH) && (TmpDevPath->SubType == HW_PCI_DP)) {
+ PciDevPath = (PCI_DEVICE_PATH *)TmpDevPath;
if ((TmpDevPath2->Type == MESSAGING_DEVICE_PATH) &&
- (TmpDevPath2->SubType == MSG_SATA_DP || TmpDevPath2->SubType == MSG_NVME_NAMESPACE_DP)) {
+ ((TmpDevPath2->SubType == MSG_SATA_DP) || (TmpDevPath2->SubType == MSG_NVME_NAMESPACE_DP)))
+ {
if (DevInfo != NULL) {
- PciDevice = &DevInfo->Device;
- PciDevice->Segment = 0;
- PciDevice->Bus = BusNum;
- PciDevice->Device = PciDevPath->Device;
+ PciDevice = &DevInfo->Device;
+ PciDevice->Segment = 0;
+ PciDevice->Bus = BusNum;
+ PciDevice->Device = PciDevPath->Device;
PciDevice->Function = PciDevPath->Function;
}
} else {
- if (TmpDevPath2->Type == HARDWARE_DEVICE_PATH && TmpDevPath2->SubType == HW_PCI_DP) {
+ if ((TmpDevPath2->Type == HARDWARE_DEVICE_PATH) && (TmpDevPath2->SubType == HW_PCI_DP)) {
BusNum = PciRead8 (PCI_LIB_ADDRESS (BusNum, PciDevPath->Device, PciDevPath->Function, PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET));
}
}
@@ -283,23 +285,23 @@ BuildOpalDeviceInfo (
VOID
)
{
- EFI_STATUS Status;
- OPAL_DEVICE_LOCKBOX_DATA *DevInfo;
- OPAL_DEVICE_LOCKBOX_DATA *TempDevInfo;
- UINTN TotalDevInfoLength;
- UINT32 DevInfoLength;
- OPAL_DRIVER_DEVICE *TmpDev;
- UINT8 DummyData;
- BOOLEAN S3InitDevicesExist;
- UINTN S3InitDevicesLength;
- EFI_DEVICE_PATH_PROTOCOL *S3InitDevices;
- EFI_DEVICE_PATH_PROTOCOL *S3InitDevicesBak;
+ EFI_STATUS Status;
+ OPAL_DEVICE_LOCKBOX_DATA *DevInfo;
+ OPAL_DEVICE_LOCKBOX_DATA *TempDevInfo;
+ UINTN TotalDevInfoLength;
+ UINT32 DevInfoLength;
+ OPAL_DRIVER_DEVICE *TmpDev;
+ UINT8 DummyData;
+ BOOLEAN S3InitDevicesExist;
+ UINTN S3InitDevicesLength;
+ EFI_DEVICE_PATH_PROTOCOL *S3InitDevices;
+ EFI_DEVICE_PATH_PROTOCOL *S3InitDevicesBak;
//
// Build OPAL device info and save them to LockBox.
//
TotalDevInfoLength = 0;
- TmpDev = mOpalDriver.DeviceList;
+ TmpDev = mOpalDriver.DeviceList;
while (TmpDev != NULL) {
ExtractDeviceInfoFromDevicePath (
TmpDev->OpalDisk.OpalDevicePath,
@@ -307,7 +309,7 @@ BuildOpalDeviceInfo (
NULL
);
TotalDevInfoLength += DevInfoLength;
- TmpDev = TmpDev->Next;
+ TmpDev = TmpDev->Next;
}
if (TotalDevInfoLength == 0) {
@@ -315,11 +317,11 @@ BuildOpalDeviceInfo (
}
S3InitDevicesLength = sizeof (DummyData);
- Status = RestoreLockBox (
- &gS3StorageDeviceInitListGuid,
- &DummyData,
- &S3InitDevicesLength
- );
+ Status = RestoreLockBox (
+ &gS3StorageDeviceInitListGuid,
+ &DummyData,
+ &S3InitDevicesLength
+ );
ASSERT ((Status == EFI_NOT_FOUND) || (Status == EFI_BUFFER_TOO_SMALL));
if (Status == EFI_NOT_FOUND) {
S3InitDevices = NULL;
@@ -356,7 +358,7 @@ BuildOpalDeviceInfo (
&DevInfoLength,
TempDevInfo
);
- TempDevInfo->Length = DevInfoLength;
+ TempDevInfo->Length = DevInfoLength;
TempDevInfo->OpalBaseComId = TmpDev->OpalDisk.OpalBaseComId;
CopyMem (
TempDevInfo->Password,
@@ -373,13 +375,14 @@ BuildOpalDeviceInfo (
if (S3InitDevicesBak != NULL) {
FreePool (S3InitDevicesBak);
}
+
ASSERT (S3InitDevices != NULL);
if (S3InitDevices == NULL) {
return;
}
- TempDevInfo = (OPAL_DEVICE_LOCKBOX_DATA *) ((UINTN) TempDevInfo + DevInfoLength);
- TmpDev = TmpDev->Next;
+ TempDevInfo = (OPAL_DEVICE_LOCKBOX_DATA *)((UINTN)TempDevInfo + DevInfoLength);
+ TmpDev = TmpDev->Next;
}
Status = SaveLockBox (
@@ -434,10 +437,10 @@ SendBlockSidCommand (
VOID
)
{
- OPAL_DRIVER_DEVICE *Itr;
- TCG_RESULT Result;
- OPAL_SESSION Session;
- UINT32 PpStorageFlag;
+ OPAL_DRIVER_DEVICE *Itr;
+ TCG_RESULT Result;
+ OPAL_SESSION Session;
+ UINT32 PpStorageFlag;
PpStorageFlag = Tcg2PhysicalPresenceLibGetManagementFlags ();
if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) {
@@ -447,9 +450,9 @@ SendBlockSidCommand (
Itr = mOpalDriver.DeviceList;
while (Itr != NULL) {
if (Itr->OpalDisk.SupportedAttributes.BlockSid) {
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Itr->OpalDisk.Sscp;
- Session.MediaId = Itr->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Itr->OpalDisk.Sscp;
+ Session.MediaId = Itr->OpalDisk.MediaId;
Session.OpalBaseComId = Itr->OpalDisk.OpalBaseComId;
DEBUG ((DEBUG_INFO, "OpalPassword: EndOfDxe point, send BlockSid command to device!\n"));
@@ -482,11 +485,11 @@ SendBlockSidCommand (
VOID
EFIAPI
OpalEndOfDxeEventNotify (
- EFI_EVENT Event,
- VOID *Context
+ EFI_EVENT Event,
+ VOID *Context
)
{
- OPAL_DRIVER_DEVICE *TmpDev;
+ OPAL_DRIVER_DEVICE *TmpDev;
DEBUG ((DEBUG_INFO, "%a() - enter\n", __FUNCTION__));
@@ -498,7 +501,7 @@ OpalEndOfDxeEventNotify (
// as the OPAL requests should have been processed.
//
FreePool (mOpalRequestVariable);
- mOpalRequestVariable = NULL;
+ mOpalRequestVariable = NULL;
mOpalRequestVariableSize = 0;
}
@@ -547,25 +550,25 @@ OpalEndOfDxeEventNotify (
**/
CHAR8 *
OpalDriverPopUpPsidInput (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *PopUpString,
- IN CHAR16 *PopUpString2,
- IN CHAR16 *PopUpString3,
- OUT BOOLEAN *PressEsc
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *PopUpString,
+ IN CHAR16 *PopUpString2,
+ IN CHAR16 *PopUpString3,
+ OUT BOOLEAN *PressEsc
)
{
- EFI_INPUT_KEY InputKey;
- UINTN InputLength;
- CHAR16 Mask[PSID_CHARACTER_LENGTH + 1];
- CHAR16 Unicode[PSID_CHARACTER_LENGTH + 1];
- CHAR8 *Ascii;
+ EFI_INPUT_KEY InputKey;
+ UINTN InputLength;
+ CHAR16 Mask[PSID_CHARACTER_LENGTH + 1];
+ CHAR16 Unicode[PSID_CHARACTER_LENGTH + 1];
+ CHAR8 *Ascii;
- ZeroMem(Unicode, sizeof(Unicode));
- ZeroMem(Mask, sizeof(Mask));
+ ZeroMem (Unicode, sizeof (Unicode));
+ ZeroMem (Mask, sizeof (Mask));
*PressEsc = FALSE;
- gST->ConOut->ClearScreen(gST->ConOut);
+ gST->ConOut->ClearScreen (gST->ConOut);
InputLength = 0;
while (TRUE) {
@@ -578,7 +581,7 @@ OpalDriverPopUpPsidInput (
L"---------------------",
Mask,
NULL
- );
+ );
} else {
if (PopUpString3 == NULL) {
CreatePopUp (
@@ -589,7 +592,7 @@ OpalDriverPopUpPsidInput (
L"---------------------",
Mask,
NULL
- );
+ );
} else {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -600,7 +603,7 @@ OpalDriverPopUpPsidInput (
L"---------------------",
Mask,
NULL
- );
+ );
}
}
@@ -616,12 +619,13 @@ OpalDriverPopUpPsidInput (
// Add the null terminator.
//
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
break;
} else if ((InputKey.UnicodeChar == CHAR_NULL) ||
(InputKey.UnicodeChar == CHAR_TAB) ||
(InputKey.UnicodeChar == CHAR_LINEFEED)
- ) {
+ )
+ {
continue;
} else {
//
@@ -630,7 +634,7 @@ OpalDriverPopUpPsidInput (
if (InputKey.UnicodeChar == CHAR_BACKSPACE) {
if (InputLength > 0) {
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
InputLength--;
}
} else {
@@ -638,14 +642,14 @@ OpalDriverPopUpPsidInput (
// add Next key entry
//
Unicode[InputLength] = InputKey.UnicodeChar;
- Mask[InputLength] = InputKey.UnicodeChar;
+ Mask[InputLength] = InputKey.UnicodeChar;
InputLength++;
if (InputLength == PSID_CHARACTER_LENGTH) {
//
// Add the null terminator.
//
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
break;
}
}
@@ -661,9 +665,9 @@ OpalDriverPopUpPsidInput (
}
}
- gST->ConOut->ClearScreen(gST->ConOut);
+ gST->ConOut->ClearScreen (gST->ConOut);
- if (InputLength == 0 || InputKey.ScanCode == SCAN_ESC) {
+ if ((InputLength == 0) || (InputKey.ScanCode == SCAN_ESC)) {
ZeroMem (Unicode, sizeof (Unicode));
ZeroMem (Mask, sizeof (Mask));
return NULL;
@@ -683,7 +687,6 @@ OpalDriverPopUpPsidInput (
return Ascii;
}
-
/**
Get password input from the popup window.
@@ -699,25 +702,25 @@ OpalDriverPopUpPsidInput (
**/
CHAR8 *
OpalDriverPopUpPasswordInput (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *PopUpString1,
- IN CHAR16 *PopUpString2,
- IN CHAR16 *PopUpString3,
- OUT BOOLEAN *PressEsc
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *PopUpString1,
+ IN CHAR16 *PopUpString2,
+ IN CHAR16 *PopUpString3,
+ OUT BOOLEAN *PressEsc
)
{
- EFI_INPUT_KEY InputKey;
- UINTN InputLength;
- CHAR16 Mask[OPAL_MAX_PASSWORD_SIZE + 1];
- CHAR16 Unicode[OPAL_MAX_PASSWORD_SIZE + 1];
- CHAR8 *Ascii;
+ EFI_INPUT_KEY InputKey;
+ UINTN InputLength;
+ CHAR16 Mask[OPAL_MAX_PASSWORD_SIZE + 1];
+ CHAR16 Unicode[OPAL_MAX_PASSWORD_SIZE + 1];
+ CHAR8 *Ascii;
- ZeroMem(Unicode, sizeof(Unicode));
- ZeroMem(Mask, sizeof(Mask));
+ ZeroMem (Unicode, sizeof (Unicode));
+ ZeroMem (Mask, sizeof (Mask));
*PressEsc = FALSE;
- gST->ConOut->ClearScreen(gST->ConOut);
+ gST->ConOut->ClearScreen (gST->ConOut);
InputLength = 0;
while (TRUE) {
@@ -730,7 +733,7 @@ OpalDriverPopUpPasswordInput (
L"---------------------",
Mask,
NULL
- );
+ );
} else {
if (PopUpString3 == NULL) {
CreatePopUp (
@@ -741,7 +744,7 @@ OpalDriverPopUpPasswordInput (
L"---------------------",
Mask,
NULL
- );
+ );
} else {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -752,7 +755,7 @@ OpalDriverPopUpPasswordInput (
L"---------------------",
Mask,
NULL
- );
+ );
}
}
@@ -768,12 +771,13 @@ OpalDriverPopUpPasswordInput (
// Add the null terminator.
//
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
break;
} else if ((InputKey.UnicodeChar == CHAR_NULL) ||
(InputKey.UnicodeChar == CHAR_TAB) ||
(InputKey.UnicodeChar == CHAR_LINEFEED)
- ) {
+ )
+ {
continue;
} else {
//
@@ -782,7 +786,7 @@ OpalDriverPopUpPasswordInput (
if (InputKey.UnicodeChar == CHAR_BACKSPACE) {
if (InputLength > 0) {
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
InputLength--;
}
} else {
@@ -790,14 +794,14 @@ OpalDriverPopUpPasswordInput (
// add Next key entry
//
Unicode[InputLength] = InputKey.UnicodeChar;
- Mask[InputLength] = L'*';
+ Mask[InputLength] = L'*';
InputLength++;
if (InputLength == OPAL_MAX_PASSWORD_SIZE) {
//
// Add the null terminator.
//
Unicode[InputLength] = 0;
- Mask[InputLength] = 0;
+ Mask[InputLength] = 0;
break;
}
}
@@ -813,9 +817,9 @@ OpalDriverPopUpPasswordInput (
}
}
- gST->ConOut->ClearScreen(gST->ConOut);
+ gST->ConOut->ClearScreen (gST->ConOut);
- if (InputLength == 0 || InputKey.ScanCode == SCAN_ESC) {
+ if ((InputLength == 0) || (InputKey.ScanCode == SCAN_ESC)) {
ZeroMem (Unicode, sizeof (Unicode));
return NULL;
}
@@ -843,8 +847,8 @@ OpalDriverPopUpPasswordInput (
**/
CHAR16 *
OpalGetPopUpString (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
if (Dev->Name16 == NULL) {
@@ -865,20 +869,20 @@ OpalGetPopUpString (
**/
VOID
OpalDriverRequestPassword (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- BOOLEAN IsEnabled;
- BOOLEAN IsLocked;
- CHAR8 *Password;
- UINT32 PasswordLen;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- CHAR16 *PopUpString;
+ UINT8 Count;
+ BOOLEAN IsEnabled;
+ BOOLEAN IsLocked;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ CHAR16 *PopUpString;
if (Dev == NULL) {
return;
@@ -892,9 +896,9 @@ OpalDriverRequestPassword (
IsEnabled = OpalFeatureEnabled (&Dev->OpalDisk.SupportedAttributes, &Dev->OpalDisk.LockingFeature);
if (IsEnabled) {
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
IsLocked = OpalDeviceLocked (&Dev->OpalDisk.SupportedAttributes, &Dev->OpalDisk.LockingFeature);
@@ -935,7 +939,7 @@ OpalDriverRequestPassword (
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
+ gST->ConOut->ClearScreen (gST->ConOut);
//
// Keep lock and continue boot.
//
@@ -973,17 +977,18 @@ OpalDriverRequestPassword (
}
if (Password == NULL) {
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
+
+ PasswordLen = (UINT32)AsciiStrLen (Password);
if (IsLocked) {
- Ret = OpalUtilUpdateGlobalLockingRange(&Session, Password, PasswordLen, FALSE, FALSE);
+ Ret = OpalUtilUpdateGlobalLockingRange (&Session, Password, PasswordLen, FALSE, FALSE);
} else {
- Ret = OpalUtilUpdateGlobalLockingRange(&Session, Password, PasswordLen, TRUE, TRUE);
+ Ret = OpalUtilUpdateGlobalLockingRange (&Session, Password, PasswordLen, TRUE, TRUE);
if (Ret == TcgResultSuccess) {
- Ret = OpalUtilUpdateGlobalLockingRange(&Session, Password, PasswordLen, FALSE, FALSE);
+ Ret = OpalUtilUpdateGlobalLockingRange (&Session, Password, PasswordLen, FALSE, FALSE);
}
}
@@ -1050,20 +1055,20 @@ OpalDriverRequestPassword (
**/
VOID
ProcessOpalRequestEnableFeature (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *Password;
- UINT32 PasswordLen;
- CHAR8 *PasswordConfirm;
- UINT32 PasswordLenConfirm;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- CHAR16 *PopUpString;
+ UINT8 Count;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ CHAR8 *PasswordConfirm;
+ UINT32 PasswordLenConfirm;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ CHAR16 *PopUpString;
if (Dev == NULL) {
return;
@@ -1075,51 +1080,54 @@ ProcessOpalRequestEnableFeature (
Count = 0;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
while (Count < MAX_PASSWORD_TRY_COUNT) {
Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please type in your new password", NULL, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- return;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ return;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (Password == NULL) {
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
+
+ PasswordLen = (UINT32)AsciiStrLen (Password);
PasswordConfirm = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please confirm your new password", NULL, &PressEsc);
if (PasswordConfirm == NULL) {
ZeroMem (Password, PasswordLen);
FreePool (Password);
- Count ++;
+ Count++;
continue;
}
- PasswordLenConfirm = (UINT32) AsciiStrLen(PasswordConfirm);
+
+ PasswordLenConfirm = (UINT32)AsciiStrLen (PasswordConfirm);
if ((PasswordLen != PasswordLenConfirm) ||
- (CompareMem (Password, PasswordConfirm, PasswordLen) != 0)) {
+ (CompareMem (Password, PasswordConfirm, PasswordLen) != 0))
+ {
ZeroMem (Password, PasswordLen);
FreePool (Password);
ZeroMem (PasswordConfirm, PasswordLenConfirm);
@@ -1133,7 +1141,8 @@ ProcessOpalRequestEnableFeature (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- Count ++;
+
+ Count++;
continue;
}
@@ -1142,7 +1151,7 @@ ProcessOpalRequestEnableFeature (
FreePool (PasswordConfirm);
}
- Ret = OpalSupportEnableOpalFeature (&Session, Dev->OpalDisk.Msid, Dev->OpalDisk.MsidLength, Password, PasswordLen);
+ Ret = OpalSupportEnableOpalFeature (&Session, Dev->OpalDisk.Msid, Dev->OpalDisk.MsidLength, Password, PasswordLen);
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -1182,7 +1191,8 @@ ProcessOpalRequestEnableFeature (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
}
@@ -1195,19 +1205,19 @@ ProcessOpalRequestEnableFeature (
**/
VOID
ProcessOpalRequestDisableUser (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *Password;
- UINT32 PasswordLen;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- BOOLEAN PasswordFailed;
- CHAR16 *PopUpString;
+ UINT8 Count;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ BOOLEAN PasswordFailed;
+ CHAR16 *PopUpString;
if (Dev == NULL) {
return;
@@ -1219,42 +1229,43 @@ ProcessOpalRequestDisableUser (
Count = 0;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
while (Count < MAX_PASSWORD_TRY_COUNT) {
Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, NULL, NULL, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- return;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ return;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (Password == NULL) {
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
- Ret = OpalUtilDisableUser(&Session, Password, PasswordLen, &PasswordFailed);
+ PasswordLen = (UINT32)AsciiStrLen (Password);
+
+ Ret = OpalUtilDisableUser (&Session, Password, PasswordLen, &PasswordFailed);
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -1294,7 +1305,8 @@ ProcessOpalRequestDisableUser (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
}
@@ -1307,21 +1319,21 @@ ProcessOpalRequestDisableUser (
**/
VOID
ProcessOpalRequestPsidRevert (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *Psid;
- UINT32 PsidLen;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- CHAR16 *PopUpString;
- CHAR16 *PopUpString2;
- CHAR16 *PopUpString3;
- UINTN BufferSize;
+ UINT8 Count;
+ CHAR8 *Psid;
+ UINT32 PsidLen;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ CHAR16 *PopUpString;
+ CHAR16 *PopUpString2;
+ CHAR16 *PopUpString3;
+ UINTN BufferSize;
if (Dev == NULL) {
return;
@@ -1332,14 +1344,14 @@ ProcessOpalRequestPsidRevert (
PopUpString = OpalGetPopUpString (Dev, RequestString);
if (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME) {
- BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds");
+ BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds");
PopUpString2 = AllocateZeroPool (BufferSize);
ASSERT (PopUpString2 != NULL);
UnicodeSPrint (
- PopUpString2,
- BufferSize,
- L"WARNING: Revert action will take about %d seconds",
- Dev->OpalDisk.EstimateTimeCost
+ PopUpString2,
+ BufferSize,
+ L"WARNING: Revert action will take about %d seconds",
+ Dev->OpalDisk.EstimateTimeCost
);
PopUpString3 = L"DO NOT power off system during the revert action!";
} else {
@@ -1349,42 +1361,43 @@ ProcessOpalRequestPsidRevert (
Count = 0;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
while (Count < MAX_PSID_TRY_COUNT) {
Psid = OpalDriverPopUpPsidInput (Dev, PopUpString, PopUpString2, PopUpString3, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input Psid again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input Psid again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- goto Done;
- } else {
- //
- // Let user input Psid again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ goto Done;
+ } else {
+ //
+ // Let user input Psid again.
+ //
+ continue;
+ }
}
if (Psid == NULL) {
- Count ++;
+ Count++;
continue;
}
- PsidLen = (UINT32) AsciiStrLen(Psid);
- Ret = OpalUtilPsidRevert(&Session, Psid, PsidLen);
+ PsidLen = (UINT32)AsciiStrLen (Psid);
+
+ Ret = OpalUtilPsidRevert (&Session, Psid, PsidLen);
if (Ret == TcgResultSuccess) {
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
} else {
@@ -1423,7 +1436,8 @@ ProcessOpalRequestPsidRevert (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
Done:
@@ -1442,23 +1456,23 @@ Done:
**/
VOID
ProcessOpalRequestRevert (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN BOOLEAN KeepUserData,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN BOOLEAN KeepUserData,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *Password;
- UINT32 PasswordLen;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- BOOLEAN PasswordFailed;
- CHAR16 *PopUpString;
- CHAR16 *PopUpString2;
- CHAR16 *PopUpString3;
- UINTN BufferSize;
+ UINT8 Count;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ BOOLEAN PasswordFailed;
+ CHAR16 *PopUpString;
+ CHAR16 *PopUpString2;
+ CHAR16 *PopUpString3;
+ UINTN BufferSize;
if (Dev == NULL) {
return;
@@ -1469,15 +1483,16 @@ ProcessOpalRequestRevert (
PopUpString = OpalGetPopUpString (Dev, RequestString);
if ((!KeepUserData) &&
- (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME)) {
- BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds");
+ (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME))
+ {
+ BufferSize = StrSize (L"Warning: Revert action will take about ####### seconds");
PopUpString2 = AllocateZeroPool (BufferSize);
ASSERT (PopUpString2 != NULL);
UnicodeSPrint (
- PopUpString2,
- BufferSize,
- L"WARNING: Revert action will take about %d seconds",
- Dev->OpalDisk.EstimateTimeCost
+ PopUpString2,
+ BufferSize,
+ L"WARNING: Revert action will take about %d seconds",
+ Dev->OpalDisk.EstimateTimeCost
);
PopUpString3 = L"DO NOT power off system during the revert action!";
} else {
@@ -1487,49 +1502,51 @@ ProcessOpalRequestRevert (
Count = 0;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
while (Count < MAX_PASSWORD_TRY_COUNT) {
Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, PopUpString2, PopUpString3, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- goto Done;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ goto Done;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (Password == NULL) {
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
+
+ PasswordLen = (UINT32)AsciiStrLen (Password);
if ((Dev->OpalDisk.SupportedAttributes.PyriteSsc == 1) &&
- (Dev->OpalDisk.LockingFeature.MediaEncryption == 0)) {
+ (Dev->OpalDisk.LockingFeature.MediaEncryption == 0))
+ {
//
// For pyrite type device which does not support media encryption,
// it does not accept "Keep User Data" parameter.
// So here hardcode a FALSE for this case.
//
- Ret = OpalUtilRevert(
+ Ret = OpalUtilRevert (
&Session,
FALSE,
Password,
@@ -1539,7 +1556,7 @@ ProcessOpalRequestRevert (
Dev->OpalDisk.MsidLength
);
} else {
- Ret = OpalUtilRevert(
+ Ret = OpalUtilRevert (
&Session,
KeepUserData,
Password,
@@ -1549,6 +1566,7 @@ ProcessOpalRequestRevert (
Dev->OpalDisk.MsidLength
);
}
+
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -1588,7 +1606,8 @@ ProcessOpalRequestRevert (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
Done:
@@ -1606,22 +1625,22 @@ Done:
**/
VOID
ProcessOpalRequestSecureErase (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *Password;
- UINT32 PasswordLen;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- BOOLEAN PasswordFailed;
- CHAR16 *PopUpString;
- CHAR16 *PopUpString2;
- CHAR16 *PopUpString3;
- UINTN BufferSize;
+ UINT8 Count;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ BOOLEAN PasswordFailed;
+ CHAR16 *PopUpString;
+ CHAR16 *PopUpString2;
+ CHAR16 *PopUpString3;
+ UINTN BufferSize;
if (Dev == NULL) {
return;
@@ -1632,58 +1651,60 @@ ProcessOpalRequestSecureErase (
PopUpString = OpalGetPopUpString (Dev, RequestString);
if (Dev->OpalDisk.EstimateTimeCost > MAX_ACCEPTABLE_REVERTING_TIME) {
- BufferSize = StrSize (L"Warning: Secure erase action will take about ####### seconds");
+ BufferSize = StrSize (L"Warning: Secure erase action will take about ####### seconds");
PopUpString2 = AllocateZeroPool (BufferSize);
ASSERT (PopUpString2 != NULL);
UnicodeSPrint (
- PopUpString2,
- BufferSize,
- L"WARNING: Secure erase action will take about %d seconds",
- Dev->OpalDisk.EstimateTimeCost
+ PopUpString2,
+ BufferSize,
+ L"WARNING: Secure erase action will take about %d seconds",
+ Dev->OpalDisk.EstimateTimeCost
);
PopUpString3 = L"DO NOT power off system during the action!";
} else {
PopUpString2 = NULL;
PopUpString3 = NULL;
}
+
Count = 0;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
while (Count < MAX_PASSWORD_TRY_COUNT) {
Password = OpalDriverPopUpPasswordInput (Dev, PopUpString, PopUpString2, PopUpString3, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- goto Done;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ goto Done;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (Password == NULL) {
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
- Ret = OpalUtilSecureErase(&Session, Password, PasswordLen, &PasswordFailed);
+ PasswordLen = (UINT32)AsciiStrLen (Password);
+
+ Ret = OpalUtilSecureErase (&Session, Password, PasswordLen, &PasswordFailed);
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -1723,7 +1744,8 @@ ProcessOpalRequestSecureErase (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
Done:
@@ -1741,22 +1763,22 @@ Done:
**/
VOID
ProcessOpalRequestSetUserPwd (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *OldPassword;
- UINT32 OldPasswordLen;
- CHAR8 *Password;
- UINT32 PasswordLen;
- CHAR8 *PasswordConfirm;
- UINT32 PasswordLenConfirm;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- CHAR16 *PopUpString;
+ UINT8 Count;
+ CHAR8 *OldPassword;
+ UINT32 OldPasswordLen;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ CHAR8 *PasswordConfirm;
+ UINT32 PasswordLenConfirm;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ CHAR16 *PopUpString;
if (Dev == NULL) {
return;
@@ -1771,38 +1793,39 @@ ProcessOpalRequestSetUserPwd (
while (Count < MAX_PASSWORD_TRY_COUNT) {
OldPassword = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please type in your password", NULL, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- return;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ return;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (OldPassword == NULL) {
- Count ++;
+ Count++;
continue;
}
- OldPasswordLen = (UINT32) AsciiStrLen(OldPassword);
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ OldPasswordLen = (UINT32)AsciiStrLen (OldPassword);
+
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
- Ret = OpalUtilVerifyPassword (&Session, OldPassword, OldPasswordLen, OPAL_LOCKING_SP_USER1_AUTHORITY);
+ Ret = OpalUtilVerifyPassword (&Session, OldPassword, OldPasswordLen, OPAL_LOCKING_SP_USER1_AUTHORITY);
if (Ret == TcgResultSuccess) {
DEBUG ((DEBUG_INFO, "Verify with USER1 authority : Success\n"));
} else {
@@ -1822,7 +1845,8 @@ ProcessOpalRequestSetUserPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- Count ++;
+
+ Count++;
continue;
}
}
@@ -1831,10 +1855,11 @@ ProcessOpalRequestSetUserPwd (
if (Password == NULL) {
ZeroMem (OldPassword, OldPasswordLen);
FreePool (OldPassword);
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
+
+ PasswordLen = (UINT32)AsciiStrLen (Password);
PasswordConfirm = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please confirm your new password", NULL, &PressEsc);
if (PasswordConfirm == NULL) {
@@ -1842,12 +1867,14 @@ ProcessOpalRequestSetUserPwd (
FreePool (OldPassword);
ZeroMem (Password, PasswordLen);
FreePool (Password);
- Count ++;
+ Count++;
continue;
}
- PasswordLenConfirm = (UINT32) AsciiStrLen(PasswordConfirm);
+
+ PasswordLenConfirm = (UINT32)AsciiStrLen (PasswordConfirm);
if ((PasswordLen != PasswordLenConfirm) ||
- (CompareMem (Password, PasswordConfirm, PasswordLen) != 0)) {
+ (CompareMem (Password, PasswordConfirm, PasswordLen) != 0))
+ {
ZeroMem (OldPassword, OldPasswordLen);
FreePool (OldPassword);
ZeroMem (Password, PasswordLen);
@@ -1863,7 +1890,8 @@ ProcessOpalRequestSetUserPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- Count ++;
+
+ Count++;
continue;
}
@@ -1872,17 +1900,17 @@ ProcessOpalRequestSetUserPwd (
FreePool (PasswordConfirm);
}
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
- Ret = OpalUtilSetUserPassword(
- &Session,
- OldPassword,
- OldPasswordLen,
- Password,
- PasswordLen
- );
+ Ret = OpalUtilSetUserPassword (
+ &Session,
+ OldPassword,
+ OldPasswordLen,
+ Password,
+ PasswordLen
+ );
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -1927,7 +1955,8 @@ ProcessOpalRequestSetUserPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
}
@@ -1940,22 +1969,22 @@ ProcessOpalRequestSetUserPwd (
**/
VOID
ProcessOpalRequestSetAdminPwd (
- IN OPAL_DRIVER_DEVICE *Dev,
- IN CHAR16 *RequestString
+ IN OPAL_DRIVER_DEVICE *Dev,
+ IN CHAR16 *RequestString
)
{
- UINT8 Count;
- CHAR8 *OldPassword;
- UINT32 OldPasswordLen;
- CHAR8 *Password;
- UINT32 PasswordLen;
- CHAR8 *PasswordConfirm;
- UINT32 PasswordLenConfirm;
- OPAL_SESSION Session;
- BOOLEAN PressEsc;
- EFI_INPUT_KEY Key;
- TCG_RESULT Ret;
- CHAR16 *PopUpString;
+ UINT8 Count;
+ CHAR8 *OldPassword;
+ UINT32 OldPasswordLen;
+ CHAR8 *Password;
+ UINT32 PasswordLen;
+ CHAR8 *PasswordConfirm;
+ UINT32 PasswordLenConfirm;
+ OPAL_SESSION Session;
+ BOOLEAN PressEsc;
+ EFI_INPUT_KEY Key;
+ TCG_RESULT Ret;
+ CHAR16 *PopUpString;
if (Dev == NULL) {
return;
@@ -1970,38 +1999,39 @@ ProcessOpalRequestSetAdminPwd (
while (Count < MAX_PASSWORD_TRY_COUNT) {
OldPassword = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please type in your password", NULL, &PressEsc);
if (PressEsc) {
- do {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Press ENTER to skip the request and continue boot,",
- L"Press ESC to input password again",
- NULL
- );
- } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
+ do {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Press ENTER to skip the request and continue boot,",
+ L"Press ESC to input password again",
+ NULL
+ );
+ } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- gST->ConOut->ClearScreen(gST->ConOut);
- return;
- } else {
- //
- // Let user input password again.
- //
- continue;
- }
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
+ gST->ConOut->ClearScreen (gST->ConOut);
+ return;
+ } else {
+ //
+ // Let user input password again.
+ //
+ continue;
+ }
}
if (OldPassword == NULL) {
- Count ++;
+ Count++;
continue;
}
- OldPasswordLen = (UINT32) AsciiStrLen(OldPassword);
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ OldPasswordLen = (UINT32)AsciiStrLen (OldPassword);
+
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
- Ret = OpalUtilVerifyPassword (&Session, OldPassword, OldPasswordLen, OPAL_LOCKING_SP_ADMIN1_AUTHORITY);
+ Ret = OpalUtilVerifyPassword (&Session, OldPassword, OldPasswordLen, OPAL_LOCKING_SP_ADMIN1_AUTHORITY);
if (Ret == TcgResultSuccess) {
DEBUG ((DEBUG_INFO, "Verify: Success\n"));
} else {
@@ -2017,7 +2047,8 @@ ProcessOpalRequestSetAdminPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- Count ++;
+
+ Count++;
continue;
}
@@ -2025,10 +2056,11 @@ ProcessOpalRequestSetAdminPwd (
if (Password == NULL) {
ZeroMem (OldPassword, OldPasswordLen);
FreePool (OldPassword);
- Count ++;
+ Count++;
continue;
}
- PasswordLen = (UINT32) AsciiStrLen(Password);
+
+ PasswordLen = (UINT32)AsciiStrLen (Password);
PasswordConfirm = OpalDriverPopUpPasswordInput (Dev, PopUpString, L"Please confirm your new password", NULL, &PressEsc);
if (PasswordConfirm == NULL) {
@@ -2036,12 +2068,14 @@ ProcessOpalRequestSetAdminPwd (
FreePool (OldPassword);
ZeroMem (Password, PasswordLen);
FreePool (Password);
- Count ++;
+ Count++;
continue;
}
- PasswordLenConfirm = (UINT32) AsciiStrLen(PasswordConfirm);
+
+ PasswordLenConfirm = (UINT32)AsciiStrLen (PasswordConfirm);
if ((PasswordLen != PasswordLenConfirm) ||
- (CompareMem (Password, PasswordConfirm, PasswordLen) != 0)) {
+ (CompareMem (Password, PasswordConfirm, PasswordLen) != 0))
+ {
ZeroMem (OldPassword, OldPasswordLen);
FreePool (OldPassword);
ZeroMem (Password, PasswordLen);
@@ -2057,7 +2091,8 @@ ProcessOpalRequestSetAdminPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- Count ++;
+
+ Count++;
continue;
}
@@ -2066,18 +2101,17 @@ ProcessOpalRequestSetAdminPwd (
FreePool (PasswordConfirm);
}
-
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->OpalDisk.Sscp;
- Session.MediaId = Dev->OpalDisk.MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->OpalDisk.Sscp;
+ Session.MediaId = Dev->OpalDisk.MediaId;
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
- Ret = OpalUtilSetAdminPassword(
- &Session,
- OldPassword,
- OldPasswordLen,
- Password,
- PasswordLen
- );
+ Ret = OpalUtilSetAdminPassword (
+ &Session,
+ OldPassword,
+ OldPasswordLen,
+ Password,
+ PasswordLen
+ );
if (Ret == TcgResultSuccess) {
OpalSupportUpdatePassword (&Dev->OpalDisk, Password, PasswordLen);
DEBUG ((DEBUG_INFO, "%s Success\n", RequestString));
@@ -2122,7 +2156,8 @@ ProcessOpalRequestSetAdminPwd (
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- gST->ConOut->ClearScreen(gST->ConOut);
+
+ gST->ConOut->ClearScreen (gST->ConOut);
}
}
@@ -2134,7 +2169,7 @@ ProcessOpalRequestSetAdminPwd (
**/
VOID
ProcessOpalRequest (
- IN OPAL_DRIVER_DEVICE *Dev
+ IN OPAL_DRIVER_DEVICE *Dev
)
{
EFI_STATUS Status;
@@ -2153,13 +2188,14 @@ ProcessOpalRequest (
Status = GetVariable2 (
OPAL_REQUEST_VARIABLE_NAME,
&gHiiSetupVariableGuid,
- (VOID **) &Variable,
+ (VOID **)&Variable,
&VariableSize
);
if (EFI_ERROR (Status) || (Variable == NULL)) {
return;
}
- mOpalRequestVariable = Variable;
+
+ mOpalRequestVariable = Variable;
mOpalRequestVariableSize = VariableSize;
//
@@ -2167,14 +2203,14 @@ ProcessOpalRequest (
//
Status = gRT->SetVariable (
OPAL_REQUEST_VARIABLE_NAME,
- (EFI_GUID *) &gHiiSetupVariableGuid,
+ (EFI_GUID *)&gHiiSetupVariableGuid,
0,
0,
NULL
);
ASSERT_EFI_ERROR (Status);
} else {
- Variable = mOpalRequestVariable;
+ Variable = mOpalRequestVariable;
VariableSize = mOpalRequestVariableSize;
}
@@ -2184,39 +2220,47 @@ ProcessOpalRequest (
TempVariable = Variable;
while ((VariableSize > sizeof (OPAL_REQUEST_VARIABLE)) &&
(VariableSize >= TempVariable->Length) &&
- (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE))) {
- DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
+ (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE)))
+ {
+ DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
DevicePathSizeInVariable = GetDevicePathSize (DevicePathInVariable);
- DevicePath = Dev->OpalDisk.OpalDevicePath;
- DevicePathSize = GetDevicePathSize (DevicePath);
+ DevicePath = Dev->OpalDisk.OpalDevicePath;
+ DevicePathSize = GetDevicePathSize (DevicePath);
if ((DevicePathSize == DevicePathSizeInVariable) &&
- (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0)) {
+ (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0))
+ {
//
// Found the node for the OPAL device.
//
if (TempVariable->OpalRequest.SetAdminPwd != 0) {
ProcessOpalRequestSetAdminPwd (Dev, L"Update Admin Pwd:");
}
+
if (TempVariable->OpalRequest.SetUserPwd != 0) {
ProcessOpalRequestSetUserPwd (Dev, L"Set User Pwd:");
}
- if (TempVariable->OpalRequest.SecureErase!= 0) {
+
+ if (TempVariable->OpalRequest.SecureErase != 0) {
ProcessOpalRequestSecureErase (Dev, L"Secure Erase:");
}
+
if (TempVariable->OpalRequest.Revert != 0) {
- KeepUserData = (BOOLEAN) TempVariable->OpalRequest.KeepUserData;
+ KeepUserData = (BOOLEAN)TempVariable->OpalRequest.KeepUserData;
ProcessOpalRequestRevert (
Dev,
KeepUserData,
KeepUserData ? L"Admin Revert(keep):" : L"Admin Revert:"
);
}
+
if (TempVariable->OpalRequest.PsidRevert != 0) {
ProcessOpalRequestPsidRevert (Dev, L"Psid Revert:");
}
+
if (TempVariable->OpalRequest.DisableUser != 0) {
ProcessOpalRequestDisableUser (Dev, L"Disable User:");
}
+
if (TempVariable->OpalRequest.EnableFeature != 0) {
ProcessOpalRequestEnableFeature (Dev, L"Enable Feature:");
}
@@ -2231,7 +2275,7 @@ ProcessOpalRequest (
}
VariableSize -= TempVariable->Length;
- TempVariable = (OPAL_REQUEST_VARIABLE *) ((UINTN) TempVariable + TempVariable->Length);
+ TempVariable = (OPAL_REQUEST_VARIABLE *)((UINTN)TempVariable + TempVariable->Length);
}
DEBUG ((DEBUG_INFO, "%a() - exit\n", __FUNCTION__));
@@ -2244,11 +2288,11 @@ ProcessOpalRequest (
**/
VOID
-AddDeviceToTail(
- IN OPAL_DRIVER_DEVICE *Dev
+AddDeviceToTail (
+ IN OPAL_DRIVER_DEVICE *Dev
)
{
- OPAL_DRIVER_DEVICE *TmpDev;
+ OPAL_DRIVER_DEVICE *TmpDev;
if (mOpalDriver.DeviceList == NULL) {
mOpalDriver.DeviceList = Dev;
@@ -2270,10 +2314,10 @@ AddDeviceToTail(
**/
VOID
RemoveDevice (
- IN OPAL_DRIVER_DEVICE *Dev
+ IN OPAL_DRIVER_DEVICE *Dev
)
{
- OPAL_DRIVER_DEVICE *TmpDev;
+ OPAL_DRIVER_DEVICE *TmpDev;
if (mOpalDriver.DeviceList == NULL) {
return;
@@ -2304,10 +2348,10 @@ GetDeviceCount (
VOID
)
{
- UINT8 Count;
- OPAL_DRIVER_DEVICE *TmpDev;
+ UINT8 Count;
+ OPAL_DRIVER_DEVICE *TmpDev;
- Count = 0;
+ Count = 0;
TmpDev = mOpalDriver.DeviceList;
while (TmpDev != NULL) {
@@ -2323,8 +2367,8 @@ GetDeviceCount (
@retval return the device list pointer.
**/
-OPAL_DRIVER_DEVICE*
-OpalDriverGetDeviceList(
+OPAL_DRIVER_DEVICE *
+OpalDriverGetDeviceList (
VOID
)
{
@@ -2339,38 +2383,38 @@ OpalDriverGetDeviceList(
**/
VOID
OpalDriverStopDevice (
- OPAL_DRIVER_DEVICE *Dev
+ OPAL_DRIVER_DEVICE *Dev
)
{
//
// free each name
//
- FreePool(Dev->Name16);
+ FreePool (Dev->Name16);
//
// remove OPAL_DRIVER_DEVICE from the list
// it updates the controllerList pointer
//
- RemoveDevice(Dev);
+ RemoveDevice (Dev);
//
// close protocols that were opened
//
- gBS->CloseProtocol(
- Dev->Handle,
- &gEfiStorageSecurityCommandProtocolGuid,
- gOpalDriverBinding.DriverBindingHandle,
- Dev->Handle
- );
-
- gBS->CloseProtocol(
- Dev->Handle,
- &gEfiBlockIoProtocolGuid,
- gOpalDriverBinding.DriverBindingHandle,
- Dev->Handle
- );
-
- FreePool(Dev);
+ gBS->CloseProtocol (
+ Dev->Handle,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ gOpalDriverBinding.DriverBindingHandle,
+ Dev->Handle
+ );
+
+ gBS->CloseProtocol (
+ Dev->Handle,
+ &gEfiBlockIoProtocolGuid,
+ gOpalDriverBinding.DriverBindingHandle,
+ Dev->Handle
+ );
+
+ FreePool (Dev);
}
/**
@@ -2385,26 +2429,26 @@ OpalDriverStopDevice (
@retval FALSE Not found the name for this device.
**/
BOOLEAN
-OpalDriverGetDeviceNameByProtocol(
- EFI_HANDLE *AllHandlesBuffer,
- UINTN NumAllHandles,
- OPAL_DRIVER_DEVICE *Dev,
- BOOLEAN UseComp1
+OpalDriverGetDeviceNameByProtocol (
+ EFI_HANDLE *AllHandlesBuffer,
+ UINTN NumAllHandles,
+ OPAL_DRIVER_DEVICE *Dev,
+ BOOLEAN UseComp1
)
{
- EFI_HANDLE* ProtocolHandlesBuffer;
+ EFI_HANDLE *ProtocolHandlesBuffer;
UINTN NumProtocolHandles;
EFI_STATUS Status;
- EFI_COMPONENT_NAME2_PROTOCOL* Cnp1_2; // efi component name and componentName2 have same layout
+ EFI_COMPONENT_NAME2_PROTOCOL *Cnp1_2; // efi component name and componentName2 have same layout
EFI_GUID Protocol;
UINTN StrLength;
- EFI_DEVICE_PATH_PROTOCOL* TmpDevPath;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevPath;
UINTN Index1;
UINTN Index2;
EFI_HANDLE TmpHandle;
CHAR16 *DevName;
- if (Dev == NULL || AllHandlesBuffer == NULL || NumAllHandles == 0) {
+ if ((Dev == NULL) || (AllHandlesBuffer == NULL) || (NumAllHandles == 0)) {
return FALSE;
}
@@ -2413,18 +2457,17 @@ OpalDriverGetDeviceNameByProtocol(
//
// Find all EFI_HANDLES with protocol
//
- Status = gBS->LocateHandleBuffer(
- ByProtocol,
- &Protocol,
- NULL,
- &NumProtocolHandles,
- &ProtocolHandlesBuffer
- );
- if (EFI_ERROR(Status)) {
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &Protocol,
+ NULL,
+ &NumProtocolHandles,
+ &ProtocolHandlesBuffer
+ );
+ if (EFI_ERROR (Status)) {
return FALSE;
}
-
//
// Exit early if no supported devices
//
@@ -2448,15 +2491,15 @@ OpalDriverGetDeviceNameByProtocol(
TmpHandle = ProtocolHandlesBuffer[Index1];
- Status = gBS->OpenProtocol(
- TmpHandle,
- &Protocol,
- (VOID**)&Cnp1_2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status) || Cnp1_2 == NULL) {
+ Status = gBS->OpenProtocol (
+ TmpHandle,
+ &Protocol,
+ (VOID **)&Cnp1_2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status) || (Cnp1_2 == NULL)) {
continue;
}
@@ -2464,53 +2507,55 @@ OpalDriverGetDeviceNameByProtocol(
// Use all handles array as controller handle
//
for (Index2 = 0; Index2 < NumAllHandles; Index2++) {
- Status = Cnp1_2->GetControllerName(
- Cnp1_2,
- AllHandlesBuffer[Index2],
- Dev->Handle,
- LANGUAGE_ISO_639_2_ENGLISH,
- &DevName
- );
- if (EFI_ERROR(Status)) {
- Status = Cnp1_2->GetControllerName(
- Cnp1_2,
- AllHandlesBuffer[Index2],
- Dev->Handle,
- LANGUAGE_RFC_3066_ENGLISH,
- &DevName
- );
+ Status = Cnp1_2->GetControllerName (
+ Cnp1_2,
+ AllHandlesBuffer[Index2],
+ Dev->Handle,
+ LANGUAGE_ISO_639_2_ENGLISH,
+ &DevName
+ );
+ if (EFI_ERROR (Status)) {
+ Status = Cnp1_2->GetControllerName (
+ Cnp1_2,
+ AllHandlesBuffer[Index2],
+ Dev->Handle,
+ LANGUAGE_RFC_3066_ENGLISH,
+ &DevName
+ );
}
- if (!EFI_ERROR(Status) && DevName != NULL) {
- StrLength = StrLen(DevName) + 1; // Add one for NULL terminator
- Dev->Name16 = AllocateZeroPool(StrLength * sizeof (CHAR16));
+
+ if (!EFI_ERROR (Status) && (DevName != NULL)) {
+ StrLength = StrLen (DevName) + 1; // Add one for NULL terminator
+ Dev->Name16 = AllocateZeroPool (StrLength * sizeof (CHAR16));
ASSERT (Dev->Name16 != NULL);
StrCpyS (Dev->Name16, StrLength, DevName);
- Dev->NameZ = (CHAR8*)AllocateZeroPool(StrLength);
+ Dev->NameZ = (CHAR8 *)AllocateZeroPool (StrLength);
UnicodeStrToAsciiStrS (DevName, Dev->NameZ, StrLength);
//
// Retrieve bridge BDF info and port number or namespace depending on type
//
TmpDevPath = NULL;
- Status = gBS->OpenProtocol(
- Dev->Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&TmpDevPath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ Dev->Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&TmpDevPath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
Dev->OpalDevicePath = DuplicateDevicePath (TmpDevPath);
return TRUE;
}
if (Dev->Name16 != NULL) {
- FreePool(Dev->Name16);
+ FreePool (Dev->Name16);
Dev->Name16 = NULL;
}
+
if (Dev->NameZ != NULL) {
- FreePool(Dev->NameZ);
+ FreePool (Dev->NameZ);
Dev->NameZ = NULL;
}
}
@@ -2529,16 +2574,16 @@ OpalDriverGetDeviceNameByProtocol(
@retval FALSE Not found the name for this device.
**/
BOOLEAN
-OpalDriverGetDriverDeviceName(
- OPAL_DRIVER_DEVICE *Dev
+OpalDriverGetDriverDeviceName (
+ OPAL_DRIVER_DEVICE *Dev
)
{
- EFI_HANDLE* AllHandlesBuffer;
- UINTN NumAllHandles;
- EFI_STATUS Status;
+ EFI_HANDLE *AllHandlesBuffer;
+ UINTN NumAllHandles;
+ EFI_STATUS Status;
if (Dev == NULL) {
- DEBUG((DEBUG_ERROR | DEBUG_INIT, "OpalDriverGetDriverDeviceName Exiting, Dev=NULL\n"));
+ DEBUG ((DEBUG_ERROR | DEBUG_INIT, "OpalDriverGetDriverDeviceName Exiting, Dev=NULL\n"));
return FALSE;
}
@@ -2546,29 +2591,29 @@ OpalDriverGetDriverDeviceName(
// Iterate through ComponentName2 handles to get name, if fails, try ComponentName
//
if (Dev->Name16 == NULL) {
- DEBUG((DEBUG_ERROR | DEBUG_INIT, "Name is null, update it\n"));
+ DEBUG ((DEBUG_ERROR | DEBUG_INIT, "Name is null, update it\n"));
//
// Find all EFI_HANDLES
//
- Status = gBS->LocateHandleBuffer(
- AllHandles,
- NULL,
- NULL,
- &NumAllHandles,
- &AllHandlesBuffer
- );
- if (EFI_ERROR(Status)) {
- DEBUG ((DEBUG_INFO, "LocateHandleBuffer for AllHandles failed %r\n", Status ));
+ Status = gBS->LocateHandleBuffer (
+ AllHandles,
+ NULL,
+ NULL,
+ &NumAllHandles,
+ &AllHandlesBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "LocateHandleBuffer for AllHandles failed %r\n", Status));
return FALSE;
}
//
// Try component Name2
//
- if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer, NumAllHandles, Dev, FALSE)) {
- DEBUG((DEBUG_ERROR | DEBUG_INIT, "ComponentName2 failed to get device name, try ComponentName\n"));
- if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer, NumAllHandles, Dev, TRUE)) {
- DEBUG((DEBUG_ERROR | DEBUG_INIT, "ComponentName failed to get device name, skip device\n"));
+ if (!OpalDriverGetDeviceNameByProtocol (AllHandlesBuffer, NumAllHandles, Dev, FALSE)) {
+ DEBUG ((DEBUG_ERROR | DEBUG_INIT, "ComponentName2 failed to get device name, try ComponentName\n"));
+ if (!OpalDriverGetDeviceNameByProtocol (AllHandlesBuffer, NumAllHandles, Dev, TRUE)) {
+ DEBUG ((DEBUG_ERROR | DEBUG_INIT, "ComponentName failed to get device name, skip device\n"));
return FALSE;
}
}
@@ -2587,13 +2632,13 @@ OpalDriverGetDriverDeviceName(
**/
EFI_STATUS
EFIAPI
-EfiDriverEntryPoint(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE* SystemTable
+EfiDriverEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- EFI_EVENT EndOfDxeEvent;
+ EFI_STATUS Status;
+ EFI_EVENT EndOfDxeEvent;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -2604,15 +2649,15 @@ EfiDriverEntryPoint(
&gOpalComponentName2
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "Install protocols to Opal driver Handle failed\n"));
- return Status ;
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Install protocols to Opal driver Handle failed\n"));
+ return Status;
}
//
// Initialize Driver object
//
- ZeroMem(&mOpalDriver, sizeof(mOpalDriver));
+ ZeroMem (&mOpalDriver, sizeof (mOpalDriver));
mOpalDriver.Handle = ImageHandle;
Status = gBS->CreateEventEx (
@@ -2628,7 +2673,7 @@ EfiDriverEntryPoint(
//
// Install Hii packages.
//
- HiiInstall();
+ HiiInstall ();
return Status;
}
@@ -2659,14 +2704,14 @@ EfiDriverEntryPoint(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingSupported(
- IN EFI_DRIVER_BINDING_PROTOCOL* This,
+OpalEfiDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL* SecurityCommand;
+ EFI_STATUS Status;
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *SecurityCommand;
if (mOpalEndOfDxe) {
return EFI_UNSUPPORTED;
@@ -2675,33 +2720,32 @@ OpalEfiDriverBindingSupported(
//
// Test EFI_STORAGE_SECURITY_COMMAND_PROTOCOL on controller Handle.
//
- Status = gBS->OpenProtocol(
- Controller,
- &gEfiStorageSecurityCommandProtocolGuid,
- ( VOID ** )&SecurityCommand,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ (VOID **)&SecurityCommand,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
//
// Close protocol and reopen in Start call
//
- gBS->CloseProtocol(
- Controller,
- &gEfiStorageSecurityCommandProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -2739,23 +2783,24 @@ OpalEfiDriverBindingSupported(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingStart(
- IN EFI_DRIVER_BINDING_PROTOCOL* This,
+OpalEfiDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- OPAL_DRIVER_DEVICE *Dev;
- OPAL_DRIVER_DEVICE *Itr;
- BOOLEAN Result;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
+ OPAL_DRIVER_DEVICE *Dev;
+ OPAL_DRIVER_DEVICE *Itr;
+ BOOLEAN Result;
Itr = mOpalDriver.DeviceList;
while (Itr != NULL) {
if (Controller == Itr->Handle) {
return EFI_SUCCESS;
}
+
Itr = Itr->Next;
}
@@ -2763,25 +2808,26 @@ OpalEfiDriverBindingStart(
// Create internal device for tracking. This allows all disks to be tracked
// by same HII form
//
- Dev = (OPAL_DRIVER_DEVICE*)AllocateZeroPool(sizeof(OPAL_DRIVER_DEVICE));
+ Dev = (OPAL_DRIVER_DEVICE *)AllocateZeroPool (sizeof (OPAL_DRIVER_DEVICE));
if (Dev == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Dev->Handle = Controller;
//
// Open EFI_STORAGE_SECURITY_COMMAND_PROTOCOL to perform Opal supported checks
//
- Status = gBS->OpenProtocol(
- Controller,
- &gEfiStorageSecurityCommandProtocolGuid,
- (VOID **)&Dev->Sscp,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR(Status)) {
- FreePool(Dev);
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ (VOID **)&Dev->Sscp,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (Dev);
return Status;
}
@@ -2789,32 +2835,32 @@ OpalEfiDriverBindingStart(
// Open EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
// function APIs
//
- Status = gBS->OpenProtocol(
- Controller,
- &gEfiBlockIoProtocolGuid,
- (VOID **)&BlkIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **)&BlkIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
//
// Block_IO not supported on handle
//
- if(Status == EFI_UNSUPPORTED) {
+ if (Status == EFI_UNSUPPORTED) {
BlkIo = NULL;
} else {
//
// Close storage security that was opened
//
- gBS->CloseProtocol(
- Controller,
- &gEfiStorageSecurityCommandProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
- FreePool(Dev);
+ FreePool (Dev);
return Status;
}
}
@@ -2822,18 +2868,18 @@ OpalEfiDriverBindingStart(
//
// Save mediaId
//
- if(BlkIo == NULL) {
+ if (BlkIo == NULL) {
// If no Block IO present, use defined MediaId value.
Dev->MediaId = 0x0;
} else {
Dev->MediaId = BlkIo->Media->MediaId;
- gBS->CloseProtocol(
- Controller,
- &gEfiBlockIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiBlockIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
//
@@ -2849,7 +2895,7 @@ OpalEfiDriverBindingStart(
goto Done;
}
- AddDeviceToTail(Dev);
+ AddDeviceToTail (Dev);
//
// Check if device is locked and prompt for password.
@@ -2867,14 +2913,14 @@ Done:
//
// free device, close protocols and exit
//
- gBS->CloseProtocol(
- Controller,
- &gEfiStorageSecurityCommandProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiStorageSecurityCommandProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
- FreePool(Dev);
+ FreePool (Dev);
return EFI_DEVICE_ERROR;
}
@@ -2894,14 +2940,14 @@ Done:
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingStop(
- EFI_DRIVER_BINDING_PROTOCOL* This,
- EFI_HANDLE Controller,
- UINTN NumberOfChildren,
- EFI_HANDLE* ChildHandleBuffer
+OpalEfiDriverBindingStop (
+ EFI_DRIVER_BINDING_PROTOCOL *This,
+ EFI_HANDLE Controller,
+ UINTN NumberOfChildren,
+ EFI_HANDLE *ChildHandleBuffer
)
{
- OPAL_DRIVER_DEVICE* Itr;
+ OPAL_DRIVER_DEVICE *Itr;
Itr = mOpalDriver.DeviceList;
@@ -2920,7 +2966,6 @@ OpalEfiDriverBindingStop(
return EFI_NOT_FOUND;
}
-
/**
Unloads UEFI Driver. Very useful for debugging and testing.
@@ -2932,11 +2977,11 @@ OpalEfiDriverBindingStop(
EFI_STATUS
EFIAPI
OpalEfiDriverUnload (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- OPAL_DRIVER_DEVICE *Itr;
+ EFI_STATUS Status;
+ OPAL_DRIVER_DEVICE *Itr;
Status = EFI_SUCCESS;
@@ -2953,14 +2998,13 @@ OpalEfiDriverUnload (
// Remove OPAL_DRIVER_DEVICE from the list
// it updates the controllerList pointer
//
- OpalDriverStopDevice(Itr);
+ OpalDriverStopDevice (Itr);
}
//
// Uninstall the HII capability
//
- Status = HiiUninstall();
+ Status = HiiUninstall ();
return Status;
}
-
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
index c19d78218e..2089bd81b6 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
@@ -44,37 +44,37 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "OpalPasswordCommon.h"
#include "OpalHiiFormValues.h"
-#define EFI_DRIVER_NAME_UNICODE L"1.0 UEFI Opal Driver"
+#define EFI_DRIVER_NAME_UNICODE L"1.0 UEFI Opal Driver"
// UEFI 2.1
-#define LANGUAGE_RFC_3066_ENGLISH ((CHAR8*)"en")
+#define LANGUAGE_RFC_3066_ENGLISH ((CHAR8*)"en")
// UEFI/EFI < 2.1
-#define LANGUAGE_ISO_639_2_ENGLISH ((CHAR8*)"eng")
+#define LANGUAGE_ISO_639_2_ENGLISH ((CHAR8*)"eng")
-#define CONCAT_(x, y) x ## y
-#define CONCAT(x, y) CONCAT_(x, y)
+#define CONCAT_(x, y) x ## y
+#define CONCAT(x, y) CONCAT_(x, y)
-#define UNICODE_STR(x) CONCAT( L, x )
+#define UNICODE_STR(x) CONCAT( L, x )
extern EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2;
-#define OPAL_MSID_LENGTH 128
+#define OPAL_MSID_LENGTH 128
#define MAX_PASSWORD_TRY_COUNT 5
// PSID Length
-#define PSID_CHARACTER_LENGTH 0x20
-#define MAX_PSID_TRY_COUNT 5
+#define PSID_CHARACTER_LENGTH 0x20
+#define MAX_PSID_TRY_COUNT 5
//
// The max timeout value assume the user can wait for the revert action. The unit of this macro is second.
// If the revert time value bigger than this one, driver needs to popup a dialog to let user confirm the
// revert action.
//
-#define MAX_ACCEPTABLE_REVERTING_TIME 10
+#define MAX_ACCEPTABLE_REVERTING_TIME 10
#pragma pack(1)
@@ -84,66 +84,66 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2;
// by the consumer of this library.
//
typedef struct {
- //
- // Indicates if the disk can support PSID Revert action. should verify disk supports PSID authority
- //
- UINT16 PsidRevert : 1;
-
- //
- // Indicates if the disk can support Revert action
- //
- UINT16 Revert : 1;
-
- //
- // Indicates if the user must keep data for revert action. It is true if no media encryption is supported.
- //
- UINT16 RevertKeepDataForced : 1;
-
- //
- // Indicates if the disk can support set Admin password
- //
- UINT16 AdminPass : 1;
-
- //
- // Indicates if the disk can support set User password. This action requires that a user
- // password is first enabled.
- //
- UINT16 UserPass : 1;
-
- //
- // Indicates if unlock action is available. Requires disk to be currently locked.
- //
- UINT16 Unlock : 1;
-
- //
- // Indicates if Secure Erase action is available. Action requires admin credentials and media encryption support.
- //
- UINT16 SecureErase : 1;
-
- //
- // Indicates if Disable User action is available. Action requires admin credentials.
- //
- UINT16 DisableUser : 1;
+ //
+ // Indicates if the disk can support PSID Revert action. should verify disk supports PSID authority
+ //
+ UINT16 PsidRevert : 1;
+
+ //
+ // Indicates if the disk can support Revert action
+ //
+ UINT16 Revert : 1;
+
+ //
+ // Indicates if the user must keep data for revert action. It is true if no media encryption is supported.
+ //
+ UINT16 RevertKeepDataForced : 1;
+
+ //
+ // Indicates if the disk can support set Admin password
+ //
+ UINT16 AdminPass : 1;
+
+ //
+ // Indicates if the disk can support set User password. This action requires that a user
+ // password is first enabled.
+ //
+ UINT16 UserPass : 1;
+
+ //
+ // Indicates if unlock action is available. Requires disk to be currently locked.
+ //
+ UINT16 Unlock : 1;
+
+ //
+ // Indicates if Secure Erase action is available. Action requires admin credentials and media encryption support.
+ //
+ UINT16 SecureErase : 1;
+
+ //
+ // Indicates if Disable User action is available. Action requires admin credentials.
+ //
+ UINT16 DisableUser : 1;
} OPAL_DISK_ACTIONS;
//
// Structure that is used to represent an OPAL_DISK.
//
typedef struct {
- UINT32 MsidLength; // Byte length of MSID Pin for device
- UINT8 Msid[OPAL_MSID_LENGTH]; // MSID Pin for device
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp;
- UINT32 MediaId; // MediaId is used by Ssc Protocol.
- EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
- UINT16 OpalBaseComId; // Opal SSC 1 base com id.
- OPAL_OWNER_SHIP Owner;
- OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
- TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature; // Locking Feature Descriptor retrieved from performing a Level 0 Discovery
- UINT8 PasswordLength;
- UINT8 Password[OPAL_MAX_PASSWORD_SIZE];
-
- UINT32 EstimateTimeCost;
- BOOLEAN SentBlockSID; // Check whether BlockSid command has been sent.
+ UINT32 MsidLength; // Byte length of MSID Pin for device
+ UINT8 Msid[OPAL_MSID_LENGTH]; // MSID Pin for device
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp;
+ UINT32 MediaId; // MediaId is used by Ssc Protocol.
+ EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
+ UINT16 OpalBaseComId; // Opal SSC 1 base com id.
+ OPAL_OWNER_SHIP Owner;
+ OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
+ TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature; // Locking Feature Descriptor retrieved from performing a Level 0 Discovery
+ UINT8 PasswordLength;
+ UINT8 Password[OPAL_MAX_PASSWORD_SIZE];
+
+ UINT32 EstimateTimeCost;
+ BOOLEAN SentBlockSID; // Check whether BlockSid command has been sent.
} OPAL_DISK;
//
@@ -152,23 +152,23 @@ typedef struct {
typedef struct _OPAL_DRIVER_DEVICE OPAL_DRIVER_DEVICE;
struct _OPAL_DRIVER_DEVICE {
- OPAL_DRIVER_DEVICE *Next; ///< Linked list pointer
- EFI_HANDLE Handle; ///< Device handle
- OPAL_DISK OpalDisk; ///< User context
- CHAR16 *Name16; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
- CHAR8 *NameZ; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
- UINT32 MediaId; ///< Required parameter for EFI_STORAGE_SECURITY_COMMAND_PROTOCOL, from BLOCK_IO_MEDIA
-
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp; /// Device protocols consumed
- EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
+ OPAL_DRIVER_DEVICE *Next; ///< Linked list pointer
+ EFI_HANDLE Handle; ///< Device handle
+ OPAL_DISK OpalDisk; ///< User context
+ CHAR16 *Name16; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
+ CHAR8 *NameZ; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
+ UINT32 MediaId; ///< Required parameter for EFI_STORAGE_SECURITY_COMMAND_PROTOCOL, from BLOCK_IO_MEDIA
+
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp; /// Device protocols consumed
+ EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
};
//
// Opal Driver UEFI Driver Model
//
typedef struct {
- EFI_HANDLE Handle; ///< Driver image handle
- OPAL_DRIVER_DEVICE *DeviceList; ///< Linked list of controllers owned by this Driver
+ EFI_HANDLE Handle; ///< Driver image handle
+ OPAL_DRIVER_DEVICE *DeviceList; ///< Linked list of controllers owned by this Driver
} OPAL_DRIVER;
#pragma pack()
@@ -176,15 +176,15 @@ typedef struct {
//
// Retrieves a OPAL_DRIVER_DEVICE based on the pointer to its StorageSecurity protocol.
//
-#define DRIVER_DEVICE_FROM_OPALDISK(OpalDiskPointer) (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))
+#define DRIVER_DEVICE_FROM_OPALDISK(OpalDiskPointer) (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))
/**
Get devcie list info.
@retval return the device list pointer.
**/
-OPAL_DRIVER_DEVICE*
-OpalDriverGetDeviceList(
+OPAL_DRIVER_DEVICE *
+OpalDriverGetDeviceList (
VOID
);
@@ -197,8 +197,8 @@ OpalDriverGetDeviceList(
@retval FALSE Not found the name for this device.
**/
BOOLEAN
-OpalDriverGetDriverDeviceName(
- OPAL_DRIVER_DEVICE *Dev
+OpalDriverGetDriverDeviceName (
+ OPAL_DRIVER_DEVICE *Dev
);
/**
@@ -222,9 +222,9 @@ GetDeviceCount (
**/
VOID
OpalSupportUpdatePassword (
- IN OUT OPAL_DISK *OpalDisk,
- IN VOID *Password,
- IN UINT32 PasswordLength
+ IN OUT OPAL_DISK *OpalDisk,
+ IN VOID *Password,
+ IN UINT32 PasswordLength
);
/**
@@ -239,11 +239,11 @@ OpalSupportUpdatePassword (
**/
TCG_RESULT
EFIAPI
-OpalSupportGetAvailableActions(
- IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes,
- IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature,
- IN UINT16 OwnerShip,
- OUT OPAL_DISK_ACTIONS *AvalDiskActions
+OpalSupportGetAvailableActions (
+ IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes,
+ IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature,
+ IN UINT16 OwnerShip,
+ OUT OPAL_DISK_ACTIONS *AvalDiskActions
);
/**
@@ -259,11 +259,11 @@ OpalSupportGetAvailableActions(
TCG_RESULT
EFIAPI
OpalSupportEnableOpalFeature (
- IN OPAL_SESSION *Session,
- IN VOID *Msid,
- IN UINT32 MsidLength,
- IN VOID *Password,
- IN UINT32 PassLength
+ IN OPAL_SESSION *Session,
+ IN VOID *Msid,
+ IN UINT32 MsidLength,
+ IN VOID *Password,
+ IN UINT32 PassLength
);
/**
@@ -276,11 +276,10 @@ OpalSupportEnableOpalFeature (
**/
EFI_STATUS
EFIAPI
-EfiDriverUnload(
- EFI_HANDLE ImageHandle
+EfiDriverUnload (
+ EFI_HANDLE ImageHandle
);
-
/**
Test to see if this driver supports Controller.
@@ -296,10 +295,10 @@ EfiDriverUnload(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingSupported(
- EFI_DRIVER_BINDING_PROTOCOL* This,
- EFI_HANDLE Controller,
- EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
+OpalEfiDriverBindingSupported (
+ EFI_DRIVER_BINDING_PROTOCOL *This,
+ EFI_HANDLE Controller,
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -335,10 +334,10 @@ OpalEfiDriverBindingSupported(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingStart(
- EFI_DRIVER_BINDING_PROTOCOL* This,
- EFI_HANDLE Controller,
- EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
+OpalEfiDriverBindingStart (
+ EFI_DRIVER_BINDING_PROTOCOL *This,
+ EFI_HANDLE Controller,
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -356,11 +355,11 @@ OpalEfiDriverBindingStart(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverBindingStop(
- EFI_DRIVER_BINDING_PROTOCOL* This,
- EFI_HANDLE Controller,
- UINTN NumberOfChildren,
- EFI_HANDLE* ChildHandleBuffer
+OpalEfiDriverBindingStop (
+ EFI_DRIVER_BINDING_PROTOCOL *This,
+ EFI_HANDLE Controller,
+ UINTN NumberOfChildren,
+ EFI_HANDLE *ChildHandleBuffer
);
/**
@@ -404,10 +403,10 @@ OpalEfiDriverBindingStop(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentNameGetDriverName(
- EFI_COMPONENT_NAME_PROTOCOL* This,
- CHAR8* Language,
- CHAR16** DriverName
+OpalEfiDriverComponentNameGetDriverName (
+ EFI_COMPONENT_NAME_PROTOCOL *This,
+ CHAR8 *Language,
+ CHAR16 **DriverName
);
/**
@@ -480,12 +479,12 @@ OpalEfiDriverComponentNameGetDriverName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentNameGetControllerName(
- EFI_COMPONENT_NAME_PROTOCOL* This,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- CHAR8* Language,
- CHAR16** ControllerName
+OpalEfiDriverComponentNameGetControllerName (
+ EFI_COMPONENT_NAME_PROTOCOL *This,
+ EFI_HANDLE ControllerHandle,
+ EFI_HANDLE ChildHandle,
+ CHAR8 *Language,
+ CHAR16 **ControllerName
);
/**
@@ -529,10 +528,10 @@ OpalEfiDriverComponentNameGetControllerName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentName2GetDriverName(
- EFI_COMPONENT_NAME2_PROTOCOL* This,
- CHAR8* Language,
- CHAR16** DriverName
+OpalEfiDriverComponentName2GetDriverName (
+ EFI_COMPONENT_NAME2_PROTOCOL *This,
+ CHAR8 *Language,
+ CHAR16 **DriverName
);
/**
@@ -605,12 +604,12 @@ OpalEfiDriverComponentName2GetDriverName(
**/
EFI_STATUS
EFIAPI
-OpalEfiDriverComponentName2GetControllerName(
- EFI_COMPONENT_NAME2_PROTOCOL* This,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- CHAR8* Language,
- CHAR16** ControllerName
+OpalEfiDriverComponentName2GetControllerName (
+ EFI_COMPONENT_NAME2_PROTOCOL *This,
+ EFI_HANDLE ControllerHandle,
+ EFI_HANDLE ChildHandle,
+ CHAR8 *Language,
+ CHAR16 **ControllerName
);
#endif //_OPAL_DRIVER_H_
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
index 0ab71a3665..c4f96bee8a 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Character definitions
//
-#define UPPER_LOWER_CASE_OFFSET 0x20
+#define UPPER_LOWER_CASE_OFFSET 0x20
//
// This is the generated IFR binary Data for each formset defined in VFR.
@@ -28,49 +28,49 @@ extern UINT8 OpalPasswordDxeStrings[];
CHAR16 OpalPasswordStorageName[] = L"OpalHiiConfig";
-EFI_HII_CONFIG_ACCESS_PROTOCOL gHiiConfigAccessProtocol;
+EFI_HII_CONFIG_ACCESS_PROTOCOL gHiiConfigAccessProtocol;
//
// Handle to the list of HII packages (forms and strings) for this driver
//
-EFI_HII_HANDLE gHiiPackageListHandle = NULL;
+EFI_HII_HANDLE gHiiPackageListHandle = NULL;
//
// Package List GUID containing all form and string packages
//
-const EFI_GUID gHiiPackageListGuid = PACKAGE_LIST_GUID;
-const EFI_GUID gHiiSetupVariableGuid = SETUP_VARIABLE_GUID;
+const EFI_GUID gHiiPackageListGuid = PACKAGE_LIST_GUID;
+const EFI_GUID gHiiSetupVariableGuid = SETUP_VARIABLE_GUID;
//
// Structure that contains state of the HII
// This structure is updated by Hii.cpp and its contents
// is rendered in the HII.
//
-OPAL_HII_CONFIGURATION gHiiConfiguration;
+OPAL_HII_CONFIGURATION gHiiConfiguration;
//
// The device path containing the VENDOR_DEVICE_PATH and EFI_DEVICE_PATH_PROTOCOL
//
-HII_VENDOR_DEVICE_PATH gHiiVendorDevicePath = {
+HII_VENDOR_DEVICE_PATH gHiiVendorDevicePath = {
+ {
{
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8)(sizeof(VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)
- }
- },
- OPAL_PASSWORD_CONFIG_GUID
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ }
},
+ OPAL_PASSWORD_CONFIG_GUID
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- (UINT8)(END_DEVICE_PATH_LENGTH),
- (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
- }
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
+ }
};
/**
@@ -82,8 +82,8 @@ HII_VENDOR_DEVICE_PATH gHiiVendorDevicePath = {
**/
VOID
GetSavedOpalRequest (
- IN OPAL_DISK *OpalDisk,
- OUT OPAL_REQUEST *OpalRequest
+ IN OPAL_DISK *OpalDisk,
+ OUT OPAL_REQUEST *OpalRequest
)
{
EFI_STATUS Status;
@@ -97,13 +97,13 @@ GetSavedOpalRequest (
DEBUG ((DEBUG_INFO, "%a() - enter\n", __FUNCTION__));
- Variable = NULL;
+ Variable = NULL;
VariableSize = 0;
Status = GetVariable2 (
OPAL_REQUEST_VARIABLE_NAME,
&gHiiSetupVariableGuid,
- (VOID **) &Variable,
+ (VOID **)&Variable,
&VariableSize
);
if (EFI_ERROR (Status) || (Variable == NULL)) {
@@ -113,13 +113,15 @@ GetSavedOpalRequest (
TempVariable = Variable;
while ((VariableSize > sizeof (OPAL_REQUEST_VARIABLE)) &&
(VariableSize >= TempVariable->Length) &&
- (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE))) {
- DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
+ (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE)))
+ {
+ DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
DevicePathSizeInVariable = GetDevicePathSize (DevicePathInVariable);
- DevicePath = OpalDisk->OpalDevicePath;
- DevicePathSize = GetDevicePathSize (DevicePath);
+ DevicePath = OpalDisk->OpalDevicePath;
+ DevicePathSize = GetDevicePathSize (DevicePath);
if ((DevicePathSize == DevicePathSizeInVariable) &&
- (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0)) {
+ (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0))
+ {
//
// Found the node for the OPAL device.
// Get the OPAL request.
@@ -132,8 +134,9 @@ GetSavedOpalRequest (
));
break;
}
+
VariableSize -= TempVariable->Length;
- TempVariable = (OPAL_REQUEST_VARIABLE *) ((UINTN) TempVariable + TempVariable->Length);
+ TempVariable = (OPAL_REQUEST_VARIABLE *)((UINTN)TempVariable + TempVariable->Length);
}
FreePool (Variable);
@@ -150,8 +153,8 @@ GetSavedOpalRequest (
**/
VOID
SaveOpalRequest (
- IN OPAL_DISK *OpalDisk,
- IN OPAL_REQUEST OpalRequest
+ IN OPAL_DISK *OpalDisk,
+ IN OPAL_REQUEST OpalRequest
)
{
EFI_STATUS Status;
@@ -174,72 +177,77 @@ SaveOpalRequest (
OpalRequest
));
- Variable = NULL;
- VariableSize = 0;
- NewVariable = NULL;
+ Variable = NULL;
+ VariableSize = 0;
+ NewVariable = NULL;
NewVariableSize = 0;
Status = GetVariable2 (
OPAL_REQUEST_VARIABLE_NAME,
&gHiiSetupVariableGuid,
- (VOID **) &Variable,
+ (VOID **)&Variable,
&VariableSize
);
if (!EFI_ERROR (Status) && (Variable != NULL)) {
- TempVariable = Variable;
+ TempVariable = Variable;
TempVariableSize = VariableSize;
while ((TempVariableSize > sizeof (OPAL_REQUEST_VARIABLE)) &&
(TempVariableSize >= TempVariable->Length) &&
- (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE))) {
- DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
+ (TempVariable->Length > sizeof (OPAL_REQUEST_VARIABLE)))
+ {
+ DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
DevicePathSizeInVariable = GetDevicePathSize (DevicePathInVariable);
- DevicePath = OpalDisk->OpalDevicePath;
- DevicePathSize = GetDevicePathSize (DevicePath);
+ DevicePath = OpalDisk->OpalDevicePath;
+ DevicePathSize = GetDevicePathSize (DevicePath);
if ((DevicePathSize == DevicePathSizeInVariable) &&
- (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0)) {
+ (CompareMem (DevicePath, DevicePathInVariable, DevicePathSize) == 0))
+ {
//
// Found the node for the OPAL device.
// Update the OPAL request.
//
CopyMem (&TempVariable->OpalRequest, &OpalRequest, sizeof (OPAL_REQUEST));
- NewVariable = Variable;
+ NewVariable = Variable;
NewVariableSize = VariableSize;
break;
}
+
TempVariableSize -= TempVariable->Length;
- TempVariable = (OPAL_REQUEST_VARIABLE *) ((UINTN) TempVariable + TempVariable->Length);
+ TempVariable = (OPAL_REQUEST_VARIABLE *)((UINTN)TempVariable + TempVariable->Length);
}
+
if (NewVariable == NULL) {
//
// The node for the OPAL device is not found.
// Create node for the OPAL device.
//
- DevicePath = OpalDisk->OpalDevicePath;
- DevicePathSize = GetDevicePathSize (DevicePath);
+ DevicePath = OpalDisk->OpalDevicePath;
+ DevicePathSize = GetDevicePathSize (DevicePath);
NewVariableSize = VariableSize + sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize;
- NewVariable = AllocatePool (NewVariableSize);
+ NewVariable = AllocatePool (NewVariableSize);
ASSERT (NewVariable != NULL);
CopyMem (NewVariable, Variable, VariableSize);
- TempVariable = (OPAL_REQUEST_VARIABLE *) ((UINTN) NewVariable + VariableSize);
- TempVariable->Length = (UINT32) (sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize);
+ TempVariable = (OPAL_REQUEST_VARIABLE *)((UINTN)NewVariable + VariableSize);
+ TempVariable->Length = (UINT32)(sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize);
CopyMem (&TempVariable->OpalRequest, &OpalRequest, sizeof (OPAL_REQUEST));
- DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
+ DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)TempVariable + sizeof (OPAL_REQUEST_VARIABLE));
CopyMem (DevicePathInVariable, DevicePath, DevicePathSize);
}
} else {
- DevicePath = OpalDisk->OpalDevicePath;
- DevicePathSize = GetDevicePathSize (DevicePath);
+ DevicePath = OpalDisk->OpalDevicePath;
+ DevicePathSize = GetDevicePathSize (DevicePath);
NewVariableSize = sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize;
- NewVariable = AllocatePool (NewVariableSize);
+ NewVariable = AllocatePool (NewVariableSize);
ASSERT (NewVariable != NULL);
- NewVariable->Length = (UINT32) (sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize);
+ NewVariable->Length = (UINT32)(sizeof (OPAL_REQUEST_VARIABLE) + DevicePathSize);
CopyMem (&NewVariable->OpalRequest, &OpalRequest, sizeof (OPAL_REQUEST));
- DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) NewVariable + sizeof (OPAL_REQUEST_VARIABLE));
+ DevicePathInVariable = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)NewVariable + sizeof (OPAL_REQUEST_VARIABLE));
CopyMem (DevicePathInVariable, DevicePath, DevicePathSize);
}
+
Status = gRT->SetVariable (
OPAL_REQUEST_VARIABLE_NAME,
- (EFI_GUID *) &gHiiSetupVariableGuid,
+ (EFI_GUID *)&gHiiSetupVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
NewVariableSize,
NewVariable
@@ -247,9 +255,11 @@ SaveOpalRequest (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OpalRequest variable set failed (%r)\n", Status));
}
+
if (NewVariable != Variable) {
FreePool (NewVariable);
}
+
if (Variable != NULL) {
FreePool (Variable);
}
@@ -262,14 +272,14 @@ SaveOpalRequest (
**/
VOID
-HiiSetCurrentConfiguration(
+HiiSetCurrentConfiguration (
VOID
)
{
- UINT32 PpStorageFlag;
- EFI_STRING NewString;
+ UINT32 PpStorageFlag;
+ EFI_STRING NewString;
- gHiiConfiguration.NumDisks = GetDeviceCount();
+ gHiiConfiguration.NumDisks = GetDeviceCount ();
//
// Update the BlockSID status string.
@@ -277,51 +287,54 @@ HiiSetCurrentConfiguration(
PpStorageFlag = Tcg2PhysicalPresenceLibGetManagementFlags ();
if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_ENABLED), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_ENABLED), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
} else {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_DISABLED), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_DISABLED), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
}
- HiiSetString(gHiiPackageListHandle, STRING_TOKEN(STR_BLOCKSID_STATUS1), NewString, NULL);
+
+ HiiSetString (gHiiPackageListHandle, STRING_TOKEN (STR_BLOCKSID_STATUS1), NewString, NULL);
FreePool (NewString);
if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) != 0) {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_DISK_INFO_ENABLE_BLOCKSID_TRUE), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_DISK_INFO_ENABLE_BLOCKSID_TRUE), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
} else {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_DISK_INFO_ENABLE_BLOCKSID_FALSE), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_DISK_INFO_ENABLE_BLOCKSID_FALSE), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
}
- HiiSetString(gHiiPackageListHandle, STRING_TOKEN(STR_BLOCKSID_STATUS2), NewString, NULL);
+
+ HiiSetString (gHiiPackageListHandle, STRING_TOKEN (STR_BLOCKSID_STATUS2), NewString, NULL);
FreePool (NewString);
if ((PpStorageFlag & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) != 0) {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_DISK_INFO_DISABLE_BLOCKSID_TRUE), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_DISK_INFO_DISABLE_BLOCKSID_TRUE), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
} else {
- NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN(STR_DISK_INFO_DISABLE_BLOCKSID_FALSE), NULL);
+ NewString = HiiGetString (gHiiPackageListHandle, STRING_TOKEN (STR_DISK_INFO_DISABLE_BLOCKSID_FALSE), NULL);
if (NewString == NULL) {
- DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
+ DEBUG ((DEBUG_INFO, "HiiSetCurrentConfiguration: HiiGetString( ) failed\n"));
return;
}
}
- HiiSetString(gHiiPackageListHandle, STRING_TOKEN(STR_BLOCKSID_STATUS3), NewString, NULL);
+
+ HiiSetString (gHiiPackageListHandle, STRING_TOKEN (STR_BLOCKSID_STATUS3), NewString, NULL);
FreePool (NewString);
}
@@ -332,47 +345,47 @@ HiiSetCurrentConfiguration(
@retval other Error occur when install the resources.
**/
EFI_STATUS
-HiiInstall(
+HiiInstall (
VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE DriverHandle;
//
// Clear the global configuration.
//
- ZeroMem(&gHiiConfiguration, sizeof(gHiiConfiguration));
+ ZeroMem (&gHiiConfiguration, sizeof (gHiiConfiguration));
//
// Obtain the driver handle that the BIOS assigned us
//
- DriverHandle = HiiGetDriverImageHandleCB();
+ DriverHandle = HiiGetDriverImageHandleCB ();
//
// Populate the config access protocol with the three functions we are publishing
//
gHiiConfigAccessProtocol.ExtractConfig = ExtractConfig;
- gHiiConfigAccessProtocol.RouteConfig = RouteConfig;
- gHiiConfigAccessProtocol.Callback = DriverCallback;
+ gHiiConfigAccessProtocol.RouteConfig = RouteConfig;
+ gHiiConfigAccessProtocol.Callback = DriverCallback;
//
// Associate the required protocols with our driver handle
//
- Status = gBS->InstallMultipleProtocolInterfaces(
- &DriverHandle,
- &gEfiHiiConfigAccessProtocolGuid,
- &gHiiConfigAccessProtocol, // HII callback
- &gEfiDevicePathProtocolGuid,
- &gHiiVendorDevicePath, // required for HII callback allow all disks to be shown in same hii
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiHiiConfigAccessProtocolGuid,
+ &gHiiConfigAccessProtocol, // HII callback
+ &gEfiDevicePathProtocolGuid,
+ &gHiiVendorDevicePath, // required for HII callback allow all disks to be shown in same hii
+ NULL
+ );
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
- return OpalHiiAddPackages();
+ return OpalHiiAddPackages ();
}
/**
@@ -382,24 +395,24 @@ HiiInstall(
@retval EFI_OUT_OF_RESOURCES Out of resource error.
**/
EFI_STATUS
-OpalHiiAddPackages(
+OpalHiiAddPackages (
VOID
)
{
- EFI_HANDLE DriverHandle;
+ EFI_HANDLE DriverHandle;
- DriverHandle = HiiGetDriverImageHandleCB();
+ DriverHandle = HiiGetDriverImageHandleCB ();
//
// Publish the HII form and HII string packages
//
- gHiiPackageListHandle = HiiAddPackages(
- &gHiiPackageListGuid,
- DriverHandle,
- OpalPasswordDxeStrings,
- OpalPasswordFormBin,
- (VOID*)NULL
- );
+ gHiiPackageListHandle = HiiAddPackages (
+ &gHiiPackageListGuid,
+ DriverHandle,
+ OpalPasswordDxeStrings,
+ OpalPasswordFormBin,
+ (VOID *)NULL
+ );
//
// Make sure the packages installed successfully
@@ -419,29 +432,29 @@ OpalHiiAddPackages(
@retval others Other errors occur when unistall the hii resource.
**/
EFI_STATUS
-HiiUninstall(
+HiiUninstall (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Remove the packages we've provided to the BIOS
//
- HiiRemovePackages(gHiiPackageListHandle);
+ HiiRemovePackages (gHiiPackageListHandle);
//
// Remove the protocols from our driver handle
//
- Status = gBS->UninstallMultipleProtocolInterfaces(
- HiiGetDriverImageHandleCB(),
- &gEfiHiiConfigAccessProtocolGuid,
- &gHiiConfigAccessProtocol, // HII callback
- &gEfiDevicePathProtocolGuid,
- &gHiiVendorDevicePath, // required for HII callback
- NULL
- );
- if (EFI_ERROR(Status)) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ HiiGetDriverImageHandleCB (),
+ &gEfiHiiConfigAccessProtocolGuid,
+ &gHiiConfigAccessProtocol, // HII callback
+ &gEfiDevicePathProtocolGuid,
+ &gHiiVendorDevicePath, // required for HII callback
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Cannot uninstall Hii Protocols: %r\n", Status));
}
@@ -458,12 +471,12 @@ HiiPopulateMainMenuForm (
VOID
)
{
- UINT8 Index;
- CHAR8 *DiskName;
- EFI_STRING_ID DiskNameId;
- OPAL_DISK *OpalDisk;
+ UINT8 Index;
+ CHAR8 *DiskName;
+ EFI_STRING_ID DiskNameId;
+ OPAL_DISK *OpalDisk;
- HiiSetCurrentConfiguration();
+ HiiSetCurrentConfiguration ();
gHiiConfiguration.SupportedDisks = 0;
@@ -471,12 +484,13 @@ HiiPopulateMainMenuForm (
OpalDisk = HiiGetOpalDiskCB (Index);
if ((OpalDisk != NULL) && OpalFeatureSupported (&OpalDisk->SupportedAttributes)) {
gHiiConfiguration.SupportedDisks |= (1 << Index);
- DiskNameId = GetDiskNameStringId (Index);
- DiskName = HiiDiskGetNameCB (Index);
+ DiskNameId = GetDiskNameStringId (Index);
+ DiskName = HiiDiskGetNameCB (Index);
if ((DiskName == NULL) || (DiskNameId == 0)) {
return EFI_UNSUPPORTED;
}
- HiiSetFormString(DiskNameId, DiskName);
+
+ HiiSetFormString (DiskNameId, DiskName);
}
}
@@ -493,18 +507,19 @@ HiiPopulateMainMenuForm (
**/
EFI_STRING_ID
-GetDiskNameStringId(
- UINT8 DiskIndex
+GetDiskNameStringId (
+ UINT8 DiskIndex
)
{
switch (DiskIndex) {
- case 0: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_0);
- case 1: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_1);
- case 2: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_2);
- case 3: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_3);
- case 4: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_4);
- case 5: return STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_5);
+ case 0: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_0);
+ case 1: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_1);
+ case 2: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_2);
+ case 3: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_3);
+ case 4: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_4);
+ case 5: return STRING_TOKEN (STR_MAIN_GOTO_DISK_INFO_5);
}
+
return 0;
}
@@ -518,15 +533,15 @@ GetDiskNameStringId(
**/
EFI_STATUS
HiiConfirmDataRemovalAction (
- IN OPAL_DISK *OpalDisk,
- IN CHAR16 *ActionString
+ IN OPAL_DISK *OpalDisk,
+ IN CHAR16 *ActionString
)
{
- CHAR16 Unicode[512];
- EFI_INPUT_KEY Key;
- CHAR16 ApproveResponse;
- CHAR16 RejectResponse;
+ CHAR16 Unicode[512];
+ EFI_INPUT_KEY Key;
+ CHAR16 ApproveResponse;
+ CHAR16 RejectResponse;
//
// When the estimate cost time bigger than MAX_ACCEPTABLE_REVERTING_TIME, pop up dialog to let user confirm
@@ -539,22 +554,22 @@ HiiConfirmDataRemovalAction (
ApproveResponse = L'Y';
RejectResponse = L'N';
- UnicodeSPrint(Unicode, StrSize(L"WARNING: ############# action needs about ####### seconds"), L"WARNING: %s action needs about %d seconds", ActionString, OpalDisk->EstimateTimeCost);
+ UnicodeSPrint (Unicode, StrSize (L"WARNING: ############# action needs about ####### seconds"), L"WARNING: %s action needs about %d seconds", ActionString, OpalDisk->EstimateTimeCost);
do {
- CreatePopUp(
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- Unicode,
- L" System should not be powered off until action completion ",
- L" ",
- L" Press 'Y/y' to continue, press 'N/n' to cancel ",
- NULL
- );
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ Unicode,
+ L" System should not be powered off until action completion ",
+ L" ",
+ L" Press 'Y/y' to continue, press 'N/n' to cancel ",
+ NULL
+ );
} while (
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (ApproveResponse | UPPER_LOWER_CASE_OFFSET)) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (RejectResponse | UPPER_LOWER_CASE_OFFSET))
- );
+ ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (ApproveResponse | UPPER_LOWER_CASE_OFFSET)) &&
+ ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (RejectResponse | UPPER_LOWER_CASE_OFFSET))
+ );
if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (RejectResponse | UPPER_LOWER_CASE_OFFSET)) {
return EFI_ABORTED;
@@ -587,13 +602,13 @@ HiiConfirmDataRemovalAction (
**/
EFI_STATUS
EFIAPI
-DriverCallback(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- EFI_BROWSER_ACTION Action,
- EFI_QUESTION_ID QuestionId,
- UINT8 Type,
- EFI_IFR_TYPE_VALUE *Value,
- EFI_BROWSER_ACTION_REQUEST *ActionRequest
+DriverCallback (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ EFI_BROWSER_ACTION Action,
+ EFI_QUESTION_ID QuestionId,
+ UINT8 Type,
+ EFI_IFR_TYPE_VALUE *Value,
+ EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
HII_KEY HiiKey;
@@ -615,26 +630,26 @@ DriverCallback(
}
HiiKey.Raw = QuestionId;
- HiiKeyId = (UINT8) HiiKey.KeyBits.Id;
+ HiiKeyId = (UINT8)HiiKey.KeyBits.Id;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
switch (HiiKeyId) {
case HII_KEY_ID_VAR_SUPPORTED_DISKS:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SUPPORTED_DISKS\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SUPPORTED_DISKS\n"));
return HiiPopulateMainMenuForm ();
case HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS\n"));
- return HiiPopulateDiskInfoForm();
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS\n"));
+ return HiiPopulateDiskInfoForm ();
}
} else if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (HiiKeyId) {
case HII_KEY_ID_GOTO_DISK_INFO:
- return HiiSelectDisk((UINT8)HiiKey.KeyBits.Index);
+ return HiiSelectDisk ((UINT8)HiiKey.KeyBits.Index);
case HII_KEY_ID_REVERT:
case HII_KEY_ID_PSID_REVERT:
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
return HiiConfirmDataRemovalAction (OpalDisk, L"Revert");
} else {
@@ -643,14 +658,13 @@ DriverCallback(
}
case HII_KEY_ID_SECURE_ERASE:
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
return HiiConfirmDataRemovalAction (OpalDisk, L"Secure erase");
} else {
ASSERT (FALSE);
return EFI_SUCCESS;
}
-
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (HiiKeyId) {
@@ -689,87 +703,96 @@ DriverCallback(
DEBUG ((DEBUG_ERROR, "Invalid value input!\n"));
break;
}
- HiiSetBlockSidAction(PpRequest);
+
+ HiiSetBlockSidAction (PpRequest);
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_SET_ADMIN_PWD:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_SET_ADMIN_PWD\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_SET_ADMIN_PWD\n"));
gHiiConfiguration.OpalRequest.SetAdminPwd = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_SET_USER_PWD:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_SET_USER_PWD\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_SET_USER_PWD\n"));
gHiiConfiguration.OpalRequest.SetUserPwd = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_SECURE_ERASE:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_SECURE_ERASE\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_SECURE_ERASE\n"));
gHiiConfiguration.OpalRequest.SecureErase = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_REVERT:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_REVERT\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_REVERT\n"));
gHiiConfiguration.OpalRequest.Revert = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_KEEP_USER_DATA:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_KEEP_USER_DATA\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_KEEP_USER_DATA\n"));
gHiiConfiguration.OpalRequest.KeepUserData = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_PSID_REVERT:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_PSID_REVERT\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_PSID_REVERT\n"));
gHiiConfiguration.OpalRequest.PsidRevert = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_DISABLE_USER:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_DISABLE_USER\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_DISABLE_USER\n"));
gHiiConfiguration.OpalRequest.DisableUser = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
case HII_KEY_ID_ENABLE_FEATURE:
- DEBUG ((DEBUG_INFO, "HII_KEY_ID_ENABLE_FEATURE\n"));
+ DEBUG ((DEBUG_INFO, "HII_KEY_ID_ENABLE_FEATURE\n"));
gHiiConfiguration.OpalRequest.EnableFeature = Value->b;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
SaveOpalRequest (OpalDisk, gHiiConfiguration.OpalRequest);
}
+
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
return EFI_SUCCESS;
@@ -790,11 +813,11 @@ DriverCallback(
**/
EFI_STATUS
-HiiSelectDisk(
- UINT8 Index
+HiiSelectDisk (
+ UINT8 Index
)
{
- OpalHiiGetBrowserData();
+ OpalHiiGetBrowserData ();
gHiiConfiguration.SelectedDiskIndex = Index;
OpalHiiSetBrowserData ();
@@ -808,32 +831,33 @@ HiiSelectDisk(
**/
EFI_STATUS
-HiiPopulateDiskInfoForm(
+HiiPopulateDiskInfoForm (
VOID
)
{
- OPAL_DISK* OpalDisk;
- OPAL_DISK_ACTIONS AvailActions;
- TCG_RESULT Ret;
- CHAR8 *DiskName;
+ OPAL_DISK *OpalDisk;
+ OPAL_DISK_ACTIONS AvailActions;
+ TCG_RESULT Ret;
+ CHAR8 *DiskName;
- OpalHiiGetBrowserData();
+ OpalHiiGetBrowserData ();
DiskName = HiiDiskGetNameCB (gHiiConfiguration.SelectedDiskIndex);
if (DiskName == NULL) {
return EFI_UNSUPPORTED;
}
- HiiSetFormString(STRING_TOKEN(STR_DISK_INFO_SELECTED_DISK_NAME), DiskName);
+
+ HiiSetFormString (STRING_TOKEN (STR_DISK_INFO_SELECTED_DISK_NAME), DiskName);
gHiiConfiguration.SelectedDiskAvailableActions = HII_ACTION_NONE;
ZeroMem (&gHiiConfiguration.OpalRequest, sizeof (OPAL_REQUEST));
gHiiConfiguration.KeepUserDataForced = FALSE;
- OpalDisk = HiiGetOpalDiskCB(gHiiConfiguration.SelectedDiskIndex);
+ OpalDisk = HiiGetOpalDiskCB (gHiiConfiguration.SelectedDiskIndex);
if (OpalDisk != NULL) {
OpalDiskUpdateStatus (OpalDisk);
- Ret = OpalSupportGetAvailableActions(&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature, OpalDisk->Owner, &AvailActions);
+ Ret = OpalSupportGetAvailableActions (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature, OpalDisk->Owner, &AvailActions);
if (Ret == TcgResultSuccess) {
//
// Update actions, always allow PSID Revert
@@ -852,7 +876,7 @@ HiiPopulateDiskInfoForm(
//
// Update strings
//
- HiiSetFormString( STRING_TOKEN(STR_DISK_INFO_PSID_REVERT), "PSID Revert to factory default");
+ HiiSetFormString (STRING_TOKEN (STR_DISK_INFO_PSID_REVERT), "PSID Revert to factory default");
} else {
DEBUG ((DEBUG_INFO, "Feature disabled but ownership != nobody\n"));
}
@@ -863,7 +887,7 @@ HiiPopulateDiskInfoForm(
gHiiConfiguration.SelectedDiskAvailableActions |= (AvailActions.SecureErase == 1) ? HII_ACTION_SECURE_ERASE : HII_ACTION_NONE;
gHiiConfiguration.SelectedDiskAvailableActions |= (AvailActions.DisableUser == 1) ? HII_ACTION_DISABLE_USER : HII_ACTION_NONE;
- HiiSetFormString (STRING_TOKEN(STR_DISK_INFO_PSID_REVERT), "PSID Revert to factory default and Disable");
+ HiiSetFormString (STRING_TOKEN (STR_DISK_INFO_PSID_REVERT), "PSID Revert to factory default and Disable");
//
// Determine revert options for disk
@@ -898,11 +922,11 @@ HiiPopulateDiskInfoForm(
**/
EFI_STATUS
HiiSetBlockSidAction (
- IN UINT32 PpRequest
+ IN UINT32 PpRequest
)
{
- UINT32 ReturnCode;
- EFI_STATUS Status;
+ UINT32 ReturnCode;
+ EFI_STATUS Status;
ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (PpRequest, 0);
if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {
@@ -938,13 +962,13 @@ HiiSetBlockSidAction (
**/
EFI_STATUS
EFIAPI
-RouteConfig(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- CONST EFI_STRING Configuration,
- EFI_STRING *Progress
+RouteConfig (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ CONST EFI_STRING Configuration,
+ EFI_STRING *Progress
)
{
- if (Configuration == NULL || Progress == NULL) {
+ if ((Configuration == NULL) || (Progress == NULL)) {
return (EFI_INVALID_PARAMETER);
}
@@ -986,50 +1010,52 @@ RouteConfig(
**/
EFI_STATUS
EFIAPI
-ExtractConfig(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- CONST EFI_STRING Request,
- EFI_STRING *Progress,
- EFI_STRING *Results
+ExtractConfig (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ CONST EFI_STRING Request,
+ EFI_STRING *Progress,
+ EFI_STRING *Results
)
{
- EFI_STATUS Status;
- EFI_STRING ConfigRequest;
- EFI_STRING ConfigRequestHdr;
- UINTN BufferSize;
- UINTN Size;
- BOOLEAN AllocatedRequest;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_STRING ConfigRequest;
+ EFI_STRING ConfigRequestHdr;
+ UINTN BufferSize;
+ UINTN Size;
+ BOOLEAN AllocatedRequest;
+ EFI_HANDLE DriverHandle;
//
// Check for valid parameters
//
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return (EFI_INVALID_PARAMETER);
}
*Progress = Request;
if ((Request != NULL) &&
- !HiiIsConfigHdrMatch (Request, &gHiiSetupVariableGuid, OpalPasswordStorageName)) {
+ !HiiIsConfigHdrMatch (Request, &gHiiSetupVariableGuid, OpalPasswordStorageName))
+ {
return EFI_NOT_FOUND;
}
AllocatedRequest = FALSE;
- BufferSize = sizeof (OPAL_HII_CONFIGURATION);
- ConfigRequest = Request;
+ BufferSize = sizeof (OPAL_HII_CONFIGURATION);
+ ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
// Request has no request element, construct full request string.
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
- DriverHandle = HiiGetDriverImageHandleCB();
+ DriverHandle = HiiGetDriverImageHandleCB ();
ConfigRequestHdr = HiiConstructConfigHdr (&gHiiSetupVariableGuid, OpalPasswordStorageName, DriverHandle);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
- ConfigRequest = AllocateZeroPool (Size);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ ConfigRequest = AllocateZeroPool (Size);
if (ConfigRequest == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
@@ -1038,14 +1064,14 @@ ExtractConfig(
//
// Convert Buffer Data to <ConfigResp> by helper function BlockToConfig( )
//
- Status = gHiiConfigRouting->BlockToConfig(
- gHiiConfigRouting,
- ConfigRequest,
- (UINT8*)&gHiiConfiguration,
- sizeof(OPAL_HII_CONFIGURATION),
- Results,
- Progress
- );
+ Status = gHiiConfigRouting->BlockToConfig (
+ gHiiConfigRouting,
+ ConfigRequest,
+ (UINT8 *)&gHiiConfiguration,
+ sizeof (OPAL_HII_CONFIGURATION),
+ Results,
+ Progress
+ );
//
// Free the allocated config request string.
@@ -1067,7 +1093,6 @@ ExtractConfig(
return (Status);
}
-
/**
Pass the current system state to the bios via the hii_G_Configuration.
@@ -1078,16 +1103,15 @@ OpalHiiSetBrowserData (
VOID
)
{
- HiiSetBrowserData(
- &gHiiSetupVariableGuid,
- (CHAR16*)L"OpalHiiConfig",
- sizeof(gHiiConfiguration),
- (UINT8*)&gHiiConfiguration,
- NULL
- );
+ HiiSetBrowserData (
+ &gHiiSetupVariableGuid,
+ (CHAR16 *)L"OpalHiiConfig",
+ sizeof (gHiiConfiguration),
+ (UINT8 *)&gHiiConfiguration,
+ NULL
+ );
}
-
/**
Populate the hii_g_Configuration with the browser Data.
@@ -1098,12 +1122,12 @@ OpalHiiGetBrowserData (
VOID
)
{
- HiiGetBrowserData(
- &gHiiSetupVariableGuid,
- (CHAR16*)L"OpalHiiConfig",
- sizeof(gHiiConfiguration),
- (UINT8*)&gHiiConfiguration
- );
+ HiiGetBrowserData (
+ &gHiiSetupVariableGuid,
+ (CHAR16 *)L"OpalHiiConfig",
+ sizeof (gHiiConfiguration),
+ (UINT8 *)&gHiiConfiguration
+ );
}
/**
@@ -1117,44 +1141,44 @@ OpalHiiGetBrowserData (
**/
EFI_STATUS
-HiiSetFormString(
- EFI_STRING_ID DestStringId,
- CHAR8 *SrcAsciiStr
+HiiSetFormString (
+ EFI_STRING_ID DestStringId,
+ CHAR8 *SrcAsciiStr
)
{
- UINT32 Len;
- UINT32 UniSize;
- CHAR16* UniStr;
+ UINT32 Len;
+ UINT32 UniSize;
+ CHAR16 *UniStr;
//
// Determine the Length of the sting
//
- Len = ( UINT32 )AsciiStrLen( SrcAsciiStr );
+ Len = (UINT32)AsciiStrLen (SrcAsciiStr);
//
// Allocate space for the unicode string, including terminator
//
- UniSize = (Len + 1) * sizeof(CHAR16);
- UniStr = (CHAR16*)AllocateZeroPool(UniSize);
+ UniSize = (Len + 1) * sizeof (CHAR16);
+ UniStr = (CHAR16 *)AllocateZeroPool (UniSize);
//
// Copy into unicode string, then copy into string id
//
- AsciiStrToUnicodeStrS ( SrcAsciiStr, UniStr, Len + 1);
+ AsciiStrToUnicodeStrS (SrcAsciiStr, UniStr, Len + 1);
//
// Update the string in the form
//
- if (HiiSetString(gHiiPackageListHandle, DestStringId, UniStr, NULL) == 0) {
- DEBUG ((DEBUG_INFO, "HiiSetFormString( ) failed\n"));
- FreePool(UniStr);
+ if (HiiSetString (gHiiPackageListHandle, DestStringId, UniStr, NULL) == 0) {
+ DEBUG ((DEBUG_INFO, "HiiSetFormString( ) failed\n"));
+ FreePool (UniStr);
return (EFI_OUT_OF_RESOURCES);
}
//
// Free the memory
//
- FreePool(UniStr);
+ FreePool (UniStr);
return (EFI_SUCCESS);
}
@@ -1170,27 +1194,28 @@ HiiSetFormString(
**/
EFI_STATUS
OpalDiskInitialize (
- IN OPAL_DRIVER_DEVICE *Dev
+ IN OPAL_DRIVER_DEVICE *Dev
)
{
- TCG_RESULT TcgResult;
- OPAL_SESSION Session;
- UINT8 ActiveDataRemovalMechanism;
- UINT32 RemovalMechanishLists[ResearvedMechanism];
-
- ZeroMem(&Dev->OpalDisk, sizeof(OPAL_DISK));
- Dev->OpalDisk.Sscp = Dev->Sscp;
- Dev->OpalDisk.MediaId = Dev->MediaId;
+ TCG_RESULT TcgResult;
+ OPAL_SESSION Session;
+ UINT8 ActiveDataRemovalMechanism;
+ UINT32 RemovalMechanishLists[ResearvedMechanism];
+
+ ZeroMem (&Dev->OpalDisk, sizeof (OPAL_DISK));
+ Dev->OpalDisk.Sscp = Dev->Sscp;
+ Dev->OpalDisk.MediaId = Dev->MediaId;
Dev->OpalDisk.OpalDevicePath = Dev->OpalDevicePath;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = Dev->Sscp;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = Dev->Sscp;
Session.MediaId = Dev->MediaId;
TcgResult = OpalGetSupportedAttributesInfo (&Session, &Dev->OpalDisk.SupportedAttributes, &Dev->OpalDisk.OpalBaseComId);
if (TcgResult != TcgResultSuccess) {
return EFI_DEVICE_ERROR;
}
+
Session.OpalBaseComId = Dev->OpalDisk.OpalBaseComId;
TcgResult = OpalUtilGetMsid (&Session, Dev->OpalDisk.Msid, OPAL_MSID_LENGTH, &Dev->OpalDisk.MsidLength);
@@ -1227,7 +1252,7 @@ OpalDiskInitialize (
**/
EFI_STATUS
OpalDiskUpdateOwnerShip (
- OPAL_DISK *OpalDisk
+ OPAL_DISK *OpalDisk
)
{
OPAL_SESSION Session;
@@ -1240,12 +1265,12 @@ OpalDiskUpdateOwnerShip (
return EFI_ACCESS_DENIED;
}
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = OpalDisk->Sscp;
- Session.MediaId = OpalDisk->MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = OpalDisk->Sscp;
+ Session.MediaId = OpalDisk->MediaId;
Session.OpalBaseComId = OpalDisk->OpalBaseComId;
- OpalDisk->Owner = OpalUtilDetermineOwnership(&Session, OpalDisk->Msid, OpalDisk->MsidLength);
+ OpalDisk->Owner = OpalUtilDetermineOwnership (&Session, OpalDisk->Msid, OpalDisk->MsidLength);
return EFI_SUCCESS;
}
@@ -1262,22 +1287,21 @@ OpalDiskUpdateOwnerShip (
**/
EFI_STATUS
OpalDiskUpdateStatus (
- OPAL_DISK *OpalDisk
+ OPAL_DISK *OpalDisk
)
{
- TCG_RESULT TcgResult;
- OPAL_SESSION Session;
+ TCG_RESULT TcgResult;
+ OPAL_SESSION Session;
- ZeroMem(&Session, sizeof(Session));
- Session.Sscp = OpalDisk->Sscp;
- Session.MediaId = OpalDisk->MediaId;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = OpalDisk->Sscp;
+ Session.MediaId = OpalDisk->MediaId;
Session.OpalBaseComId = OpalDisk->OpalBaseComId;
- TcgResult = OpalGetLockingInfo(&Session, &OpalDisk->LockingFeature);
+ TcgResult = OpalGetLockingInfo (&Session, &OpalDisk->LockingFeature);
if (TcgResult != TcgResultSuccess) {
return EFI_DEVICE_ERROR;
}
return OpalDiskUpdateOwnerShip (OpalDisk);
}
-
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h
index 557c1f8d68..3b294d8e14 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.h
@@ -20,35 +20,35 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
0x0d510a4f, 0xa81b, 0x473f, { 0x87, 0x07, 0xb7, 0xfd, 0xfb, 0xc0, 0x45, 0xba } \
}
-#define OPAL_REQUEST_VARIABLE_NAME L"OpalRequest"
+#define OPAL_REQUEST_VARIABLE_NAME L"OpalRequest"
#pragma pack(1)
typedef struct {
- UINT32 Length;
- OPAL_REQUEST OpalRequest;
- //EFI_DEVICE_PATH_PROTOCOL OpalDevicePath;
+ UINT32 Length;
+ OPAL_REQUEST OpalRequest;
+ // EFI_DEVICE_PATH_PROTOCOL OpalDevicePath;
} OPAL_REQUEST_VARIABLE;
typedef struct {
- UINT16 Id: HII_KEY_ID_BITS;
- UINT16 Index: HII_KEY_INDEX_BITS;
- UINT16 Flag: HII_KEY_FLAG_BITS;
+ UINT16 Id : HII_KEY_ID_BITS;
+ UINT16 Index : HII_KEY_INDEX_BITS;
+ UINT16 Flag : HII_KEY_FLAG_BITS;
} KEY_BITS;
typedef union {
- UINT16 Raw;
- KEY_BITS KeyBits;
+ UINT16 Raw;
+ KEY_BITS KeyBits;
} HII_KEY;
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
-extern const EFI_GUID gHiiSetupVariableGuid;
+extern const EFI_GUID gHiiSetupVariableGuid;
/**
This function processes the results of changes in configuration.
@@ -70,10 +70,10 @@ extern const EFI_GUID gHiiSetupVariableGuid;
**/
EFI_STATUS
EFIAPI
-RouteConfig(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- CONST EFI_STRING Configuration,
- EFI_STRING *Progress
+RouteConfig (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ CONST EFI_STRING Configuration,
+ EFI_STRING *Progress
);
/**
@@ -104,11 +104,11 @@ RouteConfig(
**/
EFI_STATUS
EFIAPI
-ExtractConfig(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- CONST EFI_STRING Request,
- EFI_STRING *Progress,
- EFI_STRING *Results
+ExtractConfig (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ CONST EFI_STRING Request,
+ EFI_STRING *Progress,
+ EFI_STRING *Results
);
/**
@@ -135,13 +135,13 @@ ExtractConfig(
**/
EFI_STATUS
EFIAPI
-DriverCallback(
- CONST EFI_HII_CONFIG_ACCESS_PROTOCOL* This,
- EFI_BROWSER_ACTION Action,
- EFI_QUESTION_ID QuestionId,
- UINT8 Type,
- EFI_IFR_TYPE_VALUE* Value,
- EFI_BROWSER_ACTION_REQUEST* ActionRequest
+DriverCallback (
+ CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ EFI_BROWSER_ACTION Action,
+ EFI_QUESTION_ID QuestionId,
+ UINT8 Type,
+ EFI_IFR_TYPE_VALUE *Value,
+ EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
/**
@@ -171,7 +171,7 @@ OpalHiiGetBrowserData (
**/
EFI_STATUS
-HiiPopulateDiskInfoForm(
+HiiPopulateDiskInfoForm (
VOID
);
@@ -184,8 +184,8 @@ HiiPopulateDiskInfoForm(
**/
EFI_STATUS
-HiiSelectDisk(
- UINT8 Index
+HiiSelectDisk (
+ UINT8 Index
);
/**
@@ -198,8 +198,8 @@ HiiSelectDisk(
**/
EFI_STATUS
-HiiPasswordEntered(
- EFI_STRING_ID Str
+HiiPasswordEntered (
+ EFI_STRING_ID Str
);
/**
@@ -213,7 +213,7 @@ HiiPasswordEntered(
**/
EFI_STATUS
HiiSetBlockSidAction (
- UINT32 PpRequest
+ UINT32 PpRequest
);
/**
@@ -225,8 +225,8 @@ HiiSetBlockSidAction (
**/
EFI_STATUS
-HiiPsidRevert(
- EFI_STRING_ID PsidStringId
+HiiPsidRevert (
+ EFI_STRING_ID PsidStringId
);
/**
@@ -238,8 +238,8 @@ HiiPsidRevert(
**/
EFI_STRING_ID
-GetDiskNameStringId(
- UINT8 DiskIndex
+GetDiskNameStringId (
+ UINT8 DiskIndex
);
/**
@@ -254,7 +254,7 @@ GetDiskNameStringId(
**/
EFI_STATUS
OpalDiskUpdateStatus (
- OPAL_DISK *OpalDisk
+ OPAL_DISK *OpalDisk
);
/**
@@ -264,7 +264,7 @@ OpalDiskUpdateStatus (
**/
EFI_HANDLE
-HiiGetDriverImageHandleCB(
+HiiGetDriverImageHandleCB (
VOID
);
@@ -275,7 +275,7 @@ HiiGetDriverImageHandleCB(
@retval EFI_OUT_OF_RESOURCES Out of resource error.
**/
EFI_STATUS
-OpalHiiAddPackages(
+OpalHiiAddPackages (
VOID
);
@@ -287,9 +287,9 @@ OpalHiiAddPackages(
@retval The device pointer.
**/
-OPAL_DISK*
-HiiGetOpalDiskCB(
- UINT8 DiskIndex
+OPAL_DISK *
+HiiGetOpalDiskCB (
+ UINT8 DiskIndex
);
/**
@@ -300,9 +300,9 @@ HiiGetOpalDiskCB(
@retval Returns the disk name.
**/
-CHAR8*
-HiiDiskGetNameCB(
- UINT8 DiskIndex
+CHAR8 *
+HiiDiskGetNameCB (
+ UINT8 DiskIndex
);
/**
@@ -316,9 +316,9 @@ HiiDiskGetNameCB(
**/
EFI_STATUS
-HiiSetFormString(
- EFI_STRING_ID DestStringId,
- CHAR8 *SrcAsciiStr
+HiiSetFormString (
+ EFI_STRING_ID DestStringId,
+ CHAR8 *SrcAsciiStr
);
/**
@@ -328,7 +328,7 @@ HiiSetFormString(
@retval other Error occur when install the resources.
**/
EFI_STATUS
-HiiInstall(
+HiiInstall (
VOID
);
@@ -339,7 +339,7 @@ HiiInstall(
@retval others Other errors occur when unistall the hii resource.
**/
EFI_STATUS
-HiiUninstall(
+HiiUninstall (
VOID
);
@@ -354,7 +354,7 @@ HiiUninstall(
**/
EFI_STATUS
OpalDiskInitialize (
- IN OPAL_DRIVER_DEVICE *Dev
+ IN OPAL_DRIVER_DEVICE *Dev
);
/**
@@ -369,7 +369,7 @@ OpalDiskInitialize (
**/
EFI_STATUS
OpalDiskUpdateOwnerShip (
- OPAL_DISK *OpalDisk
+ OPAL_DISK *OpalDisk
);
#endif // _HII_H_
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
index 2f270e5516..105b019959 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
@@ -16,7 +16,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_HANDLE
-HiiGetDriverImageHandleCB(
+HiiGetDriverImageHandleCB (
VOID
)
{
@@ -32,17 +32,17 @@ HiiGetDriverImageHandleCB(
**/
VOID *
-HiiGetDiskContextCB(
- UINT8 DiskIndex
+HiiGetDiskContextCB (
+ UINT8 DiskIndex
)
{
- OPAL_DRIVER_DEVICE* Dev;
- UINT8 CurrentDisk;
+ OPAL_DRIVER_DEVICE *Dev;
+ UINT8 CurrentDisk;
- Dev = OpalDriverGetDeviceList();
+ Dev = OpalDriverGetDeviceList ();
CurrentDisk = 0;
- if (DiskIndex >= GetDeviceCount()) {
+ if (DiskIndex >= GetDeviceCount ()) {
return NULL;
}
@@ -66,13 +66,13 @@ HiiGetDiskContextCB(
@retval The device pointer.
**/
-OPAL_DISK*
-HiiGetOpalDiskCB(
- UINT8 DiskIndex
+OPAL_DISK *
+HiiGetOpalDiskCB (
+ UINT8 DiskIndex
)
{
- VOID *Ctx;
- OPAL_DRIVER_DEVICE *Tmp;
+ VOID *Ctx;
+ OPAL_DRIVER_DEVICE *Tmp;
Ctx = HiiGetDiskContextCB (DiskIndex);
@@ -80,7 +80,7 @@ HiiGetOpalDiskCB(
return NULL;
}
- Tmp = (OPAL_DRIVER_DEVICE*) Ctx;
+ Tmp = (OPAL_DRIVER_DEVICE *)Ctx;
return &Tmp->OpalDisk;
}
@@ -93,20 +93,22 @@ HiiGetOpalDiskCB(
@retval Returns the disk name.
**/
-CHAR8*
-HiiDiskGetNameCB(
- UINT8 DiskIndex
+CHAR8 *
+HiiDiskGetNameCB (
+ UINT8 DiskIndex
)
{
- OPAL_DRIVER_DEVICE* Ctx;
+ OPAL_DRIVER_DEVICE *Ctx;
- Ctx = (OPAL_DRIVER_DEVICE*) HiiGetDiskContextCB (DiskIndex);
+ Ctx = (OPAL_DRIVER_DEVICE *)HiiGetDiskContextCB (DiskIndex);
if (Ctx != NULL) {
if (Ctx->NameZ == NULL) {
OpalDriverGetDriverDeviceName (Ctx);
}
+
return Ctx->NameZ;
}
+
return NULL;
}
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
index 9e1aadccf1..ab6957fc6f 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
@@ -6,28 +6,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#ifndef _OPAL_HII_FORM_VALUES_H_
#define _OPAL_HII_FORM_VALUES_H_
// ID's for various forms that will be used by HII
-#define FORMID_VALUE_MAIN_MENU 0x01
-#define FORMID_VALUE_DISK_INFO_FORM_MAIN 0x02
+#define FORMID_VALUE_MAIN_MENU 0x01
+#define FORMID_VALUE_DISK_INFO_FORM_MAIN 0x02
#pragma pack(1)
typedef struct {
- UINT16 Lock:1;
- UINT16 Unlock:1;
- UINT16 SetAdminPwd:1;
- UINT16 SetUserPwd:1;
- UINT16 SecureErase:1;
- UINT16 Revert:1;
- UINT16 PsidRevert:1;
- UINT16 DisableUser:1;
- UINT16 DisableFeature:1;
- UINT16 EnableFeature:1;
- UINT16 Reserved:5;
- UINT16 KeepUserData:1;
+ UINT16 Lock : 1;
+ UINT16 Unlock : 1;
+ UINT16 SetAdminPwd : 1;
+ UINT16 SetUserPwd : 1;
+ UINT16 SecureErase : 1;
+ UINT16 Revert : 1;
+ UINT16 PsidRevert : 1;
+ UINT16 DisableUser : 1;
+ UINT16 DisableFeature : 1;
+ UINT16 EnableFeature : 1;
+ UINT16 Reserved : 5;
+ UINT16 KeepUserData : 1;
} OPAL_REQUEST;
typedef struct {
@@ -43,17 +42,17 @@ typedef struct {
#pragma pack()
/* Action Flags */
-#define HII_ACTION_NONE 0x0000
-#define HII_ACTION_LOCK 0x0001
-#define HII_ACTION_UNLOCK 0x0002
-#define HII_ACTION_SET_ADMIN_PWD 0x0004
-#define HII_ACTION_SET_USER_PWD 0x0008
-#define HII_ACTION_SECURE_ERASE 0x0010
-#define HII_ACTION_REVERT 0x0020
-#define HII_ACTION_PSID_REVERT 0x0040
-#define HII_ACTION_DISABLE_USER 0x0080
-#define HII_ACTION_DISABLE_FEATURE 0x0100
-#define HII_ACTION_ENABLE_FEATURE 0x0200
+#define HII_ACTION_NONE 0x0000
+#define HII_ACTION_LOCK 0x0001
+#define HII_ACTION_UNLOCK 0x0002
+#define HII_ACTION_SET_ADMIN_PWD 0x0004
+#define HII_ACTION_SET_USER_PWD 0x0008
+#define HII_ACTION_SECURE_ERASE 0x0010
+#define HII_ACTION_REVERT 0x0020
+#define HII_ACTION_PSID_REVERT 0x0040
+#define HII_ACTION_DISABLE_USER 0x0080
+#define HII_ACTION_DISABLE_FEATURE 0x0100
+#define HII_ACTION_ENABLE_FEATURE 0x0200
/* Number of bits allocated for each part of a unique key for an HII_ITEM
* all bits together must be <= 16 (EFI_QUESTION_ID is UINT16)
@@ -61,32 +60,32 @@ typedef struct {
* | |-----------------------| |---------------------------|
* FLG INDEX ID
*/
-#define HII_KEY_ID_BITS 8
-#define HII_KEY_INDEX_BITS 7
-#define HII_KEY_FLAG_BITS 1
+#define HII_KEY_ID_BITS 8
+#define HII_KEY_INDEX_BITS 7
+#define HII_KEY_FLAG_BITS 1
-#define HII_KEY_FLAG 0x8000 // bit 15 (zero based)
+#define HII_KEY_FLAG 0x8000 // bit 15 (zero based)
/***********/
/* Key IDs */
/***********/
-#define HII_KEY_ID_GOTO_DISK_INFO 1
+#define HII_KEY_ID_GOTO_DISK_INFO 1
#define HII_KEY_ID_VAR_SUPPORTED_DISKS 2
#define HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS 3
-#define HII_KEY_ID_BLOCKSID 4
-#define HII_KEY_ID_SET_ADMIN_PWD 5
-#define HII_KEY_ID_SET_USER_PWD 6
-#define HII_KEY_ID_SECURE_ERASE 7
-#define HII_KEY_ID_REVERT 8
-#define HII_KEY_ID_KEEP_USER_DATA 9
-#define HII_KEY_ID_PSID_REVERT 0xA
-#define HII_KEY_ID_DISABLE_USER 0xB
-#define HII_KEY_ID_ENABLE_FEATURE 0xC
+#define HII_KEY_ID_BLOCKSID 4
+#define HII_KEY_ID_SET_ADMIN_PWD 5
+#define HII_KEY_ID_SET_USER_PWD 6
+#define HII_KEY_ID_SECURE_ERASE 7
+#define HII_KEY_ID_REVERT 8
+#define HII_KEY_ID_KEEP_USER_DATA 9
+#define HII_KEY_ID_PSID_REVERT 0xA
+#define HII_KEY_ID_DISABLE_USER 0xB
+#define HII_KEY_ID_ENABLE_FEATURE 0xC
-#define HII_KEY_ID_MAX 0xC // !!Update each time a new ID is added!!
+#define HII_KEY_ID_MAX 0xC // !!Update each time a new ID is added!!
#define HII_KEY_WITH_INDEX(id, index) \
( \
@@ -95,15 +94,14 @@ typedef struct {
((index) << HII_KEY_ID_BITS) \
)
-#define HII_KEY(id) HII_KEY_WITH_INDEX(id, 0)
+#define HII_KEY(id) HII_KEY_WITH_INDEX(id, 0)
-#define PACKAGE_LIST_GUID { 0xf0308176, 0x9058, 0x4153, { 0x93, 0x3d, 0xda, 0x2f, 0xdc, 0xc8, 0x3e, 0x44 } }
+#define PACKAGE_LIST_GUID { 0xf0308176, 0x9058, 0x4153, { 0x93, 0x3d, 0xda, 0x2f, 0xdc, 0xc8, 0x3e, 0x44 } }
/* {410483CF-F4F9-4ece-848A-1958FD31CEB7} */
-#define SETUP_FORMSET_GUID { 0x410483cf, 0xf4f9, 0x4ece, { 0x84, 0x8a, 0x19, 0x58, 0xfd, 0x31, 0xce, 0xb7 } }
+#define SETUP_FORMSET_GUID { 0x410483cf, 0xf4f9, 0x4ece, { 0x84, 0x8a, 0x19, 0x58, 0xfd, 0x31, 0xce, 0xb7 } }
// {BBF1ACD2-28D8-44ea-A291-58A237FEDF1A}
-#define SETUP_VARIABLE_GUID { 0xbbf1acd2, 0x28d8, 0x44ea, { 0xa2, 0x91, 0x58, 0xa2, 0x37, 0xfe, 0xdf, 0x1a } }
+#define SETUP_VARIABLE_GUID { 0xbbf1acd2, 0x28d8, 0x44ea, { 0xa2, 0x91, 0x58, 0xa2, 0x37, 0xfe, 0xdf, 0x1a } }
#endif //_HII_FORM_VALUES_H_
-
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h
index 22db5e605c..404367f0df 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordCommon.h
@@ -9,18 +9,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _OPAL_PASSWORD_COMMON_H_
#define _OPAL_PASSWORD_COMMON_H_
-#define OPAL_MAX_PASSWORD_SIZE 32
+#define OPAL_MAX_PASSWORD_SIZE 32
-#define OPAL_DEVICE_TYPE_UNKNOWN 0x0
-#define OPAL_DEVICE_TYPE_ATA 0x1
-#define OPAL_DEVICE_TYPE_NVME 0x2
+#define OPAL_DEVICE_TYPE_UNKNOWN 0x0
+#define OPAL_DEVICE_TYPE_ATA 0x1
+#define OPAL_DEVICE_TYPE_NVME 0x2
typedef struct {
- UINT16 Segment;
- UINT8 Bus;
- UINT8 Device;
- UINT8 Function;
- UINT8 Reserved;
+ UINT16 Segment;
+ UINT8 Bus;
+ UINT8 Device;
+ UINT8 Function;
+ UINT8 Reserved;
} OPAL_PCI_DEVICE;
typedef struct {
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.c
index 4e5e4eaa93..c998b50be5 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.c
@@ -8,8 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "OpalPasswordPei.h"
-EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
-
+EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
/**
Send a security protocol command to a device that receives data and/or the result
@@ -86,17 +85,17 @@ EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
EFI_STATUS
EFIAPI
SecurityReceiveData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- OUT VOID *PayloadBuffer,
- OUT UINTN *PayloadTransferSize
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ OUT VOID *PayloadBuffer,
+ OUT UINTN *PayloadTransferSize
)
{
- OPAL_PEI_DEVICE *PeiDev;
+ OPAL_PEI_DEVICE *PeiDev;
PeiDev = OPAL_PEI_DEVICE_FROM_THIS (This);
if (PeiDev == NULL) {
@@ -179,16 +178,16 @@ SecurityReceiveData (
EFI_STATUS
EFIAPI
SecuritySendData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- IN VOID *PayloadBuffer
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ IN VOID *PayloadBuffer
)
{
- OPAL_PEI_DEVICE *PeiDev;
+ OPAL_PEI_DEVICE *PeiDev;
PeiDev = OPAL_PEI_DEVICE_FROM_THIS (This);
if (PeiDev == NULL) {
@@ -217,18 +216,18 @@ SecuritySendData (
**/
BOOLEAN
-IsOpalDeviceLocked(
- OPAL_PEI_DEVICE *OpalDev,
- BOOLEAN *BlockSidSupported
+IsOpalDeviceLocked (
+ OPAL_PEI_DEVICE *OpalDev,
+ BOOLEAN *BlockSidSupported
)
{
- OPAL_SESSION Session;
- OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
- TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature;
- UINT16 OpalBaseComId;
- TCG_RESULT Ret;
+ OPAL_SESSION Session;
+ OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
+ TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature;
+ UINT16 OpalBaseComId;
+ TCG_RESULT Ret;
- Session.Sscp = &OpalDev->Sscp;
+ Session.Sscp = &OpalDev->Sscp;
Session.MediaId = 0;
Ret = OpalGetSupportedAttributesInfo (&Session, &SupportedAttributes, &OpalBaseComId);
@@ -236,10 +235,10 @@ IsOpalDeviceLocked(
return FALSE;
}
- Session.OpalBaseComId = OpalBaseComId;
- *BlockSidSupported = SupportedAttributes.BlockSid == 1 ? TRUE : FALSE;
+ Session.OpalBaseComId = OpalBaseComId;
+ *BlockSidSupported = SupportedAttributes.BlockSid == 1 ? TRUE : FALSE;
- Ret = OpalGetLockingInfo(&Session, &LockingFeature);
+ Ret = OpalGetLockingInfo (&Session, &LockingFeature);
if (Ret != TcgResultSuccess) {
return FALSE;
}
@@ -255,20 +254,20 @@ IsOpalDeviceLocked(
**/
VOID
UnlockOpalPassword (
- IN OPAL_PEI_DEVICE *OpalDev
+ IN OPAL_PEI_DEVICE *OpalDev
)
{
- TCG_RESULT Result;
- OPAL_SESSION Session;
- BOOLEAN BlockSidSupport;
- UINT32 PpStorageFlags;
- BOOLEAN BlockSIDEnabled;
+ TCG_RESULT Result;
+ OPAL_SESSION Session;
+ BOOLEAN BlockSidSupport;
+ UINT32 PpStorageFlags;
+ BOOLEAN BlockSIDEnabled;
BlockSidSupport = FALSE;
if (IsOpalDeviceLocked (OpalDev, &BlockSidSupport)) {
- ZeroMem(&Session, sizeof (Session));
- Session.Sscp = &OpalDev->Sscp;
- Session.MediaId = 0;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = &OpalDev->Sscp;
+ Session.MediaId = 0;
Session.OpalBaseComId = OpalDev->Device->OpalBaseComId;
Result = OpalUtilUpdateGlobalLockingRange (
@@ -292,13 +291,14 @@ UnlockOpalPassword (
} else {
BlockSIDEnabled = FALSE;
}
+
if (BlockSIDEnabled && BlockSidSupport) {
DEBUG ((DEBUG_INFO, "OpalPassword: S3 phase send BlockSid command to device!\n"));
- ZeroMem(&Session, sizeof (Session));
- Session.Sscp = &OpalDev->Sscp;
- Session.MediaId = 0;
+ ZeroMem (&Session, sizeof (Session));
+ Session.Sscp = &OpalDev->Sscp;
+ Session.MediaId = 0;
Session.OpalBaseComId = OpalDev->Device->OpalBaseComId;
- Result = OpalBlockSid (&Session, TRUE);
+ Result = OpalBlockSid (&Session, TRUE);
DEBUG ((
DEBUG_INFO,
"%a() OpalBlockSid() Result = 0x%x\n",
@@ -316,33 +316,34 @@ UnlockOpalPassword (
**/
VOID
UnlockOpalPasswordDevices (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *SscPpi
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *SscPpi
)
{
- EFI_STATUS Status;
- UINT8 *DevInfoBuffer;
- UINT8 DummyData;
- OPAL_DEVICE_LOCKBOX_DATA *DevInfo;
- UINTN DevInfoLength;
- EFI_DEVICE_PATH_PROTOCOL *SscDevicePath;
- UINTN SscDevicePathLength;
- UINTN SscDeviceNum;
- UINTN SscDeviceIndex;
- OPAL_PEI_DEVICE OpalDev;
+ EFI_STATUS Status;
+ UINT8 *DevInfoBuffer;
+ UINT8 DummyData;
+ OPAL_DEVICE_LOCKBOX_DATA *DevInfo;
+ UINTN DevInfoLength;
+ EFI_DEVICE_PATH_PROTOCOL *SscDevicePath;
+ UINTN SscDevicePathLength;
+ UINTN SscDeviceNum;
+ UINTN SscDeviceIndex;
+ OPAL_PEI_DEVICE OpalDev;
//
// Get OPAL devices info from LockBox.
//
DevInfoBuffer = &DummyData;
DevInfoLength = sizeof (DummyData);
- Status = RestoreLockBox (&mOpalDeviceLockBoxGuid, DevInfoBuffer, &DevInfoLength);
+ Status = RestoreLockBox (&mOpalDeviceLockBoxGuid, DevInfoBuffer, &DevInfoLength);
if (Status == EFI_BUFFER_TOO_SMALL) {
DevInfoBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DevInfoLength));
if (DevInfoBuffer != NULL) {
Status = RestoreLockBox (&mOpalDeviceLockBoxGuid, DevInfoBuffer, &DevInfoLength);
}
}
- if (DevInfoBuffer == NULL || DevInfoBuffer == &DummyData) {
+
+ if ((DevInfoBuffer == NULL) || (DevInfoBuffer == &DummyData)) {
return;
} else if (EFI_ERROR (Status)) {
FreePages (DevInfoBuffer, EFI_SIZE_TO_PAGES (DevInfoLength));
@@ -356,6 +357,7 @@ UnlockOpalPasswordDevices (
if (EFI_ERROR (Status)) {
goto Exit;
}
+
for (SscDeviceIndex = 1; SscDeviceIndex <= SscDeviceNum; SscDeviceIndex++) {
Status = SscPpi->GetDevicePath (
SscPpi,
@@ -373,9 +375,10 @@ UnlockOpalPasswordDevices (
//
// Search the device in the restored LockBox.
//
- for (DevInfo = (OPAL_DEVICE_LOCKBOX_DATA *) DevInfoBuffer;
- (UINTN) DevInfo < ((UINTN) DevInfoBuffer + DevInfoLength);
- DevInfo = (OPAL_DEVICE_LOCKBOX_DATA *) ((UINTN) DevInfo + DevInfo->Length)) {
+ for (DevInfo = (OPAL_DEVICE_LOCKBOX_DATA *)DevInfoBuffer;
+ (UINTN)DevInfo < ((UINTN)DevInfoBuffer + DevInfoLength);
+ DevInfo = (OPAL_DEVICE_LOCKBOX_DATA *)((UINTN)DevInfo + DevInfo->Length))
+ {
//
// Find the matching device.
//
@@ -383,7 +386,9 @@ UnlockOpalPasswordDevices (
(CompareMem (
DevInfo->DevicePath,
SscDevicePath,
- SscDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) == 0)) {
+ SscDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)
+ ) == 0))
+ {
OpalDev.Signature = OPAL_PEI_DEVICE_SIGNATURE;
OpalDev.Sscp.ReceiveData = SecurityReceiveData;
OpalDev.Sscp.SendData = SecuritySendData;
@@ -400,7 +405,6 @@ UnlockOpalPasswordDevices (
Exit:
ZeroMem (DevInfoBuffer, DevInfoLength);
FreePages (DevInfoBuffer, EFI_SIZE_TO_PAGES (DevInfoLength));
-
}
/**
@@ -418,28 +422,26 @@ Exit:
EFI_STATUS
EFIAPI
OpalPasswordStorageSecurityPpiNotify (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
- IN VOID *Ppi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
)
{
DEBUG ((DEBUG_INFO, "%a entered at S3 resume!\n", __FUNCTION__));
- UnlockOpalPasswordDevices ((EDKII_PEI_STORAGE_SECURITY_CMD_PPI *) Ppi);
+ UnlockOpalPasswordDevices ((EDKII_PEI_STORAGE_SECURITY_CMD_PPI *)Ppi);
DEBUG ((DEBUG_INFO, "%a exit at S3 resume!\n", __FUNCTION__));
return EFI_SUCCESS;
}
-
-EFI_PEI_NOTIFY_DESCRIPTOR mOpalPasswordStorageSecurityPpiNotifyDesc = {
+EFI_PEI_NOTIFY_DESCRIPTOR mOpalPasswordStorageSecurityPpiNotifyDesc = {
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEdkiiPeiStorageSecurityCommandPpiGuid,
OpalPasswordStorageSecurityPpiNotify
};
-
/**
Main entry for this module.
@@ -452,12 +454,12 @@ EFI_PEI_NOTIFY_DESCRIPTOR mOpalPasswordStorageSecurityPpiNotifyDesc = {
EFI_STATUS
EFIAPI
OpalPasswordPeiInit (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- EFI_BOOT_MODE BootMode;
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
Status = PeiServicesGetBootMode (&BootMode);
if ((EFI_ERROR (Status)) || (BootMode != BOOT_ON_S3_RESUME)) {
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h
index bd7007094f..e2b3f416de 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.h
@@ -31,16 +31,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "OpalPasswordCommon.h"
-
//
// The generic command timeout value (unit in us) for Storage Security Command
// PPI ReceiveData/SendData services
//
-#define SSC_PPI_GENERIC_TIMEOUT 30000000
+#define SSC_PPI_GENERIC_TIMEOUT 30000000
#pragma pack(1)
-#define OPAL_PEI_DEVICE_SIGNATURE SIGNATURE_32 ('o', 'p', 'd', 's')
+#define OPAL_PEI_DEVICE_SIGNATURE SIGNATURE_32 ('o', 'p', 'd', 's')
typedef struct {
UINTN Signature;
@@ -57,4 +56,3 @@ typedef struct {
#pragma pack()
#endif // _OPAL_PASSWORD_PEI_H_
-