mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
OvmfPkg/LsiScsiDxe: Install stubbed EXT_SCSI_PASS_THRU
Partially implement LsiScsiControllerStart() and LsiScsiControllerStop() to insert the scaffolding of EXT_SCSI_PASS_THRU functions. v3: Squash the newline below the declaration of LSI_SCSI_FROM_PASS_THRU v2: Remove the closing of PciIo protocol from LsiScsiControllerStop(). Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200717061130.8881-6-glin@suse.com>
This commit is contained in:
parent
79f802a50e
commit
23d982e205
@ -11,14 +11,105 @@
|
|||||||
|
|
||||||
#include <IndustryStandard/LsiScsi.h>
|
#include <IndustryStandard/LsiScsi.h>
|
||||||
#include <IndustryStandard/Pci.h>
|
#include <IndustryStandard/Pci.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Protocol/PciIo.h>
|
#include <Protocol/PciIo.h>
|
||||||
#include <Protocol/PciRootBridgeIo.h>
|
#include <Protocol/PciRootBridgeIo.h>
|
||||||
|
#include <Protocol/ScsiPassThruExt.h>
|
||||||
#include <Uefi/UefiSpec.h>
|
#include <Uefi/UefiSpec.h>
|
||||||
|
|
||||||
#include "LsiScsi.h"
|
#include "LsiScsi.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
|
||||||
|
// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata C,
|
||||||
|
// sections
|
||||||
|
// - 14.1 SCSI Driver Model Overview,
|
||||||
|
// - 14.7 Extended SCSI Pass Thru Protocol.
|
||||||
|
//
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiPassThru (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun,
|
||||||
|
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
|
||||||
|
IN EFI_EVENT Event OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetNextTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN OUT UINT8 **TargetPointer,
|
||||||
|
IN OUT UINT64 *Lun
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiBuildDevicePath (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun,
|
||||||
|
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||||
|
OUT UINT8 **TargetPointer,
|
||||||
|
OUT UINT64 *Lun
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiResetChannel (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiResetTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetNextTarget (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN OUT UINT8 **TargetPointer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Probe, start and stop functions of this driver, called by the DXE core for
|
// Probe, start and stop functions of this driver, called by the DXE core for
|
||||||
// specific devices.
|
// specific devices.
|
||||||
@ -88,7 +179,49 @@ LsiScsiControllerStart (
|
|||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
LSI_SCSI_DEV *Dev;
|
||||||
|
|
||||||
|
Dev = AllocateZeroPool (sizeof (*Dev));
|
||||||
|
if (Dev == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dev->Signature = LSI_SCSI_DEV_SIGNATURE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Host adapter channel, doesn't exist
|
||||||
|
//
|
||||||
|
Dev->PassThruMode.AdapterId = MAX_UINT32;
|
||||||
|
Dev->PassThruMode.Attributes =
|
||||||
|
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL |
|
||||||
|
EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;
|
||||||
|
|
||||||
|
Dev->PassThru.Mode = &Dev->PassThruMode;
|
||||||
|
Dev->PassThru.PassThru = &LsiScsiPassThru;
|
||||||
|
Dev->PassThru.GetNextTargetLun = &LsiScsiGetNextTargetLun;
|
||||||
|
Dev->PassThru.BuildDevicePath = &LsiScsiBuildDevicePath;
|
||||||
|
Dev->PassThru.GetTargetLun = &LsiScsiGetTargetLun;
|
||||||
|
Dev->PassThru.ResetChannel = &LsiScsiResetChannel;
|
||||||
|
Dev->PassThru.ResetTargetLun = &LsiScsiResetTargetLun;
|
||||||
|
Dev->PassThru.GetNextTarget = &LsiScsiGetNextTarget;
|
||||||
|
|
||||||
|
Status = gBS->InstallProtocolInterface (
|
||||||
|
&ControllerHandle,
|
||||||
|
&gEfiExtScsiPassThruProtocolGuid,
|
||||||
|
EFI_NATIVE_INTERFACE,
|
||||||
|
&Dev->PassThru
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto FreePool;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
FreePool:
|
||||||
|
FreePool (Dev);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -100,7 +233,36 @@ LsiScsiControllerStop (
|
|||||||
IN EFI_HANDLE *ChildHandleBuffer
|
IN EFI_HANDLE *ChildHandleBuffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return EFI_SUCCESS;
|
EFI_STATUS Status;
|
||||||
|
EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
|
||||||
|
LSI_SCSI_DEV *Dev;
|
||||||
|
|
||||||
|
Status = gBS->OpenProtocol (
|
||||||
|
ControllerHandle,
|
||||||
|
&gEfiExtScsiPassThruProtocolGuid,
|
||||||
|
(VOID **)&PassThru,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
ControllerHandle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL // Lookup only
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dev = LSI_SCSI_FROM_PASS_THRU (PassThru);
|
||||||
|
|
||||||
|
Status = gBS->UninstallProtocolInterface (
|
||||||
|
ControllerHandle,
|
||||||
|
&gEfiExtScsiPassThruProtocolGuid,
|
||||||
|
&Dev->PassThru
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool (Dev);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -12,6 +12,18 @@
|
|||||||
#ifndef _LSI_SCSI_DXE_H_
|
#ifndef _LSI_SCSI_DXE_H_
|
||||||
#define _LSI_SCSI_DXE_H_
|
#define _LSI_SCSI_DXE_H_
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT32 Signature;
|
||||||
|
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
|
||||||
|
EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
|
||||||
|
} LSI_SCSI_DEV;
|
||||||
|
|
||||||
|
#define LSI_SCSI_DEV_SIGNATURE SIGNATURE_32 ('L','S','I','S')
|
||||||
|
|
||||||
|
#define LSI_SCSI_FROM_PASS_THRU(PassThruPtr) \
|
||||||
|
CR (PassThruPtr, LSI_SCSI_DEV, PassThru, LSI_SCSI_DEV_SIGNATURE)
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Probe, start and stop functions of this driver, called by the DXE core for
|
// Probe, start and stop functions of this driver, called by the DXE core for
|
||||||
// specific devices.
|
// specific devices.
|
||||||
@ -47,6 +59,72 @@ LsiScsiControllerStop (
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
|
||||||
|
// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata C,
|
||||||
|
// sections
|
||||||
|
// - 14.1 SCSI Driver Model Overview,
|
||||||
|
// - 14.7 Extended SCSI Pass Thru Protocol.
|
||||||
|
//
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiPassThru (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun,
|
||||||
|
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
|
||||||
|
IN EFI_EVENT Event OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetNextTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN OUT UINT8 **TargetPointer,
|
||||||
|
IN OUT UINT64 *Lun
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiBuildDevicePath (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun,
|
||||||
|
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||||
|
OUT UINT8 **TargetPointer,
|
||||||
|
OUT UINT64 *Lun
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiResetChannel (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiResetTargetLun (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN UINT8 *Target,
|
||||||
|
IN UINT64 Lun
|
||||||
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
LsiScsiGetNextTarget (
|
||||||
|
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
|
||||||
|
IN OUT UINT8 **TargetPointer
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
|
// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
|
||||||
// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
|
// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
|
||||||
|
@ -26,9 +26,12 @@
|
|||||||
|
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
BaseLib
|
BaseLib
|
||||||
|
BaseMemoryLib
|
||||||
|
MemoryAllocationLib
|
||||||
UefiBootServicesTableLib
|
UefiBootServicesTableLib
|
||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
UefiLib
|
UefiLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
|
gEfiExtScsiPassThruProtocolGuid ## BY_START
|
||||||
gEfiPciIoProtocolGuid ## TO_START
|
gEfiPciIoProtocolGuid ## TO_START
|
||||||
|
Loading…
x
Reference in New Issue
Block a user