12#include <Library/VariablePolicyHelperLib.h>
14EFI_GUID mHddPasswordVendorGuid = HDD_PASSWORD_CONFIG_GUID;
15CHAR16 mHddPasswordVendorStorageName[] = L
"HDD_PASSWORD_CONFIG";
17UINT32 mNumberOfHddDevices = 0;
19EFI_GUID mHddPasswordDeviceInfoGuid = HDD_PASSWORD_DEVICE_INFO_GUID;
20BOOLEAN mHddPasswordEndOfDxe =
FALSE;
22UINTN mHddPasswordRequestVariableSize = 0;
34 HDD_PASSWORD_CONFIG_GUID
38 END_ENTIRE_DEVICE_PATH_SUBTYPE,
40 (UINT8)(END_DEVICE_PATH_LENGTH),
41 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
62 for (Index = 0; Index < HDD_PASSWORD_MAX_LENGTH; Index++) {
63 if (Password[Index] != 0) {
84 TempDevInfo->Device.Bus = (UINT8)ConfigFormEntry->Bus;
85 TempDevInfo->Device.Device = (UINT8)ConfigFormEntry->Device;
86 TempDevInfo->Device.Function = (UINT8)ConfigFormEntry->Function;
87 TempDevInfo->Device.Port = ConfigFormEntry->Port;
88 TempDevInfo->Device.PortMultiplierPort = ConfigFormEntry->PortMultiplierPort;
89 CopyMem (TempDevInfo->Password, ConfigFormEntry->Password, HDD_PASSWORD_MAX_LENGTH);
90 TempDevInfo->DevicePathLength = (UINT32)
GetDevicePathSize (ConfigFormEntry->DevicePath);
91 CopyMem (TempDevInfo->DevicePath, ConfigFormEntry->DevicePath, TempDevInfo->DevicePathLength);
110 BOOLEAN S3InitDevicesExist;
111 UINTN S3InitDevicesLength;
128 ((ConfigFormEntry->IfrData.SecurityStatus.Supported != 0) &&
129 (ConfigFormEntry->IfrData.SecurityStatus.Enabled == 0)))
136 if (DevInfoLength == 0) {
140 S3InitDevicesLength =
sizeof (DummyData);
142 &gS3StorageDeviceInitListGuid,
146 ASSERT ((Status == EFI_NOT_FOUND) || (Status == EFI_BUFFER_TOO_SMALL));
147 if (Status == EFI_NOT_FOUND) {
148 S3InitDevices =
NULL;
149 S3InitDevicesExist =
FALSE;
150 }
else if (Status == EFI_BUFFER_TOO_SMALL) {
152 ASSERT (S3InitDevices !=
NULL);
155 &gS3StorageDeviceInitListGuid,
160 S3InitDevicesExist =
TRUE;
166 ASSERT (DevInfo !=
NULL);
168 TempDevInfo = DevInfo;
173 ((ConfigFormEntry->IfrData.SecurityStatus.Supported != 0) &&
174 (ConfigFormEntry->IfrData.SecurityStatus.Enabled == 0)))
178 S3InitDevicesBak = S3InitDevices;
181 ConfigFormEntry->DevicePath
183 if (S3InitDevicesBak !=
NULL) {
187 ASSERT (S3InitDevices !=
NULL);
191 TempDevInfo->DevicePathLength);
196 &mHddPasswordDeviceInfoGuid,
203 &mHddPasswordDeviceInfoGuid,
204 LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY
209 if (S3InitDevicesExist) {
211 &gS3StorageDeviceInitListGuid,
219 &gS3StorageDeviceInitListGuid,
226 &gS3StorageDeviceInitListGuid,
227 LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY
232 ZeroMem (DevInfo, DevInfoLength);
255 IN UINT16 PortMultiplierPort
263 if (AtaPassThru ==
NULL) {
264 return EFI_INVALID_PARAMETER;
278 AtaPassThru->Mode->IoAlign
281 return EFI_OUT_OF_RESOURCES;
289 Acb.AtaCommand = ATA_SECURITY_FREEZE_LOCK_CMD;
290 Acb.AtaDeviceHead = (UINT8)(PortMultiplierPort == 0xFFFF ? 0 : (PortMultiplierPort << 4));
295 ZeroMem (&Packet,
sizeof (Packet));
296 Packet.
Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA;
297 Packet.
Length = EFI_ATA_PASS_THRU_LENGTH_NO_DATA_TRANSFER;
302 Status = AtaPassThru->PassThru (
309 if (!EFI_ERROR (Status) &&
313 Status = EFI_DEVICE_ERROR;
318 DEBUG ((DEBUG_INFO,
"%a() - %r\n", __func__, Status));
341 IN UINT16 PortMultiplierPort,
350 if ((AtaPassThru ==
NULL) || (IdentifyData ==
NULL)) {
351 return EFI_INVALID_PARAMETER;
365 AtaPassThru->Mode->IoAlign
368 return EFI_OUT_OF_RESOURCES;
377 Acb.AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (PortMultiplierPort == 0xFFFF ? 0 : (PortMultiplierPort << 4)));
382 ZeroMem (&Packet,
sizeof (Packet));
383 Packet.
Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN;
384 Packet.
Length = EFI_ATA_PASS_THRU_LENGTH_BYTES | EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
391 Status = AtaPassThru->PassThru (
417 IfrData->SecurityStatus.Supported = (IdentifyData->command_set_supported_82 & BIT1) ? 1 : 0;
418 IfrData->SecurityStatus.Enabled = (IdentifyData->security_status & BIT1) ? 1 : 0;
419 IfrData->SecurityStatus.Locked = (IdentifyData->security_status & BIT2) ? 1 : 0;
420 IfrData->SecurityStatus.Frozen = (IdentifyData->security_status & BIT3) ? 1 : 0;
421 IfrData->SecurityStatus.UserPasswordStatus = IfrData->SecurityStatus.Enabled;
422 IfrData->SecurityStatus.MasterPasswordStatus = IfrData->SecurityStatus.Supported;
424 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.Supported = %x\n", IfrData->SecurityStatus.Supported));
425 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.Enabled = %x\n", IfrData->SecurityStatus.Enabled));
426 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.Locked = %x\n", IfrData->SecurityStatus.Locked));
427 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.Frozen = %x\n", IfrData->SecurityStatus.Frozen));
428 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.UserPasswordStatus = %x\n", IfrData->SecurityStatus.UserPasswordStatus));
429 DEBUG ((DEBUG_INFO,
"IfrData->SecurityStatus.MasterPasswordStatus = %x\n", IfrData->SecurityStatus.MasterPasswordStatus));
453 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
455 mHddPasswordEndOfDxe =
TRUE;
457 if (mHddPasswordRequestVariable !=
NULL) {
462 FreePool (mHddPasswordRequestVariable);
463 mHddPasswordRequestVariable =
NULL;
464 mHddPasswordRequestVariableSize = 0;
471 gBS->CloseEvent (Event);
483 ZeroMem (ConfigFormEntry->Password, HDD_PASSWORD_MAX_LENGTH);
491 if ((ConfigFormEntry->IfrData.SecurityStatus.Supported != 0) &&
492 (ConfigFormEntry->IfrData.SecurityStatus.Locked == 0) &&
493 (ConfigFormEntry->IfrData.SecurityStatus.Frozen == 0))
495 Status =
FreezeLockDevice (ConfigFormEntry->AtaPassThru, ConfigFormEntry->Port, ConfigFormEntry->PortMultiplierPort);
496 DEBUG ((DEBUG_INFO,
"FreezeLockDevice return %r!\n", Status));
498 ConfigFormEntry->AtaPassThru,
499 ConfigFormEntry->Port,
500 ConfigFormEntry->PortMultiplierPort,
507 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
509 gBS->CloseEvent (Event);
520 IN OUT UINT8 *SaltValue
544 OUT UINT8 *Credential
558 ASSERT (Hash !=
NULL);
569 ASSERT (HashData !=
NULL);
570 if (HashData ==
NULL) {
574 CopyMem (HashData, SaltValue, PASSWORD_SALT_SIZE);
575 CopyMem ((UINT8 *)HashData + PASSWORD_SALT_SIZE, Buffer, BufferSize);
577 Status =
Sha256Update (Hash, HashData, PASSWORD_SALT_SIZE + BufferSize);
589 if (HashData !=
NULL) {
590 ZeroMem (HashData, PASSWORD_SALT_SIZE + BufferSize);
613 UINTN TempVariableSize;
618 UINTN NewVariableSize;
622 UINT8 SaltData[PASSWORD_SALT_SIZE];
624 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
631 ZeroMem (HashData,
sizeof (HashData));
632 ZeroMem (SaltData,
sizeof (SaltData));
634 HashOk =
GenerateCredential ((UINT8 *)Password, HDD_PASSWORD_MAX_LENGTH, SaltData, HashData);
636 DEBUG ((DEBUG_INFO,
"GenerateCredential failed\n"));
653 HDD_PASSWORD_VARIABLE_NAME,
654 &mHddPasswordVendorGuid,
659 if (!EFI_ERROR (Status) && (Variable !=
NULL)) {
660 TempVariable = Variable;
661 TempVariableSize = VariableSize;
663 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
664 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
665 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
666 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
667 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
673 NextNode = TempVariable + 1;
674 CopyMem (TempVariable, NextNode, (
UINTN)Variable + VariableSize - (
UINTN)NextNode);
675 NewVariable = Variable;
684 if (NewVariable ==
NULL) {
685 DEBUG ((DEBUG_INFO,
"The variable node for the HDD password device is not found\n"));
688 DEBUG ((DEBUG_INFO,
"HddPassword variable get failed (%r)\n", Status));
691 if (!EFI_ERROR (Status) && (Variable !=
NULL)) {
692 TempVariable = Variable;
693 TempVariableSize = VariableSize;
695 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
696 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
697 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
698 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
699 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
705 CopyMem (TempVariable->PasswordHash, HashData, sizeof (HashData));
706 CopyMem (TempVariable->PasswordSalt, SaltData, sizeof (SaltData));
707 NewVariable = Variable;
708 NewVariableSize = VariableSize;
716 if (NewVariable ==
NULL) {
723 ASSERT (NewVariable !=
NULL);
724 CopyMem (NewVariable, Variable, VariableSize);
726 TempVariable->Device.Bus = (UINT8)ConfigFormEntry->Bus;
727 TempVariable->Device.Device = (UINT8)ConfigFormEntry->Device;
728 TempVariable->Device.Function = (UINT8)ConfigFormEntry->Function;
729 TempVariable->Device.Port = ConfigFormEntry->Port;
730 TempVariable->Device.PortMultiplierPort = ConfigFormEntry->PortMultiplierPort;
731 CopyMem (TempVariable->PasswordHash, HashData, sizeof (HashData));
732 CopyMem (TempVariable->PasswordSalt, SaltData, sizeof (SaltData));
737 ASSERT (NewVariable !=
NULL);
738 NewVariable->Device.Bus = (UINT8)ConfigFormEntry->Bus;
739 NewVariable->Device.Device = (UINT8)ConfigFormEntry->Device;
740 NewVariable->Device.Function = (UINT8)ConfigFormEntry->Function;
741 NewVariable->Device.Port = ConfigFormEntry->Port;
742 NewVariable->Device.PortMultiplierPort = ConfigFormEntry->PortMultiplierPort;
743 CopyMem (NewVariable->PasswordHash, HashData, sizeof (HashData));
744 CopyMem (NewVariable->PasswordSalt, SaltData, sizeof (SaltData));
748 if (NewVariable !=
NULL) {
749 Status =
gRT->SetVariable (
750 HDD_PASSWORD_VARIABLE_NAME,
751 &mHddPasswordVendorGuid,
756 if (EFI_ERROR (Status)) {
757 DEBUG ((DEBUG_INFO,
"HddPassword variable set failed (%r)\n", Status));
761 if (NewVariable != Variable) {
765 if (Variable !=
NULL) {
769 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
795 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
801 HDD_PASSWORD_VARIABLE_NAME,
802 &mHddPasswordVendorGuid,
806 if (EFI_ERROR (Status) || (Variable ==
NULL)) {
807 DEBUG ((DEBUG_INFO,
"HddPassword variable get failed (%r)\n", Status));
812 TempVariable = Variable;
814 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
815 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
816 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
817 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
818 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
836 DEBUG ((DEBUG_INFO,
"The variable node for the HDD password device is not found\n"));
839 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
868 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
871 DEBUG ((DEBUG_INFO,
"GetSavedHddPasswordVariable failed\n"));
872 return EFI_NOT_FOUND;
875 ZeroMem (HashData,
sizeof (HashData));
876 HashOk =
GenerateCredential ((UINT8 *)Password, HDD_PASSWORD_MAX_LENGTH, HddPasswordVariable.PasswordSalt, HashData);
878 DEBUG ((DEBUG_INFO,
"GenerateCredential failed\n"));
879 return EFI_DEVICE_ERROR;
882 if (
CompareMem (HddPasswordVariable.PasswordHash, HashData, sizeof (HashData)) != 0) {
883 Status = EFI_INVALID_PARAMETER;
888 DEBUG ((DEBUG_INFO,
"%a() - exit (%r)\n", __func__, Status));
912 IN UINT16 PortMultiplierPort,
921 UINT8 Buffer[HDD_PAYLOAD];
923 if ((AtaPassThru ==
NULL) || (Password ==
NULL)) {
924 return EFI_INVALID_PARAMETER;
938 AtaPassThru->Mode->IoAlign
941 return EFI_OUT_OF_RESOURCES;
949 Acb.AtaCommand = ATA_SECURITY_UNLOCK_CMD;
950 Acb.AtaDeviceHead = (UINT8)(PortMultiplierPort == 0xFFFF ? 0 : (PortMultiplierPort << 4));
955 ZeroMem (&Packet,
sizeof (Packet));
956 Packet.
Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT;
957 Packet.
Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
961 ((CHAR16 *)Buffer)[0] = Identifier & BIT0;
962 CopyMem (&((CHAR16 *)Buffer)[1], Password, HDD_PASSWORD_MAX_LENGTH);
968 Status = AtaPassThru->PassThru (
975 if (!EFI_ERROR (Status) &&
979 Status = EFI_DEVICE_ERROR;
984 ZeroMem (Buffer,
sizeof (Buffer));
986 DEBUG ((DEBUG_INFO,
"%a() - %r\n", __func__, Status));
1010 IN UINT16 PortMultiplierPort,
1011 IN CHAR8 Identifier,
1019 UINT8 Buffer[HDD_PAYLOAD];
1021 if ((AtaPassThru ==
NULL) || (Password ==
NULL)) {
1022 return EFI_INVALID_PARAMETER;
1036 AtaPassThru->Mode->IoAlign
1039 return EFI_OUT_OF_RESOURCES;
1047 Acb.AtaCommand = ATA_SECURITY_DIS_PASSWORD_CMD;
1048 Acb.AtaDeviceHead = (UINT8)(PortMultiplierPort == 0xFFFF ? 0 : (PortMultiplierPort << 4));
1053 ZeroMem (&Packet,
sizeof (Packet));
1054 Packet.
Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT;
1055 Packet.
Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
1059 ((CHAR16 *)Buffer)[0] = Identifier & BIT0;
1060 CopyMem (&((CHAR16 *)Buffer)[1], Password, HDD_PASSWORD_MAX_LENGTH);
1066 Status = AtaPassThru->PassThru (
1073 if (!EFI_ERROR (Status) &&
1077 Status = EFI_DEVICE_ERROR;
1082 ZeroMem (Buffer,
sizeof (Buffer));
1084 DEBUG ((DEBUG_INFO,
"%a() - %r\n", __func__, Status));
1110 IN UINT16 PortMultiplierPort,
1111 IN CHAR8 Identifier,
1112 IN CHAR8 SecurityLevel,
1113 IN CHAR16 MasterPasswordIdentifier,
1121 UINT8 Buffer[HDD_PAYLOAD];
1123 if ((AtaPassThru ==
NULL) || (Password ==
NULL)) {
1124 return EFI_INVALID_PARAMETER;
1138 AtaPassThru->Mode->IoAlign
1141 return EFI_OUT_OF_RESOURCES;
1149 Acb.AtaCommand = ATA_SECURITY_SET_PASSWORD_CMD;
1150 Acb.AtaDeviceHead = (UINT8)(PortMultiplierPort == 0xFFFF ? 0 : (PortMultiplierPort << 4));
1155 ZeroMem (&Packet,
sizeof (Packet));
1156 Packet.
Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT;
1157 Packet.
Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
1161 ((CHAR16 *)Buffer)[0] = (Identifier | (UINT16)(SecurityLevel << 8)) & (BIT0 | BIT8);
1162 CopyMem (&((CHAR16 *)Buffer)[1], Password, HDD_PASSWORD_MAX_LENGTH);
1163 if ((Identifier & BIT0) != 0) {
1164 ((CHAR16 *)Buffer)[17] = MasterPasswordIdentifier;
1171 Status = AtaPassThru->PassThru (
1178 if (!EFI_ERROR (Status) &&
1182 Status = EFI_DEVICE_ERROR;
1187 ZeroMem (Buffer,
sizeof (Buffer));
1189 DEBUG ((DEBUG_INFO,
"%a() - %r\n", __func__, Status));
1203 IN OUT CHAR16 *String
1212 for (Index = 0; Index < 40; Index += 2) {
1213 String[Index] = IdentifyData->ModelName[Index + 1];
1214 String[Index + 1] = IdentifyData->ModelName[Index];
1238 IN CHAR16 *PopUpString1,
1239 IN CHAR16 *PopUpString2,
1240 IN OUT CHAR8 *Password
1245 CHAR16 Mask[HDD_PASSWORD_MAX_LENGTH + 1];
1246 CHAR16 Unicode[HDD_PASSWORD_MAX_LENGTH + 1];
1247 CHAR8 Ascii[HDD_PASSWORD_MAX_LENGTH + 1];
1249 ZeroMem (Unicode,
sizeof (Unicode));
1250 ZeroMem (Ascii,
sizeof (Ascii));
1251 ZeroMem (Mask,
sizeof (Mask));
1257 Mask[Length] = L
'_';
1258 if (PopUpString2 ==
NULL) {
1260 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1263 L
"---------------------",
1269 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1273 L
"---------------------",
1282 if (Key.ScanCode == SCAN_NULL) {
1283 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
1287 Unicode[Length] = 0;
1289 }
else if ((Key.UnicodeChar == CHAR_NULL) ||
1290 (Key.UnicodeChar == CHAR_TAB) ||
1291 (Key.UnicodeChar == CHAR_LINEFEED)
1296 if (Key.UnicodeChar == CHAR_BACKSPACE) {
1298 Unicode[Length] = 0;
1303 Unicode[Length] = Key.UnicodeChar;
1304 Mask[Length] = L
'*';
1306 if (Length == HDD_PASSWORD_MAX_LENGTH) {
1310 Unicode[Length] = 0;
1318 if (Key.ScanCode == SCAN_ESC) {
1319 ZeroMem (Unicode,
sizeof (Unicode));
1320 ZeroMem (Ascii,
sizeof (Ascii));
1327 CopyMem (Password, Ascii, HDD_PASSWORD_MAX_LENGTH);
1328 ZeroMem (Unicode,
sizeof (Unicode));
1329 ZeroMem (Ascii,
sizeof (Ascii));
1348 IN UINT16 PortMultiplierPort,
1353 CHAR16 PopUpString[100];
1357 CHAR8 Password[HDD_PASSWORD_MAX_LENGTH];
1361 DEBUG ((DEBUG_INFO,
"%a()\n", __func__));
1363 UnicodeSPrint (PopUpString,
sizeof (PopUpString), L
"Unlock: %s", ConfigFormEntry->HddString);
1368 if ((ConfigFormEntry->IfrData.SecurityStatus.Supported) &&
1369 (ConfigFormEntry->IfrData.SecurityStatus.Enabled))
1380 if (ConfigFormEntry->IfrData.SecurityStatus.Locked) {
1394 if (!EFI_ERROR (Status)) {
1399 if (!ConfigFormEntry->IfrData.SecurityStatus.Frozen) {
1400 Status =
UnlockHddPassword (AtaPassThru, Port, PortMultiplierPort, 0, Password);
1409 Status = EFI_INVALID_PARAMETER;
1412 if (!EFI_ERROR (Status)) {
1413 CopyMem (ConfigFormEntry->Password, Password, HDD_PASSWORD_MAX_LENGTH);
1414 if (!ConfigFormEntry->IfrData.SecurityStatus.Frozen) {
1418 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1429 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1431 if (EFI_ERROR (Status)) {
1433 if (RetryCount < MAX_HDD_PASSWORD_RETRY_COUNT) {
1436 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1438 L
"Invalid password.",
1439 L
"Press ENTER to retry",
1442 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1448 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1450 L
"Hdd password retry count is expired. Please shutdown the machine.",
1451 L
"Press ENTER to shutdown",
1454 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1460 }
else if (Status == EFI_ABORTED) {
1461 if (ConfigFormEntry->IfrData.SecurityStatus.Locked) {
1469 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1471 L
"Press ENTER to skip the request and continue boot,",
1472 L
"Press ESC to input password again",
1475 }
while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
1477 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
1497 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1499 L
"Press ENTER to shutdown, Press ESC to input password again",
1502 }
while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
1504 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
1531 IN UINT16 PortMultiplierPort,
1536 CHAR16 PopUpString[100];
1540 CHAR8 Password[HDD_PASSWORD_MAX_LENGTH];
1541 CHAR8 PasswordConfirm[HDD_PASSWORD_MAX_LENGTH];
1545 DEBUG ((DEBUG_INFO,
"%a()\n", __func__));
1547 if (ConfigFormEntry->IfrData.SecurityStatus.Frozen) {
1548 DEBUG ((DEBUG_INFO,
"%s is frozen, do nothing\n", ConfigFormEntry->HddString));
1552 if (ConfigFormEntry->IfrData.SecurityStatus.Locked) {
1553 DEBUG ((DEBUG_INFO,
"%s is locked, do nothing\n", ConfigFormEntry->HddString));
1557 UnicodeSPrint (PopUpString,
sizeof (PopUpString), L
"Set User Pwd: %s", ConfigFormEntry->HddString);
1562 if (ConfigFormEntry->IfrData.SecurityStatus.Supported) {
1565 if (!EFI_ERROR (Status)) {
1567 if (!EFI_ERROR (Status)) {
1568 if (
CompareMem (Password, PasswordConfirm, HDD_PASSWORD_MAX_LENGTH) == 0) {
1570 Status =
SetHddPassword (AtaPassThru, Port, PortMultiplierPort, 0, 1, 0, Password);
1572 if (ConfigFormEntry->IfrData.SecurityStatus.Enabled) {
1573 Status =
DisableHddPassword (AtaPassThru, Port, PortMultiplierPort, 0, ConfigFormEntry->Password);
1575 Status = EFI_INVALID_PARAMETER;
1579 if (!EFI_ERROR (Status)) {
1580 CopyMem (ConfigFormEntry->Password, Password, HDD_PASSWORD_MAX_LENGTH);
1582 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1583 ZeroMem (PasswordConfirm, HDD_PASSWORD_MAX_LENGTH);
1595 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1597 L
"Set/Disable User Pwd failed or invalid password.",
1598 L
"Press ENTER to retry",
1601 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1606 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1608 L
"Passwords are not the same.",
1609 L
"Press ENTER to retry",
1612 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1614 Status = EFI_INVALID_PARAMETER;
1618 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1619 ZeroMem (PasswordConfirm, HDD_PASSWORD_MAX_LENGTH);
1621 if (EFI_ERROR (Status)) {
1623 if (RetryCount >= MAX_HDD_PASSWORD_RETRY_COUNT) {
1626 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1628 L
"Hdd password retry count is expired.",
1629 L
"Press ENTER to skip the request and continue boot",
1632 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1638 }
else if (Status == EFI_ABORTED) {
1641 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1643 L
"Press ENTER to skip the request and continue boot,",
1644 L
"Press ESC to input password again",
1647 }
while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
1649 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
1676 IN UINT16 PortMultiplierPort,
1681 CHAR16 PopUpString[100];
1684 CHAR8 Password[HDD_PASSWORD_MAX_LENGTH];
1685 CHAR8 PasswordConfirm[HDD_PASSWORD_MAX_LENGTH];
1689 DEBUG ((DEBUG_INFO,
"%a()\n", __func__));
1691 if (ConfigFormEntry->IfrData.SecurityStatus.Frozen) {
1692 DEBUG ((DEBUG_INFO,
"%s is frozen, do nothing\n", ConfigFormEntry->HddString));
1696 if (ConfigFormEntry->IfrData.SecurityStatus.Locked) {
1697 DEBUG ((DEBUG_INFO,
"%s is locked, do nothing\n", ConfigFormEntry->HddString));
1701 UnicodeSPrint (PopUpString,
sizeof (PopUpString), L
"Set Master Pwd: %s", ConfigFormEntry->HddString);
1706 if (ConfigFormEntry->IfrData.SecurityStatus.Supported) {
1709 if (!EFI_ERROR (Status)) {
1711 if (!EFI_ERROR (Status)) {
1712 if (
CompareMem (Password, PasswordConfirm, HDD_PASSWORD_MAX_LENGTH) == 0) {
1714 Status =
SetHddPassword (AtaPassThru, Port, PortMultiplierPort, 1, 1, 1, Password);
1716 Status = EFI_INVALID_PARAMETER;
1719 if (!EFI_ERROR (Status)) {
1720 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1721 ZeroMem (PasswordConfirm, HDD_PASSWORD_MAX_LENGTH);
1726 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1728 L
"Set Master Pwd failed or invalid password.",
1729 L
"Press ENTER to retry",
1732 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1737 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1739 L
"Passwords are not the same.",
1740 L
"Press ENTER to retry",
1743 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1745 Status = EFI_INVALID_PARAMETER;
1749 ZeroMem (Password, HDD_PASSWORD_MAX_LENGTH);
1750 ZeroMem (PasswordConfirm, HDD_PASSWORD_MAX_LENGTH);
1752 if (EFI_ERROR (Status)) {
1754 if (RetryCount >= MAX_HDD_PASSWORD_RETRY_COUNT) {
1757 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1759 L
"Hdd password retry count is expired.",
1760 L
"Press ENTER to skip the request and continue boot",
1763 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
1769 }
else if (Status == EFI_ABORTED) {
1772 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1774 L
"Press ENTER to skip the request and continue boot,",
1775 L
"Press ESC to input password again",
1778 }
while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
1780 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
1807 IN UINT16 PortMultiplierPort,
1816 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
1818 if (mHddPasswordRequestVariable ==
NULL) {
1820 HDD_PASSWORD_REQUEST_VARIABLE_NAME,
1821 &mHddPasswordVendorGuid,
1825 if (EFI_ERROR (Status) || (Variable ==
NULL)) {
1829 mHddPasswordRequestVariable = Variable;
1830 mHddPasswordRequestVariableSize = VariableSize;
1835 Status =
gRT->SetVariable (
1836 HDD_PASSWORD_REQUEST_VARIABLE_NAME,
1837 &mHddPasswordVendorGuid,
1844 Variable = mHddPasswordRequestVariable;
1845 VariableSize = mHddPasswordRequestVariableSize;
1851 TempVariable = Variable;
1853 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
1854 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
1855 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
1856 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
1857 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
1862 if (TempVariable->Request.UserPassword != 0) {
1866 if (TempVariable->Request.MasterPassword != 0) {
1877 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
1896 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
1902 HDD_PASSWORD_REQUEST_VARIABLE_NAME,
1903 &mHddPasswordVendorGuid,
1907 if (EFI_ERROR (Status) || (Variable ==
NULL)) {
1911 TempVariable = Variable;
1913 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
1914 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
1915 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
1916 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
1917 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
1926 "HddPasswordRequest got: 0x%x\n",
1927 ConfigFormEntry->IfrData.Request
1938 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
1954 UINTN TempVariableSize;
1958 UINTN NewVariableSize;
1960 DEBUG ((DEBUG_INFO,
"%a() - enter\n", __func__));
1964 "HddPasswordRequest to save: 0x%x\n",
1965 ConfigFormEntry->IfrData.Request
1971 NewVariableSize = 0;
1974 HDD_PASSWORD_REQUEST_VARIABLE_NAME,
1975 &mHddPasswordVendorGuid,
1979 if (!EFI_ERROR (Status) && (Variable !=
NULL)) {
1980 TempVariable = Variable;
1981 TempVariableSize = VariableSize;
1983 if ((TempVariable->Device.Bus == ConfigFormEntry->Bus) &&
1984 (TempVariable->Device.Device == ConfigFormEntry->Device) &&
1985 (TempVariable->Device.Function == ConfigFormEntry->Function) &&
1986 (TempVariable->Device.Port == ConfigFormEntry->Port) &&
1987 (TempVariable->Device.PortMultiplierPort == ConfigFormEntry->PortMultiplierPort))
1994 NewVariable = Variable;
1995 NewVariableSize = VariableSize;
2003 if (NewVariable ==
NULL) {
2010 ASSERT (NewVariable !=
NULL);
2011 CopyMem (NewVariable, Variable, VariableSize);
2013 TempVariable->Device.Bus = (UINT8)ConfigFormEntry->Bus;
2014 TempVariable->Device.Device = (UINT8)ConfigFormEntry->Device;
2015 TempVariable->Device.Function = (UINT8)ConfigFormEntry->Function;
2016 TempVariable->Device.Port = ConfigFormEntry->Port;
2017 TempVariable->Device.PortMultiplierPort = ConfigFormEntry->PortMultiplierPort;
2023 ASSERT (NewVariable !=
NULL);
2024 NewVariable->Device.Bus = (UINT8)ConfigFormEntry->Bus;
2025 NewVariable->Device.Device = (UINT8)ConfigFormEntry->Device;
2026 NewVariable->Device.Function = (UINT8)ConfigFormEntry->Function;
2027 NewVariable->Device.Port = ConfigFormEntry->Port;
2028 NewVariable->Device.PortMultiplierPort = ConfigFormEntry->PortMultiplierPort;
2032 Status =
gRT->SetVariable (
2033 HDD_PASSWORD_REQUEST_VARIABLE_NAME,
2034 &mHddPasswordVendorGuid,
2039 if (EFI_ERROR (Status)) {
2040 DEBUG ((DEBUG_INFO,
"HddPasswordRequest variable set failed (%r)\n", Status));
2043 if (NewVariable != Variable) {
2047 if (Variable !=
NULL) {
2051 DEBUG ((DEBUG_INFO,
"%a() - exit\n", __func__));
2067 UINT32 CurrentIndex;
2071 ConfigFormEntry =
NULL;
2074 if (CurrentIndex == Index) {
2082 return ConfigFormEntry;
2152 OUT EFI_STRING *Progress,
2153 OUT EFI_STRING *Results
2160 EFI_STRING ConfigRequestHdr;
2161 EFI_STRING ConfigRequest;
2162 BOOLEAN AllocatedRequest;
2165 if ((Progress ==
NULL) || (Results ==
NULL)) {
2166 return EFI_INVALID_PARAMETER;
2169 *Progress = Request;
2170 if ((Request !=
NULL) && !
HiiIsConfigHdrMatch (Request, &mHddPasswordVendorGuid, mHddPasswordVendorStorageName)) {
2171 return EFI_NOT_FOUND;
2174 ConfigRequestHdr =
NULL;
2175 ConfigRequest =
NULL;
2176 AllocatedRequest =
FALSE;
2179 Private = HDD_PASSWORD_DXE_PRIVATE_FROM_THIS (This);
2181 ASSERT (IfrData !=
NULL);
2182 if (Private->Current !=
NULL) {
2190 ConfigRequest = Request;
2191 if ((Request ==
NULL) || (
StrStr (Request, L
"OFFSET") ==
NULL)) {
2197 ConfigRequestHdr =
HiiConstructConfigHdr (&mHddPasswordVendorGuid, mHddPasswordVendorStorageName, Private->DriverHandle);
2198 Size = (
StrLen (ConfigRequestHdr) + 32 + 1) *
sizeof (CHAR16);
2200 ASSERT (ConfigRequest !=
NULL);
2201 AllocatedRequest =
TRUE;
2202 UnicodeSPrint (ConfigRequest, Size, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
2218 if (AllocatedRequest) {
2220 ConfigRequest =
NULL;
2226 if (Request ==
NULL) {
2228 }
else if (
StrStr (Request, L
"OFFSET") ==
NULL) {
2229 *Progress = Request +
StrLen (Request);
2272 IN CONST EFI_STRING Configuration,
2273 OUT EFI_STRING *Progress
2276 if ((Configuration ==
NULL) || (Progress ==
NULL)) {
2277 return EFI_INVALID_PARAMETER;
2284 if (!
HiiIsConfigHdrMatch (Configuration, &mHddPasswordVendorGuid, mHddPasswordVendorStorageName)) {
2285 *Progress = Configuration;
2286 return EFI_NOT_FOUND;
2289 *Progress = Configuration +
StrLen (Configuration);
2323 IN EFI_BROWSER_ACTION Action,
2324 IN EFI_QUESTION_ID QuestionId,
2327 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
2331 EFI_STRING_ID DeviceFormTitleToken;
2335 if (ActionRequest !=
NULL) {
2336 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
2338 return EFI_INVALID_PARAMETER;
2341 if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED)) {
2345 return EFI_UNSUPPORTED;
2348 Private = HDD_PASSWORD_DXE_PRIVATE_FROM_THIS (This);
2354 ASSERT (IfrData !=
NULL);
2357 return EFI_NOT_FOUND;
2360 switch (QuestionId) {
2361 case KEY_HDD_USER_PASSWORD:
2362 if (Action == EFI_BROWSER_ACTION_CHANGED) {
2363 DEBUG ((DEBUG_INFO,
"KEY_HDD_USER_PASSWORD\n"));
2364 ConfigFormEntry = Private->Current;
2365 ConfigFormEntry->IfrData.Request.UserPassword = Value->b;
2367 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
2371 case KEY_HDD_MASTER_PASSWORD:
2372 if (Action == EFI_BROWSER_ACTION_CHANGED) {
2373 DEBUG ((DEBUG_INFO,
"KEY_HDD_MASTER_PASSWORD\n"));
2374 ConfigFormEntry = Private->Current;
2375 ConfigFormEntry->IfrData.Request.MasterPassword = Value->b;
2377 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
2383 if ((QuestionId >= KEY_HDD_DEVICE_ENTRY_BASE) && (QuestionId < (mNumberOfHddDevices + KEY_HDD_DEVICE_ENTRY_BASE))) {
2384 if (Action == EFI_BROWSER_ACTION_CHANGING) {
2389 ASSERT (ConfigFormEntry !=
NULL);
2391 DeviceFormTitleToken = (EFI_STRING_ID)STR_HDD_SECURITY_HD;
2392 HiiSetString (Private->HiiHandle, DeviceFormTitleToken, ConfigFormEntry->HddString,
NULL);
2394 Private->Current = ConfigFormEntry;
2440 IN UINT16 PortMultiplierPort
2445 BOOLEAN EntryExisted;
2447 VOID *StartOpCodeHandle;
2448 VOID *EndOpCodeHandle;
2451 CHAR16 HddString[40];
2455 ConfigFormEntry =
NULL;
2456 EntryExisted =
FALSE;
2461 if ((ConfigFormEntry->Bus == Bus) &&
2462 (ConfigFormEntry->Device == Device) &&
2463 (ConfigFormEntry->Function == Function) &&
2464 (ConfigFormEntry->Port == Port) &&
2465 (ConfigFormEntry->PortMultiplierPort == PortMultiplierPort))
2467 EntryExisted =
TRUE;
2472 if (!EntryExisted) {
2477 if (ConfigFormEntry ==
NULL) {
2478 return EFI_OUT_OF_RESOURCES;
2482 ConfigFormEntry->Controller = Controller;
2483 ConfigFormEntry->Bus = Bus;
2484 ConfigFormEntry->Device = Device;
2485 ConfigFormEntry->Function = Function;
2486 ConfigFormEntry->Port = Port;
2487 ConfigFormEntry->PortMultiplierPort = PortMultiplierPort;
2488 ConfigFormEntry->AtaPassThru = AtaPassThru;
2490 DEBUG ((DEBUG_INFO,
"HddPasswordDxe: Create new form for device[%d][%d] at Bus 0x%x Dev 0x%x Func 0x%x\n", Port, PortMultiplierPort, Bus, Device, Function));
2495 Status = AtaPassThru->BuildDevicePath (
2501 if (EFI_ERROR (Status)) {
2507 if (ConfigFormEntry->DevicePath ==
NULL) {
2508 return EFI_OUT_OF_RESOURCES;
2516 if (EFI_ERROR (Status)) {
2524 UnicodeSPrint (ConfigFormEntry->HddString, sizeof (ConfigFormEntry->HddString), L
"HDD %d:%s", mNumberOfHddDevices, HddString);
2525 ConfigFormEntry->TitleToken =
HiiSetString (HiiHandle, 0, ConfigFormEntry->HddString,
NULL);
2526 ConfigFormEntry->TitleHelpToken =
HiiSetString (HiiHandle, 0, L
"Request to set HDD Password",
NULL);
2530 InsertTailList (&mHddPasswordConfigFormList, &ConfigFormEntry->Link);
2536 ASSERT (StartOpCodeHandle !=
NULL);
2539 ASSERT (EndOpCodeHandle !=
NULL);
2546 StartLabel->
Number = HDD_DEVICE_ENTRY_LABEL;
2553 EndLabel->
Number = HDD_DEVICE_LABEL_END;
2555 mNumberOfHddDevices = 0;
2561 FORMID_HDD_DEVICE_FORM,
2562 ConfigFormEntry->TitleToken,
2563 ConfigFormEntry->TitleHelpToken,
2564 EFI_IFR_FLAG_CALLBACK,
2565 (UINT16)(KEY_HDD_DEVICE_ENTRY_BASE + mNumberOfHddDevices)
2568 mNumberOfHddDevices++;
2573 &mHddPasswordVendorGuid,
2574 FORMID_HDD_MAIN_FORM,
2617 UINT16 PortMultiplierPort;
2628 if (mHddPasswordEndOfDxe) {
2629 gBS->CloseEvent (Event);
2638 Status =
gBS->LocateHandleBuffer (
2640 &gEfiAtaPassThruProtocolGuid,
2645 if (EFI_ERROR (Status)) {
2652 for (Index = 0; Index < HandleCount; Index += 1) {
2653 Controller = HandleBuffer[Index];
2654 Status =
gBS->HandleProtocol (
2656 &gEfiAtaPassThruProtocolGuid,
2657 (VOID **)&AtaPassThru
2659 if (EFI_ERROR (Status)) {
2670 Status =
gBS->HandleProtocol (
2672 &gEfiPciIoProtocolGuid,
2676 if (EFI_ERROR (Status)) {
2680 Status = PciIo->GetLocation (
2688 if (EFI_ERROR (Status)) {
2695 ASSERT (SegNum == 0);
2703 Status = AtaPassThru->GetNextPort (AtaPassThru, &Port);
2704 if (EFI_ERROR (Status)) {
2711 PortMultiplierPort = 0xFFFF;
2713 Status = AtaPassThru->GetNextDevice (AtaPassThru, Port, &PortMultiplierPort);
2714 if (EFI_ERROR (Status)) {
2726 gBS->RestoreTPL (TPL_APPLICATION);
2727 Status =
HddPasswordConfigUpdateForm (Private->HiiHandle, AtaPassThru, PciIo, Controller, BusNum, DevNum, FuncNum, Port, PortMultiplierPort);
2728 gBS->RaiseTPL (TPL_CALLBACK);
2729 if (EFI_ERROR (Status)) {
2760 if (Private ==
NULL) {
2761 return EFI_OUT_OF_RESOURCES;
2764 Private->Signature = HDD_PASSWORD_DXE_PRIVATE_SIGNATURE;
2773 Status =
gBS->InstallMultipleProtocolInterfaces (
2774 &Private->DriverHandle,
2775 &gEfiDevicePathProtocolGuid,
2776 &mHddPasswordHiiVendorDevicePath,
2777 &gEfiHiiConfigAccessProtocolGuid,
2778 &Private->ConfigAccess,
2782 if (EFI_ERROR (Status)) {
2791 &mHddPasswordVendorGuid,
2792 Private->DriverHandle,
2793 HddPasswordDxeStrings,
2797 if (Private->HiiHandle ==
NULL) {
2799 return EFI_OUT_OF_RESOURCES;
2802 *Instance = Private;
2834 if (EFI_ERROR (Status)) {
2842 &gEfiAtaPassThruProtocolGuid,
2849 Status =
gBS->CreateEventEx (
2854 &gEfiEndOfDxeEventGroupGuid,
2862 Status =
gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid,
NULL, (VOID **)&VariablePolicy);
2863 if (!EFI_ERROR (Status)) {
2864 Status = RegisterBasicVariablePolicy (
2866 &mHddPasswordVendorGuid,
2867 HDD_PASSWORD_VARIABLE_NAME,
2868 VARIABLE_POLICY_NO_MIN_SIZE,
2869 VARIABLE_POLICY_NO_MAX_SIZE,
2870 VARIABLE_POLICY_NO_MUST_ATTR,
2871 VARIABLE_POLICY_NO_CANT_ATTR,
2872 VARIABLE_POLICY_TYPE_LOCK_NOW
2874 DEBUG ((DEBUG_INFO,
"%a(): Lock %s variable (%r)\n", __func__, HDD_PASSWORD_VARIABLE_NAME, Status));
#define ATA_ERRREG_ABRT
Aborted Command defined from ATA-1.
#define ATA_STSREG_ERR
Error defined from ATA-1.
#define ATA_CMD_IDENTIFY_DRIVE
defined from ATA-3
UINTN EFIAPI Sha256GetContextSize(VOID)
BOOLEAN EFIAPI RandomBytes(OUT UINT8 *Output, IN UINTN Size)
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
#define SHA256_DIGEST_SIZE
BOOLEAN EFIAPI RandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI UnicodeStrToAsciiStrS(IN CONST CHAR16 *Source, OUT CHAR8 *Destination, IN UINTN DestMax)
#define BASE_LIST_FOR_EACH(Entry, ListHead)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
BOOLEAN GetSavedHddPasswordVariable(IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry, OUT HDD_PASSWORD_VARIABLE *HddPasswordVariable)
EFI_STATUS ValidateHddPassword(IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry, IN CHAR8 *Password)
EFI_STATUS SetHddPassword(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN CHAR8 Identifier, IN CHAR8 SecurityLevel, IN CHAR16 MasterPasswordIdentifier, IN CHAR8 *Password)
EFI_STATUS UnlockHddPassword(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN CHAR8 Identifier, IN CHAR8 *Password)
VOID GenSalt(IN OUT UINT8 *SaltValue)
EFI_STATUS EFIAPI HddPasswordFormRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
EFI_STATUS PopupHddPasswordInputWindows(IN CHAR16 *PopUpString1, IN CHAR16 *PopUpString2, IN OUT CHAR8 *Password)
VOID ProcessHddPasswordRequestSetUserPwd(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
EFI_STATUS EFIAPI HddPasswordDxeInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS DisableHddPassword(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN CHAR8 Identifier, IN CHAR8 *Password)
VOID HddPasswordRequestPassword(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
VOID SaveDeviceInfo(IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry, IN OUT HDD_PASSWORD_DEVICE_INFO *TempDevInfo)
EFI_STATUS EFIAPI HddPasswordFormExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
VOID EFIAPI HddPasswordEndOfDxeEventNotify(EFI_EVENT Event, VOID *Context)
VOID GetHddPasswordSecurityStatus(IN ATA_IDENTIFY_DATA *IdentifyData, IN OUT HDD_PASSWORD_CONFIG *IfrData)
VOID SaveHddPasswordRequest(IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
BOOLEAN GenerateCredential(IN UINT8 *Buffer, IN UINTN BufferSize, IN UINT8 *SaltValue, OUT UINT8 *Credential)
EFI_STATUS GetHddDeviceIdentifyData(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN ATA_IDENTIFY_DATA *IdentifyData)
VOID GetHddDeviceModelNumber(IN ATA_IDENTIFY_DATA *IdentifyData, IN OUT CHAR16 *String)
VOID EFIAPI HddPasswordNotificationEvent(IN EFI_EVENT Event, IN VOID *Context)
BOOLEAN PasswordIsFullZero(IN CHAR8 *Password)
EFI_STATUS HddPasswordConfigFormInit(OUT HDD_PASSWORD_DXE_PRIVATE_DATA **Instance)
VOID GetSavedHddPasswordRequest(IN OUT HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
HDD_PASSWORD_CONFIG_FORM_ENTRY * HddPasswordGetConfigFormEntryByIndex(IN UINT32 Index)
VOID ProcessHddPasswordRequestSetMasterPwd(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
VOID BuildHddPasswordDeviceInfo(VOID)
EFI_STATUS EFIAPI HddPasswordFormCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
VOID SaveHddPasswordVariable(IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry, IN CHAR8 *Password)
EFI_STATUS FreezeLockDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort)
VOID ProcessHddPasswordRequest(IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN HDD_PASSWORD_CONFIG_FORM_ENTRY *ConfigFormEntry)
EFI_STATUS HddPasswordConfigUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru, IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_HANDLE Controller, IN UINTN Bus, IN UINTN Device, IN UINTN Function, IN UINT16 Port, IN UINT16 PortMultiplierPort)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
BOOLEAN EFIAPI HiiGetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, OUT UINT8 *Buffer)
UINT8 *EFIAPI HiiCreateGotoOpCode(IN VOID *OpCodeHandle, IN EFI_FORM_ID FormId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_QUESTION_ID QuestionId)
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
BOOLEAN EFIAPI HiiSetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, IN CONST UINT8 *Buffer, IN CONST CHAR16 *RequestElement OPTIONAL)
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
BOOLEAN EFIAPI HiiIsConfigHdrMatch(IN CONST EFI_STRING ConfigHdr, IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
#define EFI_IFR_EXTEND_OP_LABEL
RETURN_STATUS EFIAPI SetLockBoxAttributes(IN GUID *Guid, IN UINT64 Attributes)
RETURN_STATUS EFIAPI RestoreLockBox(IN GUID *Guid, IN VOID *Buffer OPTIONAL, IN OUT UINTN *Length OPTIONAL)
RETURN_STATUS EFIAPI UpdateLockBox(IN GUID *Guid, IN UINTN Offset, IN VOID *Buffer, IN UINTN Length)
RETURN_STATUS EFIAPI SaveLockBox(IN GUID *Guid, IN VOID *Buffer, IN UINTN Length)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define BASE_CR(Record, TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL
#define PcdGetBool(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID *EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
#define EFI_SIZE_TO_PAGES(Size)
EFI_HII_CONFIG_ROUTING_PROTOCOL * gHiiConfigRouting
EFI_STATUS EFIAPI GetVariable2(IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
#define EFI_VARIABLE_NON_VOLATILE
EFI_ATA_STATUS_BLOCK * Asb
EFI_ATA_PASS_THRU_LENGTH Length
EFI_ATA_PASS_THRU_CMD_PROTOCOL Protocol
EFI_ATA_COMMAND_BLOCK * Acb
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut