summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c
diff options
context:
space:
mode:
Diffstat (limited to 'SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c')
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c321
1 files changed, 0 insertions, 321 deletions
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c
index 7657bb26e2..01c316d597 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalNvmeMode.c
@@ -794,46 +794,6 @@ NvmeCreatePrpList (
}
/**
- Check whether there are available command slots.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[in] Qid - Queue index
-
- @retval EFI_SUCCESS - Available command slot is found
- @retval EFI_NOT_READY - No available command slot is found
- @retval EFI_DEVICE_ERROR - Error occurred on device side.
-
-**/
-EFI_STATUS
-NvmeHasFreeCmdSlot (
- IN NVME_CONTEXT *Nvme,
- IN UINT8 Qid
- )
-{
- return TRUE;
-}
-
-/**
- Check whether all command slots are clean.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[in] Qid - Queue index
-
- @retval EFI_SUCCESS - All command slots are clean
- @retval EFI_NOT_READY - Not all command slots are clean
- @retval EFI_DEVICE_ERROR - Error occurred on device side.
-
-**/
-EFI_STATUS
-NvmeIsAllCmdSlotClean (
- IN NVME_CONTEXT *Nvme,
- IN UINT8 Qid
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
Waits until all NVME commands completed.
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
@@ -1861,284 +1821,3 @@ NvmeControllerExit (
Nvme->State = NvmeStatusUnknown;
return Status;
}
-
-/**
- Read sector Data from the NVMe device.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[in,out] Buffer - The Buffer used to store the Data read from the device.
- @param[in] Lba - The start block number.
- @param[in] Blocks - Total block number to be read.
-
- @retval EFI_SUCCESS - Datum are read from the device.
- @retval Others - Fail to read all the datum.
-
-**/
-EFI_STATUS
-NvmeReadSectors (
- IN NVME_CONTEXT *Nvme,
- IN OUT UINT64 Buffer,
- IN UINT64 Lba,
- IN UINT32 Blocks
- )
-{
- UINT32 Bytes;
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
- EFI_STATUS Status;
- UINT32 BlockSize;
-
- BlockSize = Nvme->BlockSize;
- Bytes = Blocks * BlockSize;
-
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
-
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
-
- CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_READ_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Nvme->Cid[NVME_IO_QUEUE]++;
- CommandPacket.NvmeCmd->Nsid = Nvme->Nsid;
- CommandPacket.TransferBuffer = Buffer;
-
- CommandPacket.TransferLength = Bytes;
- CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
-
- CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
- CommandPacket.NvmeCmd->Cdw11 = (UINT32)(RShiftU64 (Lba, 32));
- CommandPacket.NvmeCmd->Cdw12 = (Blocks - 1) & 0xFFFF;
-
- CommandPacket.NvmeCmd->Flags = CDW10_VALID | CDW11_VALID | CDW12_VALID;
-
- Status = NvmePassThru (
- Nvme,
- Nvme->Nsid,
- 0,
- &CommandPacket
- );
-
- return Status;
-}
-
-/**
- Write sector Data to the NVMe device.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[in] Buffer - The Buffer to be written into the device.
- @param[in] Lba - The start block number.
- @param[in] Blocks - Total block number to be written.
-
- @retval EFI_SUCCESS - Datum are written into the Buffer.
- @retval Others - Fail to write all the datum.
-
-**/
-EFI_STATUS
-NvmeWriteSectors (
- IN NVME_CONTEXT *Nvme,
- IN UINT64 Buffer,
- IN UINT64 Lba,
- IN UINT32 Blocks
- )
-{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
- EFI_STATUS Status;
- UINT32 Bytes;
- UINT32 BlockSize;
-
- BlockSize = Nvme->BlockSize;
- Bytes = Blocks * BlockSize;
-
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
-
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
-
- CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_WRITE_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Nvme->Cid[NVME_IO_QUEUE]++;
- CommandPacket.NvmeCmd->Nsid = Nvme->Nsid;
- CommandPacket.TransferBuffer = Buffer;
-
- CommandPacket.TransferLength = Bytes;
- CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
-
- CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
- CommandPacket.NvmeCmd->Cdw11 = (UINT32)(RShiftU64 (Lba, 32));
- CommandPacket.NvmeCmd->Cdw12 = (Blocks - 1) & 0xFFFF;
-
- CommandPacket.MetadataBuffer = (UINT64)(UINTN)NULL;
- CommandPacket.MetadataLength = 0;
-
- CommandPacket.NvmeCmd->Flags = CDW10_VALID | CDW11_VALID | CDW12_VALID;
-
- Status = NvmePassThru (
- Nvme,
- Nvme->Nsid,
- 0,
- &CommandPacket
- );
-
- return Status;
-}
-
-/**
- Flushes all modified Data to the device.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
-
- @retval EFI_SUCCESS - Datum are written into the Buffer.
- @retval Others - Fail to write all the datum.
-
-**/
-EFI_STATUS
-NvmeFlush (
- IN NVME_CONTEXT *Nvme
- )
-{
- NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- NVM_EXPRESS_COMMAND Command;
- NVM_EXPRESS_RESPONSE Response;
- EFI_STATUS Status;
-
- ZeroMem (&CommandPacket, sizeof(NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(NVM_EXPRESS_COMMAND));
- ZeroMem (&Response, sizeof(NVM_EXPRESS_RESPONSE));
-
- CommandPacket.NvmeCmd = &Command;
- CommandPacket.NvmeResponse = &Response;
-
- CommandPacket.NvmeCmd->Cdw0.Opcode = NVME_IO_FLUSH_OPC;
- CommandPacket.NvmeCmd->Cdw0.Cid = Nvme->Cid[NVME_IO_QUEUE]++;
- CommandPacket.NvmeCmd->Nsid = Nvme->Nsid;
- CommandPacket.CommandTimeout = NVME_GENERIC_TIMEOUT;
- CommandPacket.QueueId = NVME_IO_QUEUE;
-
- Status = NvmePassThru (
- Nvme,
- Nvme->Nsid,
- 0,
- &CommandPacket
- );
- if (!EFI_ERROR (Status)) {
- Status = NvmeWaitAllComplete (Nvme, CommandPacket.QueueId);
- }
-
- return Status;
-}
-
-/**
- Read some blocks from the device.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[out] Buffer - The Buffer used to store the Data read from the device.
- @param[in] Lba - The start block number.
- @param[in] Blocks - Total block number to be read.
-
- @retval EFI_SUCCESS - Datum are read from the device.
- @retval Others - Fail to read all the datum.
-
-**/
-EFI_STATUS
-NvmeRead (
- IN NVME_CONTEXT *Nvme,
- OUT UINT64 Buffer,
- IN UINT64 Lba,
- IN UINTN Blocks
- )
-{
- EFI_STATUS Status;
- UINT32 BlockSize;
- UINT32 MaxTransferBlocks;
-
- ASSERT (Blocks <= NVME_MAX_SECTORS);
- Status = EFI_SUCCESS;
- BlockSize = Nvme->BlockSize;
- if (Nvme->ControllerData->Mdts != 0) {
- MaxTransferBlocks = (1 << (Nvme->ControllerData->Mdts)) * (1 << (Nvme->Cap.Mpsmin + 12)) / BlockSize;
- } else {
- MaxTransferBlocks = 1024;
- }
-
- while (Blocks > 0) {
- if (Blocks > MaxTransferBlocks) {
- Status = NvmeReadSectors (Nvme, Buffer, Lba, MaxTransferBlocks);
-
- Blocks -= MaxTransferBlocks;
- Buffer += (MaxTransferBlocks * BlockSize);
- Lba += MaxTransferBlocks;
- } else {
- Status = NvmeReadSectors (Nvme, Buffer, Lba, (UINT32) Blocks);
- Blocks = 0;
- }
-
- if (EFI_ERROR(Status)) {
- DEBUG ((DEBUG_ERROR, "NvmeRead fail, Status = %r\n", Status));
- break;
- }
- }
-
- return Status;
-}
-
-/**
- Write some blocks to the device.
-
- @param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
- @param[in] Buffer - The Buffer to be written into the device.
- @param[in] Lba - The start block number.
- @param[in] Blocks - Total block number to be written.
-
- @retval EFI_SUCCESS - Datum are written into the Buffer.
- @retval Others - Fail to write all the datum.
-
-**/
-EFI_STATUS
-NvmeWrite (
- IN NVME_CONTEXT *Nvme,
- IN UINT64 Buffer,
- IN UINT64 Lba,
- IN UINTN Blocks
- )
-{
- EFI_STATUS Status;
- UINT32 BlockSize;
- UINT32 MaxTransferBlocks;
-
- ASSERT (Blocks <= NVME_MAX_SECTORS);
- Status = EFI_SUCCESS;
- BlockSize = Nvme->BlockSize;
-
- if (Nvme->ControllerData->Mdts != 0) {
- MaxTransferBlocks = (1 << (Nvme->ControllerData->Mdts)) * (1 << (Nvme->Cap.Mpsmin + 12)) / BlockSize;
- } else {
- MaxTransferBlocks = 1024;
- }
-
- while (Blocks > 0) {
- if (Blocks > MaxTransferBlocks) {
- Status = NvmeWriteSectors (Nvme, Buffer, Lba, MaxTransferBlocks);
-
- Blocks -= MaxTransferBlocks;
- Buffer += (MaxTransferBlocks * BlockSize);
- Lba += MaxTransferBlocks;
- } else {
- Status = NvmeWriteSectors (Nvme, Buffer, Lba, (UINT32) Blocks);
- Blocks = 0;
- }
-
- if (EFI_ERROR(Status)) {
- DEBUG ((DEBUG_ERROR, "NvmeWrite fail, Status = %r\n", Status));
- break;
- }
- }
-
- return Status;
-}