summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/MptScsiDxe
diff options
context:
space:
mode:
authorNikita Leshenko <nikita.leshchenko@oracle.com>2020-05-05 00:06:01 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-05-05 20:43:02 +0000
commit093cceaf79b5d16880050a08e4bd465954ea6a97 (patch)
tree5f6639c261e6af40b8584d6f98d19c9f360f1a62 /OvmfPkg/MptScsiDxe
parenta53e5b417413bae3f3ea89976380d169e2f6861d (diff)
downloadedk2-093cceaf79b5d16880050a08e4bd465954ea6a97.tar.gz
edk2-093cceaf79b5d16880050a08e4bd465954ea6a97.tar.bz2
edk2-093cceaf79b5d16880050a08e4bd465954ea6a97.zip
OvmfPkg/MptScsiDxe: Report targets and one LUN
The controller supports up to 8 targets in practice (Not reported by the controller, but based on the implementation of the virtual device), report them in GetNextTarget and GetNextTargetLun. The firmware will then try to communicate with them and create a block device for each one that responds. Support for multiple LUNs will be implemented in another series. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200504210607.144434-7-nikita.leshchenko@oracle.com>
Diffstat (limited to 'OvmfPkg/MptScsiDxe')
-rw-r--r--OvmfPkg/MptScsiDxe/MptScsi.c63
-rw-r--r--OvmfPkg/MptScsiDxe/MptScsiDxe.inf5
2 files changed, 66 insertions, 2 deletions
diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
index 40d392c234..d396bff85c 100644
--- a/OvmfPkg/MptScsiDxe/MptScsi.c
+++ b/OvmfPkg/MptScsiDxe/MptScsi.c
@@ -11,8 +11,10 @@
#include <IndustryStandard/FusionMptScsi.h>
#include <IndustryStandard/Pci.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/PciIo.h>
@@ -34,6 +36,7 @@ typedef struct {
UINT32 Signature;
EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
+ UINT8 MaxTarget;
} MPT_SCSI_DEV;
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
@@ -58,6 +61,22 @@ MptScsiPassThru (
}
STATIC
+BOOLEAN
+IsTargetInitialized (
+ IN UINT8 *Target
+ )
+{
+ UINTN Idx;
+
+ for (Idx = 0; Idx < TARGET_MAX_BYTES; ++Idx) {
+ if (Target[Idx] != 0xFF) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+STATIC
EFI_STATUS
EFIAPI
MptScsiGetNextTargetLun (
@@ -66,7 +85,28 @@ MptScsiGetNextTargetLun (
IN OUT UINT64 *Lun
)
{
- return EFI_UNSUPPORTED;
+ MPT_SCSI_DEV *Dev;
+
+ Dev = MPT_SCSI_FROM_PASS_THRU (This);
+ //
+ // Currently support only LUN 0, so hardcode it
+ //
+ if (!IsTargetInitialized (*Target)) {
+ ZeroMem (*Target, TARGET_MAX_BYTES);
+ *Lun = 0;
+ } else if (**Target > Dev->MaxTarget || *Lun > 0) {
+ return EFI_INVALID_PARAMETER;
+ } else if (**Target < Dev->MaxTarget) {
+ //
+ // This device interface support 256 targets only, so it's enough to
+ // increment the LSB of Target, as it will never overflow.
+ //
+ **Target += 1;
+ } else {
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
}
STATIC
@@ -77,7 +117,24 @@ MptScsiGetNextTarget (
IN OUT UINT8 **Target
)
{
- return EFI_UNSUPPORTED;
+ MPT_SCSI_DEV *Dev;
+
+ Dev = MPT_SCSI_FROM_PASS_THRU (This);
+ if (!IsTargetInitialized (*Target)) {
+ ZeroMem (*Target, TARGET_MAX_BYTES);
+ } else if (**Target > Dev->MaxTarget) {
+ return EFI_INVALID_PARAMETER;
+ } else if (**Target < Dev->MaxTarget) {
+ //
+ // This device interface support 256 targets only, so it's enough to
+ // increment the LSB of Target, as it will never overflow.
+ //
+ **Target += 1;
+ } else {
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
}
STATIC
@@ -206,6 +263,8 @@ MptScsiControllerStart (
Dev->Signature = MPT_SCSI_DEV_SIGNATURE;
+ Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit);
+
//
// Host adapter channel, doesn't exist
//
diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf
index 9f7c98829e..d5fd2516e4 100644
--- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf
+++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf
@@ -24,8 +24,10 @@
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseMemoryLib
DebugLib
MemoryAllocationLib
+ PcdLib
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiLib
@@ -33,3 +35,6 @@
[Protocols]
gEfiExtScsiPassThruProtocolGuid ## BY_START
gEfiPciIoProtocolGuid ## TO_START
+
+[FixedPcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit ## CONSUMES