On 03/25/20 17:10, Liran Alon wrote:
> The following commits will complete the implementation of
> device initialization.
> 
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567
> Signed-off-by: Liran Alon <liran.a...@oracle.com>
> ---
>  OvmfPkg/PvScsiDxe/PvScsi.c | 91 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c
> index 531bed4e5ab7..831a78cc18c7 100644
> --- a/OvmfPkg/PvScsiDxe/PvScsi.c
> +++ b/OvmfPkg/PvScsiDxe/PvScsi.c
> @@ -30,6 +30,84 @@
>  // Ext SCSI Pass Thru utilities
>  //
>  
> +/**
> +  Writes a 32-bit value into BAR0 using MMIO
> +**/
> +STATIC
> +EFI_STATUS
> +PvScsiMmioWrite32 (
> +  IN CONST PVSCSI_DEV   *Dev,
> +  IN UINT64             Offset,
> +  IN UINT32             Value
> +  )
> +{
> +  return Dev->PciIo->Mem.Write (
> +                           Dev->PciIo,
> +                           EfiPciIoWidthUint32,
> +                           PCI_BAR_IDX0,
> +                           Offset,
> +                           1,   // Count
> +                           &Value
> +                           );
> +}
> +
> +/**
> +  Writes multiple words of data into BAR0 using MMIO
> +**/
> +STATIC
> +EFI_STATUS
> +PvScsiMmioWrite32Multiple (
> +  IN CONST PVSCSI_DEV   *Dev,
> +  IN UINT64             Offset,
> +  IN UINTN              Count,
> +  IN UINT32             *Words
> +  )
> +{
> +  return Dev->PciIo->Mem.Write (
> +                           Dev->PciIo,
> +                           EfiPciIoWidthFifoUint32,
> +                           PCI_BAR_IDX0,
> +                           Offset,
> +                           Count,
> +                           Words
> +                           );
> +}
> +
> +/**
> +  Send PVSCSI command to device
> +**/
> +STATIC
> +EFI_STATUS
> +PvScsiWriteCmdDesc (
> +  IN CONST PVSCSI_DEV   *Dev,
> +  IN UINT32             Cmd,
> +  IN UINT32             *DescWords,
> +  IN UINTN              DescWordsCount
> +  )
> +{
> +  EFI_STATUS Status;
> +
> +  if (DescWordsCount > PVSCSI_MAX_CMD_DATA_WORDS) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Status = PvScsiMmioWrite32 (Dev, PvScsiRegOffsetCommand, Cmd);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  if (DescWordsCount > 0) {
> +    return PvScsiMmioWrite32Multiple (
> +             Dev,
> +             PvScsiRegOffsetCommandData,
> +             DescWordsCount,
> +             DescWords
> +             );
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
>  /**
>    Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and
>    EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized
> @@ -357,6 +435,14 @@ PvScsiInit (
>      return Status;
>    }
>  
> +  //
> +  // Reset adapter
> +  //
> +  Status = PvScsiWriteCmdDesc (Dev, PvScsiCmdAdapterReset, NULL, 0);
> +  if (EFI_ERROR (Status)) {
> +    goto RestorePciAttributes;
> +  }
> +
>    //
>    // Populate the exported interface's attributes
>    //
> @@ -387,6 +473,11 @@ PvScsiInit (
>    Dev->PassThruMode.IoAlign = 0;
>  
>    return EFI_SUCCESS;
> +
> +RestorePciAttributes:
> +  PvScsiRestorePciAttributes (Dev);
> +
> +  return Status;
>  }
>  
>  STATIC
> 

Nice.

Reviewed-by: Laszlo Ersek <ler...@redhat.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56417): https://edk2.groups.io/g/devel/message/56417
Mute This Topic: https://groups.io/mt/72544121/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to