TianoCore EDK2 master
Loading...
Searching...
No Matches
PvScsi.c File Reference

Go to the source code of this file.

Macros

#define PVSCSI_BINDING_VERSION   0x10
 

Functions

STATIC EFI_STATUS PvScsiMmioRead32 (IN CONST PVSCSI_DEV *Dev, IN UINT64 Offset, OUT UINT32 *Value)
 
STATIC EFI_STATUS PvScsiMmioWrite32 (IN CONST PVSCSI_DEV *Dev, IN UINT64 Offset, IN UINT32 Value)
 
STATIC EFI_STATUS PvScsiMmioWrite32Multiple (IN CONST PVSCSI_DEV *Dev, IN UINT64 Offset, IN UINTN Count, IN UINT32 *Words)
 
STATIC EFI_STATUS PvScsiWriteCmdDesc (IN CONST PVSCSI_DEV *Dev, IN UINT32 Cmd, IN UINT32 *DescWords OPTIONAL, IN UINTN DescWordsCount)
 
STATIC EFI_STATUS PvScsiResetAdapter (IN CONST PVSCSI_DEV *Dev)
 
STATIC BOOLEAN PvScsiIsReqRingFull (IN CONST PVSCSI_DEV *Dev)
 
STATIC PVSCSI_RING_REQ_DESCPvScsiGetCurrentRequest (IN CONST PVSCSI_DEV *Dev)
 
STATIC PVSCSI_RING_CMP_DESCPvScsiGetCurrentResponse (IN CONST PVSCSI_DEV *Dev)
 
STATIC EFI_STATUS PvScsiWaitForRequestCompletion (IN CONST PVSCSI_DEV *Dev)
 
STATIC EFI_STATUS ReportHostAdapterError (OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
 
STATIC EFI_STATUS ReportHostAdapterOverrunError (OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
 
STATIC EFI_STATUS PopulateRequest (IN CONST PVSCSI_DEV *Dev, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, OUT PVSCSI_RING_REQ_DESC *Request)
 
STATIC EFI_STATUS HandleResponse (IN PVSCSI_DEV *Dev, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN CONST PVSCSI_RING_CMP_DESC *Response)
 
STATIC BOOLEAN IsTargetInitialized (IN UINT8 *Target)
 
STATIC EFI_STATUS EFIAPI PvScsiPassThru (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)
 
STATIC EFI_STATUS EFIAPI PvScsiGetNextTargetLun (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
 
STATIC EFI_STATUS EFIAPI PvScsiBuildDevicePath (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
 
STATIC EFI_STATUS EFIAPI PvScsiGetTargetLun (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT8 **Target, OUT UINT64 *Lun)
 
STATIC EFI_STATUS EFIAPI PvScsiResetChannel (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This)
 
STATIC EFI_STATUS EFIAPI PvScsiResetTargetLun (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun)
 
STATIC EFI_STATUS EFIAPI PvScsiGetNextTarget (IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target)
 
STATIC EFI_STATUS PvScsiSetPciAttributes (IN OUT PVSCSI_DEV *Dev)
 
STATIC VOID PvScsiRestorePciAttributes (IN PVSCSI_DEV *Dev)
 
STATIC EFI_STATUS PvScsiAllocateSharedPages (IN PVSCSI_DEV *Dev, IN UINTN Pages, OUT VOID **HostAddress, OUT PVSCSI_DMA_DESC *DmaDesc)
 
STATIC VOID PvScsiFreeSharedPages (IN PVSCSI_DEV *Dev, IN UINTN Pages, IN VOID *HostAddress, IN PVSCSI_DMA_DESC *DmaDesc)
 
STATIC EFI_STATUS PvScsiInitRings (IN OUT PVSCSI_DEV *Dev)
 
STATIC VOID PvScsiFreeRings (IN OUT PVSCSI_DEV *Dev)
 
STATIC EFI_STATUS PvScsiSetupRings (IN OUT PVSCSI_DEV *Dev)
 
STATIC EFI_STATUS PvScsiInit (IN OUT PVSCSI_DEV *Dev)
 
STATIC VOID PvScsiUninit (IN OUT PVSCSI_DEV *Dev)
 
STATIC VOID EFIAPI PvScsiExitBoot (IN EFI_EVENT Event, IN VOID *Context)
 
STATIC EFI_STATUS EFIAPI PvScsiDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
 
STATIC EFI_STATUS EFIAPI PvScsiDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
 
STATIC EFI_STATUS EFIAPI PvScsiDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
STATIC EFI_STATUS EFIAPI PvScsiGetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
STATIC EFI_STATUS EFIAPI PvScsiGetDeviceName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI PvScsiEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC EFI_DRIVER_BINDING_PROTOCOL mPvScsiDriverBinding
 
STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable []
 
STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName
 
STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2
 

Detailed Description

This driver produces Extended SCSI Pass Thru Protocol instances for pvscsi devices.

Copyright (C) 2020, Oracle and/or its affiliates.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PvScsi.c.

Macro Definition Documentation

◆ PVSCSI_BINDING_VERSION

#define PVSCSI_BINDING_VERSION   0x10

Definition at line 29 of file PvScsi.c.

Function Documentation

◆ HandleResponse()

Handle the PVSCSI device response:

  • Copy returned data from DMA communication buffer.
  • Update fields in Extended SCSI Pass Thru Protocol packet as required.
  • Translate response code to EFI status code and host adapter status.

Definition at line 430 of file PvScsi.c.

◆ IsTargetInitialized()

STATIC BOOLEAN IsTargetInitialized ( IN UINT8 *  Target)

Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized

Definition at line 548 of file PvScsi.c.

◆ PopulateRequest()

STATIC EFI_STATUS PopulateRequest ( IN CONST PVSCSI_DEV Dev,
IN UINT8 *  Target,
IN UINT64  Lun,
IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet,
OUT PVSCSI_RING_REQ_DESC Request 
)

Populate a PVSCSI request descriptor from the Extended SCSI Pass Thru Protocol packet.

Definition at line 294 of file PvScsi.c.

◆ PvScsiAllocateSharedPages()

STATIC EFI_STATUS PvScsiAllocateSharedPages ( IN PVSCSI_DEV Dev,
IN UINTN  Pages,
OUT VOID **  HostAddress,
OUT PVSCSI_DMA_DESC DmaDesc 
)

Definition at line 930 of file PvScsi.c.

◆ PvScsiBuildDevicePath()

STATIC EFI_STATUS EFIAPI PvScsiBuildDevicePath ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This,
IN UINT8 *  Target,
IN UINT64  Lun,
IN OUT EFI_DEVICE_PATH_PROTOCOL **  DevicePath 
)

Definition at line 698 of file PvScsi.c.

◆ PvScsiDriverBindingStart()

STATIC EFI_STATUS EFIAPI PvScsiDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath  OPTIONAL 
)

Definition at line 1356 of file PvScsi.c.

◆ PvScsiDriverBindingStop()

STATIC EFI_STATUS EFIAPI PvScsiDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Definition at line 1437 of file PvScsi.c.

◆ PvScsiDriverBindingSupported()

STATIC EFI_STATUS EFIAPI PvScsiDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath  OPTIONAL 
)

Definition at line 1300 of file PvScsi.c.

◆ PvScsiEntryPoint()

EFI_STATUS EFIAPI PvScsiEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Definition at line 1557 of file PvScsi.c.

◆ PvScsiExitBoot()

STATIC VOID EFIAPI PvScsiExitBoot ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification called by ExitBootServices()

Definition at line 1274 of file PvScsi.c.

◆ PvScsiFreeRings()

STATIC VOID PvScsiFreeRings ( IN OUT PVSCSI_DEV Dev)

Definition at line 1061 of file PvScsi.c.

◆ PvScsiFreeSharedPages()

STATIC VOID PvScsiFreeSharedPages ( IN PVSCSI_DEV Dev,
IN UINTN  Pages,
IN VOID *  HostAddress,
IN PVSCSI_DMA_DESC DmaDesc 
)

Definition at line 983 of file PvScsi.c.

◆ PvScsiGetCurrentRequest()

STATIC PVSCSI_RING_REQ_DESC * PvScsiGetCurrentRequest ( IN CONST PVSCSI_DEV Dev)

Returns pointer to current request descriptor to produce

Definition at line 179 of file PvScsi.c.

◆ PvScsiGetCurrentResponse()

STATIC PVSCSI_RING_CMP_DESC * PvScsiGetCurrentResponse ( IN CONST PVSCSI_DEV Dev)

Returns pointer to current completion descriptor to consume

Definition at line 197 of file PvScsi.c.

◆ PvScsiGetDeviceName()

STATIC EFI_STATUS EFIAPI PvScsiGetDeviceName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_HANDLE  ChildHandle,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Definition at line 1528 of file PvScsi.c.

◆ PvScsiGetDriverName()

STATIC EFI_STATUS EFIAPI PvScsiGetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Definition at line 1510 of file PvScsi.c.

◆ PvScsiGetNextTarget()

STATIC EFI_STATUS EFIAPI PvScsiGetNextTarget ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This,
IN OUT UINT8 **  Target 
)

Definition at line 805 of file PvScsi.c.

◆ PvScsiGetNextTargetLun()

STATIC EFI_STATUS EFIAPI PvScsiGetNextTargetLun ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This,
IN OUT UINT8 **  Target,
IN OUT UINT64 *  Lun 
)

Definition at line 639 of file PvScsi.c.

◆ PvScsiGetTargetLun()

STATIC EFI_STATUS EFIAPI PvScsiGetTargetLun ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This,
IN EFI_DEVICE_PATH_PROTOCOL DevicePath,
OUT UINT8 **  Target,
OUT UINT64 *  Lun 
)

Definition at line 742 of file PvScsi.c.

◆ PvScsiInit()

STATIC EFI_STATUS PvScsiInit ( IN OUT PVSCSI_DEV Dev)

Definition at line 1131 of file PvScsi.c.

◆ PvScsiInitRings()

STATIC EFI_STATUS PvScsiInitRings ( IN OUT PVSCSI_DEV Dev)

Definition at line 996 of file PvScsi.c.

◆ PvScsiIsReqRingFull()

STATIC BOOLEAN PvScsiIsReqRingFull ( IN CONST PVSCSI_DEV Dev)

Returns if PVSCSI request ring is full

Definition at line 162 of file PvScsi.c.

◆ PvScsiMmioRead32()

STATIC EFI_STATUS PvScsiMmioRead32 ( IN CONST PVSCSI_DEV Dev,
IN UINT64  Offset,
OUT UINT32 *  Value 
)

Reads a 32-bit value into BAR0 using MMIO

Definition at line 40 of file PvScsi.c.

◆ PvScsiMmioWrite32()

STATIC EFI_STATUS PvScsiMmioWrite32 ( IN CONST PVSCSI_DEV Dev,
IN UINT64  Offset,
IN UINT32  Value 
)

Writes a 32-bit value into BAR0 using MMIO

Definition at line 61 of file PvScsi.c.

◆ PvScsiMmioWrite32Multiple()

STATIC EFI_STATUS PvScsiMmioWrite32Multiple ( IN CONST PVSCSI_DEV Dev,
IN UINT64  Offset,
IN UINTN  Count,
IN UINT32 *  Words 
)

Writes multiple words of data into BAR0 using MMIO

Definition at line 82 of file PvScsi.c.

◆ PvScsiPassThru()

STATIC EFI_STATUS EFIAPI PvScsiPassThru ( 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 
)

Definition at line 570 of file PvScsi.c.

◆ PvScsiResetAdapter()

STATIC EFI_STATUS PvScsiResetAdapter ( IN CONST PVSCSI_DEV Dev)

Definition at line 150 of file PvScsi.c.

◆ PvScsiResetChannel()

STATIC EFI_STATUS EFIAPI PvScsiResetChannel ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This)

Definition at line 783 of file PvScsi.c.

◆ PvScsiResetTargetLun()

STATIC EFI_STATUS EFIAPI PvScsiResetTargetLun ( IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL This,
IN UINT8 *  Target,
IN UINT64  Lun 
)

Definition at line 793 of file PvScsi.c.

◆ PvScsiRestorePciAttributes()

STATIC VOID PvScsiRestorePciAttributes ( IN PVSCSI_DEV Dev)

Definition at line 916 of file PvScsi.c.

◆ PvScsiSetPciAttributes()

STATIC EFI_STATUS PvScsiSetPciAttributes ( IN OUT PVSCSI_DEV Dev)

Definition at line 855 of file PvScsi.c.

◆ PvScsiSetupRings()

STATIC EFI_STATUS PvScsiSetupRings ( IN OUT PVSCSI_DEV Dev)

Definition at line 1089 of file PvScsi.c.

◆ PvScsiUninit()

STATIC VOID PvScsiUninit ( IN OUT PVSCSI_DEV Dev)

Definition at line 1239 of file PvScsi.c.

◆ PvScsiWaitForRequestCompletion()

STATIC EFI_STATUS PvScsiWaitForRequestCompletion ( IN CONST PVSCSI_DEV Dev)

Wait for device to signal completion of submitted requests

Definition at line 215 of file PvScsi.c.

◆ PvScsiWriteCmdDesc()

STATIC EFI_STATUS PvScsiWriteCmdDesc ( IN CONST PVSCSI_DEV Dev,
IN UINT32  Cmd,
IN UINT32 *DescWords  OPTIONAL,
IN UINTN  DescWordsCount 
)

Send a PVSCSI command to device.

Parameters
[in]DevThe pvscsi host device.
[in]CmdThe command to send to device.
[in]OPTIONALDescWords An optional command descriptor (If command have a descriptor). The descriptor is provided as an array of UINT32 words and is must be 32-bit aligned.
[in]DescWordsCountThe number of words in command descriptor. Caller must specify here 0 if DescWords is not supplied (It is optional). In that case, DescWords is ignored.
Returns
Status codes returned by Dev->PciIo->Mem.Write().

Definition at line 118 of file PvScsi.c.

◆ ReportHostAdapterError()

STATIC EFI_STATUS ReportHostAdapterError ( OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet)

Create a fake host adapter error

Definition at line 260 of file PvScsi.c.

◆ ReportHostAdapterOverrunError()

STATIC EFI_STATUS ReportHostAdapterOverrunError ( OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet)

Create a fake host adapter overrun error

Definition at line 277 of file PvScsi.c.

Variable Documentation

◆ mComponentName

Initial value:
= {
&PvScsiGetDriverName,
&PvScsiGetDeviceName,
"eng"
}

Definition at line 1505 of file PvScsi.c.

◆ mComponentName2

Initial value:
= {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&PvScsiGetDriverName,
"en"
}
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_DRIVER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)

Definition at line 1545 of file PvScsi.c.

◆ mDriverNameTable

STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable[]
Initial value:
= {
{ "eng;en", L"PVSCSI Host Driver" },
{ NULL, NULL }
}
#define NULL
Definition: Base.h:319

Definition at line 1500 of file PvScsi.c.

◆ mPvScsiDriverBinding

STATIC EFI_DRIVER_BINDING_PROTOCOL mPvScsiDriverBinding
Initial value:
= {
&PvScsiDriverBindingSupported,
&PvScsiDriverBindingStart,
&PvScsiDriverBindingStop,
PVSCSI_BINDING_VERSION,
NULL,
}

Definition at line 1487 of file PvScsi.c.