]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/MptScsiDxe: Build and decode DevicePath
authorNikita Leshenko <nikita.leshchenko@oracle.com>
Mon, 4 May 2020 21:06:02 +0000 (00:06 +0300)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 5 May 2020 20:43:02 +0000 (20:43 +0000)
Used to identify the individual disks in the hardware tree.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390
Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200504210607.144434-8-nikita.leshchenko@oracle.com>

OvmfPkg/MptScsiDxe/MptScsi.c

index d396bff85cb6df7f81e2f6e63089deb51f28b7af..66d57f1c85d877b21b944c54abe6c5004dea0954 100644 (file)
@@ -147,7 +147,36 @@ MptScsiBuildDevicePath (
   IN OUT EFI_DEVICE_PATH_PROTOCOL                  **DevicePath\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  MPT_SCSI_DEV     *Dev;\r
+  SCSI_DEVICE_PATH *ScsiDevicePath;\r
+\r
+  if (DevicePath == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // This device support 256 targets only, so it's enough to dereference\r
+  // the LSB of Target.\r
+  //\r
+  Dev = MPT_SCSI_FROM_PASS_THRU (This);\r
+  if (*Target > Dev->MaxTarget || Lun > 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  ScsiDevicePath = AllocateZeroPool (sizeof (*ScsiDevicePath));\r
+  if (ScsiDevicePath == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  ScsiDevicePath->Header.Type      = MESSAGING_DEVICE_PATH;\r
+  ScsiDevicePath->Header.SubType   = MSG_SCSI_DP;\r
+  ScsiDevicePath->Header.Length[0] = (UINT8)sizeof (*ScsiDevicePath);\r
+  ScsiDevicePath->Header.Length[1] = (UINT8)(sizeof (*ScsiDevicePath) >> 8);\r
+  ScsiDevicePath->Pun              = *Target;\r
+  ScsiDevicePath->Lun              = (UINT16)Lun;\r
+\r
+  *DevicePath = &ScsiDevicePath->Header;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 STATIC\r
@@ -160,7 +189,35 @@ MptScsiGetTargetLun (
   OUT UINT64                                       *Lun\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  MPT_SCSI_DEV     *Dev;\r
+  SCSI_DEVICE_PATH *ScsiDevicePath;\r
+\r
+  if (DevicePath == NULL ||\r
+      Target == NULL || *Target == NULL || Lun == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (DevicePath->Type    != MESSAGING_DEVICE_PATH ||\r
+      DevicePath->SubType != MSG_SCSI_DP) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Dev = MPT_SCSI_FROM_PASS_THRU (This);\r
+  ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath;\r
+  if (ScsiDevicePath->Pun > Dev->MaxTarget ||\r
+      ScsiDevicePath->Lun > 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  ZeroMem (*Target, TARGET_MAX_BYTES);\r
+  //\r
+  // This device support 256 targets only, so it's enough to set the LSB\r
+  // of Target.\r
+  //\r
+  **Target = (UINT8)ScsiDevicePath->Pun;\r
+  *Lun = ScsiDevicePath->Lun;\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 STATIC\r