MdeModulePkg/NvmExpressDxe: Add SecurityStorageProtocol support

Produce this protocol for each namespace at NVMe controller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tian Feng <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17638 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Tian Feng
2015-06-16 01:04:47 +00:00
committed by erictian
parent 9c4ae34ebb
commit 754b489b46
8 changed files with 628 additions and 42 deletions

View File

@@ -154,6 +154,12 @@ EnumerateNvmeDevNamespace (
Device->BlockIo.WriteBlocks = NvmeBlockIoWriteBlocks;
Device->BlockIo.FlushBlocks = NvmeBlockIoFlushBlocks;
//
// Create StorageSecurityProtocol Instance
//
Device->StorageSecurity.ReceiveData = NvmeStorageSecurityReceiveData;
Device->StorageSecurity.SendData = NvmeStorageSecuritySendData;
//
// Create DiskInfo Protocol instance
//
@@ -211,6 +217,32 @@ EnumerateNvmeDevNamespace (
if(EFI_ERROR(Status)) {
goto Exit;
}
//
// Check if the NVMe controller supports the Security Send and Security Receive commands
//
if ((Private->ControllerData->Oacs & SECURITY_SEND_RECEIVE_SUPPORTED) != 0) {
Status = gBS->InstallProtocolInterface (
&Device->DeviceHandle,
&gEfiStorageSecurityCommandProtocolGuid,
EFI_NATIVE_INTERFACE,
&Device->StorageSecurity
);
if(EFI_ERROR(Status)) {
gBS->UninstallMultipleProtocolInterfaces (
&Device->DeviceHandle,
&gEfiDevicePathProtocolGuid,
Device->DevicePath,
&gEfiBlockIoProtocolGuid,
&Device->BlockIo,
&gEfiDiskInfoProtocolGuid,
&Device->DiskInfo,
NULL
);
goto Exit;
}
}
gBS->OpenProtocol (
Private->ControllerHandle,
&gEfiNvmExpressPassThruProtocolGuid,
@@ -339,6 +371,7 @@ UnregisterNvmeNamespace (
EFI_BLOCK_IO_PROTOCOL *BlockIo;
NVME_DEVICE_PRIVATE_DATA *Device;
NVME_CONTROLLER_PRIVATE_DATA *Private;
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;
BlockIo = NULL;
@@ -394,6 +427,37 @@ UnregisterNvmeNamespace (
return Status;
}
//
// If Storage Security Command Protocol is installed, then uninstall this protocol.
//
Status = gBS->OpenProtocol (
Handle,
&gEfiStorageSecurityCommandProtocolGuid,
(VOID **) &StorageSecurity,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
Status = gBS->UninstallProtocolInterface (
Handle,
&gEfiStorageSecurityCommandProtocolGuid,
&Device->StorageSecurity
);
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
Controller,
&gEfiNvmExpressPassThruProtocolGuid,
(VOID **) &Private->Passthru,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
return Status;
}
}
if(Device->DevicePath != NULL) {
FreePool (Device->DevicePath);
}
@@ -480,8 +544,8 @@ NvmExpressDriverBindingSupported (
if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
(DevicePathNode.DevPath->SubType != MSG_NVME_NAMESPACE_DP) ||
DevicePathNodeLength(DevicePathNode.DevPath) != sizeof(NVME_NAMESPACE_DEVICE_PATH)) {
return EFI_UNSUPPORTED;
(DevicePathNodeLength(DevicePathNode.DevPath) != sizeof(NVME_NAMESPACE_DEVICE_PATH))) {
return EFI_UNSUPPORTED;
}
}
}