11EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID;
93 IN UINT8 SecurityProtocolId,
94 IN UINT16 SecurityProtocolSpecificData,
96 OUT VOID *PayloadBuffer,
102 PeiDev = OPAL_PEI_DEVICE_FROM_THIS (This);
103 if (PeiDev ==
NULL) {
104 return EFI_DEVICE_ERROR;
107 return PeiDev->SscPpi->ReceiveData (
110 SSC_PPI_GENERIC_TIMEOUT,
112 SecurityProtocolSpecificData,
188 IN UINT8 SecurityProtocolId,
189 IN UINT16 SecurityProtocolSpecificData,
191 IN VOID *PayloadBuffer
196 PeiDev = OPAL_PEI_DEVICE_FROM_THIS (This);
197 if (PeiDev ==
NULL) {
198 return EFI_DEVICE_ERROR;
201 return PeiDev->SscPpi->SendData (
204 SSC_PPI_GENERIC_TIMEOUT,
206 SecurityProtocolSpecificData,
225 BOOLEAN *BlockSidSupported
231 UINT16 OpalBaseComId;
234 Session.Sscp = &OpalDev->Sscp;
238 if (Ret != TcgResultSuccess) {
242 Session.OpalBaseComId = OpalBaseComId;
243 *BlockSidSupported = SupportedAttributes.BlockSid == 1 ?
TRUE :
FALSE;
246 if (Ret != TcgResultSuccess) {
266 BOOLEAN BlockSidSupport;
267 UINT32 PpStorageFlags;
268 BOOLEAN BlockSIDEnabled;
270 BlockSidSupport =
FALSE;
272 ZeroMem (&Session,
sizeof (Session));
273 Session.Sscp = &OpalDev->Sscp;
275 Session.OpalBaseComId = OpalDev->Device->OpalBaseComId;
279 OpalDev->Device->Password,
280 OpalDev->Device->PasswordLength,
286 "%a() OpalUtilUpdateGlobalLockingRange() Result = 0x%x\n",
293 if ((PpStorageFlags & TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID) != 0) {
294 BlockSIDEnabled =
TRUE;
296 BlockSIDEnabled =
FALSE;
299 if (BlockSIDEnabled && BlockSidSupport) {
300 DEBUG ((DEBUG_INFO,
"OpalPassword: S3 phase send BlockSid command to device!\n"));
301 ZeroMem (&Session,
sizeof (Session));
302 Session.Sscp = &OpalDev->Sscp;
304 Session.OpalBaseComId = OpalDev->Device->OpalBaseComId;
308 "%a() OpalBlockSid() Result = 0x%x\n",
327 UINT8 *DevInfoBuffer;
332 UINTN SscDevicePathLength;
334 UINTN SscDeviceIndex;
340 DevInfoBuffer = &DummyData;
341 DevInfoLength =
sizeof (DummyData);
342 Status =
RestoreLockBox (&mOpalDeviceLockBoxGuid, DevInfoBuffer, &DevInfoLength);
343 if (Status == EFI_BUFFER_TOO_SMALL) {
345 if (DevInfoBuffer !=
NULL) {
346 Status =
RestoreLockBox (&mOpalDeviceLockBoxGuid, DevInfoBuffer, &DevInfoLength);
350 if ((DevInfoBuffer ==
NULL) || (DevInfoBuffer == &DummyData)) {
352 }
else if (EFI_ERROR (Status)) {
360 Status = SscPpi->GetNumberofDevices (SscPpi, &SscDeviceNum);
361 if (EFI_ERROR (Status)) {
365 for (SscDeviceIndex = 1; SscDeviceIndex <= SscDeviceNum; SscDeviceIndex++) {
366 Status = SscPpi->GetDevicePath (
369 &SscDevicePathLength,
383 (
UINTN)DevInfo < ((
UINTN)DevInfoBuffer + DevInfoLength);
389 if ((DevInfo->DevicePathLength >= SscDevicePathLength) &&
396 OpalDev.Signature = OPAL_PEI_DEVICE_SIGNATURE;
399 OpalDev.Device = DevInfo;
400 OpalDev.Context =
NULL;
401 OpalDev.SscPpi = SscPpi;
402 OpalDev.DeviceIndex = SscDeviceIndex;
410 ZeroMem (DevInfoBuffer, DevInfoLength);
434 DEBUG ((DEBUG_INFO,
"%a entered at S3 resume!\n", __func__));
438 DEBUG ((DEBUG_INFO,
"%a exit at S3 resume!\n", __func__));
444 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
445 &gEdkiiPeiStorageSecurityCommandPpiGuid,
469 if ((EFI_ERROR (Status)) || (BootMode != BOOT_ON_S3_RESUME)) {
470 return EFI_UNSUPPORTED;
473 DEBUG ((DEBUG_INFO,
"%a: Enters in S3 path.\n", __func__));
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
RETURN_STATUS EFIAPI RestoreLockBox(IN GUID *Guid, IN VOID *Buffer OPTIONAL, IN OUT UINTN *Length OPTIONAL)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
BOOLEAN IsOpalDeviceLocked(OPAL_PEI_DEVICE *OpalDev, BOOLEAN *BlockSidSupported)
EFI_STATUS EFIAPI OpalPasswordStorageSecurityPpiNotify(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, IN VOID *Ppi)
EFI_STATUS EFIAPI OpalPasswordPeiInit(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
VOID UnlockOpalPassword(IN OPAL_PEI_DEVICE *OpalDev)
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)
VOID UnlockOpalPasswordDevices(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *SscPpi)
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)
VOID * EFI_PEI_FILE_HANDLE
VOID *EFIAPI AllocatePages(IN UINTN Pages)
UINT32 EFIAPI Tcg2PhysicalPresenceLibGetManagementFlags(VOID)
TCG_RESULT EFIAPI OpalGetSupportedAttributesInfo(OPAL_SESSION *Session, OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes, UINT16 *OpalBaseComId)
TCG_RESULT EFIAPI OpalBlockSid(OPAL_SESSION *Session, BOOLEAN HardwareReset)
TCG_RESULT EFIAPI OpalUtilUpdateGlobalLockingRange(OPAL_SESSION *LockingSpSession, const VOID *Password, UINT32 PasswordLength, BOOLEAN ReadLocked, BOOLEAN WriteLocked)
TCG_RESULT EFIAPI OpalGetLockingInfo(OPAL_SESSION *Session, TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature)
BOOLEAN OpalDeviceLocked(OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes, TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_SIZE_TO_PAGES(Size)