mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 06:04:52 +02:00
SecurityPkg: Remove dead code and inf redundant definitions.
Fix BZ1065, https://bugzilla.tianocore.org/show_bug.cgi?id=1065. Remove dead code and inf redundant definitions from SecurityPkg. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Cc: Zhang Chao B <chao.b.zhang@intel.com> Reviewed-by: Zhang Chao B <chao.b.zhang@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
parent
56fbaecb15
commit
f4c8c1bbf1
@ -43,7 +43,6 @@
|
|||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
UefiBootServicesTableLib
|
UefiBootServicesTableLib
|
||||||
UefiRuntimeServicesTableLib
|
UefiRuntimeServicesTableLib
|
||||||
ReportStatusCodeLib
|
|
||||||
DebugLib
|
DebugLib
|
||||||
UefiLib
|
UefiLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
|
@ -969,58 +969,6 @@ AhciReset (
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Send Buffer cmd to specific device.
|
|
||||||
|
|
||||||
@param[in] AhciContext The pointer to the AHCI_CONTEXT.
|
|
||||||
@param[in] Port The port number of attached ATA device.
|
|
||||||
@param[in] PortMultiplier The port number of port multiplier of attached ATA device.
|
|
||||||
@param[in, out] Buffer The Data Buffer to store IDENTIFY PACKET Data.
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR The cmd abort with error occurs.
|
|
||||||
@retval EFI_TIMEOUT The operation is time out.
|
|
||||||
@retval EFI_UNSUPPORTED The device is not ready for executing.
|
|
||||||
@retval EFI_SUCCESS The cmd executes successfully.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
AhciIdentify (
|
|
||||||
IN AHCI_CONTEXT *AhciContext,
|
|
||||||
IN UINT8 Port,
|
|
||||||
IN UINT8 PortMultiplier,
|
|
||||||
IN OUT ATA_IDENTIFY_DATA *Buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
|
|
||||||
|
|
||||||
if (AhciContext == NULL || Buffer == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
|
|
||||||
|
|
||||||
AtaCommandBlock.AtaCommand = ATA_CMD_IDENTIFY_DRIVE;
|
|
||||||
AtaCommandBlock.AtaSectorCount = 1;
|
|
||||||
|
|
||||||
Status = AhciPioTransfer (
|
|
||||||
AhciContext,
|
|
||||||
Port,
|
|
||||||
PortMultiplier,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
TRUE,
|
|
||||||
&AtaCommandBlock,
|
|
||||||
NULL,
|
|
||||||
Buffer,
|
|
||||||
sizeof (ATA_IDENTIFY_DATA),
|
|
||||||
ATA_TIMEOUT
|
|
||||||
);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate transfer-related data struct which is used at AHCI mode.
|
Allocate transfer-related data struct which is used at AHCI mode.
|
||||||
|
|
||||||
|
@ -293,29 +293,6 @@ typedef struct {
|
|||||||
UINT32 AhciBar;
|
UINT32 AhciBar;
|
||||||
} AHCI_CONTEXT;
|
} AHCI_CONTEXT;
|
||||||
|
|
||||||
/**
|
|
||||||
Send Buffer cmd to specific device.
|
|
||||||
|
|
||||||
@param AhciContext The pointer to the AHCI_CONTEXT.
|
|
||||||
@param Port The number of port.
|
|
||||||
@param PortMultiplier The timeout Value of stop.
|
|
||||||
@param Buffer The Data Buffer to store IDENTIFY PACKET Data.
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR The cmd abort with error occurs.
|
|
||||||
@retval EFI_TIMEOUT The operation is time out.
|
|
||||||
@retval EFI_UNSUPPORTED The device is not ready for executing.
|
|
||||||
@retval EFI_SUCCESS The cmd executes successfully.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
AhciIdentify (
|
|
||||||
IN AHCI_CONTEXT *AhciContext,
|
|
||||||
IN UINT8 Port,
|
|
||||||
IN UINT8 PortMultiplier,
|
|
||||||
IN OUT ATA_IDENTIFY_DATA *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate transfer-related data struct which is used at AHCI mode.
|
Allocate transfer-related data struct which is used at AHCI mode.
|
||||||
|
|
||||||
|
@ -285,17 +285,6 @@ OpalHiiAddPackages(
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether enable feature or not.
|
|
||||||
|
|
||||||
@retval Return the disk number.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINT8
|
|
||||||
HiiGetNumConfigRequiredOpalDisksCB(
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the driver name.
|
Returns the driver name.
|
||||||
|
|
||||||
|
@ -15,56 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include "OpalHii.h"
|
#include "OpalHii.h"
|
||||||
|
|
||||||
/**
|
|
||||||
Get Opal var name.
|
|
||||||
The return Value must be freed by caller if not NULL
|
|
||||||
|
|
||||||
@param OpalDisk The disk.
|
|
||||||
@param Prefix The prefix string.
|
|
||||||
|
|
||||||
@retval The var name string.
|
|
||||||
|
|
||||||
**/
|
|
||||||
CHAR16*
|
|
||||||
OpalDriverGetOpalVarName(
|
|
||||||
OPAL_DISK *OpalDisk,
|
|
||||||
const CHAR16 *Prefix
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OPAL_DRIVER_DEVICE* Dev;
|
|
||||||
UINTN PrefixLen;
|
|
||||||
UINTN NameLen;
|
|
||||||
UINTN VarNameLen;
|
|
||||||
CHAR16* VarName;
|
|
||||||
|
|
||||||
Dev = DRIVER_DEVICE_FROM_OPALDISK(OpalDisk);
|
|
||||||
if (Dev == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefixLen = StrLen(Prefix);
|
|
||||||
|
|
||||||
NameLen = 0;
|
|
||||||
if (Dev->Name16 != NULL) {
|
|
||||||
NameLen = StrLen(Dev->Name16);
|
|
||||||
}
|
|
||||||
|
|
||||||
VarNameLen = PrefixLen + NameLen;
|
|
||||||
|
|
||||||
VarName = (CHAR16*)AllocateZeroPool((VarNameLen + 1) * sizeof(CHAR16));
|
|
||||||
if (VarName == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyMem(VarName, Prefix, PrefixLen * sizeof(CHAR16));
|
|
||||||
if (Dev->Name16 != NULL) {
|
|
||||||
CopyMem(VarName + PrefixLen, Dev->Name16, NameLen * sizeof(CHAR16));
|
|
||||||
}
|
|
||||||
VarName[VarNameLen] = 0;
|
|
||||||
|
|
||||||
return VarName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the driver image handle.
|
Get the driver image handle.
|
||||||
|
|
||||||
@ -79,43 +29,6 @@ HiiGetDriverImageHandleCB(
|
|||||||
return gImageHandle;
|
return gImageHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether enable feature or not.
|
|
||||||
|
|
||||||
@retval Return the disk number.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINT8
|
|
||||||
HiiGetNumConfigRequiredOpalDisksCB(
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UINT8 NumDisks;
|
|
||||||
UINT8 NumLockedOpalDisks;
|
|
||||||
OPAL_DISK *OpalDisk;
|
|
||||||
UINT8 Index;
|
|
||||||
|
|
||||||
NumLockedOpalDisks = 0;
|
|
||||||
|
|
||||||
NumDisks = GetDeviceCount();
|
|
||||||
|
|
||||||
for (Index = 0; Index < NumDisks; Index++) {
|
|
||||||
OpalDisk = HiiGetOpalDiskCB(Index);
|
|
||||||
|
|
||||||
if (OpalDisk != NULL) {
|
|
||||||
if (!OpalFeatureEnabled (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) {
|
|
||||||
DEBUG ((DEBUG_INFO, "Ignoring disk %u because feature is disabled or health has already been inspected\n", Index));
|
|
||||||
} else if (OpalDeviceLocked (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) {
|
|
||||||
NumLockedOpalDisks++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NumLockedOpalDisks;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the opaque pointer to a physical disk context.
|
Returns the opaque pointer to a physical disk context.
|
||||||
|
|
||||||
|
@ -793,46 +793,6 @@ NvmeCreatePrpList (
|
|||||||
return PrpListPhyAddr;
|
return PrpListPhyAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
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.
|
Waits until all NVME commands completed.
|
||||||
|
|
||||||
@ -1861,284 +1821,3 @@ NvmeControllerExit (
|
|||||||
Nvme->State = NvmeStatusUnknown;
|
Nvme->State = NvmeStatusUnknown;
|
||||||
return Status;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -300,134 +300,6 @@ NvmeControllerExit (
|
|||||||
IN NVME_CONTEXT *Nvme
|
IN NVME_CONTEXT *Nvme
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Security send and receive commands.
|
Security send and receive commands.
|
||||||
|
|
||||||
|
@ -71,8 +71,6 @@
|
|||||||
gEfiComponentNameProtocolGuid ## PRODUCES
|
gEfiComponentNameProtocolGuid ## PRODUCES
|
||||||
gEfiComponentName2ProtocolGuid ## PRODUCES
|
gEfiComponentName2ProtocolGuid ## PRODUCES
|
||||||
gEfiBlockIoProtocolGuid ## CONSUMES
|
gEfiBlockIoProtocolGuid ## CONSUMES
|
||||||
gEfiPciIoProtocolGuid ## CONSUMES
|
|
||||||
gEfiDevicePathToTextProtocolGuid ## CONSUMES
|
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
|
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
TimerLib
|
TimerLib
|
||||||
HobLib
|
|
||||||
LockBoxLib
|
LockBoxLib
|
||||||
TcgStorageOpalLib
|
TcgStorageOpalLib
|
||||||
Tcg2PhysicalPresenceLib
|
Tcg2PhysicalPresenceLib
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
BaseLib
|
BaseLib
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
MemoryAllocationLib
|
|
||||||
PeiServicesLib
|
PeiServicesLib
|
||||||
PeimEntryPoint
|
PeimEntryPoint
|
||||||
DebugLib
|
DebugLib
|
||||||
|
@ -92,7 +92,6 @@
|
|||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiTcg2ProtocolGuid ## PRODUCES
|
gEfiTcg2ProtocolGuid ## PRODUCES
|
||||||
gEfiTcg2FinalEventsTableGuid ## PRODUCES
|
gEfiTcg2FinalEventsTableGuid ## PRODUCES
|
||||||
gEfiAcpiTableProtocolGuid ## NOTIFY
|
|
||||||
gEfiMpServiceProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiMpServiceProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiVariableWriteArchProtocolGuid ## NOTIFY
|
gEfiVariableWriteArchProtocolGuid ## NOTIFY
|
||||||
gEfiResetNotificationProtocolGuid ## CONSUMES
|
gEfiResetNotificationProtocolGuid ## CONSUMES
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
TpmMeasurementLib
|
TpmMeasurementLib
|
||||||
Tpm2CommandLib
|
Tpm2CommandLib
|
||||||
Tcg2PhysicalPresenceLib
|
Tcg2PhysicalPresenceLib
|
||||||
IoLib
|
|
||||||
PcdLib
|
PcdLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence"
|
## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence"
|
||||||
gEfiPhysicalPresenceGuid
|
gEfiPhysicalPresenceGuid
|
||||||
|
|
||||||
gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## GUID # HII opcode
|
|
||||||
## PRODUCES ## HII
|
## PRODUCES ## HII
|
||||||
## CONSUMES ## HII
|
## CONSUMES ## HII
|
||||||
gTcgConfigFormSetGuid
|
gTcgConfigFormSetGuid
|
||||||
|
@ -105,7 +105,6 @@
|
|||||||
gEfiCertPkcs7Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
gEfiCertPkcs7Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
||||||
gEfiCertTypeRsa2048Sha256Guid ## SOMETIMES_CONSUMES ## GUID # Unique ID for the type of the certificate.
|
gEfiCertTypeRsa2048Sha256Guid ## SOMETIMES_CONSUMES ## GUID # Unique ID for the type of the certificate.
|
||||||
gEfiFileSystemVolumeLabelInfoIdGuid ## SOMETIMES_CONSUMES ## GUID # Indicate the information type
|
gEfiFileSystemVolumeLabelInfoIdGuid ## SOMETIMES_CONSUMES ## GUID # Indicate the information type
|
||||||
gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## GUID # Indicate the information type
|
|
||||||
|
|
||||||
gEfiCertX509Sha256Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
gEfiCertX509Sha256Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
||||||
gEfiCertX509Sha384Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
gEfiCertX509Sha384Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID for the type of the certificate.
|
||||||
@ -114,7 +113,6 @@
|
|||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
|
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
|
||||||
gEfiDevicePathProtocolGuid ## PRODUCES
|
gEfiDevicePathProtocolGuid ## PRODUCES
|
||||||
gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
|
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gEfiHiiConfigRoutingProtocolGuid AND
|
gEfiHiiConfigRoutingProtocolGuid AND
|
||||||
|
Loading…
x
Reference in New Issue
Block a user